akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.AbstractMap;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner(System.in);
		PrintWriter out = new PrintWriter(System.out);

		solve(sc,out);

		out.flush();
	}

	public static void solve(FastScanner sc, PrintWriter out) {
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		
		if(a+b==c||b+c==a||a+c==b) {
			out.println("Yes");
		}else{
			out.println("No");
		}
	}

	public static int gcd(int a, int b) {
		if(a < b) return gcd(b, a);
		if(b == 0) return a;
		return gcd(b, a % b);
	}

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

	public static int lcm(int a, int b) {
		return (a * b) / gcd(a, b);
	}
}

class Pair<K, V> extends AbstractMap.SimpleEntry<K, V> {

    public Pair(final K key, final V value) {
        super(key, value);
    }

    public Pair<V, K> swap() {
    	return new Pair<V, K>(getValue(), getKey());
    }
 }

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }

        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public double nextDouble() {
         return Double.parseDouble(next());
     }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    }
}

Measured memory_bytes: 21332
#[allow(unused_imports)]
use std::io::Write;

#[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! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

#[allow(non_snake_case)]
fn main() {
    input![N: usize, X: usize, L: [usize; N]];
    let mut ans = 1;
    let mut sum = 0;
    for l in L {
        sum += l;
        if sum <= X {
            ans += 1;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 2076
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

      int N=sc.nextInt();
      boolean truth=false;
      if((N%1000>=700&&N%1000<=799)||(N%100>=70&&N%100<=79)||(N%10==7)){
         truth=true;
      }
      if(truth){
         System.out.println("Yes");
      }else{
         System.out.println("No");
      }
   }
}


Measured memory_bytes: 35592
#include <stdio.h>
int main(void){
    char s[27];
    int a[26]={0};
    scanf("%s",s);
    int i;
    for(i=0;i<26;i++)a[i]=0;
    for(i=0;s[i]!='\0';i++){
        if(a[s[i]-'a']==1){
            printf("no\n");
            return 0;
        }
        else a[s[i]-'a']++;
    }
    printf("yes\n");
    return 0;
}

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

using namespace std;
using ll = long long;
using vl = vector<ll>;
using pll = pair<ll, ll>;

#define rep(i, n) for (ll i = 0, xxx_rep_end = (n); i < xxx_rep_end; ++i)
#define all(x) (x).begin(), (x).end()

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

constexpr ll INF = 0x3f3f3f3f3f3f3f3fLL;
constexpr ll mod = 1000000007;

int main() {
    ll N, X, Y;
    cin >> N >> X >> Y;
    --X;
    --Y;

    vector<ll> cnt(N);

    for (ll i = 0; i < N; ++i) {
        for (ll j = i + 1; j < N; ++j) {
            ++cnt[min(j - i, abs(X - i) + abs(Y - j) + 1)];
        }
    }

    for (int i = 1; i < N; ++i) {
        cout << cnt[i] << endl;
    }
}

Measured memory_bytes: 3592
///////////////////////////////////////////// Template /////////////////////////////////////////////
#![allow(non_snake_case, unused)]
use std::collections::*;

//////////////////// missing functions in 1.15.1 ////////////////////
macro_rules! eprint {
	($($t:tt)*) => { {
		use ::std::io::Write;
		let _ = write!(::std::io::stderr(), $($t)*);
	} };
}
macro_rules! eprintln {
	($($t:tt)*) => { {
		use ::std::io::Write;
		let _ = writeln!(::std::io::stderr(), $($t)*);
	} };
}

//////////////////// useful functions ////////////////////
pub trait SetMin {
	fn setmin(&mut self, v: Self) -> bool;
}
impl<T> SetMin for T where T: PartialOrd {
	fn setmin(&mut self, v: T) -> bool {
		*self > v && { *self = v; true }
	}
}
pub trait SetMax {
	fn setmax(&mut self, v: Self) -> bool;
}
impl<T> SetMax for T where T: PartialOrd {
	fn setmax(&mut self, v: T) -> bool {
		*self < v && { *self = v; true }
	}
}

macro_rules! debug {
	($($v: expr),*) => {
		$(eprint!("{} = {:?} ", stringify!($v), $v);)*
		eprintln!("@ {}:{}", file!(), line!());
	}
}

macro_rules! mat {
	($($e:expr),*) => { Vec::from(vec![$($e),*]) };
	($($e:expr,)*) => { Vec::from(vec![$($e),*]) };
	($e:expr; $d:expr) => { Vec::from(vec![$e; $d]) };
	($e:expr; $d:expr $(; $ds:expr)+) => { Vec::from(vec![mat![$e $(; $ds)*]; $d]) };
}

pub fn readln() -> String {
	let mut line = String::new();
	::std::io::stdin().read_line(&mut line).unwrap_or_else(|e| panic!("{}", e));
	line
}

macro_rules! read {
	($($t:tt),*; $n:expr) => {{
		let stdin = ::std::io::stdin();
		let ret = ::std::io::BufRead::lines(stdin.lock()).take($n).map(|line| {
			let line = line.unwrap();
			let mut it = line.split_whitespace();
			_read!(it; $($t),*)
		}).collect::<Vec<_>>();
		ret
	}};
	($($t:tt),*) => {{
		let line = readln();
		let mut it = line.split_whitespace();
		_read!(it; $($t),*)
	}};
}

macro_rules! _read {
	($it:ident; [char]) => {
		_read!($it; String).chars().collect::<Vec<_>>()
	};
	($it:ident; [u8]) => {
		Vec::from(_read!($it; String).into_bytes())
	};
	($it:ident; [$t:ty]) => {
		$it.map(|s| s.parse::<$t>().unwrap_or_else(|e| panic!("{}", e))).collect::<Vec<_>>()
	};
	($it:ident; $t:ty) => {
		$it.next().unwrap_or_else(|| panic!("input mismatch")).parse::<$t>().unwrap_or_else(|e| panic!("{}", e))
	};
	($it:ident; $($t:ty),+) => {
		($(_read!($it; $t)),*)
	};
}

pub fn main() {
	let _ = ::std::thread::Builder::new().name("run".to_string()).stack_size(32 * 1024 * 1024).spawn(run).unwrap().join();
}
////////////////////////////////////////////////////////////////////////////////////////////////////

fn run() {
	let mut a = 0;
	for c in read!([char]) {
		if c == '+' {
			a += 1;
		} else {
			a -= 1;
		}
	}
	println!("{}", a);
}


Measured memory_bytes: 8572
//                                 Alisher_2211
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        # include <bits/stdc++.h>
# define  long          long long
# define  all(vc)       vc.begin(),vc.end()
# define  allr(vc)      vc.rbegin(),vc.rend()
# define  pb            push_back
# define  fi            first 
# define  se            second
# define  pi            pair <long, long>    
# define  lcm(a, b)     (a * b) / __gcd(a, b)
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        using namespace std;
const long N = 100100;
void read(){freopen("input.txt" , "r" , stdin );freopen("output.txt", "w" , stdout );}
long dp[N][2];
string s;
void solve(){
    long n, m;
    cin >> n;
    vector <long> v(n);
    for(auto &i: v) cin >> i;
    cin >> m;
    vector <pi> vc(m);
    for(auto &i: vc) cin >> i.fi >> i.se;
    for (int i = 0; i < m; ++i){ 
        long ans = 0;
        for (int j = 0; j < n; ++j){
            if( vc[i].fi == j + 1 ){
                ans += vc[i].se;
                continue;
            }
            ans += v[j];
        }
        cout << ans << '\n'; 
    }
}
int32_t main(){
ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); 
        long T = 1;
        //cin >> T;
        while( T-- ){
            solve();
            cout<<'\n';
        }
cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
}

