akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int a[] = new int [n];
		int b[] = new int [n];
		int c[] = new int [n];
		for(int i=0;i<n;i++){
			a[i] = scan.nextInt();
			b[i] = scan.nextInt();
			c[i] = scan.nextInt();
			a[i]=a[i]*a[i];
			b[i]=b[i]*b[i];
			c[i]=c[i]*c[i];
			if(a[i]==b[i]+c[i])
				System.out.println("YES");
			else if(b[i]==a[i]+c[i])
				System.out.println("YES");
			else if(c[i]==b[i]+a[i])
				System.out.println("YES");
			else System.out.println("NO");
		}
	}
}

Measured memory_bytes: 21592
use std::collections::VecDeque;
fn main() {
    let mut sc = Scanner::new();
    let n = sc.usize_read();
    let m = sc.usize_read();
    let mut graph = vec![vec![]; n];
    for _ in 0..m {
        let a = sc.usize_read() - 1;
        let b = sc.usize_read() - 1;
        graph[a].push(b);
        graph[b].push(a);
    }

    let q = sc.usize_read();
    let queries: Vec<(usize, usize, usize)> = (0..q)
        .map(|_| (sc.usize_read() - 1, sc.usize_read(), sc.usize_read()))
        .collect();

    let mut ans = vec![0; n];
    let mut max_d = vec![-1; n];
    for q in (0..q).rev() {
        let (v, d, c) = queries[q];
        let mut queue = VecDeque::new();
        queue.push_back((v, d as i32));
        while let Some((v, d)) = queue.pop_front() {
            if max_d[v] >= d {
                continue;
            }
            max_d[v] = d;
            if ans[v] == 0 {
                ans[v] = c;
            }
            for &to in &graph[v] {
                queue.push_back((to, d - 1));
            }
        }
    }
    for &c in &ans {
        println!("{}", c);
    }
}

struct Scanner {
    ptr: usize,
    length: usize,
    buf: Vec<u8>,
    small_cache: Vec<u8>,
}

#[allow(dead_code)]
impl Scanner {
    fn new() -> Scanner {
        Scanner {
            ptr: 0,
            length: 0,
            buf: vec![0; 1024],
            small_cache: vec![0; 1024],
        }
    }

    fn load(&mut self) {
        use std::io::Read;
        let mut s = std::io::stdin();
        self.length = s.read(&mut self.buf).unwrap();
    }

    fn byte(&mut self) -> u8 {
        if self.ptr >= self.length {
            self.ptr = 0;
            self.load();
            if self.length == 0 {
                self.buf[0] = b'\n';
                self.length = 1;
            }
        }

        self.ptr += 1;
        return self.buf[self.ptr - 1];
    }

    fn is_space(b: u8) -> bool {
        b == b'\n' || b == b'\r' || b == b'\t' || b == b' '
    }

    fn read_vec<T>(&mut self, n: usize) -> Vec<T>
    where
        T: std::str::FromStr,
        T::Err: std::fmt::Debug,
    {
        (0..n).map(|_| self.read()).collect()
    }

    fn usize_read(&mut self) -> usize {
        self.read()
    }

    fn read<T>(&mut self) -> T
    where
        T: std::str::FromStr,
        T::Err: std::fmt::Debug,
    {
        let mut b = self.byte();
        while Scanner::is_space(b) {
            b = self.byte();
        }

        for pos in 0..self.small_cache.len() {
            self.small_cache[pos] = b;
            b = self.byte();
            if Scanner::is_space(b) {
                return String::from_utf8_lossy(&self.small_cache[0..(pos + 1)])
                    .parse()
                    .unwrap();
            }
        }

        let mut v = self.small_cache.clone();
        while !Scanner::is_space(b) {
            v.push(b);
            b = self.byte();
        }
        return String::from_utf8_lossy(&v).parse().unwrap();
    }
}


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

#define PI 3.1415926535897

typedef long long ll;

using namespace std;


ll n, m, q;
ll* a;
ll* b;
ll* c;
ll* d;

int ans;

void dfs(vector<int> A) {
	if (A.size() == n + 1) {
		int now = 0;
		for (int i = 0; i < q; i++) {
			if (A[b[i]] - A[a[i]] == c[i]) {
				now += d[i];
			}
		}

		ans = max(ans, now);

		return;
	}

	A.push_back(A.back());

	while (A.back() <= m) {
		dfs(A);

		A.back()++;
	}

}

int main() {

	cin >> n >> m >> q;

	a = new ll[q];
	b = new ll[q];
	c = new ll[q];
	d = new ll[q];

	for (int i = 0; i < q; i++) {
		cin >> a[i] >> b[i] >> c[i] >> d[i];
	}

	dfs(vector<int>(1,1));
	cout << ans;
}

Measured memory_bytes: 3544
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <math.h>

using namespace std;

