akhauriyash/Code-Regression huggingface dataset:
S = int(input())
l = int(S/100)
r = int(S%100)
YYMM = bool(1 <= r <= 12)
MMYY = bool(1 <= l <= 12)

if YYMM:
  if MMYY:
    print('AMBIGUOUS')
  else:
    print('YYMM')
else:
  if MMYY:
    print('MMYY')
  else:
    print('NA')

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

#define rep(l, r) for (int i = (l); i < (r); i++)

typedef long long ll;
 
using namespace std;

void solve() {
    int n;
    cin >> n;

    int cnt = 0, divs;
    for (int i = 1; i <= n; i++) {
        if (i % 2 == 0) continue;
        divs = 0;
        for (int j = 1; j <= i; j++) {
            if (i % j == 0) divs++;
        }

        if (divs == 8) cnt++;
    }
    cout << cnt << endl;
}

int main() {
    solve();

    return 0;
}


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

#define For(i,x,y) for (int i=x;i<y;i++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define lf else if

#define dprintf(...) fprintf(stderr,__VA_ARGS__)
using namespace std;

typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> Vi;

int IN(){
	int c,f,x;
	while (!isdigit(c=getchar())&&c!='-');c=='-'?(f=1,x=0):(f=0,x=c-'0');
	while (isdigit(c=getchar())) x=(x<<1)+(x<<3)+c-'0';return !f?x:-x;
}

const int N=2000+19;
const int oo=(1<<30)-1;

char A[N],B[N],C[N];
pii P[N],Q[N];
int n,m,ans,chk,res;

void Work(int a){
	int tmp;
	tmp=0;
	For(i,1,n+1){
		if (B[i]=='1') tmp=0;else tmp++;
		Q[i].fi=tmp;
	}
	For(i,1,n+1){
		if (B[i]=='1') tmp=0;else tmp++;
		Q[i].fi=tmp;
	}
	tmp=0;
	for (int i=n;i;i--){
		if (B[i]=='1') tmp=0;else tmp++;
		Q[i].se=tmp;
	}
	for (int i=n;i;i--){
		if (B[i]=='1') tmp=0;else tmp++;
		Q[i].se=tmp;
	}
	m=0;
	For(i,1,n+1){
		if (C[i]!=B[i]){
			int u=(i-a+n)%n;
			if (u==0) u=n;
			P[++m]=Q[u];
		}
	}
	if (!m){
		ans=min(ans,abs(a)+m);
		return;
	}
	if (!chk) return;
	sort(P+1,P+m+1);
	res=oo;
	for (int i=m,x=0,y=0;~i;i--){
		x=P[i].fi;
		if (a<0){
			res=min(res,x+x+y+y+abs(a));
			res=min(res,y+y+x+abs(x+a));
		} else{
			res=min(res,x+x+y+abs(y-a));
			res=min(res,y+y+x+x+abs(a));
		}
		y=max(y,P[i].se);
	}
	ans=min(ans,res+m);
}

int main(){
	scanf("%s%s",A+1,B+1);
	n=strlen(A+1);
	For(i,1,n+1) if (B[i]=='1') chk=1;
	ans=oo;
	For(i,1,n+1) C[i]=A[i];
	For(i,0,n){
		Work(-i);
		int tmp=C[1];
		For(j,1,n) C[j]=C[j+1];
		C[n]=tmp;
	}
	For(i,1,n+1) C[i]=A[i];
	For(i,0,n){
		Work(i);
		int tmp=C[n];
		for (int j=n;j>1;j--) C[j]=C[j-1];
		C[1]=tmp;
	}
	printf("%d\n",ans==oo?-1:ans);
}

Measured memory_bytes: 256
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import collections

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))

N = int(input())
S = str(input())

cnt = 0
cnt += S.count("R") * S.count("G") * S.count("B")

# for i in range(1, N - 1):
#     for j in range(i + 1, N):
#         k = 2 * j - i
#         if k > N :
#             continue
#         if S[i - 1] != S[j - 1] and S[j-1] != S[k-1] and S[i -1] != S[k-1]:
#             cnt -= 1

for k in range(N):
    for j in range(k):
        i = 2 * j - k
        if i < 0:
            continue
        if S[i] != S[j] and S[j] != S[k] and S[i] != S[k]:
            cnt -= 1 

print(cnt)


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

using namespace std;

int main(void){
  long long mod = 1000000007LL;
  long long N, M;
  cin >> N >> M;
  if(abs(N - M) > 1){
    cout << 0 << endl;
    return 0;
  }
  long long ans = 1;
  for(int i = 1; i <= N; i++){
    ans *= i;
    ans %= mod;
  }
  for(int i = 1; i <= M; i++){
    ans *= i;
    ans %= mod;
  }
  if(N == M){
    ans *= 2;
    ans %= mod;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
string s;
int main() {
cin>>s;
s.erase(s.length()-1,1);
for(int i=s.length()-1;i>1;i--) {
	if(s.substr(0,(s.length()/2))==s.substr((s.length()/2),(s.length()/2))) {
		cout<<s.length()-1<<endl;
		break;
	} else {
		s.erase(s.length()-1,1);
	}
}
}


Measured memory_bytes: 3620
while gets
	n = $_.to_i
	break if n==0
	sum = 0
	max = max_input = -100001
	n.times do |i|
		m = gets.to_i
		max_input = [max_input,m].max
		sum = [sum+m,0].max
		max = [max,sum].max
	end
	puts max_input < 0 ? max_input : max
end

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

#define FOR(i,a,b) for(int i= (a); i<((int)b); ++i)
#define RFOR(i,a) for(int i=(a); i >= 0; --i)
#define FOE(i,a) for(auto i : a)
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v,x) (std::find(v.begin(), v.end(), x) != v.end())
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());

typedef long long LL;
template<typename T> using V = std::vector<T>;
template<typename T> using VV = std::vector<std::vector<T>>;
template<typename T> using VVV = std::vector<std::vector<std::vector<T>>>;