Measured memory_bytes: 3824
class PriorityQueue

  def initialize(heap=[])
    @size = heap.size
    @heap = heap.sort
  end

  # log( log n )
  def push x
    i = @size
    @size += 1
    while i > 0
      par = ( i - 1 ) / 2
      break if @heap[par] <= x
      @heap[i] = @heap[par]
      i = par
    end
    @heap[i] = x
  end

  # log( log n )
  # return nil if @size == 0
  def pop

    ret = @heap[0]
    x = @heap[@size-=1]
    # @heap.delete_at(-1)

    i = 0
    while (child = i * 2 + 1) < @size
      child_1 = i * 2 + 2
      child = child_1 if child_1 < @size && @heap[child_1] < @heap[child]
      break if @heap[child] >= x
      @heap[i] = @heap[child]
      i = child
    end

    @heap[i] = x
    @heap.delete_at(-1)
    ret
  end

  def size
    @heap.size
  end

  def top
    @heap[0]
  end

  def any?
    @size > 0
  end

  def empty?
    @size == 0
  end

  def all
    @heap
  end

  def first
    @heap[0]
  end

  def second
    @size < 3 ? @heap[1] : [@heap[1], @heap[2]].min
  end

  def third
    @size < 3 ? nil : [@heap[1], @heap[2]].max
  end
  
  def sum
    @heap.reduce(0){|s,t| s+t }
  end
  
  def update
    if second && (-top) / 2 < -second
      push( -( -pop / 2 ))
    else
      @heap[0] = -( -@heap[0] / 2 )
    end
  end
end

class Nil
end

class Array

  include Comparable

  def to_pq
    PriorityQueue.new(self)
  end
  
  def -@
    map{|e| -e.to_i }
  end
end

n, m = gets.to_s.split.map{|t|  t.to_i }
a    = gets.to_s.split.map{|t| -t.to_i }
# 大きい順に見たいが、PriorityQueueが小さいのが優先なので、マイナスをつけていく。

q = PriorityQueue.new(a)

m.times do
  q.update
end
# p q.all
puts -q.sum

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

    long long n,a,m,k,q,b,c=1;
    float qq,ww,ff=2,qs;
    string ss,s1,s2;
    int main(){
        cin>>a>>b;
        cout<<max(0*1ll,a-b*2);
    }


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

using namespace std;

const int N = 1e5 + 5;

int f[N], g[N];

int main(){
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    string s, t; cin >> s >> t;
    for (int i = 1; i <= s.length(); i++) f[i] = f[i - 1] + (s[i - 1] - 'A' + 1);
    for (int i = 1; i <= t.length(); i++) g[i] = g[i - 1] + (t[i - 1] - 'A' + 1);

    int q; cin >> q;
    while (q--) {
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        int sum = f[b] - f[a - 1], sum2 = g[d] - g[c - 1];
        cout << ((sum - sum2) % 3 == 0 ? "YES\n" : "NO\n");
    }
    return 0;
}