int main(){
    int n, max=0;
    cin >> n;
    vector<int> vc(n, 0);
    for(int i=1; i<n; i++){
        int a;
        cin >> a;
        --a;
        vc[a]++;
    }

    for(int i=0; i<n; i++){
        cout << vc[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 4012
#include <stdio.h>
#include <math.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;

int main(void)
{
    int n, d;
    int ans = 0, p[10][10] = {0};
    scanf("%d%d", &n, &d);
    rep(i, n)
        rep(j, d)
            scanf("%d", &p[i][j]);

    for (int i = 0; i < n; i++)
        for (int j = 0; j < n; j++)
            if (i != j)
            {
                ll dist = 0;
                rep(k, d)
                    dist += (p[i][k] - p[j][k]) * (p[i][k] - p[j][k]);
                int tmp = sqrt(dist);
                if (tmp * tmp == dist)
                    ans++;
            }

    printf("%d\n", ans / 2);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const ll mod = 1000000007;
const int INF = 1001001001;
const ll LINF = 1001001001001001001;
vector<ll> a;
ll n,k;

ll gutyoku(){
    vector<ll> test(0);
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            test.push_back(a.at(i)*a.at(j));
        }
    }
    sort(test.begin(),test.end());
    for(auto i:test) cout << i << " ";
    cout << endl;
    return 0;
}


ll countltx(ll x){
    ll ans = 0;
    for(int i=0;i<n;i++){
        ll f = a.at(i);
        if(f<0){
            long double t = x/(long double)f;
            auto it = upper_bound(a.begin(),a.end(),t);
            ll num = it - a.begin();
            ans += n-num;
            if(num == 0) ans--;
            else if(*it<=f) ans--;
        }else if(a.at(i)>0){
            long double t = x/(long double)f;  
            auto it = lower_bound(a.begin(),a.end(),t);
            ll num = it - a.begin();
            ans += num;
            if(num == n) ans--;
            else if(*it>f) ans--;
        }else{
            if(0<x) ans += n-1;            
        }
        //cout << "i=" << i << " "  << ans << endl;
    }
    return ans/2;
}

int main(){
    cin >> n >> k;
    a.resize(n);
    rep(i,n) cin >> a.at(i);
    sort(a.begin(),a.end());
    
    ll left = -LINF, right = LINF;
    ll center = (left+right)/2;
    
    while(right-left>1){
        if(countltx(center)<k){
            left = center;
        }else{
            right = center;
        }
        center = (left+right)/2;
        //cout << left << " " << center << " " << right << endl;
    }
    /*
    for(int i=1;i<46;i++){
        ll left = -LINF, right = LINF;
        ll center = (left+right)/2;
        while(right-left>1){
            if(countltx(center)<i){
                left = center;
            }else{
                right = center;
            }
            center = (left+right)/2;
            //cout << left << " " << center << " " << right << endl;
        }
        cout << left << " ";
    }
    cout << endl;
    */
    
    
    //for(int i=-100;i<1;i++){
    //    cout << i << " " << countltx(i) << endl;
    //}
    
    //gutyoku();
    cout << left << endl;
    //for(int i=-13;i<17;i++) cout << "i=" << i << " " << countltx(i) << endl;
    
}

Measured memory_bytes: 1920
package main

import "fmt"

func main() {
        var a, b, count int
        fmt.Scan(&a, &b)
        for i := a; i <= b; i++ {
                if palindromic(i) {
                        count++
                }
        }
        fmt.Printf("%d\n", count)
}

func palindromic(input int) bool {
        tmp := input
        digits := []int{}
        for tmp != 0 {
                digits = append(digits, tmp%10)
                tmp /= 10
        }
        for i := 0; i < len(digits)/2; i++ {
                if digits[i] != digits[len(digits)-1-i] {
                        return false
                }
        }
        return true
}

Measured memory_bytes: 6400
#include <bits/stdc++.h>
#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 all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
typedef long long ll;
typedef pair<ll,ll> P;

bool can(ll x,ll y,ll t){
	ll nt;
	rep(i,61){
		if((t>>i)&1){
			nt = t ^ (1LL<<i);
			break;
		}
	}
	return x<=nt;
}

map<P,ll> memo;

ll solve(ll x,ll y){
	if(x==y) return 1;
	if(memo.count(P(x,y))) return memo[P(x,y)];

	ll r0 =  solve((x+1)/2,y/2);	//even
	ll r1 =  solve(x/2,y/2) - (y%2==0?(1-can(x/2,y/2-1,y/2)):0);
	ll res = r0 + r1;
	return memo[P(x,y)] = res;
}
int main(){
	ll A,B;
	cin>>A>>B;
	cout<<solve(A,B)<<endl;
}


Measured memory_bytes: 256
def examA():
    N = I()
    ans = 0
    print(ans)
    return

def examB():
    N, A, B, C, D = LI()
    for i in range(N-1):
        low = A + i*C - (N-1-i)*D
        up = A + i*D - (N-1-i)*C
        if low<=B<=up:
            print("YES")
            return
    print("NO")
    return

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

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

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

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

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LFI(): return list(map(float,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
alphabet = [chr(ord('a') + i) for i in range(26)]

if __name__ == '__main__':
    examB()

"""

"""

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

using namespace std;

const int INF = 1 << 30;
const std::vector<int> dx = {1, -1, 0, 0}, dy = {0, 0, 1, -1};

template <typename T>
bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int H, W, K;
  cin >> H >> W >> K;
  int sx, sy, gx, gy;
  cin >> sy >> sx >> gy >> gx;
  sx--, sy--, gx--, gy--;
  vector<string> S(H);
  for (int i = 0; i < H; i++) {
    cin >> S[i];
  }
  priority_queue<pair<int, pair<int, int>>, vector<pair<int, pair<int, int>>>,
                 greater<pair<int, pair<int, int>>>>
      que;
  que.push(make_pair(0, make_pair(sy, sx)));
  vector<vector<int>> G(H, vector<int>(W, INF));
  G[sy][sx] = 0;
  while (!que.empty()) {
    auto q = que.top();
    que.pop();
    int c = q.first, y = q.second.first, x = q.second.second;
    for (int i = 0; i < 4; i++) {
      int ny = y, nx = x;
      for (int k = 0; k < K; k++) {
        ny += dy[i], nx += dx[i];
        if (ny < 0 || ny >= H || nx < 0 || nx >= W) break;
        if (S[ny][nx] == '@') break;
        if (chmin(G[ny][nx], c + 1)) {
          que.push(make_pair(G[ny][nx], make_pair(ny, nx)));
        } else {
          if (G[ny][nx] != G[y][x] + 1) break;
        }
      }
    }
  }
  if (G[gy][gx] == INF) {
    cout << -1 << '\n';
  } else {
    cout << G[gy][gx] << '\n';
  }
  return 0;
}


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

public class Main {
  public static void main(String[] args)throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    String[] str = in.readLine().split(" ");
    int n = Integer.parseInt(str[0]);
    int d = Integer.parseInt(str[1]);
    int watchman = (d*2)+1;
    if(n%watchman != 0)
      System.out.println(n/watchman + 1);
    else
      System.out.println(n/watchman);
  }
}

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

bool isPrime(int x){
    int iter = pow(x, 0.5) + 1;
    for(int i=2;i<iter;i++){
        if(x%i == 0){
            return false;
        }
    }
    return true;
}
int main(){
    int x;
    cin >> x;
    for(int i=x;i<1000000;i++){
        if(isPrime(i)){
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 4060
fn main() {
	let mut s = String::new();
	use std::io::Read;
	std::io::stdin().read_to_string(&mut s).unwrap();
	let mut s = s.split_whitespace();
	let n: usize = s.next().unwrap().parse().unwrap();
	let mut coord: Vec<_> = (0..n).map(|i|{
		let x: i64 = s.next().unwrap().parse().unwrap();
		let y: i64 = s.next().unwrap().parse().unwrap();
		(Vec2(x, y), i)
	}).collect();
	coord.sort_by_key(|&(c, _)| (c.0 + 1000000) * 2000001 + (c.1 + 1000000));

	let mut k = 0;
	let mut ch: Vec<(Vec2<i64>, usize)> = vec![];
	for &(c, i) in coord.iter() {
		while k > 1 && (ch[k - 1].0 - ch[k - 2].0).cross(&(c - ch[k - 1].0)) <= 0 { k -= 1; }
		if k < ch.len() {
			ch[k] = (c, i);
		} else {
			ch.push((c, i));
		}
		k += 1;
	}
	let lk = k;
	for &(c, i) in coord.iter().rev().skip(1) {
		while k > lk && (ch[k - 1].0 - ch[k - 2].0).cross(&(c - ch[k - 1].0)) <= 0 { k -= 1; }
		if k < ch.len() {
			ch[k] = (c, i);
		} else {
			ch.push((c, i));
		}
		k += 1;
	}
	ch.resize(k - 1, <(Vec2<i64>, usize)>::default());
	let rad: Vec<f64> = (0..ch.len()).map(|i| (ch.get(i + 1).unwrap_or(&ch[0]).0 - ch[i].0).normal().atan()).collect();
	const TWOPI: f64 = std::f64::consts::PI * 2.;
	let prb: Vec<f64> = (0..rad.len()).map(|i| (((rad[i] - rad.get(i - 1).unwrap_or(rad.last().unwrap())) + TWOPI) % TWOPI) / TWOPI).collect();
	let mut ans: Vec<(usize, f64)> = prb.iter().zip(ch.iter()).map(|(&p, &(_, i))| (i, p)).collect();
	ans.sort_by_key(|a| a.0);
	let mut it = ans.into_iter().peekable();
	for i in 0..n {
		if let Some(&pair) = it.peek() {
			if pair.0 == i {
				println!("{}", pair.1);
				it.next();
			} else {
				println!("0");
			}
		} else {
			println!("0");
		}
	}
}

#[derive(Default, Clone, Copy)]
struct Vec2<T>(T, T);

macro_rules! impl_binops_vec2 {
	($(($op:ident, $method:ident)),+) => {$(
		impl<T: Copy + std::ops::$op<Output = T>> std::ops::$op for Vec2<T> {
			type Output = Self;
			fn $method(self, rhs: Self) -> Self::Output {
				Vec2((self.0).$method(rhs.0), (self.1).$method(rhs.1))
			}
		}
	)+};
}

macro_rules! impl_vec2_signed {
	($($T:ty),+) => {$(
		impl Vec2<$T> {
			fn normal(&self) -> Vec2<$T> {
				Vec2(-self.1, self.0)
			}
			fn cross(&self, rhs: &Self) -> $T {
				self.0 * rhs.1 - self.1 * rhs.0
			}
		}
	)+};
}

macro_rules! impl_vec2_float {
	($($Ts:ty),+; $F:ty) => {$(
		impl_vec2_float![implement $Ts, $F];
	)+};
	($($Ts:ty),+) => {$(
		impl_vec2_float![implement $Ts, $Ts];
	)+};
	(implement $T:ty, $F:ty) => {
		impl Vec2<$T> {
			fn atan(&self) -> $F {
				(self.1 as $F).atan2(self.0 as $F)
			}
		}
	};
}

impl_binops_vec2![(Sub, sub)];
impl_vec2_signed![i64];
impl_vec2_float![i64; f64];


Measured memory_bytes: 4352
N = int(input())
cap = 100
table = [0] * 10001

for x in range(1, cap):
    for y in range(1, cap):
        for z in range(1, cap):
            idx = x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x
            if idx <= 10000:
                table[idx] += 1

for i in range(1, N+1):
    print(table[i])


Measured memory_bytes: 68848
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
    int n,m;
    cin >> n >> m;
    int a[n];
    double sum = 0;
    for(int i=0;i<n;i++){
        cin >> a[i];
        sum += a[i];
    }
    double judge=sum/(m*4);
   // cout << judge << endl;
    int cnt=0;
    for(int i=0;i<n;i++){
        if(a[i] >= judge){
            cnt++;
        }
    }

    if(cnt < m){
        cout << "No" <<endl;
    }else{
        cout << "Yes" << endl;
    }
    return 0;
}


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

#include <assert.h>    // LON
#include <math.h>    // sqrt()


using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
typedef long long ll;
//typedef pair<int, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = LONG_LONG_MAX;
const ll MINF = -10e10;
//const int INF = INT_MAX;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }


//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

typedef priority_queue<ll, vector<ll>, greater<ll>> PQ_ASK;
const int mod = 1000000007;

class CumulativeSum {
    vector<ll> numbers;
    vector<ll> sums;

public:
    CumulativeSum(ll n) {
        numbers.resize(n);
        sums.resize(n);
    }

    void set(ll i, ll value) {
        numbers[i] = value;
    }

    ll getSum(ll i) {
        if (i == -1) return 0;
        if (i == sums.size()) return 0;
        return sums[i];
    }

    ll getSectionSum(ll start, ll end) {
        return getSum(end) - getSum(start - 1);
    }

    void calculate() {
        for (ll i = 0; i < numbers.size(); i++) {
            sums[i] = getSum(i - 1) + numbers[i];
        }
    }

    ll lb(ll k) {
        auto it = lower_bound(sums.begin(), sums.end(), k);
        return distance(sums.begin(), it);
    }

};


int main() {

    ll n, k;
    cin >> n >> k;

    map<ll, ll> numbers;
    rep(i, n) {
        ll a, b;
        cin >> a >> b;
        numbers[a] += b;
    }

    map<ll, ll> index_to_ans;

    CumulativeSum cs(numbers.size());
    {
        ll i = 0;
        for (auto e : numbers) {
            cs.set(i, e.second);
            index_to_ans[i] = e.first;
            i++;
        }
    }
    cs.calculate();
    ll index = cs.lb(k);

    cout << index_to_ans[index] << endl;

}



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

int main(){
  int n,m;
  int d[300][4];
  int dp[3][301];
  string tmp;

  while(cin >> n >> m){
    for(int i=0;i<n;i++){
      cin.ignore();
      getline(cin,tmp);
      for(int j=0;j<4;j++)cin >> d[i][j];
    }

    

    for(int i=0;i<3;i++){
      for(int j=0;j<=m;j++)dp[i][j] = 0;
    }

    for(int i=0;i<3;i++){
      for(int j=1;j<=m;j++){
	for(int k=0;k<=j;k++){
	  dp[i][j] = max(dp[i][j],dp[i][k]+dp[i][j-k]);
	  for(int l=0;l<n;l++){
	    if(d[l][0] == j-k)dp[i][j] = max(dp[i][j],dp[i][k]+d[l][i+1]);
	  }
	}
      }
    }

    int ans = 0;
    for(int i=0;i<3;i++)ans = max(ans,dp[i][m]);
    cout << ans << endl;
  }
}

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

int main() {
	int h, w;
	cin >> h >> w;
	string s[50];

	rep(i, h) cin >> s[i];
	const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
	const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

	rep(i, h) {
		rep(j, w) {
		if (s[i][j] == '#') continue;

		int num = 0;
		rep(d, 8) {
			const int ni = i + dy[d];
			const int nj = j + dx[d];
			if (ni < 0 || h <= ni) continue;
			if (nj < 0 || w <= nj) continue;
			if (s[ni][nj] == '#') num++;
		}
		s[i][j] = char(num + '0');
		}
	}

	rep(i, h) cout << s[i] << endl;



	return 0;
}

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

using namespace std;

long long int acum = 0;
int n;

int main()
{

    cin >> n;

    for (int i = 1; i <= n; i++)
    {
        if ((i % 3 != 0) && (i % 5 != 0))
        {
            
            acum += i;
        }
            
    }

    cout << acum << endl;



    return 0;
}

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

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) v.erase(unique(v.begin(), v.end()), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

#define MAX_V 1000000
ll mod = 1e9 + 7;

ll modpow(ll a, ll n, ll mod) {
	ll res = 1;
	while(n > 0) {
		if(n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}

	return res;
}

ll modinv(ll a, ll m) {
	return modpow(a, m - 2, m);
}

ll modkaijo(ll n) {
	ll res = 1;
	while(n > 1) {
		res = (res % mod) * (n % mod);
		n--;
	}

	return res;
}

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

	ll H, W, A, B;
	cin >> H >> W >> A >> B;

	ll fact[H + W], invfact[H + W];
	fact[0] = invfact[0] = 1;
	rep(i, 1, H + W) {
		fact[i] = (fact[i - 1] * i) % mod;
		invfact[i] = modinv(fact[i], mod);
	}


		
	ll res = 0;
	rep(i, B, W) {
		ll h = H - A - 1, w = i;
		ll tmp = fact[h + w] * invfact[h] % mod * invfact[w] % mod;
		h = A - 1, w = W - i - 1;
		tmp *= (fact[h + w] * invfact[h] % mod * invfact[w] % mod);
		res += tmp % mod;
	}

	cout << res % mod << endl;

}


Measured memory_bytes: 3328
N,M = gets.split.map(&:to_i)
a,b = N.times.map{gets.split.map(&:to_i)}.transpose
c,d = M.times.map{gets.split.map(&:to_i)}.transpose
N.times do |n|
    ans = []
    sum = 0
    M.times do |m|
        sum = (a[n] - c[m]).abs + (b[n] - d[m]).abs
        ans << sum
    end
    puts ans.index(ans.min) + 1
end


Measured memory_bytes: 1788
/*
#pragma GCC optimize(2)
#pragma GCC optimize(3,"Ofast","inline")
*/
#include<bits/stdc++.h>
#define ALL(x) (x).begin(),(x).end()
#define ll long long
#define db double
#define ull unsigned long long
#define pii_ pair<int,int>
#define mp_ make_pair
#define pb push_back
#define fi first
#define se second
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define show1(a) cout<<#a<<" = "<<a<<endl
#define show2(a,b) cout<<#a<<" = "<<a<<"; "<<#b<<" = "<<b<<endl
using namespace std;
const ll INF = 1LL<<60;
const int inf = 1<<30;
const int maxn = 2e5+5;
inline void fastio() {ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);}


int main()
{
    fastio();
    int d,t,s;
    cin>>d>>t>>s;
    if(t*s >= d) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 3648
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
using ll = long long;
using P = pair<ll,ll>;

int main(){
ios::sync_with_stdio(false);
std::cin.tie(nullptr);
ll n;
cin >> n;
vector<ll> p(n);
vector<ll> perm(n + 1,-1);
rep(i,n){
    cin >> p[i];
    perm[p[i]] = i + 1;
}
ll max_stan = 1;
ll cnt = 1;
for(int i = 2; i <= n; i++){
    if(perm[i] > perm[i - 1])
        cnt++;
    else{
        max_stan = max(max_stan,cnt);
        cnt = 1;
    }
}
max_stan = max(max_stan,cnt);
cout << n - max_stan << endl;
}


Measured memory_bytes: 6340
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n;
	vector <int> a(n), b(n), c(n);
	cin >> n;
	for(int i = 0; i < n; i++) cin >> a[i];
	for(int i = 0; i < n; i++) cin >> b[i];
	for(int i = 0; i < n - 1; i++) cin >> c[i];
	
	long long sum = 0;
	for(int i = 0; i < n; i++) sum += b[a[i] - 1];
	for(int i = 1; i < n; i++) if(a[i] == a[i - 1] + 1) sum += c[a[i - 1] - 1];
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll lcm(ll a, ll b){return (1ll*a*b)/gcd(a, b);}

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int a,b;
    cin>>a>>b;
    if(a>9 || a==0 || b>9 || b==0)
    {
        return puts("-1"),0;
    }
    cout<<a*b;
}


Measured memory_bytes: 256
import sys


# 一つ前の座標と、方向を返す
def f(x, y, i):
    d = 1 << i
    if y > x and y > -x:
        return x, y - d, "U"
    elif y < x and y > -x:
        return x - d, y, "R"
    elif y < x and y < -x:
        return x, y + d, "D"
    else:
        return x + d, y, "L"


N = int(input())
X = []
Y = []
mx = 0
for i in range(N):
    x, y = [int(x) for x in input().split()]
    mx = max(abs(x) + abs(y), mx)
    X.append(x)
    Y.append(y)

s = (X[0] + Y[0]) % 2
for i in range(N):
    if s != (X[i] + Y[i]) % 2:
        print(-1)
        sys.exit(0)

# s == 1 のとき：D:[1,2,4,8,...]
# s == 0 のとき：D:[1,1,2,4,8,...]

if s == 0:
    X = [x - 1 for x in X]

D = []
d = 1
while d < mx:
    D.append(d)
    d = d * 2

m = len(D)
print(m if s != 0 else m + 1)
if s == 0:
    D = [1] + D
print(" ".join([str(d) for d in D]))

for i in range(N):
    x, y = X[i], Y[i]
    dirs = []
    for j in range(m - 1, -1, -1):
        x, y, dir = f(x, y, j)
        dirs.append(dir)
    if s == 0:
        dirs.append("R")
    print("".join(dirs[::-1]))


Measured memory_bytes: 3444
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]

n,m=n1()
sc=n3(m)

d={i:-1 for i in range(1,n+1)}
ans=9999
for i in range(m):
    if d[sc[i][0]]>=0 and d[sc[i][0]]!=sc[i][1]:
        ans=-1
        break;
    else:
        d[sc[i][0]]=sc[i][1]
else:
    if len(d)==3:
        if d[1]==0:
            ans=-1
        if d[1]==-1:d[1]=1
        if d[2]==-1:d[2]=0
        if d[3]==-1:d[3]=0
        if ans!=-1:ans=d[1]*100+d[2]*10+d[3]
    elif len(d)==2:
        if d[1]==0:
            ans=-1
        if d[1]==-1:d[1]=1
        if d[2]==-1:d[2]=0
        if ans!=-1:ans=d[1]*10+d[2]
    else:
        if d[1]==-1:d[1]=0
        if ans!=-1:ans=d[1]
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a[3],n;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a[0]>>a[1]>>a[2];
		sort(a,a+3);
		if(a[0]*a[0]+a[1]*a[1]==a[2]*a[2]) cout<<"YES"<<endl;
		else cout<<"NO"<<endl;
	} 
}


Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
int main(void){
    long long int x,y;
    cin>>x>>y;
    if (x%y==0) {
        cout<<-1<<endl;
    } else {
        for (long long int i=1;x*i<=1000000000000000000;i++) {
            if (x*i%y!=0) {
                cout<<x*i<<endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 3636
//abc177_c.cpp
//Sat Aug 29 20:53:38 2020

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
#define MOD 1000000007
#define rep(i,n) for (int i=0;i<(n);++i)

using namespace std;
using ll=long long;
typedef pair<int,int> P;

struct mint {
	ll x; // typedef long long ll;
	mint(ll x=0):x((x%MOD+MOD)%MOD){}
	mint operator-() const { return mint(-x);}
	mint& operator+=(const mint a) {
		if ((x += a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += MOD-a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator*=(const mint a) { (x *= a.x) %= MOD; return *this;}
	mint operator+(const mint a) const { return mint(*this) += a;}
	mint operator-(const mint a) const { return mint(*this) -= a;}
	mint operator*(const mint a) const { return mint(*this) *= a;}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t>>1);
		a *= a;
		if (t&1) a *= *this;
		return a;
	}

	// for prime mod
	mint inv() const { return pow(MOD-2);}
	mint& operator/=(const mint a) { return *this *= a.inv();}
	mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}


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

	mint a[n];
	mint sum[n];
	rep(i,n){
		cin >> a[i];
		if (i==0){
			sum[0] = a[0];
		}else {
			sum[i] = sum[i-1]+a[i];
		}
	}

	mint ans = 0;
	for(int i=n-1;i>0;i--){
		ans += a[i]*sum[i-1];
	}


	cout << ans << endl;
//	printf("%.4f\n",ans);
}

Measured memory_bytes: 6748
a,b,c,x,y = map(int, input().split())

mins, maxs = min(x,y), max(x,y)
diff = maxs - mins

total = min((a+b) * mins, c * mins*2)

pp = a if x > y else b
total += (pp if pp < c * 2 else c * 2 ) * diff
print(total)

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


int main() {
    int X, Y, Z, K; cin >> X >> Y >> Z >> K;
    vector<long long> A(X); for (int i = 0; i < X; i++) cin >> A[i];
    vector<long long> B(Y); for (int i = 0; i < Y; i++) cin >> B[i];
    vector<long long> C(Z); for (int i = 0; i < Z; i++) cin >> C[i];

    sort(A.rbegin(), A.rend());
    sort(B.rbegin(), B.rend());
    sort(C.rbegin(), C.rend());

    using state_t = tuple<long long, int, int, int>;  // (value, i, j, k)
    set<state_t> visited;
    priority_queue<state_t> q;

	auto visit = [&](int i, int j, int k) {
		state_t s(A[i] + B[j] + C[k], i, j, k);
		if (visited.emplace(s).second) {
			q.emplace(s);
		}
	};
    visit(0, 0, 0);

	vector<long long> ans;
	while (ans.size() < K) {
		long long s;
		int i, j, k;
		tie(s, i, j, k) = q.top();
		q.pop();
		
		ans.push_back(s);
 
		if (i + 1 < X) visit(i + 1, j, k);
		if (j + 1 < Y) visit(i, j + 1, k);
		if (k + 1 < Z) visit(i, j, k + 1);
	}
 
	for (auto e : ans) {
		cout << e << endl;
	}

    return 0;
}

Measured memory_bytes: 896
#include<bits/stdc++.h>
#define ll          long long int
#define ld          long double
#define pb          push_back
#define mp          make_pair
#define ff          first
#define se          second
#define endl        '\n'
#define fd(n)       fixed<<setprecision(n)
#define MAX         100000000000001
#define MAXN        200005
#define mod         1000000007
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,k;
    cin>>n>>k;
    if(k==1){
        cout<<0;
    }
    else{
        cout<<n-k;
    }
}

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

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  double ans = 0;
  rep(i,n){
    ans += (double)1/a[i];
  }
  
  double ans1 = 1/ans;
  
  printf("%.10f\n",ans1);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pb push_back
#define f(i,x,n) for(int i=x;i<n;i++)
#define all(c) c.begin(),c.end()
#define int ll
using ll = long long;
using pii = pair<int,int>;
const int MOD = 1e9+7, N = 1e5 + 10; 

int32_t main(){
   ios::sync_with_stdio(false);
   cin.tie(NULL);
   int n,k;
   cin >> n >> k;
   vector<bool> R(n+1,true);
   f(i,0,k){
      int d;
      cin >> d;
      int v;
      f(j,0,d){
         cin >> v;
         R[v] = false;
      }
   }
   int ans = 0;
   f(i,1,n+1) ans += R[i];
   cout << ans ;
   return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1e9
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

vector<int> places[210000];
ll dp[210000];
void add(ll &a,ll b){a+=b; if(a>=MOD) a-=MOD;}

int main(){
	int n;
	cin>>n;
	vector<int> c(n);
	rep(i,n) cin>>c[i];

	for(int i=0;i<210000;i++) places[i].clear();
	rep(i,n) places[c[i]].push_back(i);

	dp[0]=1;
	for(int i=1;i<=n;i++){
		add(dp[i],dp[i-1]);

		int color=c[i-1];
		int it=lower_bound(places[color].begin(),places[color].end(),i-1)-places[color].begin();
		if(it>0){
			int j=places[color][it-1];
			if((i-1)-j>1) add(dp[i],dp[j+1]);
		}
	} 
	cout<<dp[n]<<endl;
}

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

int f(const string &S, char start_ch)
{
    char ch = start_ch;
    int count = 0;
    for (auto s : S)
    {
        if (s != ch)
        {
            count++;
        }
        ch = (ch == '0') ? '1' : '0';
    }
    return count;
}

int main_()
{
    string S;
    cin >> S;

    cout << min(f(S, '0'), f(S, '1')) << endl;
}
int main()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);
    main_();
    return 0;
}


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

int main(){
    int A, B, C, K;
    int sum = 0;
    cin >> A >> B >> C >> K;
    
    if(A > K){
        sum = K;
    }else if((A + B) >= K){
        sum = A;
    }else{
        sum = A - (K - (A + B));
    }

    cout << sum << endl;
}

Measured memory_bytes: 3632
n = int(input())
xyh = [list(map(int, input().split())) for _ in range(n)]
xyh.sort(key=lambda x: x[2], reverse=True)
ans = []

for cx in range(101):
    for cy in range(101):
        x, y, h = xyh[0]
        ch = h + abs(x - cx) + abs(y - cy)
        if all([h == max(ch - abs(x - cx) - abs(y - cy), 0) for x, y, h in xyh[1:]]):
            ans = [cx, cy, ch]
            break
print(*ans, sep=' ')

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

int main() {
  long long x;
  cin >> x;
  long long p = 100;
  int step = 0;
  while(p < x) {
    p += p / 100;
    step++;
  }
  cout << step << endl;
} 


Measured memory_bytes: 3592
N = int(input())
H = [int(i) for i in input().split()]
#N =7
#H = [4,4,5,6,6,5,5]

good_count = 0
good_counts = []


for i in range(N-1, 0, -1):
    temp1 = H[i]
    temp2 = H[i-1]
    #print(temp1, temp2)
    if temp1<= temp2:
        good_count += 1
    else:
        good_counts.append(good_count)
        good_count = 0
good_counts.append(good_count)
print(max(good_counts))

Measured memory_bytes: 14224
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <queue>
#include <functional>
#include <utility>
#include <unordered_map>
#define INF 9999999
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

int main() {
	int N,i;
	cin >> N >> i;
	cout << N - i + 1 << endl;
	return 0;
}

Measured memory_bytes: 256
N = int(input())
A = [0] + list(map(int, input().split()))
A.sort()
A_max = A[-1]
dp = [1] * (1 + A_max)
from bisect import bisect_left, bisect_right

for x in A[1:]:
    if dp[x] == 0:
        continue
    y = x * 2
    while y <= A_max:
        dp[y] = 0
        y += x
ans = []
for i in range(1, A_max+1):
    if dp[i] == 1:
        idx_l = bisect_left(A, i)
        idx_r = bisect_right(A, i)
        if idx_r - idx_l > 1:
            continue
        if A[idx_l] == i:
            ans.append(idx_l)
print(len(ans))


Measured memory_bytes: 113764
def solve():
  N = int(input())
  p = []
  for i in range(N):
    p.append(int(input()))
  mx = max(p)
  ans = 0
  for i in range(N):
    if p[i] == mx:
      p[i] = int (p[i] / 2)
      mx = 0
    ans = ans + p[i]
  print(ans)

if __name__ == '__main__':
  solve()


Measured memory_bytes: 3060
s = input().split()
a = int(s[0])
b = int(s[1])
c = int(s[2])

if a == b and b != c:
  print("Yes")
  exit()
if a == c and b != c:
  print("Yes")
  exit()
if c == b and a != c:
  print("Yes")
  exit()

print("No")

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



int main() 
{
  ll N,M; cin>>N>>M;
  if(N==1&&M==1) {cout<<1<<endl; return 0;}
  cout<<abs((N-2)*(M-2))<<endl;
  return 0;
}

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

using namespace std;

int main(){

    int N;
    cin >> N;
    vector<int> A(N);
    for(int i = 0; i < N; i++){
        cin >> A[i];
    }

    for(int i = 0; i < N; i++){
        if(A[i] % 2 == 0){
            if(A[i] % 3 != 0 && A[i] % 5 != 0){
                cout << "DENIED" << endl;
                return 0;
            }
        }
    }

    cout << "APPROVED" << endl;

    return 0;
}

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

int main()
{
  long long x;
  int n=0;
  cin >> x;
  long long m = 100;
  bool loop = true;
  
  while (loop) {
    n++;
    m = (long long)((double)m *1.01);
    if (m>=x) loop = false;
  }
  
  cout << n << endl;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll ZERO = 0;
const int INF = 1e9;
const ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<int,int> P;

int main() {
    int N;
    cin >> N;
    vector<pair<int,int>> vec(N);
    for(int i = 0;i < N;i++) {
        int A,B;
        cin >> A >> B;
        vec.at(i) = make_pair(A + B,A - B);
    }
    sort(vec.begin(),vec.end());
    int ans = 0;
    ll t = -INF;
    for(int i = 0;i < N;i++) {
        if(t <= vec[i].second) {
            ans++;
            t = vec[i].first;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;

vector<int> to[600];//[]の中の人がどこに行けるか
bool res[600] = {};

void bfs()
{
	queue<int> q;

	for(int i=0;i<to[1].size();++i){
		q.push(to[1][i]);
	}
	for(int i=0;i<2;++i)
	{
		int size = q.size();
		for(int i=0;i<size;++i)
		{
			int now = q.front();q.pop();
			if(res[now]) continue;
			res[now] = true;
			for(int i=0;i<to[now].size();++i){
				q.push(to[now][i]);
			}
		}
	}
}

int main(void)
{
	while(1)
	{
		for(int i=0;i<501;++i){
			to[i].clear();
			res[i] = false;
		}
		int n;
		int m;
		cin >> n >> m;
		if(n == 0 || m == 0) return 0;
		for(int i=0;i<m;++i){
			int a,b;
			cin >> a >> b;
			to[a].push_back(b);
			to[b].push_back(a);
		}
		bfs();
		int count = 0;
		for(int i=2;i<501;++i){
			if(res[i])
				++count;
		}
		cout << count << endl;
	}
	return 0;
}

Measured memory_bytes: 1440
n = int(input()) 
t = [int(input()) for i in range(n)] 

minv = t[0]
maxv = t[1] - t[0]

for i in range(1, n):
    maxv = max([maxv, t[i] - minv])
    minv = min([minv, t[i]])

print(maxv)


Measured memory_bytes: 13592
import Control.Monad
import Control.Applicative
import Data.List

main = do
  xs <- input $ map read . words :: IO [[Int]]
  mapM_ putStrLn $ solve xs
  
solve :: [[Int]] -> [String]
solve [] = []
solve (xs:ys:yss) = (show h ++ " " ++ show b) : solve yss
  where h = hit xs ys
        b = smn xs ys - h

hit :: [Int] -> [Int] -> Int
hit xs ys = sum $ zipWith (\x y -> if x == y then 1 else 0) xs ys

smn :: [Int] -> [Int] -> Int
smn xs ys = foldl f 0 ys
  where
    f :: Int -> Int -> Int
    f acc z = if z `elem` xs then acc + 1 else acc

input :: (String -> a) -> IO [a]
input f = map f . lines <$> getContents 

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

typedef unsigned long long ull;
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define range(a) a.begin(), a.end()
#define endl "\n"
#define Yes() cout << "Yes" << endl
#define No() cout << "No" << endl

int main(void){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int N;cin>>N;
	int x[N];
  	ull sum,m;
	FOR(i,0,N) cin>>x[i];
	FOR(i,1,101){
		FOR(j,0,N){
			sum+=(x[j]-i)*(x[j]-i);
        }
          	if(i==1) m=sum;
            else m=min(sum,m);
      sum=0;
	}
	
	cout <<m<<endl;


    return 0;
}

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

using namespace std;

int main(){
    int N, x;
    int a[200001];
    cin >> N >> x;
    for(int i = 0; i <= 2*N-1; i++){
        a[i] = i;
    }
    if(N == 2){
        if(x == 2){
            cout << "Yes" << endl;
            cout << 1 << '\n' << 2 << '\n' << 3 << endl;
        }else{
            cout << "No" << endl;
        }
    }else{
        if(x == 1 || x == 2*N-1){
            cout << "No" << endl;
        }else{
            if(x == 2){
                cout << "Yes" << endl;
                for(int i = 1; i <= N-3; i++){
                    cout << i+4 << '\n';
                }
                cout << 4 << '\n' << 2 << '\n' << 1 << '\n' << 3 << '\n' ;
                for(int i = N+2; i <= 2*N-1; i++){
                    cout << i << '\n';
                }
            }else{
                cout << "Yes" << endl;
                a[x-2] = 0;a[x-1] = 0;a[x] = 0; a[x+1] = 0;
                sort(a, a+2*N);
                for(int i = 1; i <= N-3; i++){
                    cout << a[i+4] << '\n';
                }
                cout << x-2 << '\n' << x+1 << '\n' << x << '\n' << x-1 << '\n' ;
                for(int i = N+2; i <= 2*N-1; i++){
                    cout << a[i] << '\n';
                }
            }
        }
    }
}

Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
int main(){
int n;
cin >> n;
vector<int>vec(4);
int p=n%10;
n/=10;
int q=n%10;
n/=10;
  int r=n%10;
  n/=10;
    int s=n%10;
  vec.at(0)=p;
  vec.at(1)=q;
  vec.at(2)=r;
  vec.at(3)=s;
  int counter =0;
  
  if((p==q && q==r)||(q==r && r==s))cout <<"Yes" <<endl;
  else cout << "No" <<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include<algorithm>
#include<math.h>
#include<vector>
#include<string>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#include <cstring>
#include <map>
using namespace std;
typedef long long ll;



int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false);
	ll A, B, N; cin >> A >> B >> N;
	ll t = min(N, B - 1);
	cout << (A * t) / B << '\n';





}

Measured memory_bytes: 3168
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
using namespace std;
//cout <<  << endl;
typedef long long int ll;
typedef long double ld;
#define MOD 1000000007

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

ll junnretu(ll n){
    ll ans=1;
    for (ll i=1;i<=n;i++){
        ans*=i;
    }
    return ans;
}

int main(){
    ll n,m,count=0,c2=0;
    cin >> n >> m;
    bool x[n];
    ll xc[n];
    fill(xc,xc+n,0);
    fill(x,x+n,false);
    for (ll i=0;i<m;i++){
        ll p;
        string s;
        cin >> p >> s;
        if (!x[p-1]){
            if (s=="AC"){
                x[p-1]=true;
            }else{
                xc[p-1]=xc[p-1]+1;
            }
        }
    }
    for (ll i=0;i<n;i++){
        if (x[i]){
            c2++;
            count+=xc[i];
        }
    }
    cout << c2 << " " << count << endl;
    return 0;
}




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

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	string s, t;
	cin >> s >> t;
	int ans = 3;
	
	for(int i = 0; i < (int) s.length(); i++) {
		if(s[i] != t[i]) {
			ans--;
		}
	}
	
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
	int i,n;
	long long a[200000];
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%lld",&a[i]);
	}
	for(i=n-1;i>=0;i-=2)
	{
		printf("%lld ",a[i]);
	}
	if(n%2==0)
	{
		for(i=0;i<=(n-2);i+=2)
		   printf("%lld ",a[i]);
	}
	else
	{
		for(i=1;i<=(n-2);i+=2)
		   printf("%lld ",a[i]);
	}
	return 0;
}

Measured memory_bytes: 3712
def main():
    n = int(input())
    a = list(map(int, input().split()))

    min_two_count = 2 ** 30

    for i in range(len(a)):
        temp_two_count = 0
        while a[i] % 2 == 0:
            temp_two_count += 1
            a[i] = a[i] // 2

        if min_two_count > temp_two_count:
            min_two_count = temp_two_count

    print(min_two_count)


if __name__ == "__main__":
    main()


Measured memory_bytes: 63348
X, Y = map(int, input().split())

turu = X
kame = 0
flag = False
for i in range(X+1):
    if turu*2 + kame*4 == Y:
        flag = True
        break
    else:
        turu -= 1
        kame += 1
        
if flag:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9172
#include<bits/stdc++.h>
using namespace std;
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
int main()
{
	string s;vector <string> ma;int dp[120][120],num[120][120];
	while(cin>>s) ma.push_back(s);
	int n=ma.size();
	memset(num,-1,sizeof(num));
	rep(i,n) rep(j,ma.size()){if(ma[i][j]==',') ma[i][j]=' ';}
	rep(i,n){
		int t=abs(i-n/2);istringstream sin(ma[i]);
		rep(j,n/2+1-t) sin>>num[i][t+j*2]; 
	}
	memset(dp,-1,sizeof(dp));dp[0][n/2]=num[0][n/2];
	rep(i,n-1) rep(j,n){
		if(num[i+1][j-1]>=0) dp[i+1][j-1]=max(dp[i+1][j-1],dp[i][j]+num[i+1][j-1]);
		if(num[i+1][j+1]>=0) dp[i+1][j+1]=max(dp[i+1][j+1],dp[i][j]+num[i+1][j+1]);
	}
	cout<<dp[n-1][n/2]<<endl;
}

Measured memory_bytes: 1352
import java.util.Scanner;

public class Main {

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

		String s = sc.next();

		int N = s.length();

		// N→S、S→N、E→W、W→Eがないといけない。
		boolean northFlag = false;
		boolean southFlag = false;
		boolean eastFlag = false;
		boolean westFlag = false;

		char[] mojiretsu = s.toCharArray();

		for (int i = 0; i < N; i++) {
			if (northFlag && southFlag && eastFlag && westFlag) {
				System.out.println("Yes");
				return;
			}
			switch (mojiretsu[i]) {
			case 'N':
				northFlag = true;
				break;
			case 'S':
				southFlag = true;
				break;
			case 'E':
				eastFlag = true;
				break;
			case 'W':
				westFlag = true;
				break;
			}
		}
		if (northFlag && southFlag || !northFlag && !southFlag) {
			if (eastFlag && westFlag || !eastFlag && !westFlag) {
				System.out.println("Yes");
				return;
			}
		}
		System.out.println("No");
	}
}


Measured memory_bytes: 9684
#include<cstdio>
#include<cstdlib>
#include<string>
#include<iostream>
using namespace std;

struct Node {
  int key;
  Node *right, *left, *parent;
};

Node *root, *NIL;

void insert(int k) {
  Node *y = NIL;
  Node *x = root;
  Node *z;

  z = (Node *)malloc(sizeof(Node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while ( x != NIL ) {
    y = x;
    if ( z->key < x->key ) {
      x = x->left;
    } else {
      x = x->right;
    }
  }
  z->parent = y;

  if ( y == NIL ) {
    root = z;
  } else {
    if ( z->key < y->key ) {
      y->left = z;
    } else {
      y->right = z;
    }
  }
}

void inorder(Node *u){
  if ( u == NIL ) return;
  inorder(u->left);
  printf(" %d", u->key);
  inorder(u->right);
}

void preorder(Node *u) {
  if ( u == NIL ) return;
  printf(" %d", u->key);
  preorder(u->left);
  preorder(u->right);
}

int main(){
  int n, i, x;
  string com;

  scanf("%d", &n);

  for ( i = 0; i < n; i++ ) {
    cin >> com;
    if ( com == "insert" ) {
      scanf("%d", &x);
      insert(x);
    } else if ( com == "print" ) {
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }

  return 0;
}


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

using namespace std;
using LL = long long;
using P = pair<int,int>;

int main(){
	int N;
	cin >> N;
	vector<int> A(N);
	rep(i,N) cin >> A[i];
	map<int,int> m;
	rep(i,N) m[A[i]]++;
	int ans=0;
	rep(i,N){
		bool flag=true;
		if(m[A[i]]>=2) continue;
		if(A[i]!=1 && m[1]) continue;
		for(int j=2; j*j<=A[i]; j++){
			if(A[i]%j!=0) continue;
			if(m[j]||m[A[i]/j]){
				flag=false;
				break;
			}
		}
		if(flag) ans++;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 32740