template<class T> inline T ceil(T a, T b) { return (a + b - 1) / b; }
template<class T> inline void print(T x) { std::cout << x << std::endl; }
template<class T> inline void print_vec(const std::vector<T> &v) { for (int i = 0; i < v.size(); ++i) {  if (i != 0) {std::cout << " ";} std::cout << v[i];} std::cout << "\n"; }
template<class T> inline bool inside(T y, T x, T H, T W) {return 0 <= y and y < H and 0 <= x and x < W; }
template<class T> inline double euclidean_distance(T y1, T x1, T y2, T x2) { return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)); }
template<class T> inline double manhattan_distance(T y1, T x1, T y2, T x2) { return abs(x1 - x2) + abs(y1 - y2); }

const int INF = 1L << 30;
const double EPS = 1e-9;
const std::string YES = "YES", Yes = "Yes", NO = "NO", No = "No";
const std::vector<int> dy4 = { 0, 1, 0, -1 }, dx4 = { 1, 0, -1, 0 };    // 4近傍（右, 下, 左, 上）
const std::vector<int> dy8 = { 0, -1, 0, 1, 1, -1, -1, 1 }, dx8 = { 1, 0, -1, 0, 1, 1, -1, -1 };

using namespace std;

void dfs(int i, const vector<vector<int>> &g, vector<bool> &used) {
    used[i] = true;
    FOE(j, g[i]) {
        if (not used[j]) {
            dfs(j, g, used);
        }
    }
}

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

	vector<int> fib(1100);
	fib[0] = 1;
	fib[1] = 2;
	FOR(i, 2, fib.size()) {
	    fib[i] = (fib[i - 1] + fib[i - 2]) % 1001;
	}

	int V, D;
    while (cin >> V >> D) {

        vector<vector<int>> g(V + 1);
        FOR(i, 1, V + 1) {
            FOR(j, 1, V + 1) {
                if (abs(fib[i] - fib[j]) < D) {
                    g[i].emplace_back(j);
                    g[j].emplace_back(i);
                }
            }
        }

        int ans = 0;
        vector<bool> used(V, false);
        FOR(i, 1, V + 1) {
            if (used[i]) {
                continue;
            }
            ans++;
            dfs(i, g, used);
        }
        print(ans);

    }

	return 0;
}


Measured memory_bytes: 6772
#include <iostream>
#include <cstdio>
#include <cstring>
char s[100010];
int main()
{
    scanf("%s",s);
    int l = strlen(s);
    int ans = 0;
    for(int i = 1; i < l; i++)
    {
    	 if(s[i] == s[i-1])
    	   continue;
    	   ans++;
	}
    printf("%d\n",ans);
	return 0;
}

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