Measured memory_bytes: 1744
n=int(input())
A=list(map(int,input().split()))
S=sorted(A)
a=S[n//2-1]
b=S[n//2]
for i in A:
    if i<a:
        print(b)
    elif a==i: print(b)
    elif b==i: print(a)
    else:
        print(a)

Measured memory_bytes: 104844
#include <stdio.h>

int main(void) {
    int a;

    scanf("%d", &a);

    if (!(1<=a && a <= 10)) {
        fprintf(stderr, "ERROR\n");
        return 1;
    }

    printf("%d\n", a+(a*a)+(a*a*a));
    return 0;
}

Measured memory_bytes: 1716
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
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 (b<a) {a=b; return 1;} return 0;}

int next_combination(int sub) {
    int x = sub & -sub, y = sub + x;
    return (((sub & ~y) / x) >> 1) | y;
}

// for (int bit = (1<<k)-1 ;bit < (1<<n); bit = next_combination(bit))

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    map<char, ll> mp;
    rep(i, n) {
        string s;
        cin >> s;
        mp[s[0]]++;
    }
    ll ans = 0;
    vc c = {'M', 'A', 'R', 'C', 'H'};
    for (int bit = (1<<3)-1 ;bit < (1<<5); bit = next_combination(bit)) {
        ll now = 1;
        rep(i, 5) {
            if (bit>>i&1) now *= mp[c[i]];
        }
        ans += now;
    }
    cout << ans << endl; 
}

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

int main() {
 string N;
  cin >> N ;
  if(N.size() == 1)
  {  
  if(N.at(0) == '2' || N.at(0) == '4' || N.at(0) == '5'|| N.at(0) == '7'|| N.at(0) == '9')
  { 
    cout << "hon" << endl;
  }
    else if(N.at(0) == '0' || N.at(0) == '1' || N.at(0) == '6'|| N.at(0) == '8')
    {
  cout <<"pon" << endl;
    }
    else{
    cout <<"bon" << endl;
}
  }
  else if(N.size() == 2)
  {
    if(N.at(1) == '2' || N.at(1) == '4' || N.at(1) == '5'|| N.at(1) == '7'|| N.at(1) == '9')
  { 
      cout << "hon" << endl;
  }
    else if(N.at(1) == '0' || N.at(1) == '1' || N.at(1) == '6' || N.at(1) == '8')
    {
  cout <<"pon" << endl;
    }
    else
    {
    cout <<"bon" << endl;
}
 }
  else if(N.size() == 3)
  {
    if(N.at(2) == '2' || N.at(2) == '4'|| N.at(2) == '5'|| N.at(2) == '7'|| N.at(2) == '9')
  { 
      cout << "hon" << endl;
  }
    else if(N.at(2) == '0' || N.at(2) == '1' || N.at(2) == '6'|| N.at(2) == '8')
    {
  cout <<"pon" << endl;
    }
    else{
    cout <<"bon" << endl;
}
 }

}


Measured memory_bytes: 3632
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
int f[105][12][3];
int p[105][12];
int cnt[105];
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<5;j++)
        {
            for(int k=0;k<2;k++)
            {
                scanf("%d",&f[i][j][k]);
            }
        }
    }
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<=10;j++)
        {
            scanf("%d",&p[i][j]);
        }
    }
    int ans=-1000000007;
    for(int c=1;c<(1<<10);c++)
    {
        memset(cnt,0,sizeof(cnt));
        for(int p=0;p<10;p++)
        {
            if(!(c&(1<<p)))continue;
            int nowj=p/2,nowk=p%2;
            for(int i=0;i<n;i++)
            {
                if(f[i][nowj][nowk])cnt[i]++;
            }
        }
        int now=0;
        for(int i=0;i<n;i++)
        {
            now=now+p[i][cnt[i]];
        }
        ans=max(ans,now);
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;
public class Main
{
	static int cost[][];
	static int n;
	public static void main(String[] args) 
	{
		Scanner in=new Scanner(System.in);
		for(;;)
		{
			n=in.nextInt();
			if(n==0)
				return;
			cost=new int[n+1][n+1];
			int ans=0;
			for(int i=0;i<n-1;i++)
			{
				int a=in.nextInt();
				int b=in.nextInt();
				int c=in.nextInt();
				cost[a][b]=cost[b][a]=c;
				ans+=cost[a][b]*2;
			}
			
			for(int i=1;i<=n;i++)
			{
				int reaf=0;
				int ii=0,jj=0;
				for(int j=1;j<=n;j++)
				{
					if(cost[i][j]>0||cost[i][j]==-1)
					{
						reaf++;
						ii=i;
						jj=j;
					}
				}
				if(i!=1&&reaf==1)
				{
					ans-=cost[ii][jj]*2;
					cost[ii][jj]=cost[jj][ii]=-1;
				}
			}
			System.out.println(ans-max(1));
		}
	}
	static int max(int m)
	{
		int cut=0;
		for(int i=2;i<=n;i++)
		{
			if(cost[m][i]>0)
			{
				cost[i][m]=0;
				cut=Math.max(cut, cost[m][i]+max(i));
			}
		}
		return cut;
	}
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
using namespace std;
vector<int> cnt = {5, 12, 17, 24, 31};
int main(){
  while (1){
    int n;
    cin >> n;
    if (n == 0){
      break;
    }
    vector<string> w(n);
    for (int i = 0; i < n; i++){
      cin >> w[i];
    }
    vector<int> sum(n + 1, 0);
    for (int i = 0; i < n; i++){
      sum[i + 1] = sum[i] + w[i].size();
    }
    set<int> st;
    for (int i = 0; i <= n; i++){
      st.insert(sum[i]);
    }
    for (int i = 0; i < n; i++){
      bool ok = true;
      for (int j = 0; j < 5; j++){
        if (!st.count(sum[i] + cnt[j])){
          ok = false;
        }
      }
      if (ok){
        cout << i + 1 << endl;
        break;
      }
    }
  }
}


Measured memory_bytes: 3224
#include <iostream>

int main () {
	int input, minimum, count, num, N;
	minimum = 1e+5;
	std::cin >> N;
	for (int i = 0; i < N; i++) {
		count = 0;
		std::cin >> num;
		while (num > 0) {
			if (num % 2 == 0) {
				count++;
				num /= 2;
			} else {
				break;
			}
		}
		minimum = std::min(minimum, count);
	}
	std::cout << minimum << std::endl;
	return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N=100005;
int read(){
	int x=0;
	char ch=getchar();
	while (!isdigit(ch))
		ch=getchar();
	while (isdigit(ch))
		x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	return x;
}
int n,T,E;
int x[N];
LL dp[N],Min=1LL<<50;
int main(){
	n=read(),E=read(),T=read();
	for (int i=1;i<=n;i++)
		x[i]=read();
	int j=1;
	dp[0]=0;
	for (int i=1;i<=n;i++){
		while (2LL*(x[i]-x[j])>=T){
			Min=min(Min,dp[j-1]-2LL*x[j]);
			j++;
		}
		dp[i]=min(Min+2LL*x[i],dp[max(j-1,0)]+T);
	}
	printf("%lld",dp[n]+E);
	return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <sstream>

using namespace std;

int main () {
    int n; cin >> n;
    int ans = 0;
    for (int i = 1; i <= n; i++ ){
        stringstream ss;
        string tmp;
        ss << i;
        ss >> tmp;
        if (tmp.size() % 2 == 1) {
            ans++;
        }
    }
    cout << ans << endl;
}


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

typedef long long LL;

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(x) (x).begin(),(x).end()
const int IINF = 1e9;
const LL LINF = 1e18;
const LL mod = 1e9+7;

template<typename T>
bool isprime(T x) {
    if(x == 1)return false;
    if(x == 2)return true;
    if(x%2 == 0)return false;

    for(LL i = 3;i*i <= x;i += 2)
        if(x%i == 0)return false;
    return true;
}

int main() {
    int N = 100000;
    vector<int> v(N + 1, 0);
    vector<int> s(N + 1, 0);
    FOR(i, 1, N + 1) {
        v[i] = isprime(i) && isprime((i + 1)/2);
    }
    FOR(i, 1, N + 1) {
        s[i] = v[i] + s[i - 1];
    }
    int Q;
    cin >> Q;
    REP(q, Q) {
        int l, r;
        cin >> l >> r;
        cout << s[r] - s[l - 1] << endl;
    }
    return 0;
}


Measured memory_bytes: 1408
///Bismillahir Rahmanir Rahim
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define pi 3.1415926535897932384626
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    string x;
    cin>>x;
    for(int i = 0; i<x.size()-2;i++)
    {
        if(x[i]==x[i+1] && x[i]== x[i+2])
        {
            cout<<"Yes"<<endl;
            return 0;
        }

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 int N;
 cin >> N;
 long long d = 1000000000+7;
  long long p = 1;
  for(int i = 1;i<=N;i++){
    p = (p*i)%d;
 }
 cout << p  <<endl;
}

Measured memory_bytes: 256
#最大公約数、最小公倍数
#C - Multiple Clocks(最小公倍数)a*b//gcd(a,b)
#https://atcoder.jp/contests/abc070/tasks/abc070_c

from fractions import gcd
n = int(input())
t = [int(input()) for _ in range(n)]
ans = t[0]
for i in range(1,n):
    ans *= t[i]//gcd(ans,t[i])
print(ans)

Measured memory_bytes: 5048
#include<stdio.h>

	int main()
	{
		long long int a;
		long long int count = 0;
		long long int n;
		scanf("%lld",&n);
		long long int i;
		long long int carry = 0;
		for( i =0;i<n;++i)
		{
			scanf("%lld",&a);
		    count = count + (a+ carry)/2;
		    if( a>0)
		    {
		    	carry = (a+carry)%2;
			}
			else
			{ 
				carry = 0;
			}
		    
		}
		printf("%lld",count);
		return 0;
	}

Measured memory_bytes: 128
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <algorithm>
#include <random>
#include <chrono>
#include <iomanip>
#define lint long long int
#define FOR(x, to) for(int x=0; x<(int)(to); x++) // for簡略表記
#define DUMP(ar) for(int loop=0; loop<(int)ar.size(); loop++) cout << "[" << loop << "]:" << ar[loop] << endl // 配列一覧表示
#define DUMPL(ar) for(int loop=0; loop<(int)ar.size(); loop++) { cout << ar[loop]; if(loop<(int)ar.size()-1) cout << ' '; } cout << endl; // 配列一行一覧表示
#define COUT(x) cout << x << endl // 単要素出力
#define ALL(ar) ar.begin(), ar.end() // コンテナの全要素
#define LOOPD(i) cout << "ループ[" << i << "]回目---------------" << endl // ループ回数デバグ
using namespace std;
// cout << fixed << setprecision(4) で小数点以下4桁の桁そろえ
// cout << setw(5) << ... で表示形式を5桁に設定 5桁未満なら頭に空白がつく 5桁越なら先頭から5桁まで
// cout << setw(5) << setfill('0') << ... で空白部分の埋め文字に5を使う
// getline(cin, [変数]); で空白などを含む入力の受け取り(行ごとの受け取り)
// cin >> ws; でそこまでにストリームに残されたホワイトスペースを取り除く(=以降のgetlineの有効化)

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

    int a, b, c;
    cin >> a >> b >> c;

    if(a == b){
        COUT(c);
    }else if(a == c){
        COUT(b);
    }else{
        COUT(a);
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define y_n(ans) cout<<(ans?"Yes":"No")<<endl;

const long long mod = 1e9 + 7;

int main() {
    int n; cin >> n;
    vector<long long> a(n);
    rep(i, n) cin >> a[i];
    vector<long long> csum(n-1);
    csum[n-2] = a[n-1];
    for (int i = n-3; i >= 0; --i) {
        csum[i] = csum[i+1] + a[i+1];
    }
    long long ans = 0;
    for (int i = 0; i < n-1; ++i) {
        ans += csum[i]%mod * a[i]%mod;
        ans %= mod;
    }
    cout << ans << endl;
}

Measured memory_bytes: 6420
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

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

    int n;
    cin >> n;
    vi q(n);  
    rep(i,n){
        cin >> q[i];
    }

    vi p = q;
    sort(all(p));
    reverse(all(p));
    int m1 = p[0];
    int m2 = p[1];
    rep(i,n){
        if(q[i]==m1){cout << m2 << endl;}
        else{cout << m1 << endl;}
    }

    return 0;
}

Measured memory_bytes: 3200
question_num = int(input())
question_resolve_time = list(map(int, input().split()))
drink_num = int(input())

drink_data = []
for i in range(0, drink_num):
    a = list(map(int, input().split()))
    drink_data.append(a)

not_drinking_time = sum(question_resolve_time)

for drink in drink_data:
    result_time = not_drinking_time - question_resolve_time[drink[0] - 1] + drink[1]
    print(result_time)

Measured memory_bytes: 3064
import java.util.*;
class Main{
	public static void main(String[]agrs){
		Scanner sc=new Scanner(System.in);
		while(sc.hasNextInt()){
			
		int n=sc.nextInt();
		int a[]=new int[n];
		int b=0;long c=1;
		for(int i=0;i<a.length;i++){
			a[i]=n-b;
			b++;
		}
		for(int j=0;j<a.length;j++){
			c*=a[j];
			
		}
		
		System.out.println(c);
	}
		
	}
}

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

int main(void){
    int N,D,X; cin >> N >> D >> X;
    vector<int> A(N);
    for(int i=0; i<N; i++) cin >> A[i];
    int ans=X;

    for(int i=0; i<N; i++) ans+=(D-1)/A[i]+1;

    cout << ans << endl;
} 

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
    int a,b,c,x,ans=0;
    scanf("%d%d%d%d",&a,&b,&c,&x);
    for(int i=0;a>=i;++i){
        for(int j=0;b>=j;++j){
            for(int k=0;c>=k;++k){
                if(500*i+100*j+50*k==x)
                ++ans;
            }
        }
    }
    printf("%d",ans);
    return 0;
}

Measured memory_bytes: 128
import sys
bbn=1000000007
	
#+++++

def ai(n, c):
	if n <= 9550:
		bb=1	
		ret=0
		while n >= 10**bb:
			ret += n // 10**bb
			bb+=1
		return ret+c
	else:
		p=0
		b=n
		while b % 10 == 0:
			p+=1
			b=b//10
		return ai(n-2, c+p)
		
def main():
	n = int(input())
	if n%2==1:
		return 0
	bb=1	
	ret=0
	while n >= 2*(5**bb):
		ret += n // (2*(5**bb))
		bb+=1
	#pa(ai(n,0))
	print(ret)
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)

if __name__ == "__main__":
	if sys.platform =='ios':
		sys.stdin=open('inputFile.txt')
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

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

string decy(string s,int k) {
    string res = "";
    for(int i=0; i<s.length(); ++i) {
        if(s[i] >= 'a' && s[i] <= 'z') res += string(1,(s[i]-'a'+k)%26+'a');
        else res += string(1, s[i]);
    }
    return res;
}

bool isvalid(string s) {
    if(s.find("this") != string::npos || s.find("that") != string::npos
       || s.find("the") != string::npos) return true;
    return false;
}

int main() {
    string s;
    while(getline(cin,s)) {
        for(int i=0; i<=25; ++i) {
            s = decy(s,1);
            if(isvalid(s)) {
                cout<<s<<endl;
                break;
            }
        }
    }
}

Measured memory_bytes: 0
#include<cstdio>
#include<iostream>
#include<cmath>
using namespace std;
int n;
long long f[400];
int main()
{
    scanf("%d",&n);
    f[0]=2;
    for(int i=0;i<=n;i++)
    f[i]=f[i-1]*2+2;
    cout<<f[n]<<endl;
    return 0;
}

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

#define rep(i, j) for(int i=0; i < (int)(j); i++)
#define repeat(i, j, k) for(int i = (j); i < (int)(k); i++)
#define all(v) v.begin(),v.end()

template<class T> bool set_max(T &a, const T &b) { return a < b  ? a = b, true : false; }
template<class T> istream& operator >> (istream &is , vector<T> &v) { for(T &a : v) is >> a; return is; }

class Solver {
  public:
    vector<int> W;
    vector<vector<int>> DP;

    // [i, j]
    bool removable(int i, int j) {
        if(i > j) return true;
        if(i == j) return DP[i][j] = false;
        if(DP[i][j] >= 0) return DP[i][j];

        bool ok = false;
        repeat(k, i + 1, j + 1) { // [i+1, j]
            ok |= abs(W[i] - W[k]) <= 1 and removable(i + 1, k - 1) and removable(k + 1, j);
        }
        return DP[i][j] = ok;
    }
    
    bool solve() {
        int N; cin >> N;
        if(not N) return false;
        W.resize(N); cin >> W;

        DP.resize(N, vector<int>(N, -1));
        rep(i, N) rep(j, N) removable(i, j);

        vector<int> max_removable(N + 1, 0);

        rep(i, N) {
            set_max(max_removable[i + 1], max_removable[i]);
            repeat(j, i + 1, N) {                
                if(removable(i, j)) set_max(max_removable[j + 1], max_removable[i] + j - i + 1);
            }
        }
        cout << max_removable.back() << endl;
        return true;
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(true) {
        Solver s;
        if(not s.solve()) break;
    }
    return 0;
}

Measured memory_bytes: 3284
# -*- coding: utf-8 -*-
import math

# スペース区切りの整数の入力
N = int(input())
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())

bottle_neck=min(A,B,C,D,E)

ans= 4 + math.ceil(N/bottle_neck)

print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip>//setprecision
#include<math.h>
#include <functional>
#include<climits>
using namespace std;
#define rep(i, n)        for(int i=0; i<(int)(n); ++i)
int sub(int a,vector<char>b,int c,int d){
  if(c%2019==0&&c!=0)return 1;
  return sub(a+1,b,c+b[d]*a,d+1);
}
int main(){ 
  long long int a,b,c=0,d,e=0,f;
  cin>>a;
  b=a/11+1;
  b*=2;
  if(a%11<7&&a%11!=0)b--;
  else if(a%11==0)b-=2;
  cout<<b;
  }


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

const int MOD = 1000000007;

//long long
using ll = long long;

//出力系
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()

//for
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

//最大公約数 
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

 int main(){
 int A, B, C;
 cin >> A >> B >> C;
 if(A == B) print(C);
 if(A == C) print(B);
 if(B == C) print(A);
 
 }

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

using namespace std;
typedef long long ll;
typedef double db;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define inf 0x3f3f3f3f
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll a[212345];
signed main() {
	ll n, k, i, t;
	cin >> n >> k;
	for (i = 1; i <= n; ++i)cin >> a[i];
	for (i = k + 1; i <= n; ++i) {
		if (a[i] > a[i - k])cout << "Yes" << endl;
		else cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 5152
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

ll power(ll n, ll p) {
    ll ret = 1;
    rep(i, p) { ret *= n; }
    return ret;
}

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i, N) { cin >> A[i]; }
    ll res = power(3, N);
    ll ng = 1;
    rep(i, N) {
        if(A[i] % 2 == 1) {

        } else {
            ng *= 2;
        }
    }
    cout << res - ng << endl;
    return 0;
}

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

const int MOD = 1e9 + 7;

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

	int cost = 0;
	for (int i = 1; i < n; i++) {
		if (a[i] < a[i - 1]) {
			cost += a[i - 1] - a[i];
			a[i] = a[i - 1];
		}
	}

	cout << cost << '\n';
}

int32_t main() {
	int T; 
	// cin >> T;
	T = 1;
	while (T--)
		solve_test();

	return 0;
}


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

using namespace std;

#define ll long long
#define ull unsigned long long
#define PI acos(-1.0)
#define eps 1e-12
#define fi first
#define se second
#define pb push_back
#define MEM(a,b) memset((a),(b),sizeof(a))
#define mod(x) ((x)%MOD)
#define pii pair<int,int>
#define wz cout<<"-----"<<endl;
const int INF_INT = 2147483647;
const ll INF_LL = 9223372036854775807LL;
const ull INF_ULL = 18446744073709551615Ull;
const ll P = 92540646808111039LL;

const ll maxn = 1e5 + 10, MOD = 1e9 + 7;
const int Move[4][2] = {-1,0,1,0,0,1,0,-1};
const int Move_[8][2] = {-1,-1,-1,0,-1,1,0,-1,0,1,1,-1,1,0,1,1};

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


void init() {

}

char mp[111][111];
bool h[111],l[111];

vector<string> r;

int main(){
//    freopen("C:\\Users\\Administrator\\Desktop\\in.txt","r",stdin);
//    freopen("C:\\Users\\Administrator\\Desktop\\out.txt","w",stdout);
//    ios_base::sync_with_stdio(0);
    init();
    int n,m; cin >>n >>m;
    for (int i = 0; i < n; i++) cin >> mp[i];
    for (int i = 0; i <n; i++){
        bool flg = false;
        for (int j = 0; j < m; j++){
            if (mp[i][j] == '#') {
                flg = true;
            }
        }
        if (!flg) {
            h[i] = 1;
        }
    }

    for (int i = 0; i < m; i++) {
        bool flg = false;
        for (int j = 0; j < n; j++){
            if (mp[j][i] == '#') {
                flg = true;
            }
        }
        if (!flg) {
            l[i] = 1;
        }
    }
    for (int i = 0; i < n; i++) {
        string st;
        for (int j = 0; j < m; j++) {
            if (h[i] || l[j]) {

            } else {
                st += mp[i][j];
            }
        }
        if (st.size()) {
            r.pb(st);
        }

    }
    for (auto it:r) cout <<it <<endl;

    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
int main(){
	int h,w;
	scanf("%d%d",&h,&w);
	int a[h][w]={};
	for(int i=0;i<h;i++){
		char s[w]={};
		scanf("%s",s);
		for(int j=0;j<w;j++){
			if(s[j]=='#')a[i][j]=1;
		}
	}
	int u=0;
	for(int i=0;i<w;i++){
		int y=0;
		for(int j=0;j<u;j++){
			y+=a[j][i];
		}
		if(y!=0){
			u=-1;
			break;
		}
		for(int j=u;j<h;j++){
			if(a[j][i]==0){
				u=j-1;
				break;
			}
			if(a[j][i]==1&&j==h-1){
				u=j;
				break;
			}
		}
		for(int j=u+1;j<h;j++){
			if(a[j][i]==1){
				u=-1;
				break;
			}
		}
	}
	if(u==-1)printf("Impossible");
	else printf("Possible");
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define int long long
#define ll long long
using ull = unsigned long long;
using namespace std;
const int INF = 1e10;
const int MOD = 1e9 + 7;
#define dump(x)                             \
    if (dbg) {                              \
        cerr << #x << " = " << (x) << endl; \
    }
#define overload4(_1, _2, _3, _4, name, ...) name
#define FOR1(n) for (ll i = 0; i < (n); ++i)
#define FOR2(i, n) for (ll i = 0; i < (n); ++i)
#define FOR3(i, a, b) for (ll i = (a); i < (b); ++i)
#define FOR4(i, a, b, c) for (ll i = (a); i < (b); i += (c))
#define FOR(...) overload4(__VA_ARGS__, FOR4, FOR3, FOR2, FOR1)(__VA_ARGS__)
#define FORR(i, a, b) for (int i = (a); i <= (b); ++i)
template <class T>
bool chmin(T& a, const T& b) {
    if (a > b) {
        a = b;
        return 1;
    } else
        return 0;
}
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    } else
        return 0;
}
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(), (v).end()
#define SZ(x) ((int)(x).size())
#define P pair<int, int>
#define V vector<int>
//#define S set<int>
#define itn int
bool dbg = false;

int N;
int a[202020];


void solve() {
    itn ans = -1;
    int tmp = 0;
    FOR(i, N) {
        if (a[i] == tmp + 1) {
            tmp++;
        }
    }
    if (tmp == 0) {
        cout << ans << endl;
    } else {
        cout << N - tmp << endl;
    }
}

signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cin >> N;
    FOR(N)
    cin >> a[i];
    solve();
    return 0;
}


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