int main(){
  int N;
  int a;
  int prev= 0;
  cin >> N;
  long long int sum = 0;
  for(int i = 0; i < N; ++i){
    cin >> a;
    if(prev > a){
      sum += (prev - a);
      a = prev;
    }
    prev = a;
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

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

using namespace std;

namespace mp = boost::multiprecision;
using Bint = mp::cpp_int;

using ll = long long;
ll mod = pow(10, 9) + 7;

template <typename T> void output(T, ll);
ll gcd(ll, ll);
ll lcm(ll, ll);
Bint comb(Bint, Bint);
void prime_map(map<ll, ll> &, ll);

int main() {
    // source
    int n, m;
    cin >> n >> m;
    priority_queue<ll> a;
    rep(i, n) {
        ll temp;
        cin >> temp;
        a.push(temp);
    }

    rep(i, m) {
        ll t = a.top();
        a.pop();
        a.push(t / 2);
    }

    ll ans = 0;
    rep(i, n) {
        ll temp = a.top();
        a.pop();
        ans += temp;
    }

    cout << ans << endl;
    return 0;
}

Bint comb(Bint a, Bint b) {
    Bint ans = 1;

    if (a < b) {
        return 0;
    }

    rep(i, b) {
        ans *= a - i;
        ans /= i + 1;
    }

    return ans;
}

template <typename T> void output(T a, int precision) {
    if (precision > 0) {
        cout << setprecision(precision) << a << "\n";
    } else {
        cout << a << "\n";
    }
}

template <typename T> T min(T a, T b) {

    if (a < b) {
        return a;
    } else {
        return b;
    }
}

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

ll lcm(ll a, ll b) { return a * b / gcd(a, b); }

void prime_map(map<ll, ll> &m, ll num) {
    ll cache = num;
    repd(i, 2, sqrt(num) + 2) {
        if (num % i == 0) {
            if (m[i] == 0) {
                m[i] = 1;
            } else {
                m[i]++;
            }

            num /= i;
            break;
        }
    }

    if (cache == num) {
        if (m[num] == 0) {
            m[num] = 1;
        } else {
            m[num]++;
        }
        return;
    } else {
        prime_map(m, num);
    }
}


Measured memory_bytes: 1400
// https://atcoder.jp/contests/abc179/submissions/16845772

#include <bits/stdc++.h>

using namespace std;
using ll = long long;
const int MOD = 1e9 + 7;

int main() {
  ll n, q;
  cin >> n >> q;
  vector<ll> a(n + 1), b(n + 1);
  for (int i = 1; i <= n; i++) {
    a[i] = b[i] = n;
  }
  ll black = ll(n - 2) * ll(n - 2);
  int h = n, w = n;
  for (int i = 0; i < q; i++) {
    int t, x;
    cin >> t >> x;
    if (t == 1) {  // 縦
      if (x < w) {
        for (int i = x; i < w; i++) {
          b[i] = h;
        }
        w = x;
      }
      black -= b[x] - 2;
    } else {
      if (x < h) {
        for (int i = x; i < h; i++) {
          a[i] = w;
        }
        h = x;
      }
      black -= a[x] - 2;
    }
  }
  cout << black << endl;
}


Measured memory_bytes: 6408
N, M = map(int,input().split())
E = [[False for i in range(N)] for j in range(N)]

for i in range(M):
    a, b = map(int,input().split())
    E[a-1][b-1] = True
    E[b-1][a-1] = True

# 葉のindexを取得
def search_leaf(edge_list):
    for i in range(N):
        if edge_list[i].count(True) == 1:
            return i
    return -1

ans = 0
for _ in range(M):
    V = search_leaf(E)
    if V == -1: 
        break
    
    # 橋を壊す
    main_land = E[V].index(True)
    E[V][main_land] = E[main_land][V] = False

    ans += 1

print(ans)

Measured memory_bytes: 3064
n = int(input())
a = list(map(int, input().split()))
max_a_list = [0]*n
max_a_list[0] = a[0]

for i in range(1,n):
  max_a_list[i] = max(max_a_list[i - 1],a[i])
sum_ = 0
for i in range(n):
  if max_a_list[i] > a[i]:
    sum_ += max_a_list[i] - a[i]
print(sum_)



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


int check(int m,int N){
	vector<int> dp(10000001);
	for(int j=1;j<=m;j++){
		for(int i=N;i>=0;i--){
			if(dp[i] && i+j<=N)dp[i+j] = 1;
		}
	}
	if(dp[N])return true;
	else return false;
}
int main(void){
	int N;
	cin >> N;

	int sum = 0,m;
	for(int i=1;i<=N;i++){
		sum += i;
		if( sum >= N ){
			m = i;
			break;
		}
	}
	// cout << m << endl;

	while(m != 0){
		if( N - m >= 0){
			N -= m;
			cout << m << endl;
		}
		m--;
	}

	return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

var s = bufio.NewScanner(os.Stdin)

func next() int64 {
	s.Scan()
	i, _ := strconv.ParseInt(s.Text(), 10, 64)
	return i
}

type Point struct {
	x, y int
	h    int64
}

func main() {
	s.Split(bufio.ScanWords)
	N := next()
	points := make([]Point, N)
	var i int64
	for i = 0; i < N; i++ {
		points[i] = Point{int(next()), int(next()), next()}
	}

	//fmt.Println(points)

	var H0 int64 = -1
	var cx, cy int

BR:
	for x := 0; x <= 100; x++ {
		for y := 0; y <= 100; y++ {
			H0 = -1
			for i := 0; i < len(points); i++ {
				p := points[i]

				if H0 == -1 {
					if p.h != 0 {
						H0 = p.h + int64(math.Abs(float64(p.x-x))) + int64(math.Abs(float64(p.y-y)))
					} else {
						points = append(points, p)
					}
				} else {
					if p.h != 0 {
						H1 := p.h + int64(math.Abs(float64(p.x-x))) + int64(math.Abs(float64(p.y-y)))
						if H0 != H1 {
							H0 = -1
							break
						}
					} else {
						if H0-int64(math.Abs(float64(p.x-x)))-int64(math.Abs(float64(p.y-y))) > 0 {
							H0 = -1
							break
						}
					}
				}
			}

			if H0 != -1 {
				cx = x
				cy = y
				break BR
			}
		}
	}

	fmt.Println(cx, cy, H0)
}


Measured memory_bytes: 93440
#include <iostream>
#include <string>
#include <math.h>
using namespace std;

int main() {

	string S;

	cin >> S;

	int count = 0;
	for (int i = 0; i < S.size(); i++) {
		if (S[i] == 'x') {
			count++;
		}
	}

	if (count <= 7) {
		cout << "YES" << endl;
	}
	else {

		cout << "NO" << endl;
	}



	return 0;

}

Measured memory_bytes: 256
#include<iostream>
 #include<stdio.h>
 #include<string>
 #include<math.h>
 #include<iomanip>
 #include<algorithm>
 #include<string.h>
 #include<cctype>
 #include<map>
 #include<set>
 #include<vector>
 #include<sstream>
 #include<stack>
 #include<queue>
 
 using namespace std;
 
 int main()
 {
   int h,w;
   //bool flag=false;
   while(cin>>h>>w&&(h||w))
   {
     for(int i=0;i<h;i++)
     {
       for(int j=0;j<w;j++)
       {
         cout<<"#";        
       }        
       cout<<endl;
     }
     cout<<endl;
   }
   //while(1);
   return 0;
 }
 
 
 
 

Measured memory_bytes: 3084
// -*- coding:utf-8-unix -*-

#[macro_use]
extern crate lazy_static;
extern crate num_bigint; // 0.2.2
extern crate num_traits; // 0.2.8
use num_bigint::BigInt;
use num_traits::Pow;

// use proconio::derive_readable;
use proconio::fastout;
use proconio::input;
// use std::convert::TryInto;
use libm::*;
use std::cmp::*;
use std::collections::{BinaryHeap, HashSet};
use std::io::*;
use std::str::FromStr;
use superslice::*;

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

//abc175-B
// #[fastout]
fn main() {
    input![mut x: i64, k: i64, d: i64];

    let is_minus = x < 0;
    x = if is_minus { -x } else { x };

    // let x: BigInt = x.into();
    // let k: BigInt = k.into();
    // let d: BigInt = d.into();

    //中に入ることはできる
    let count_inner = &x / &d;
    if count_inner >= k {
        // eprintln!("count_inner: {}", count_inner);
        println!("{}", x - k * d);
        return;
    }

    let remaind = x % d;
    let remaind_inv = d - remaind;
    let rest = k - count_inner;
    if (rest % 2 == 0) {
        println!("{}", remaind);
    } else {
        println!("{}", remaind_inv);
    }
}

fn go(mid: usize, d: usize, use_num: usize, num753_cand: &mut Vec<usize>, n: usize) {}

// use lazy_static::lazy_static;
// use std::sync::Mutex;

// lazy_static! {
//     static ref VALUES: Mutex<Vec<i32>> = Mutex::default();
// }

// let mut values = VALUES.lock().unwrap();
// values.extend_from_slice(&[1, 2, 3, 4]);
// assert_eq!(&*values, &[1, 2, 3, 4]);



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

int main() {
  ll A,B,K;
  cin >>A>>B>>K;

  if ((B-A)/2 < K) {
    for(int i=A; i<=B; i++) {
      cout << i << endl;
    }
    return 0;
  }
  for (int i=A; i<A+K; i++) {
    cout << i << endl;
  }
  for (int i=B-K+1; i<=B; i++)
    cout << i << endl;
} 

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import math
n, d = map(int, input().split())

x = []
for i in range(n):
    x.append(list(map(int, input().split())))

#print(x)

def dist_calc(lis1, lis2):
    sum = 0
    for i in range(len(lis1)):
        sum += (lis1[i]-lis2[i])**2
    return math.sqrt(sum)

count = 0
for i in range(n):
    for j in range(i+1,n):
        if i==j:
            continue
        else:
            dist = dist_calc(x[i],x[j])
#            print(dist)
            if dist.is_integer() == True:
                count += 1
            else:
                continue

print(count)


Measured memory_bytes: 3064
N = int(input())
B_list = list(map(int, input().split(" ")))

out = 0
for i in range(N):
    if i == 0:
        out += B_list[i]
    elif i == N-1:
        out += B_list[i-1]
    else:
        out += min(B_list[i], B_list[i-1])

print(out)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include <bitset>
using namespace std;
#define ll long long 
#define ld long double
#define mod7 1000000007
#define mod9 1000000009
#define mod 1000003
#define fast ios_base :: sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define mp make_pair
#define pb push_back
#define ct ll t;cin>>t;while(t--)
#define bi begin()
#define ei end()
#define fi first 
#define se second

//   ll flag[100005]={0};
	// ll a[100005]={0};
	// ll b[100005]={0}; 
	// vector<ll>v(100005);     	
bool isPrime(ll n) 
{ 
	// Corner case 
	if (n <= 1) 
		return false; 
	
	// Check from 2 to n-1 
	for (ll i = 2; i*i <= n; i++) 
		if (n % i == 0) 
			return false; 
	
	return true; 
}
long long binpow(long long a, long long b) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = (res%mod) * (a%mod);
        a = (a%mod) * (a%mod);
        b >>= 1;
    }
    return res%mod;
}

bool compare(const pair<ll,ll>&a,const pair<ll,ll>&b)
{
    return (a.se<b.se);
}
ll lcm(ll a,ll b)
{
	return(a*b)/__gcd(a,b);
}
void SieveOfEratosthenes() 
{  
	ll n=100005;
    bool prime[100005]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        
        if (prime[p] == true) 
        {   
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
	for(ll i=2;i<100005;i++)
	{
		if(prime[i])
		{
			// v.pb(i);
		}
	}
	
} 
ll fact[1000007]={0};
ll expo(ll x, ll y) {ll res=1;x=x%mod7;while(y>0){if(y&1)res=(1ll*res*x)%mod7;
y=y>>1;x=(1ll*x*x)%mod7;} return res;}
void facto() {fact[0]=1;fact[1]=1;for(ll i=2;i<100007;i++)fact[i]=(fact[i-1]*i)%mod7;}
ll npr(ll n,ll r) {facto(); ll res=1; res=fact[n]; res=(res*(expo(fact[n-r],mod7-2)))%mod7; return res; }
ll ncr(ll n,ll r){ ll res=1; if(r>n-r)r=n-r; for(ll i=0;i<r;i++) {  res*=n-i;  res/=i+1; } return res;}
 int main()
{
    fast
	float n;
	cin>>n;
	float a=n/3;
	// cout<<a<<" ";
	float ans;
	ans=a*a*a;
	cout<<fixed<<setprecision(12)<<ans<<"\n";
	
}




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

public class Program
{
    public static void Main(string[] args)
    {
        var kx = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
        var total = kx[0] * 500;
        Console.WriteLine(total >= kx[1] ? "Yes" : "No");
    }
}

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

int main(){
    int n,m;
    cin >> n >> m;
    int a,b,c,d;
    vector<pair<int,int>> ns,ms;
    for(int i =0;i<n;i++){
		cin >> a >> b;
		ns.emplace_back(a,b);
	}
	for(int i = 0; i<m;i++){
		cin >> c >> d;
		ms.emplace_back(c,d);
	}
	
	for(int i = 0;i<n;i++){
		long long mini = 1e10,mind=-1;
		for(int j=0;j<m;j++){
		long long distance = abs(ns[i].first-ms[j].first) + abs(ns[i].second-ms[j].second);
		if (distance < mini){
			mini=distance;
			mind = j+1;
			}
		
		}
		cout << mind << endl;
	}
			
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
using namespace std;

int main() {
  int D;
  cin >> D;
  if(D == 25)
    cout << "Christmas" << endl;
  else if(D == 24)
    cout << "Christmas Eve" << endl;
  else if(D == 23)
    cout << "Christmas Eve Eve" << endl;
  else
    cout << "Christmas Eve Eve Eve" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd(b,a%b);
  }
}
 
long long lcm(long long x, long long y){
  return (x/gcd(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};


  
int main(){
  
  string s;
  cin>>s;
  int n=s.size();
  vector<int> b;//RとLの境界
  for(int i=0;i<n-1;i++){
    if(s[i]=='R' && s[i+1]=='L'){
      b.push_back(i+1);
    }
  }
  int bs = b.size();
  int index = 0;
  int ans[n] = {};
  REP(i,n){
    if(s[i]=='R'){
      if(i>0 && s[i-1]=='L'){
        index++;
      }
      if((b[index]-i)%2==0){
        ans[b[index]]++;
      }else{
        ans[b[index]-1]++;
      }
    }else{
      if((i-b[index])%2==0){
        ans[b[index]]++;
      }else{
        ans[b[index]-1]++;
      }
    }
  }
  REP(i,n){
    cout<<ans[i]<<' ';
  }
  cout<<endl;
  
  return 0;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
using lint = long long;

void Main() {
  int N, M;
  cin >> N >> M;
  priority_queue<int> items;
  for (int i=0; i<N; ++i) {
    int a;
    cin >> a;
    items.push(a);
  }

  for (int i=0; i<M; ++i) {
    int a = items.top();
    items.pop();
    items.push(a/2);
  }

  lint ans = 0;
  while(!items.empty()) {
    ans += items.top();
    items.pop();
  }
  cout << ans << endl;
}

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


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

int main() {
	int n;
	while (cin >> n, n) {
		int cnt[7]{};
		rep(i, n) {
			int d; cin >> d;
			if (d >= 60)cnt[6]++;
			else cnt[d / 10]++;
		}
		rep(i, 7)cout << cnt[i] << endl;
	}
}

Measured memory_bytes: 3084
#include <stdio.h>
#define M 10000
#define NIL -1
 
typedef struct{
  int p,l,r;
}Node;
 
Node T[M];
int n;
 
void pre(int u)
{
  if(u == NIL){
    return;
  }
  printf(" %d",u);
  pre(T[u].l);
  pre(T[u].r);
}
 
void in(int u){
  if(u == NIL){
    return;
  }
  in(T[u].l);
  printf(" %d", u);
  in(T[u].r);
}
void post(int u){
  if(u == NIL){
    return;
  }
  post(T[u].l);
  post(T[u].r);
  printf(" %d",u);
}
 
int main(){
  int i,v,l,r,root;
  scanf("%d",&n);
  for(i = 0; i <n;i++)
    {
      T[i].p =NIL;
    }
  for(i = 0;i<n;i++)
    {
      scanf("%d %d %d",&v,&l,&r);
      T[v].l = l;
      T[v].r = r;
      if(l != NIL) T[l].p = v;
      if(r != NIL) T[r].p = v;
    }
  for(i = 0; i < n;i++)
    {
      if(T[i].p == NIL){
	root = i;
      }
    }
  printf("Preorder\n");
  pre(root);
  printf("\n");
  printf("Inorder\n");
  in(root);
  printf("\n");
  printf("Postorder\n");
  post(root);
  printf("\n");
  return 0;
}
 

Measured memory_bytes: 620
use proconio::{input, fastout};

#[fastout]
fn main() {
    input! {
        n: usize,
    }

    match n % 10 {
        n if n == 3 => {
            println!("bon");
        },
        n if n == 0 || n == 1 || n == 6 || n == 8 => {
            println!("pon");
        }
        _ => {
            println!("hon");
        }
    }
}


Measured memory_bytes: 2168
#include <bits/stdc++.h>
#define pw(x) (1LL << (x))
#define db(x) cerr << #x << " = " << x << endl
#define db2(x, y) cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")" << endl

using namespace std;
typedef long long ll;
typedef double dbl;
const int INF = 1.01e9;

int go(pair<int, int> a, int x) {
    if (a.first <= x && x <= a.second) return x;
    if (x < a.first) return a.first;
    return a.second;
}

ll fast(vector<pair<int, int>> a) {
    int n = a.size();
    ll ans = -1;

    vector<vector<pair<int, int>>> v(2);
    for (int i = 0; i < n; i++) {
        v[0].push_back({a[i].second, i});
        v[1].push_back({a[i].first, i});
    }
    sort(v[0].begin(), v[0].end());
    sort(v[1].begin(), v[1].end());
    reverse(v[0].begin(), v[0].end());

    vector<char> taken(n);
    for (int s = 0; s < 2; s++) {
        auto ov = v;

        int cur = 0;
        ll cans = 0;
        int j = s;
        vector<char> taken(n);
        for (int it = 0; it < n; it++) {
            while (taken[v[j].back().second]) v[j].pop_back();
            taken[v[j].back().second] = 1;
            int ncur = go(a[v[j].back().second], cur);
            cans += abs(cur - ncur);
            j ^= 1;
            cur = ncur;
        }
        cans += abs(cur);
        ans = max(ans, cans);

        v = ov;
    }
    return ans;
}

ll slow(vector<pair<int, int>> a) {
    int n = a.size();
    ll ans = -1;

    vector<int> p(n);
    iota(p.begin(), p.end(), 0);
    do {
        int cur = 0;
        ll cans = 0;
        for (int x : p) {
            int ncur = go(a[x], cur);
            cans += abs(ncur - cur);
            cur = ncur;
        }
        cans += abs(cur);
        ans = max(ans, cans);
    } while (next_permutation(p.begin(), p.end()));
    return ans;
}
void stress() {
    for (int it = 0;; it++) {
        cout << it << endl;

        const int C = 30;
        int n = rand() % 8 + 1;
        vector<pair<int, int>> a(n);
        for (int i = 0; i < n; i++) {
            a[i].first = rand() % (C + C + 1) - C;
            a[i].second = rand() % (C + C + 1) - C;
            if (a[i].first > a[i].second) swap(a[i].first, a[i].second);
        }
        ll ans1 = fast(a);
        ll ans2 = slow(a);
        if (ans1 != ans2) {
            cout << ans1 << " instead of " << ans2 << endl;
            cout << n << endl;
            for (auto o : a) cout << o.first << " " << o.second << endl;
            exit(0);
        }
    }
}

int main() {
#ifdef HOME
    assert(freopen("in", "r", stdin));
#endif
    //stress();

    int n;
    while (scanf("%d", &n) == 1) {
        vector<pair<int, int>> a(n);
        for (int i = 0; i < n; i++) scanf("%d%d", &a[i].first, &a[i].second);

        printf("%lld\n", fast(a));
    }

#ifdef HOME
    cerr << "time = " << (clock() * 1. / CLOCKS_PER_SEC) << "\n";
#endif
    return 0;
}


Measured memory_bytes: 5196
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <limits.h>
#include <string.h>
#define ll long long int

int main(void)
{
 double A,B;
 scanf("%lf %lf",&A,&B);

 double a1=A/0.08;
 double b1=B/0.1;

 a1 = round(a1);
 b1 = round(b1);

 if ((int)(b1*0.1)==(int)B && (int)(b1*0.08)==(int)A)printf("%d",(int)b1);
 else if ((int)(a1*0.1)==(int)B && (int)(a1*0.08)==A)  printf("%d",(int)a1);
 else printf("-1");
    return EXIT_SUCCESS;
}



Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long a;
	string b;
	cin>>a>>b;
	long long b2=(b[0]-'0')*100,b3=(b[2]-'0')*10,b4=(b[3]-'0');
	long long ans=a*(b2+b3+b4);
	ans=ans/100;
	cout<<ans<<endl;
	return 0;
}

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

int main(){
  int sx, sy, tx, ty;
  cin >> sx >> sy >> tx >> ty;

  string f="", s="";
  for(int i=0; i<ty-sy; i++){
    f += 'U'; s+= 'D';
  }
  for(int i=0; i<tx-sx; i++){
    f += 'R'; s += 'L';
  }

  string ans = f+s+("LU"+f+"RD")+("RD"+s+"LU");

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
a_to_index = [0] * n
for i in range(n):
    a_to_index[a[i]-1] = i + 1
a.sort()
ans = [0] * n
for index, ai in enumerate(a):
    ans[index] = a_to_index[ai-1]
print(*ans)


Measured memory_bytes: 20640
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
ll m=1000000007;
ll sieve[1000001]={0},i,j;
ll power(ll p, ll k)
{
ll a=1;
while(k)
{
if(k&1)
a=(a*p)%m;
p=(p*p)%m;
k>>=1;
}
return a;
}
using namespace std;
int main()
{
 
 int tc=1;
// cin>>tc;
 while(tc--)
 {
	 double l;
	 cin>>l;
	 double ans=l/3;
	 ans=ans*ans*ans;
	 printf("%.10f",ans);
	 cout<<"\n";
 }
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <string>
#include <iterator>
#include <cmath>
#include <deque>
#include <stack>
#include <functional>
#include <queue>

#define int long long


signed main()
{
    {
        if (fopen("input.txt", "r")) {
            freopen("input.txt", "r", stdin);
            freopen("output.txt", "w", stdout);
        }
        std::ios_base::sync_with_stdio(false);
        std::cin.tie(NULL);
        std::cout.tie(NULL);
    }
    
    int a, b;
    std::cin >> a >> b;
    std::cout << a * b;
    return 0;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
#define ll long long
#define rep(i, n) for(int i=0;i<(n);++i)
#define per(i, n) for(int i=(n)-1;i>=0;--i)
#define repa(i, n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define plll pair<ll, pll>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
const ll MOD = (ll)1e9+7;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}

ll modpow(ll x, ll b){
	ll res = 1;
	while(b){
		if(b&1)res = res * x % MOD;
		x = x * x % MOD;
		b>>=1;
	}
	return res;
}

ll modinv(ll x){
	return modpow(x, MOD-2);
}

bool was_output = false;
template<class t>
void output(t x){
	if(was_output)cout << " ";
	was_output = true;
	cout << x;
}

void outendl(){
	was_output = false;
	cout << endl;
}


int main(){
	ll n;
	cin >> n;
	ll ans = INFLL;
	for(ll i = 1;i*i<=n;++i){
		if(n%i==0){
			chmin(ans, i + n / i - 2);
		}
	}

	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
using ll=long long;
 
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define pb push_back
#define eb emplace_back
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
const ll MOD = 1e9 + 7;



int main() {
    int n; cin >> n;
    vector<int> as(n);
    rep(i, n) cin >> as[i]; 
    sort(all(as), greater<int>());
    ll ans = 0;  
    if (n > 0) ans += as[0];
    rng(i, 2, n) {
        ans += as[i/2];     
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4060
#include <iostream>
#include <cmath>
#include <iomanip>
#include <limits>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <list>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(n);i++)

ll power(ll a,ll b){
    ll p=1;
    for(ll i=0;i<b;i++){
        p *= a;
    }
    return p;
}

int main(){
    ll n;
    cin >> n;
    ll a[n],even=0;
    rep(i,n){
        cin >> a[i];
        if(a[i]%2 == 0) even++;
    }
    cout << power(3,n) - power(2,even) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define sz(a) int((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(typeof((c).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define LSOne(i) (i&(-i))
#define rep(i,a,b) for(int(i)=(a);(i)<(b);i++)
#define BUG(x) {cout<<#x<<" = "<<x<<endl;}
#define left(x) (x<<1)
#define right(x) ((x<<1) +1)
#define middle(s,e)(s+(e-s)/2)
#define size_tree(n) 2*(int)pow(2,ceil(log2(n)))
#define CL(A,I) (memset(A,I,sizeof(A)))
#define endl '\n'

static const int INF = 0x3f3f3f3f;
static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;
static const long double epsilon = 1e-15;
static const long double pi = acos((long double) -1);
using namespace std;
inline void init_io(){ios_base::sync_with_stdio(false);cin.tie(NULL);}

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> ii;
typedef long long ll;

const int maxn = 100004;
int arr[maxn][3];
int dp[maxn][3];
int n;
int solve(int idx, int j)
{
    if(idx>=n)return 0;
    int &ret = dp[idx][j];
    if(~ret)return ret;
    if(j==0)
        dp[idx][j]=max(arr[idx][1]+solve(idx+1,1),arr[idx][2]+solve(idx+1,2));
    else if(j==1)
        dp[idx][j]=max(arr[idx][0]+solve(idx+1,0),arr[idx][2]+solve(idx+1,2));
    else
        dp[idx][j]=max(arr[idx][1]+solve(idx+1,1),arr[idx][0]+solve(idx+1,0));
    return dp[idx][j];
}

int main()
{
    CL(dp,-1);
    cin>>n;
    rep(i,0,n)
        cin>>arr[i][0]>>arr[i][1]>>arr[i][2];
    cout<<max(solve(0,0),solve(0,1));
    return 0;
}

Measured memory_bytes: 7296
#include<cstdio>

#include<algorithm>

int n,a,b,u,x[101],h[101],y[101],cx,cy,H;

int main()

{

    scanf("%d",&n);

    for(int i=1;i<=n;++i)

    {

        scanf("%d%d%d",&x[i],&y[i],&h[i]); 

        if(h[i]!=0)u=i;

    }

    for(int xi=0;xi<=100;++xi)

      for(int yi=0;yi<=100;++yi)

        {

            cx=xi,cy=yi;

            H=h[u]+abs(x[u]-cx)+abs(y[u]-cy);

            for(int i=1;i<=n;++i)

            {

                if(h[i]!=std::max(H-std::abs(x[i]-cx)-std::abs(y[i]-cy),0))break;

                if(i==n)

                {

                    printf("%d %d %d",cx,cy,H);

                    return 0;

                }

            }

        }

}


Measured memory_bytes: 128
n = gets.to_i
ary = []
n.times do
  ary << gets.to_i
end
num = ary[0]
count = 2
if num == 2
  puts 1
else
  (n-1).times do
    if ary[num-1] == 2
      puts count
      break
    end
    num = ary[num-1]
    count += 1
  end
end
if count == n-1+2
  puts -1
end

Measured memory_bytes: 2996
package main

import (
	"fmt"
	"os"
	"strconv"
	"strings"
	"bufio"
)

var (
	sc = bufio.NewScanner(os.Stdin)
	buf = make([]byte, 1000)
)

func scanText() string{
	sc.Scan()
	return sc.Text()
}

func scanTextArray(n int) []string {
	out := make([]string, n)
	for i, v := range(strings.Split(scanText(), "")) {
		out[i] = v
	}
	return out
}

func scanInt() int {
	out, e := strconv.Atoi(scanText())
	if e != nil {
        panic(e)
    }
	return out
}

func scanIntArray(n int) []int {
	out := make([]int, n)
	for i, v := range(strings.Split(scanText(), " ")) {
		num, e := strconv.Atoi(v)
		if e != nil {
			panic(e)
		}
		out[i] = num
	}
	return out
}
//  template end

var (
	N, M = 0, 0
	node_list = make([][]int, 0)
	ans = 0
)

func check_all_true(reached_list []bool) bool{
	is_all_true := true
	for _, v := range reached_list {
		if v == false {
			is_all_true = false
			break
		}
	}
	return is_all_true
}
func f(now int, reached_list_origin []bool){
	reached_list := make([]bool, N)
	copy(reached_list, reached_list_origin)
	if reached_list[now] == true {
		return
	}
	reached_list[now] = true
	if check_all_true(reached_list) {
		ans++
		return
	}
	for _, v := range node_list[now] {
		f(v, reached_list)
	}
}

func main() {
	sc.Buffer(buf, 10000)
	nm := scanIntArray(2)
	N, M = nm[0], nm[1]
	node_list = make([][]int, N)
	for i:=0; i<M; i++ {
		ab := scanIntArray(2)
		a, b := ab[0]-1, ab[1]-1
		node_list[a] = append(node_list[a], b)
		node_list[b] = append(node_list[b], a)
	}
	reached_list := make([]bool, N)
	f(0, reached_list)
	fmt.Println(ans)
}

Measured memory_bytes: 1152
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>

using namespace std;

typedef long long ll;

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

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

void calc_dists(const int cur_pos, const int cur_dist,
        const vector<vector<int> > &edges, map<int, int> &dists, vector<bool> &visited) {
    if (visited[cur_pos]) return;
    visited[cur_pos] = true;
    dists[cur_pos] = cur_dist;
    for (auto next : edges[cur_pos]) {
        calc_dists(next, cur_dist + 1, edges, dists, visited);
    }
}

int main(void) {
    int N, u, v;
    cin >> N >> u >> v;

    vector<vector<int> > edges(N + 1);
    for (int i = 0; i < N - 1; i++) {
        int A, B;
        cin >> A >> B;
        edges[A].push_back(B);
        edges[B].push_back(A);
    }

    map<int, int> dists_t, dists_a;
    vector<bool> visited_t(N + 1, false), visited_a(N + 1, false);
    calc_dists(u, 0, edges, dists_t, visited_t);
    calc_dists(v, 0, edges, dists_a, visited_a);

    int cand_dist = 0;
    for (int i = 1; i <= N; i++) {
        if (dists_a[i] > dists_t[i]) {
            chmax(cand_dist, dists_a[i]);
        }
    }

    cout << cand_dist - 1 << endl;

    return 0;
}


Measured memory_bytes: 24064
#include<bits/stdc++.h>
using namespace std;
const int N=200500;
typedef long long ll;
int t[N];
int n,m;
int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    for(int i=1; i<=n; i++)
    {
        scanf("%d",&t[i]);
    }
    ll ans=0;
    ll sum=0;
    for(int i=2; i<=n; i++)
    {
    	ans+=min(t[i]-t[i-1],m);
    }
    cout<<ans+m<<endl;
    return 0;
}


Measured memory_bytes: 1024
/*
 ***
 Question Name:
 ***
 Question Link:
 
 ***
 Idea:
 */

#include <memory.h>
#include <iomanip>
#include <algorithm>
#include <iostream>
#include <iterator>
#include <numeric>
#include <sstream>
#include <fstream>
#include <cassert>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cstdio>
#include <vector>
#include <cmath>
#include <functional>
#include <queue>
#include <deque>
#include <stack>
#include <list>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>

#define REP(i,s,n) for(int (i)=s; (i)<(int)(n);(i)++)
#define RIT(it,c) for(__typeof(c.begin()) it = c.begin();it!=c.end();it++)
#define ALL(x) x.begin(), x.end()
#define SZ(x) (int)(x).size()
#define MSET(m,v) memset(m,v,sizeof(m))

using namespace std;

typedef long long LL;
typedef long double LD;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<LL> vL;
typedef vector<bool> vb;
typedef unordered_set<int> ui;
typedef pair<LL,LL> pLL;

class PrimeFlip{
    int N = 1E7, n, m;
    vi mapping;
    vb vist;
    vector<vb> E;
    void init(){
        int K;
        cin>>K;
        unordered_set<int> cnt;
        vi odds,evens;
        for(int i=0;i<K;++i){
            int x;
            cin>>x;
            if(cnt.count(x)) cnt.erase(x);
            else cnt.insert(x);
            cnt.insert(x+1);
        }
        for(auto k:cnt){
            if(k%2) odds.push_back(k);
            else evens.push_back(k);
        }
        cnt.clear();
        n = (int)odds.size();
        m = (int)evens.size();
        mapping = vi(m,-1);
        E = vector<vb>(n,vb(m, false));
        vb prime(N+1,true);
        prime[0] = prime[1] = false;
        for(int i=2;i<=N;++i) if(prime[i]){
            for(int j=2;j*i<=N;++j) prime[i*j] = false;
        }
        prime[2] = false;
        for(int i=0;i<n;++i) for(int j=0;j<m;++j) E[i][j] =prime[abs(odds[i]-evens[j])];
        prime.clear();
    }
    bool arange(int i){
        for(int j=0;j<m;++j) if(E[i][j] && !vist[j]){
            vist[j] = true;
            if(mapping[j]==-1 || arange(mapping[j])){
                mapping[j] = i;
                return true;
            }
        }
        return false;
    }
public:
    void solve(){
        init();
        int cnt = 0;
        for(int i=0;i<n;++i) {
            vist.assign(m, false);
            cnt += arange(i);
        }
        int ans = cnt + ((n-cnt)/2 + (m-cnt)/2)*2 + ((m-cnt)%2)*3;
        cout<<ans<<endl;
    }
};



int main(){
    PrimeFlip().solve();
    return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<pi, pi> pp;
typedef pair<ll, ll> pl;
const double EPS = 1e-9;
const ll MOD = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;

int n, m;
vector<int> e[100000];
bool saw[100000];
int par[100000];
int two[100000];

void dfs (int v) {
    saw[v] = true;
    rep(i,e[v].size()) {
        if (saw[e[v][i]]) continue;
        par[e[v][i]] = v;
        dfs(e[v][i]);
    }
}

void dfs2 (int v) {
    saw[v] = true;
    rep(i,e[v].size()) {
        if (saw[e[v][i]]) continue;
        dfs2(e[v][i]);
    }
    if (v == 0) return;
    if (two[v]) {
        cout << v+1 << " " << par[v]+1 << endl;
        two[v] ^= 1;
    } else {
        cout << par[v]+1 << " " << v+1 << endl;
        two[par[v]] ^= 1;
    }
}

int main() {
    cin >> n >> m;
    rep(i,m) {
        int a, b; cin >> a >> b;
        a--; b--;
        e[a].push_back(b);
        e[b].push_back(a);
    }
    if (m%2) {
        cout << -1 << endl;
        return 0;
    }
    dfs(0);
    rep(i,n) {
        rep(j,e[i].size()) {
            if (e[i][j] < i) continue;
            if (par[i] == e[i][j] || par[e[i][j]] == i) continue;
            two[e[i][j]] ^= 1;
            cout << e[i][j]+1 << " " << i+1 << endl;
        }
    }
    memset(saw, 0, sizeof(saw));
    dfs2(0);
}


Measured memory_bytes: 12416
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

mt19937 mrand(random_device{} ()); 

int rnd(int x) {
  return mrand() % x;
}

typedef long double ld;
typedef long long ll;

#ifdef DEBUG
#define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#else
#define eprintf(...) ;
#endif

#define pb push_back
#define mp make_pair
#define sz(x) ((int) (x).size())
#define TASK "text"

const int inf = (int) 1.01e9;
const ld eps = 1e-9;
const ld pi = acos((ld) -1.0);

const int mod = (int) 1e9 + 7;

void add(int &x, int y) {
  if ((x += y) >= mod) {
    x -= mod;
  }
}

int mult(int x, int y) {
  return (long long) x * y % mod;
}

int myPower(int x, int pw) {
  int res = 1;
  for (; pw; pw >>= 1) {
    if (pw & 1) {
      res = mult(res, x);
    }
    x = mult(x, x);
  }
  return res;
}

void precalc() {
}


int n, x;

int read() {
  if (scanf("%d%d", &n, &x) < 2) {
    return 0;
  }
  return 1;
}

const int maxn = (int) 2e5 + 10;
int a[maxn];

void solve() {
  if (x != 1 && x != 2 * n - 1) {
    printf("Yes\n");

    int k = min(x, 2 * n - x);

    int v2 = 2 * n - 1;
    for (int i = 1; i < 2 * n; ++i) {
      int val;
      if (i >= n - k + 1 && i <= n) {
        val = i + k - n;
      } else {
        val = v2--;
      }
      if (x > n) {
        val = 2 * n - val;
      }
      printf("%d\n", val);
    }
  } else {
    printf("No\n");
  }
}

int main() {
  precalc();
#ifdef LOCAL
  freopen(TASK ".out", "w", stdout);
  assert(freopen(TASK ".in", "r", stdin));
#endif

  while (1) {
    if (!read()) {
      break;
    }
    solve();
#ifdef DEBUG
    eprintf("Time %.2f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
  }
  return 0;
}


Measured memory_bytes: 1536
#include <iostream>
#include <assert.h>
#include <vector>
#include <algorithm>

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

    int32_t N;
    std::cin >> N;
    std::vector<int32_t> h(N);
    for(auto& i : h){
        std::cin >> i;
    }

    int32_t nz_idx = 0;
    int32_t cnt = 0;
    while(nz_idx < N){
        while(nz_idx < N && h[nz_idx] == 0){
            nz_idx++;
        }
        if(nz_idx == N){
            break;
        }

        for(int32_t i = nz_idx; i < N; i++){
            if(h[i] > 0){
                h[i]--;
            }
            else{
                break;
            }
        }
        cnt++;
    }

    std::cout << cnt;
    return 0;

}

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

using namespace std;

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

ll A[200005];

int main() {
    ll N;
    cin >> N;
    REP(i, N) {
        cin >> A[i];
    }
    sort(A, A + N);
    bool e = false;
    REP(i, N - 1) {
        if (A[i] == A[i + 1])
            e = true;
    }

    if (e)
        cout << "NO" << endl;
    else
        cout << "YES" << endl;
    return 0;
}

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

#define int long long
#define MOD 1000000007

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

using namespace std;

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

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

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

	string S, T;
	cin >> S >> T;
	
	int ret;
	bool two;
	int pt;
	if (S[0] == T[0]) {
		ret = 3;
		two = false;
		pt = 1;
	} else {
		ret = 6;
		two = true;
		pt = 2;
	}

	while (pt < N) {
		if (!two) {
			if (S[pt] == T[pt]) {
				ret *= 2;
				ret %= MOD;
				two = false;
				pt++;
			} else {
				ret *= 2;
				ret %= MOD;
				two = true;
				pt += 2;
			}
		} else {
			if (S[pt] == T[pt]) {
				two = false;
				pt++;
			} else {
				ret *= 3;
				ret %= MOD;
				two = true;
				pt += 2;
			}
		}
	}

	cout << ret << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repR(i, n) for(int i = n; i >= 0; ++i)
#define FDS(i, n) for(ll i = 0; i < n; ++i)
#define FDSR(i, n) for(int i = n; i >= 0; ++i)
#define FOR(i, m, n) for(int i = m; i < n; ++i)
#define FORR(i, m, n) for(int i = m;i >= n;--i)
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
#define itn int
#define ednl endl
using namespace std;
typedef long long ll;
int main(){
	int A,B,C;
	cin>>A>>B>>C;
  cout<<max({A,B,C})-min({A,B,C})<<endl;
}


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

int calc(int value, int f) {
	int temp = 1;
	while (temp * f <= value) {
		temp *= f;
	}
	return temp;
}

int main() {
	int N, dp[100001];
	std::scanf("%d", &N);
	dp[0] = 0;
	dp[1] = 1;
	for (int i = 1; i <= N; ++i) {
		int a = dp[i - 1] + 1;
		int b = dp[i - calc(i, 6)] + 1;
		int c = dp[i - calc(i, 9)] + 1;
		dp[i] = std::min(a, std::min(b, c));
	}
	std::printf("%d", dp[N]);
}

Measured memory_bytes: 512