using namespace std;
typedef long long ll;
typedef long int lt;
typedef vector<ll> vi;
typedef vector<int> vin;
typedef pair<ll,ll> pll;
typedef pair<int,int> pin;
#define all(a) a.begin(),a.end()
#define rep(i,a,b) for(int i=a;i<b;++i)
#define f(i,b) for(int i=0;i<b;++i)
#define per(i,a,b) for(int i=a;i>=b;--i)
#define test(t) int t; cin>>t; while(t--) solve()
#define endl "\n"
#define p1 cout<<"YES"<<endl
#define p0 cout<<"NO"<<endl
#define fst ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define read(x) for(auto &i:x) cin>>i;

const int mod=1e9+7;

ll mod_pow(ll a,ll n,ll mod)	//(a^n)%mod
{	ll res=1;
	while(n){	if(n&1)	res=(res*a)%mod; n/=2; a=(a*a)%mod;	}
	return res;
}
/*
    xi<xj yi<yj     xj-xi + yj -yi == xj+yj - (xi+yi)
    xi<xj yi>yj     xj-xi + yi-yj  == xj-yj - (xi-yi)
    xi>xj  ||       xi-xj + yi-yj  == xi+yi -(xj+yj)
    xi>xj yi<yj
*/


void solve()
{
    int n;
    cin>>n;
    vector<pll> a(n);

    for(int i=0;i<n;++i) cin>>a[i].first>>a[i].second;

    sort(all(a),[&](pll a,pll b)
    {
        return a.first+a.second<b.first+b.second;
    });

    ll ans=abs(a[0].first-a[n-1].first)+abs(a[0].second-a[n-1].second);

     sort(all(a),[&](pll a,pll b)
    {
        return a.first-a.second<b.first-b.second;
    });

    ans = max(ans,abs(a[0].first-a[n-1].first)+abs(a[0].second-a[n-1].second));

    cout<<ans<<endl;

    
}

int main()
{
    fst;
    //test(t);
    solve();
}



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

Measured memory_bytes: 580
N, M, C = map(int,input().split())
B = list(map(int,input().split()))
A = [list(map(int,input().split())) for _ in range(N)]

ans = 0
for a in A:
  tmp = C
  for j in range(M):
    tmp += a[j]*B[j]
  if tmp > 0:
    ans += 1
print(ans)

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

int main()
{
  int n, m;
  cin >> n >> m;
  char c[n][m];
  rep(i, n){
    rep(j, m) cin >> c[i][j];
  }
  
  string s = "Yes";
  int cnt;
  rep(i, n){
    rep(j, m){
      if(c[i][j] == '.') continue;
      cnt = 0;
      if(i != 0 && c[i - 1][j] == '#') cnt++;
      if(i != n - 1 && c[i + 1][j] == '#') cnt++;
      if(j != 0 && c[i][j - 1] == '#') cnt++;
      if(j != m - 1 && c[i][j + 1] == '#') cnt++;
      if(cnt == 0) {
        s = "No";
      }
    }
  }
  cout << s << endl;
       

  return 0;
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
using vvll = vector< vector<ll> >;
using vll = vector<ll> ;    
using pll = pair<ll, ll> ;
 
#define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define I insert
#define ar array
#define endl '\n'
#define all(x) x.begin(), x.end()
#define sz(x) ((long long)x.size())
 
 
template<typename T> void umin(T& a,T b){a = min(a,b);}
template<typename T> void umax(T& a,T b){a = max(a,b);}
 
const ll maxs = 1e6+5;
const ll lmaxs = 20;
ll mod = 1e9+7;
ll oo = 1e15;
 
ll fast(ll x,ll y){
    ll res=1;
    while(y){
        if(y&1)
            res = (res*x)%mod;
        x = (x*x)%mod;
        y >>= 1;
    }
    return res;
}
 
ll inv(ll n){
    return fast(n,mod-2);
}
 
void pre(){
    
    
 
}




void solve(){    

    int n;
    cin >> n;
    int a[n+1], b[n+1];
    vector<int> ma(n+1,0) , mb(n+1,0);
    for(int i=0;i<n;i++){
        cin >> a[i];
        ma[a[i]]++;
    } 
    for(int i=0;i<n;i++){
        cin >> b[i];
        mb[b[i]]++;
    }

    for(int i=0;i<=n;i++){
        if(ma[i] + mb[i] > n){
            cout << "No";
            return;
        }
    }
    cout << "Yes\n";
    int v[n+1];
    for(int i=0;i<n;i++){
        int ind = upper_bound(b,b+n,a[i]) - b;
        v[i] = ind;
        if(i)umax(v[i],v[i-1] + 1);
    } 
    for(int i=n-2;i>=0;i--){
        umax(v[i] , v[i+1] - 1);
    }
    for(int i=0;i<n;i++){
        cout << b[v[i]%(n)] << " ";
    }   

}
 
int32_t main(){
    #ifndef ONLINE_JUDGE
    freopen("input00.txt","r",stdin);
    freopen("output00.txt","w",stdout);
    #endif
    IOS;
    pre();
    ll T = 1;
    //cin >> T;
    while(T--){
        static int i=1;
        //cout << "Case #" << i << ": ";
        i++;
        solve();   
    }
    return 0;
} 

Measured memory_bytes: 7224
#include <stdio.h>
#define NMAX 100000
int main(void)
{
  int i, n, s = 0, t = 0, a[NMAX];
  long long ans = 0, p[3], asum[NMAX*2];
  scanf("%d", &n);
  for (i = 0; i < n; i++) scanf("%d", &a[i]);
  asum[0] = a[0];
  for (i = 1; i < n * 2; i++) asum[i] = asum[i-1] + a[i%n];
  p[0] = 0;
  while (s < n) {
    int lo, hi, mid = 0;
    while (mid != s + n - 1) {
      while (p[0] <= ans) {
        t++;
        p[0] += a[(t-1)%n];
      }
      lo = t;
      hi = s + n - 1;
      while (hi >= lo) {
        mid = (lo + hi) / 2;
        if (asum[mid] >= p[0] + asum[t-1]) hi = mid - 1;
        else lo = mid + 1;
      }
      if (mid != s + n - 1) {
        p[1] = asum[lo] - asum[t-1];
        p[2] = asum[n-1] - p[0] - p[1];
        if (p[2] >= p[0]) ans = p[0];
        else break;
      }
    }
    s++;
    p[0] = asum[t-1] - asum[s-1];
  }
  printf("%lld\n", ans);
}


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

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define rep(i, k, n) for (int i = (int)(k); i < (int)(n); ++i)
#define rrep(i, k, n) for (int i = (int)(n) - 1; i >= (int)(k); --i)

typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vii> vv_ii;
typedef pair<int,ii> i_ii;
typedef vector<i_ii> vi_ii;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;

template <class T>
inline ostream& operator<<(ostream & o, vector<T> const& v) {
    for (int i = 0; i < (int)(v.size()) - 1; ++i)
        o << v[i] << ' ';
    if (!v.empty())
        o << v.back();
    return o;
}

template <class T, class Q>
inline ostream& operator<<(ostream & o, pair<T,Q> const& p) {
    o << "(" << p.fi << "," << p.se << ")";
    return o;
}

#define MOD 1000000007

inline int fun(vector<ull> const& v, int ind) {
    int x = v[ind];
    int ans = 0;
    rep(i, ind + 1, v.size()) {
        ans += (x ^ v[i]);
    }
    return ans;
}

inline void count(ull a, ull & x, ull & y) {
    //x = y = 0ULL;
    while (a) {
        ++((a & 1ULL) == 1ULL ? x : y);
        a >>= 1ULL;
    }
    x %= MOD;
    y %= MOD;
}

int main(){

    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);

    int n;
    cin >> n;
    vector<ull> v(n);
    rep(i, 0, n)
        cin >> v[i];

    ull ans = 0;
    for (ull i = 0ULL; i < 64ULL; ++i) {
        ull x = 0, y = 0;
        rep(j, 0, n) {
            //count(v[j], x, y);
            //cerr << "v[j] -> " << v[j] << " x -> " << x << " y -> " << y << endl;
            ++((v[j] & 1ULL) == 1ULL ? x : y);
            v[j] >>= 1ULL;
        }
        //cerr << "x -> " << x << " y -> " << y << endl;
        ans += ((((x % MOD) * (y % MOD)) % MOD) * ((1ULL << i) % MOD)) % MOD;
    }
    
    cout << ans % MOD << '\n';

    return 0;
}

Measured memory_bytes: 2560