akhauriyash/Code-Regression huggingface dataset:
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Deque;
import java.util.List;
import java.util.NoSuchElementException;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Scanner;
 
 
public class Main {
	
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		
		Scanner sc = new Scanner(System.in);
		
		
		int N = Integer.parseInt(sc.next());
		int K = Integer.parseInt(sc.next());
		Deque<Integer> pre_ = new ArrayDeque<>();
		for(int i=0;i<N;i++){
			pre_.addFirst(Integer.parseInt(sc.next()));
		}

		
		
		int ans =0;
		for(int i=0;i<=K;i++){
			//i個(0<=i<=K)取り出す。（K-i個押し戻すことができる）
			for(int j=0;j<=i;j++){
				//左からｊ個取り出す(右からi-j個取り出す)
				Deque<Integer> pre = new ArrayDeque<>();
				Queue<Integer> hand = new PriorityQueue<>();
				for(int p : pre_){
					pre.addFirst(p);
				}
				for(int left=0;left<j;left++){
					if(pre.peekFirst()==null)break;
					int get = pre.pollFirst();
					hand.add(get);
				}
				for(int right=0;right<i-j;right++){
					if(pre.peekLast()==null)break;
					int get = pre.pollLast();
					hand.add(get);
				}
				//最大K-i個分消す。マイナスだったら消す
				int count =1;
				while(count <= K-i){
					if (hand.size() == 0)break;
					int min = hand.peek();
					if(min < 0){
						count++;
						hand.poll();
					}else{
						break;
					}
				}
				int tmp_ans = 0;
				if(hand.size() != 0){
					for(int p : hand){
						tmp_ans += p;
					}
				}
				ans = Math.max(ans, tmp_ans);
			}
			
		}
		
		System.out.println(ans);
		
		
		
	}
	
}



Measured memory_bytes: 36792
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	N := ReadInt()
	a := ReadInts(N)
	colors := make(map[int]bool)
	wcount := 0
	for _, ai := range a {
		color := ai / 400
		if color >= 8 {
			wcount++
		} else {
			colors[color] = true
		}
	}
	min := Max(1, len(colors))
	max := Min(len(colors) + wcount)
	fmt.Println(min, max)
}

func Max(xs ...int) int {
	max := xs[0]
	for _, x := range xs[1:] {
		if max < x {
			max = x
		}
	}
	return max
}

func Min(xs ...int) int {
	min := xs[0]
	for _, x := range xs[1:] {
		if min > x {
			min = x
		}
	}
	return min
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


Measured memory_bytes: 1844
#include <bits/stdc++.h>
// #include <atcoder/all>
#define ll long long int
#define ld long double
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i, n) for (ll i = 1; i < (ll)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
// using namespace atcoder;
void Main()
{
    string S;
    cin >> S;

    int n = S.size();
    vector<int> L(n), R(n);
    L[0] = S[0] == 'L' ? 1 : 0;
    R[0] = S[0] == 'R' ? 1 : 0;
    repi(i, n) {
        L[i] = L[i-1] + (S[i] == 'L' ? 1 : 0);
        R[i] = R[i-1] + (S[i] == 'R' ? 1 : 0);
    }

    vector<int> pos(n);
    rep(i, n) {
        if (S[i] == 'L') {
            int r = lower_bound(R.begin(), R.begin() + i, R[i]) - R.begin();
            int p = (i - r) % 2 == 1 ? r + 1 : r;
            pos[p]++;
        }
        else {
            int l = upper_bound(L.begin() + i, L.end(), L[i]) - L.begin();
            int p = (l - i) % 2 == 1 ? l - 1 : l;
            pos[p]++;
        }
    }

    rep(i, pos.size()) cout << pos[i] << (i == pos.size() - 1 ? "" : " ");
    cout << endl;

}
signed main(){ Main();return 0;}

Measured memory_bytes: 4496
import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 19
MOD = 10 ** 9 + 7
EPS = 10 ** -10

def bisearch_min(mn, mx, func):
    ok = mx
    ng = mn
    while ng+1 < ok:
        mid = (ok+ng) // 2
        if func(mid):
            ok = mid
        else:
            ng = mid
    return ok

def check(m):
    cnt = 0
    for a in A:
        cnt += ceil(a, m) - 1
    return cnt <= K

N, K = MAP()
A = LIST()

res = bisearch_min(0, INF, check)
print(res)


Measured memory_bytes: 94640
import java.awt.geom.Line2D;
import java.awt.geom.Point2D;
import java.awt.geom.Point2D.Double;
import java.util.ArrayList;
import java.util.Scanner;
import java.lang.Object;
 
public class Main {
    Scanner sc = new Scanner(System.in);
   
    public static void main(String[] args) {
        new Main(); 
    }
   
    public Main() {
        new H().doIt();
    }
    class H{
    	int p, n;
    	int x = 0, y = 0, v = 0, u = 0;
    	void sternBrocot(int pl,int ql ,int pr,int qr){
    		int pm = pl+pr, qm = ql+qr;
//    		System.out.println(x+" "+y);
    		//??????
    		if (pm > n || qm > n) return;
    		//??§?????????
    	    if (p*qm*qm < pm*pm) {
    	        u = pm; v = qm;
    	        sternBrocot(pl, ql, pm, qm);
    	    //?°??????????
    	    } else if (p*qm*qm > pm*pm) {
    	        x = pm; y = qm;
    	        sternBrocot(pm, qm, pr, qr);
    	    //?±??????°
    	    } else {
    	        x = u = pm;
    	        y = v = qm;
    	    }
    	}
    	void doIt(){
    		while(true){
    			p = sc.nextInt();
    			n = sc.nextInt();
    			if(p + n == 0)break;
    			//?????????1/1?????¨??????????????????????????????
    			sternBrocot(0,1,1,0);
    			System.out.println(u+"/"+v+" "+x+"/"+y);
    		}
    	}
    }
}

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

int main() {
	int A;
	int64_t B, N;
	cin >> A >> B >> N;
	cout << floor(A * min(B - 1, N) / B) - A * floor(min(B - 1, N) / B) << endl;
	return 0;
}

Measured memory_bytes: 3788
#include<stdio.h>
int main(void)
{
 int N;
  int i;
  double x[11];
  char u[11];
  double num=0;
  double BTC=380000.0;
  scanf("%d", &N);
  for(i=0;i<N;i++){
    scanf("%lf", &x[i]);
    scanf("%s", &u[i]);
  }
   for(i=0;i<N;i++){
    if(u[i]=='J'){
      num=num+x[i];
    }
    if(u[i]=='B'){
      num=num+(x[i]*BTC);
    }
  }
    printf("%lf", num);
    return 0;
}

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

int main(){
    int N, K, count = 0;
    cin >> N >> K;
    int h[N];
    for(int i=0; i<N; i++){
        cin >> h[i];
        if(h[i] >= K) count++;
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 640
{-# OPTIONS_GHC -O2 -funbox-strict-fields #-}
import qualified Data.ByteString.Char8 as BC
import           Data.Maybe            (fromJust)
import qualified Data.Graph as G
import Data.List (delete)

main :: IO ()
main = do
  [n, m] <- getInts
  abs <- getIntss
  print $ solve n m abs

solve :: Int -> Int -> [[Int]] -> Int
solve n m abs = length $ filter (not . isBridge) abs where
  isBridge [a, b] = G.path g a b where
    g = G.buildG (1, n) es
    es = twin $ delete [a, b] abs

twin :: [[Int]] -> [(Int, Int)]
twin = concatMap $ \[a, b] -> [(a, b), (b, a)]

readInts :: BC.ByteString -> [Int]
readInts = map (fst . fromJust . BC.readInt) . BC.words

getInts :: IO [Int]
getInts = readInts <$> BC.getLine

getIntss :: IO [[Int]]
getIntss = map readInts . BC.lines <$> BC.getContents


Measured memory_bytes: 892
import numpy as np
N,K=list(map(int, input().split())) 
P =list(map(int, input().split())) 
am = np.cumsum(list(range(1, 1000+1)))
e = [am[P[i]-1] / P[i] for i in range(N)]
e_sum = np.cumsum(e)
ans = 0
for i in range(K-1, N):
  if(i == K-1):
    ans = e_sum[i]
  else:
    ans = max([ans, e_sum[i] - e_sum[i-K]])
print(ans)

Measured memory_bytes: 33736
#include<bits/stdc++.h>
#define EM 100000000
using namespace std;
using LL = long long;
using P = pair<LL, LL>;
LL LINF = 1e18;
int INF = 1e9;
using vint = vector<int>;
using vLL = vector<LL>;

// vector<vector<int>> G(200010);
vector<int> G[200010];
vector<int> c(200010, 0), used(200010, 0);
void dfs(int s, int cnt){
    if(used[s]) return;
    used[s] = 1;
    c[s] += cnt;
    for(auto v : G[s]){
        dfs(v, c[s]);
    }
}
int main(){
    int N, Q;
    cin >> N >> Q;
    for(int i = 0; i < N-1;i++){
        int a, b;
        cin >> a >> b;
        G[a-1].push_back(b-1);
        G[b-1].push_back(a-1);
    }
    for(int i = 0;i < Q;i++){
        int p, x;
        cin >> p >> x;
        c[p-1] += x;
    }
    dfs(0, 0);
    for(int i = 0;i < N;i++)    cout << c[i] << endl;
}

Measured memory_bytes: 21120
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <bitset>
using namespace std;

int main(){
    int n, m;
    cin >> n >> m;
    int mas[m];
    for(int i = 0; i < m; i++){
        int k;
        cin >> k;
        int ma = 0;
        for(int j = 0; j < k; j++){
            int s;
            cin >> s;
            ma = ma | (1<<(s-1));
        }
//        cerr << i+1 << " " << bitset<4>(ma) << endl;
        mas[i] = ma;
    }
    int ps[m];
    for(int i = 0; i < m; i++){
        int p;
        cin >> p;
        ps[i] = p;
    }

    int s = 0;
    for(int i = 0; i < 1<<n; i++){
        int light = 0;
//        cerr << "i  " << bitset<4>(i) << endl;
        for(int j = 0; j < m; j++){
            int an = i&mas[j];
            int c = 0;
//            cerr << "j  " << bitset<4>(mas[j]) << endl;
//            cerr << "an " << bitset<4>(an) << endl;
            for(int k = 0, mask = 1; k < n; k++, mask<<=1){
//                cerr << "mask" << bitset<4>(mask) << endl;
                if(an&mask){
//                    cerr << "aa " << bitset<4>(an&mask) << endl;
                    c++;
                }
            }
            if(c%2 == ps[j]){
                light++;
            }
        }
        if(light == m){
            s++;
//            cerr << bitset<4>(i) << endl;
        }
    }
    cout << s << endl;

    return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
#define BIT(n) (1LL << (n))
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPB(i, n) for (int i = 0; i < BIT(n); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORA(i, n) for (auto &&i : n)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
#define DEBUG(x) cerr << #x << ": " << x << "\n"
#define PRINTALL(V)                                                            \
  for (auto v : (V)) {                                                         \
    cerr << v << " ";                                                          \
  }                                                                            \
  cerr << "\n";
#define ALL(v) v.begin(), v.end()
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define epb emplace_back
#define int long long
using namespace std;
template < class T > bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template < class T > bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template < class T > using vec = std::vector< T >;
template < class T > void print(const T &x) { cout << x << "\n"; }
const int MOD = 1000000007, INF = 1061109567;
const double EPS = 1e-10, PI = acos(-1.0);
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
signed main() {
  cin.tie(0), ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  string S;
  int X, Y;
  cin >> S >> X >> Y;
  int N = S.size();
  int initPos = S.find('T');
  if (initPos == (int)string::npos) {

    if (X == N)
      print("Yes");
    else {
      print("No");
    }

    return 0;
  } else {
    // DEBUG(S);
    // DEBUG(initPos);
    X -= initPos;
    int dtype = 0; // xtype
    vec< vec< int > > xyLis(2, vec< int >());
    int cnt = 0;
    S.pb('T');
    int xyLisSum[2] = {0, 0};
    FOR(i, initPos, (int)S.size()) {
      if (S[i] == 'T') {
        if (cnt != 0) {
          xyLis[dtype].pb(cnt);
          xyLisSum[dtype] += cnt;
          cnt = 0;
        }
        dtype++;
        dtype %= 2;
      } else {
        cnt++;
      }
    }
    //
    int sx = xyLisSum[0] - X;
    int sy = xyLisSum[1] - Y;

    if (sx % 2 == 0 && sy % 2 == 0 && sx >= 0 && sy >= 0) {
      sx /= 2;
      sy /= 2;
      // DEBUG(sx);
      // DEBUG(sy);
      // PRINTALL(xyLis[0]);
      // PRINTALL(xyLis[1]);

      vec< bool > flgX(sx + 1, false);
      flgX[sx] = true;
      FORA(e, xyLis[0]) {
        REPS(i, sx) {
          if (flgX[i] && i - e >= 0 && !flgX[i - e]) {
            flgX[i - e] = true;
          }
        }
      }

      vec< bool > flgY(sy + 1, false);
      flgY[sy] = true;
      FORA(e, xyLis[1]) {
        REPS(i, sy) {
          if (flgY[i] && i - e >= 0 && !flgY[i - e]) {
            flgY[i - e] = true;
          }
        }
      }

      if (flgX[0] && flgY[0]) {
        print("Yes");
      } else {
        print("No");
      }
    } else {
      print("No");
    }
    return 0;
  }
}

Measured memory_bytes: 384
#include <iostream>
using namespace std;
 
int main() {
    int n;
    cin >> n;

    int array[n];
    for(int i=0; i < n; i++){
        cin >> array[i];
    }
    
    int ans = 0;
    for(int i=0; i < n; i++){
        if((i+1) != array[i]){
            ++ans;
        }
    }
    // cout << ans << endl;
    if(ans <= 2){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include "iostream"
#include "vector"
#include "set"
#include "string"

using namespace std;

int main(void) {
	int n, q;
	string s;
	cin >> n >> s >> q;

	vector<set<int>> pos(26);
	for (int i = 0; i < n; ++i) {
		pos.at(s.at(i) - 'a').insert(i);
	}

	for (int tmp_i = 0; tmp_i < q; ++tmp_i) {
		int type;
		cin >> type;
		if (type == 1) {
			int ti;
			char c;
			cin >> ti >> c;
			int i = ti - 1;
			pos.at(s.at(i) - 'a').erase(i);
			pos.at(c - 'a').insert(i);
			s.at(i) = c;
		}
		else {
			int tl, tr;
			cin >> tl >> tr;
			int l = tl - 1, r = tr - 1;
			int num = 0;
			for (int j = 0; j < 26; ++j)
				if (pos.at(j).lower_bound(l) != pos.at(j).end() && *pos.at(j).lower_bound(l) <= r)
					num++;
			cout << num << endl;
		}
	}
}

Measured memory_bytes: 24196
// 解き直し.
// ARC 085/ABC 078 解説.
// https://img.atcoder.jp/arc085/editorial.pdf
#include <iostream>

using namespace std;

#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define abs(x) ((x > 0) ? x : (-(x)))
#define max(x, y) ((x > y) ? x : y)

typedef long long LL;

int main() {
    
    // 1. 入力情報取得.
    int N, Z, W;
    cin >> N >> Z >> W;
    LL A[N] = {};
    FOR(i, 0, N) cin >> A[i];
    
    // 2. カードの引き方を考える.
    // N = 1  -> 最後のカードは, Xさん が引く.
    // N >= 2 -> 最後のカードは, Xさん or Yさん が引く.
    // 以下は, 解説通り.
    LL diff = 0;
    if(N == 1) diff = abs(A[0] - W);
    if(N >= 2) diff = max(abs(A[N - 1] - W), abs(A[N - 2] - A[N - 1]));
    
    // 3. 出力 ～ 後処理.
    cout << diff << endl;
    return 0;
    
}


Measured memory_bytes: 256
#include<iostream>
using std::cout;
using std::cin;
using std::endl;

int main()
{
  int a, b;
  cin >> a >> b;
  
  int sum = 0;
  
  if (a > b)
    sum += a--;
  else
    sum += b--;

  if (a > b)
    sum += a--;
  else
    sum += b--;

  cout << sum << endl;
  
  return 0;
}

Measured memory_bytes: 256
<?php

$input_str = trim(fgets(STDIN));

$check_idx = 0;

$list = [
	0 => 1,
	1 => 0,
	2 => 0,
	3 => 1,
	4 => 1,
	5 => 1
];
$target = 'KIHBR';

$count_list = [
	0 => 0,
	1 => 0,
	2 => 0,
	3 => 0,
	4 => 0,
	5 => 0
];
$is_enable_target_str = false;
foreach (str_split($input_str) as $value)
{
	if ($value === 'A')
	{
		$count_list[$check_idx]++;

		if ($count_list[$check_idx] > $list[$check_idx])
		{
			$is_enable_target_str = false;
			break;
		}

		continue;
	}

	if (isset($target[$check_idx]) && $value === $target[$check_idx])
	{
		$check_idx++;
	}
	else
	{
		$is_enable_target_str = false;
		break;
	}

	if ($check_idx >= strlen($target))
	{
		$is_enable_target_str = true;
	}
}

echo ($is_enable_target_str)? 'YES' : 'NO';


Measured memory_bytes: 3828
using System;

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            string line = Console.ReadLine();
            string[] strs = line.Split(' ');
            int N = int.Parse(strs[0]);
            int M = int.Parse(strs[1]);
            line = Console.ReadLine();
            strs = line.Split(' ');
            int[] A = new int[N];
            int sum = 0;
            for(int i = 0; i < N; i++)
            {
                A[i] = int.Parse(strs[i]);
                sum += A[i];
            }
            int count = 0;
            for (int i = 0; i < N; i++)
            {
                if (sum / (4 * (double)M) <=  A[i])
                {
                    count++;
                }
            }
            if (count >= M)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}


Measured memory_bytes: 11092
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define mt make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;

const int MA = 100099;
int vis[MA], col[MA];
bool isBi;
int ccSize;
vi G[MA];

void dfs(int u, int c) {
	if (vis[u]++) {
		if (col[u] != c) {
			isBi = false;
		}
		return;
	}
	ccSize++;
	col[u] = c;
	each(v, G[u]) {
		dfs(v, 1 - c);
	}
}

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

	int N, M;
	cin >> N >> M;
	rep(i, M) {
		int u, v;
		cin >> u >> v;
		--u; --v;
		G[u].push_back(v);
		G[v].push_back(u);
	}

	ll isolated = 0, bi = 0, other = 0;
	rep(i, N)if (!vis[i]) {
		isBi = true;
		ccSize = 0;
		dfs(i, 0);
		
		if (ccSize == 1)isolated++;
		else if (isBi)bi++;
		else other++;
	}

	ll ans = 0;
	// 少なくとも１つが孤立点
	ans += isolated * (N - isolated) * 2 + isolated*isolated;
	// 孤立点なし、両方が二部グラフ
	ans += bi * bi * 2;
	// 孤立点なし、どちらかが二部グラフではない
	ans += bi*other * 2 + other*other;

	cout << ans << endl;
}


Measured memory_bytes: 9472
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_int.hpp>
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
//#define i_7 (ll)(1E9+7)
#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E17;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
////////////////////////////


 
int main(){fastio
    
    ll n;cin>>n;
    ll a[n];rep(i,0,n-1)a[i]=i;
    dd x[n],y[n];
    rep(i,0,n-1)cin>>x[i]>>y[i];
    dd sum=0.0;
    do{
        rep(i,0,n-2){
            sum+=sqrt(powl((x[a[i]]-x[a[i+1]]),2)+powl((y[a[i]]-y[a[i+1]]),2));
        }
    }while(next_permutation(a,a+n));
    rep(i,1,n){
        sum=sum/i;
    }
    cout<<setprecision(15)<<sum<<endl;
    
    
    
    return 0;
}




Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		while(true) {
			int h = sc.nextInt();
			int w = sc.nextInt();

			if(h == 0 && w == 0) break;
			for(int i=0; i<h; i++) {
				for(int j=0; j<w; j++) {
					if(i != 0 && i != h-1 && j != 0 && j != w-1) System.out.print(".");
					else System.out.print("#");
				}
				System.out.println("");
			}
			System.out.println("");
		}

		sc.close();

	}

}


Measured memory_bytes: 34216
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int n,k,Q;
  cin>>n>>k>>Q;
  int a[2000],b[2000];
  for(int i=0;i<n;i++){
    cin>>a[i];
    b[i]=a[i];
  }
  sort(b,b+n);
  int ans=b[Q-1]-b[0];
  for(int m=0;m<n;m++){
    priority_queue<int> q;
    for(int i=0;i<n;i++){
      if(a[i]<a[m]){
	continue;
      }
      priority_queue<int> q2;
      while(a[i]>=a[m]){
	q2.push(-a[i]);
	i++;
	if(i==n)break;
      }
      while(q2.size()>k-1){
	q.push(q2.top());
	q2.pop();
      }
    }
    if(q.size()<Q)continue;
    int y=-q.top();
    for(int i=0;i<Q-1;i++){
      q.pop();
    }
    int x=-q.top();
    ans=min(ans,x-y);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 384
//#typedef int ll
// include
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <tuple>
// namespace
using namespace std;
// typedef
typedef long long ll;
typedef long double ld;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int, int> pint;
// const
const int inf = 1e9;
const ll mod = ((ll)1e9 + 7);
// loop
#define rep(i, n) for(ll i = 0, i##_mx = n; i < i##_mx; i++)
#define brep(i, b, e) for(ll i = b; i < e; i++)
#define erep(i, b, e) for(ll i = b; i <= e; i++)
#define rrep(i, b, e) for(ll i = b; i >= e; i--)
// STL
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define all(v) (v).begin(), (v).end()
// sort
#define vsort(v, b) sort(all(v), [](auto l, auto r){return (b);})
// access
#define gt(i, n) get<n>(i)
// debug
#define debug(x) cout << (#x) << ": " << x << endl;
// function
ll gcd(ll a, ll b){return b ? gcd(b, a % b) : a;}
ll lcm(ll a, ll b){return a * b / gcd(a, b);}
void prime(vll& v, ll n){v.pb(2); for(auto i = 3; i <= n; i += 2){bool fg = false; for(auto e : v){if(i % e == 0){fg = true;}} if(fg){continue;} v.pb(i);}}
void in(vint& v){for(auto& i : v){cin >> i;}}
void in(vll& v){for(auto& i : v){cin >> i;}}
ll egcd(ll a, ll b, ll& x, ll& y){if(b == 0){x = 1; y = 0; return a;} ll d = egcd(b, a % b, y, x); y -= a / b * x; return d;}

signed main(){
    int x;
    cin >> x;
    
    vll p;
    prime(p, 1000);
    
    int check = x * 2;
    int last;
    while(check >= x){
        bool flg = true;
        for(auto i : p){
            if(i >= check){
                break;
            }
            if(check % i == 0){
                check;
                flg = false;
                break;
            }
        }
        if(flg){
            last = check;
        }
        check--;
    }
    
    cout << last << endl;
    
    return 0;
}


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

#define BR "\n"
#define SP " "
#define SHOW(x) for(int i = 0; i < x.size(); i++) { cout << x[i] << SP; } cout << BR;
#define SHOW2(x) for(int j = 0; j < x.size(); j++) { SHOW(x[j]); } cout << BR;

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

  ll INF = 1e11;

  vector<ll> s(A + 2);
  vector<ll> t(B + 2);

  for (int i = 1; i <= A; i++) { cin >> s[i]; }
  for (int i = 1; i <= B; i++) { cin >> t[i]; }

  s[0] = -INF, t[0] = -INF;
  s[A+1] = INF, t[B+1] = INF;

  for (int i = 0; i < Q; i++) {
    ll x; cin >> x;

    int l, r, m;
    l = -1, r = A + 1, m;
    while (l+1 < r) {
      m = (l+r)/2;
      if (s[m] <= x) {
        l = m;
      } else {
        r = m;
      }
    }
    int la = l, ra = r;
    // cout << SP << la << SP << ra << BR;

    l = -1, r = B + 1, m;
    while (l + 1 < r) {
      m = (l + r) / 2;
      if (t[m] <= x) {
        l = m;
      } else {
        r = m;
      }
    }
    int lb = l, rb = r;
    // cout << SP << lb << SP << rb << BR;

    ll al = abs(x - s[la]), ar = abs(x - s[ra]);
    ll bl = abs(x - t[lb]), br = abs(x - t[rb]);

    ll ans = min(max(al, bl), max(ar, br));
    ans = min(ans, min(al, ar) * 2 + min(bl, br));
    ans = min(ans, min(al, ar) + min(bl, br) * 2);
    cout << ans << BR;
  }
  return 0;
}

Measured memory_bytes: 2944
n = int(input())
p = [int(i) for i in input().split()]
ans = 0
for i in range(1, n - 1):
    if p[i - 1] < p[i] < p[i + 1] or p[i + 1] < p[i] < p[i - 1]:
        ans += 1
print(ans)

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

    // int scan
    /*
    int x;
    scanf("%d",&x);
    int y;
    scanf("%d",&y);
    int z;
    scanf("%d",&z);

    // matrix scan
    /*
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    */

    // string scan
    /*
    string s;
    cin >> s;
    */


int main() {
    int n;
    scanf("%d",&n);
    ll a[n] = {};
    ll ans = 0;
    rep(i,n){
        scanf("%lld",&a[i]);
        ans += a[i];
    }
    int m;
    cin >> m;
    rep(i,m){
        int p,x;
        cin >> p >> x;
        cout << ans-a[p-1]+x << endl;
    }


    return 0;
}



Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
	int a, b, c;
	cin >> a >> b >> c;

	if(a == b && a == c){
		cout << 1 << endl;
	} else if (a == b || b == c || c == a){
		cout << 2 << endl;
	} else {
		cout << 3 << endl;
	}
	return 0;
}


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





int main(){

	int n;
	cin>>n;
	int a = n%10;
	if(a == 2 || a == 4 || a == 5 || a== 7 || a==9)
		cout<<"hon"<<endl;
	else if(a == 1 || a==0 || a== 6 || a==8)
		cout<<"pon"<<endl;
	else
		cout<<"bon"<<endl;
  
	return 0; 
  
}


Measured memory_bytes: 3596
# coding: utf-8

import sys
import math

import array
import bisect
import collections
from collections import Counter, defaultdict
import fractions
import heapq
import re

sys.setrecursionlimit(1000000)


def array2d(dim1, dim2, init=None):
    return [[init for _ in range(dim2)] for _ in range(dim1)]

def argsort(l, reverse=False):
    return sorted(range(len(l)), key=lambda i: l[i], reverse=reverse)

def argmin(l):
    return l.index(min(l))

def YESNO(ans, yes="YES", no="NO"):
    print([no, yes][ans])

II = lambda: int(input())
MI = lambda: map(int, input().split())
MIL = lambda: list(MI())
MIS = lambda: input().split()


def main():
    a, b = MI()
    if a >= 13: return b
    if a >= 6: return b // 2
    return 0


if __name__ == "__main__":
    print(main())


Measured memory_bytes: 5644
#include<stdio.h>
#include<math.h>
int main(){
    int x,a,b,sub1,sub2;
    unsigned u,v;
    scanf("%d %d %d",&x,&a,&b);
    sub1=x-a;
    sub2=x-b;
    u=sub1;
    v=sub2;
    u=(sub1>=0 ? sub1: -sub1);
    v=(sub2>=0 ? sub2: -sub2);
    if(u<v){
        printf("A\n");
    }
    else{
        printf("B\n");
    }
    return 0;
}


Measured memory_bytes: 128
#include <cstdio>
#include <algorithm>
#define N 200005
typedef long long ll;
using namespace std;
ll n, cnt, ans, a[N], b[N], c[N], d[N];
int main() {
	ll i, j, k;
	scanf("%lld", &n);
	for(i=0; i<n; i++) scanf("%lld", &a[i]);
	for(i=0; i<n; i++) scanf("%lld", &b[i]);
	for(j=0; j<30; j++) {
		k = 1<<j;
		for(i=0; i<n; i++) c[i] = a[i] % (2*k);
		for(i=0; i<n; i++) d[i] = b[i] % (2*k);
		sort(d, d+n);
		cnt = 0;
		for(i=0; i<n; i++) {
			cnt += lower_bound(d, d+n, 2*k-c[i]) - lower_bound(d, d+n, 1*k-c[i]);
			cnt += lower_bound(d, d+n, 4*k-c[i]) - lower_bound(d, d+n, 3*k-c[i]);
		}
		if(cnt%2==1) ans += k;
	}
	printf("%lld", ans);
	return 0;
}

Measured memory_bytes: 6400
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

bool check(char c) {
  char target[] = {'A', 'C', 'G', 'T'};
  REP(l, 4){
    if (c == target[l]) {
      return true;
    }
  }
  return false;
}

int solve(string s) {
  int ret{};
  REP(i, (int)s.size()) {
    string t;
    REP(k, (int)s.size()) {
      if (check(s[i + k])) {
        t += s[i + k];
      } else {
        break;
      }
    }
    ret = max(ret, (int)t.size());
  }
  return ret;
}

int main() {
  string s;
  cin >> s;
  cout << solve(s) << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <vector>
#include <string>
#include <bitset>
#include <stack>
#include <queue>
#include <tuple>
#include <regex>
#include <cmath>
#include <map>
#include <set>
#include <functional>
#include <cstring>

using namespace std;

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

using ll = long long;
using Pint = pair<int, int>;
using Pll  = pair<ll, ll>;

#define eb emplace_back
#define pb push_back
#define mp make_pair

#define F first
#define S second

#define popcnt __builtin_popcountll

#define rep( i, n ) for ( ll i = 0; i < (ll)( n ); ++i )
#define reps( i, n ) for ( ll i = 1; i <= (ll)( n ); ++i )
#define rrep( i, n ) for ( ll i = (ll)( ( n ) - 1 ); i >= 0; --i )
#define rreps( i, n ) for ( ll i = (ll)( ( n ) ); i > 0; --i )
#define arep( i, v ) for ( auto &&i : ( v ) )

#define ALL( c ) ( c ).begin(), ( c ).end()
#define RALL( c ) ( c ).rbegin(), ( c ).rend()
#define UNIQUE( c ) ( c ).erase( unique( ( c ).begin(), ( c ).end() ), ( c ).end() )

template<typename T = ll> constexpr T MAX = numeric_limits<T>::max();
template<typename T> T gcd( const T a, const T b ) { return ( b ? gcd( b, a % b ) : a ); }
template<typename T> T lcm( const T a, const T b ) { return ( a / gcd( a, b ) * b ); }


int main()
{
	ll R, C, K; cin >> R >> C >> K;
	static ll item[3005][3005] = { { 0 } };
	rep( i, K )
	{
		ll r, c, v;
		cin >> r >> c >> v;
		--r; --c;
		item[r][c] = v;
	}

	static ll dp[3005][3005][4] = { { { 0 } } };
	rep( i, R )
	{
		rep( j, C )
		{
			rep( k, 4 )
			{
				chmax( dp[i][j + 1][k], dp[i][j][k] );
				if ( k <= 2 )
				{
					chmax( dp[i][j + 1][k + 1], dp[i][j][k] + item[i][j] );
					chmax( dp[i + 1][j][0], dp[i][j][k] + item[i][j] );
				}
				chmax( dp[i + 1][j][0], dp[i][j][k] );
			}
		}
	}

#if 0
	rep( i, R + 1 )
	{
		rep( j, C + 1 )
		{
			cout << "[ ";
			rep( k, 3 )
			{
				cout << dp[i][j][k] << ", ";
			}
			cout << dp[i][j][3] << " ] ";
		}
		cout << endl;
	}
#endif

	ll ans = 0;
	rep( i, 4 ) chmax( ans, dp[R][C - 1][i] );
	rep( i, 4 ) chmax( ans, dp[R - 1][C][i] );
	cout << ans << endl;

	return ( 0 );
}


Measured memory_bytes: 355268
#include<bits/stdc++.h>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define inf 2000000000
#define infLL 2000000000000000000
#define MAX 500005
#define sf(a) scanf("%d", &a)
#define sfl(a) scanf("%lld", &a)
#define pf(a) printf("%d ", a)
#define pfl(a) printf("%lld\n", a)
#define Case(t) printf("Case %d: ", t)
#define pii pair<int, int>
#define MOD 1000000007
#define mod 998244353
#define PI acos(-1.0)
#define eps 1e-9
#define mem(a, b) memset(a, b, sizeof(a))
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

inline int Set(int N, int pos){return N=N | (1<<pos);}
inline int Reset(int N, int pos){return N=N & ~(1<<pos);}
inline bool Check(ll N, ll pos){return (bool)(N & (1LL<<pos));}

inline void normal(ll &a) { a %= mod; (a < 0) && (a += mod); }
inline ll modMul(ll a, ll b) { a %= mod, b %= mod; normal(a), normal(b); return (a * b) % mod; }
inline ll modAdd(ll a, ll b) { a %= mod, b %= mod; normal(a), normal(b); return (a + b) % mod; }
inline ll modSub(ll a, ll b) { a %= mod, b %= mod; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while (p) { if (p & 1LL) r = modMul(r, b); b = modMul(b, b); p >>= 1LL; } return r; }
inline ll modInverse(ll a) { return modPow(a, mod - 2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

ll fast_exp(ll x, ll n, ll m)
{
    ll res = 1;
    while(n>0)
    {
        if(n%2==1)
            res = (res * x) % m;
        x = (x * x) % m;
        n/=2;
    }
    return res%m;
}

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{
    cerr << *it << " = " << a << endl;
    err(++it, args...);
}

clock_t t_Start;
void Start()
{
    t_Start = clock();
}
void End()
{
    double Time = (double)(clock()-t_Start)/CLOCKS_PER_SEC;
    error(Time);
}

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>orderedSet;
typedef tree<int,null_type,greater<int>,rb_tree_tag,tree_order_statistics_node_update>orderedSet1;

vector<ll> NOD(ll n)
{
    vector<ll>v;
    for(ll i = 1; i * i <= n; i++)
    {
        if(n%i==0)
        {
            v.push_back(i);
            if(i!=(n/i))
                v.push_back(n/i);
        }
    }
    return v;
}

int main()
{
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    //Start();

    FASTIO;
    ll n;
    cin>>n;
    int cnt = NOD(n-1).size() - 1;
    for(auto x : NOD(n))
    {
        if(x==1)
            continue;
        ll tmp = n;
        while(tmp%x==0)
            tmp/=x;
        if(tmp%x==1)
            cnt++;
    }
    cout<<cnt<<endl;

    //End();
    return 0;
}


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

int main() {
    ll a, b;
    cin >> a >> b;
    
    ll n = gcd(a, b);
    
    vector<ll> factor;
    for (ll i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            factor.push_back(i);
           	if(i * i != a) factor.push_back(n/i);
        }
    }
    sort(factor.begin(), factor.end());
    
    int len = factor.size();
    vector<int> used(len, 0);
    int ans = 0;
    for (int i = 0; i < len; i++) {
        if (used[i]) continue;
        if (factor[i] == 1) ans++;
        else {
            ans++;
            for (int j = i + 1; j < len; j++) {
                if (factor[j] % factor[i] == 0) {
                    used[j] = 1;
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;



int main(){
  int n;
  string s;
  cin >> n;
  cin.ignore();
  cin >> s;
  cin.ignore();

  int cnt = 0;

  for (int i = 0; i < n - 2; i++){
    if(s[i] == 'A'){
      if(s.substr(i, 3) == "ABC"){
        ++cnt;
      }
    }
  }

  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int 
#define ld double
#define mp make_pair
#define pb push_back
#define mod 1000000007
#define ff first
#define ss second
#define pll pair <ll,ll>
#define nl "\n"
ll dp[100005][2];// 0 -> Black 
vector <ll> adj[100005];
void dfs(ll x,ll p)
{
	ll pro=1,s=1;
	for(auto it:adj[x])
	{
		if(it!=p)
		{
			dfs(it,x);
			s=(s*dp[it][1])%mod;
			pro=(pro*((dp[it][1]+dp[it][0])%mod))%mod;
		}
	}
	dp[x][0]=s;
	dp[x][1]=pro;
}
int main()
{
	ios_base::sync_with_stdio(false);
	ll n,i;
	cin>>n;
	for(i=0;i<n-1;i++)
	{
		ll u,v;
		cin>>u>>v;
		adj[u].pb(v);
		adj[v].pb(u);
	}
	if(n==1)
	{
		cout<<2<<nl;
		return 0;
	}
	dfs(1,-1);
	cout<<(dp[1][0]+dp[1][1])%mod<<nl;
	return 0;
}

Measured memory_bytes: 14208
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<n;i++)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

int main(){
    int x,y;
    cin >> x >> y;
    set<int> a{1,3,5,7,8,10,12},b{4,6,9,11},c{2};

    if((a.count(x) and a.count(y)) or (b.count(x) and b.count(y)) or (c.count(x) and c.count(y))) cout << "Yes" << endl;
    else cout << "No" << endl;
}


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

const string YES = "Yes";
const string NO = "No";

void solve(std::string S){
    int size = S.size();
    bool A=false;
    bool B=false;
    for(int i= 0;i<size;i++){
        if(S[i] == 'A'){
            A=true;
        }
        if(S[i]=='B'){
            B=true;
        }
    }
    if(A&&B){
        cout <<YES<<endl;
    }else{
        cout<<NO<<endl;
    }

}

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


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

#define X first
#define Y second
#define ll long long
#define MP make_pair
#define PB push_back

using namespace std;

const int MAXN=1e5;
ll MOD=1e9+7;

string s;
ll d;
ll dp[105];
ll novidp[105];
ll rj,n;
ll br;

void update(){
	for(int i=0; i<103; i++){
		dp[i]=novidp[i];
		novidp[i]=0;
	}
}

void cist(){
	memset(novidp,0,sizeof(novidp));
}

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

	cin>>s>>d;
	n=s.size();
	for(int i=0; i<n-1; i++){
		br+=s[i]-'0';
	}
	for(int i='0'; i<=s[n-1]; i++){
		if((br+i-'0')%d==0){
			rj++;
		}
	}
	for(int i=0; i<=9; i++){
		dp[i%d]++;
	}
	for(int i=n-2; i>=0; i--){
		br-=s[i]-'0';
		for(int j=0; j<s[i]-'0'; j++){
			rj+=dp[(d*1000000000000-br-j)%d];
			rj%=MOD;
		}
		cist();
		for(int j=0; j<d; j++){
			for(int i=0; i<10; i++){
				novidp[(j+i)%d]+=dp[j];
				novidp[(j+i)%d]%=MOD;
			}
		}
		update();
	}
	rj--;
	if(rj==-1){
		rj=1e9+6;
	}
	cout<<rj;
	
	return 0;
}

Measured memory_bytes: 3676
n=int(input())
s={}
for i in range(n):
  si = input()
  if si not in s:
    s[si] = 1
  else:
    s[si]+=1
sa = sorted(s.items())
ma = max(s.values())
for a in sorted(a for a in s if s[a]==ma):
  print(a)

Measured memory_bytes: 150204
#include <iostream>
#include <algorithm>
#include <vector>
#include <limits>

using namespace std;

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

    vector<int> R;
    for (int i = 0; i < n; ++i) {
        int r;
        cin >> r;
        R.push_back(r);
    }

    int maxv = R[1] - R[0];
    int minv = R[0];
    for (int j = 1; j < n; ++j) {
        maxv = max(maxv, R[j] - minv);
        minv = min(minv, R[j]);
    }
    cout << maxv << endl;

    return 0;
}

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

int main() {
    int a,b,c,d,k;
    cin>>a>>b>>c>>d>>k;
    int h1 = 60*a+b;
    int h2= 60*c+d;
    int time = h2-h1;
    if ((time-k) >= 0) cout << time-k <<endl;
    else cout << 0 << endl;
}


Measured memory_bytes: 3624
# https://qiita.com/HUVEC/items/97739696ab51cacd10f2
from sys import stdin

def main():
    from collections import defaultdict
    input = stdin.readline

    n = int(input())
    a = sorted(list(map(int, input().split())))
    p = defaultdict(int)
    for x in a:
        p[x] += 1
    q = a[-1] + 1
    f = [True] * (q)
    for k, v in p.items():
        if v > 1:
            f[k] = False
        for i in range(k + k, q, k):
            f[i] = False
    print(sum(1 for x in a if f[x]))
main()



Measured memory_bytes: 135316
function main(input) {
  input = input.split(' ');
  var n = parseInt(input[0]);
  var m = parseInt(input[1]);
  for(var x = 0; x <= m; x += 10000) {
    for(var y = 0; y <= m - x; y += 5000) {
      var z = (m - x - y);
      if (0 <= z && ((x / 10000) + (y / 5000) + (z / 1000)) == n) {
        console.log(x / 10000 + ' ' + y / 5000 + ' ' + z / 1000);
        return;
      }
    }
  }
  console.log('-1 -1 -1');
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

const ll MAXN = 200000;
const ll INF = 1001001001;
const ll MOD = 1000000007;

ll N, ans=0, tmp=0;
vector<ll> A, B, C, D, BS, DS;
string S;

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;
}

signed main(){
    cin >> S;
    A.resize(S.size(),0);
    B.resize(S.size(),0);
    C.resize(S.size(),0);
    D.resize(S.size(),0);
    for(int i=0;i<S.size();i++) {
        if(S[i]=='A'){
            A[i]++;
            continue;
        }
        if(S[i]=='B'){
            B[i]++;
            BS.push_back(i);
            continue;
        }
        if(S[i]=='C'){
            C[i]++;
            continue;
        }
        D[i]++;
        DS.push_back(i);
    }
    for(int i=0;i<S.size()-1;i++) {
        A[i+1] = A[i+1] + A[i];
        B[i+1] = B[i+1] + B[i];
        C[i+1] = C[i+1] + C[i];
        D[i+1] = D[i+1] + D[i];
    }
    for(int i=0;i<BS.size();i++) {
        if(BS[i]-1>=0) {
            ans += modpow(3,D[S.size()-1],MOD)*A[BS[i]-1]*(C[S.size()-1]-C[BS[i]]);
            ans += modpow(3,D[S.size()-1]-1,MOD)*A[BS[i]-1]*(D[S.size()-1]-D[BS[i]]);
            ans += modpow(3,D[S.size()-1]-1,MOD)*D[BS[i]-1]*(C[S.size()-1]-C[BS[i]]);
            ans += modpow(3,D[S.size()-1]-2,MOD)*D[BS[i]-1]*(D[S.size()-1]-D[BS[i]]);
            ans %= MOD;
            //cout << ans << endl;
        }
    }
    for(int i=0;i<DS.size();i++) {
        if(DS[i]-1>=0) {
            ans += modpow(3,D[S.size()-1]-1,MOD)*A[DS[i]-1]*(C[S.size()-1]-C[DS[i]]);
            ans += modpow(3,D[S.size()-1]-2,MOD)*D[DS[i]-1]*(C[S.size()-1]-C[DS[i]]);
            ans += modpow(3,D[S.size()-1]-2,MOD)*A[DS[i]-1]*(D[S.size()-1]-D[DS[i]]);
            ans += modpow(3,D[S.size()-1]-3,MOD)*D[DS[i]-1]*(D[S.size()-1]-D[DS[i]]);
            ans %= MOD;
            //cout << ans << endl;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 7484
#include <bits/stdc++.h>
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define ll long long
#define mod 1000000007

using namespace std;

int n, m, a[200001], b[200001], c[200001];

int main() {
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		cin >> a[i] >> b[i];
		if (a[i] == 1) c[b[i]] = 1;
	}
	for (int i = 0; i < m; i++) {
		if (c[a[i]] && b[i] == n) {
			cout << "POSSIBLE" << endl;
			return 0;
		}
	}
	cout << "IMPOSSIBLE" << endl;
	return 0;
}


Measured memory_bytes: 2560
#include <stdio.h>
int main()
{
	int n, x, i, j, k, g, p;
	scanf("%d %d", &n, &x);
	while (n != 0 || x != 0)
	{
		p = 0;
		for (i = 1; i <= n; i++)
		{
			for (j = 2; j <= n; j++)
			{
				if (i == j)
					break;
				for (k = 3; k <= n; k++)
				{
					if (i == k || j == k)
						break;
					g = i + j + k;
					if (x == g)
						p++;
				}
			}
		}
		printf("%d\n", p);
		scanf("%d %d", &n, &x);
	}
}


Measured memory_bytes: 2064
import numpy as np
import sys

n, k = map(int, input().split())
h = []
for i in range(n):
	p = int(input())
	h.append(p)
h.sort()
m = 10000000000
for i in range(n - k + 1):
	if(h[k + i - 1] - h[i] < m):
		m = h[k + i - 1] - h[i]
print(m)


Measured memory_bytes: 16728
#https://atcoder.jp/contests/abc162/tasks/abc162_c
# -*- coding: utf-8 -*-
import math
ans = 0
K = int(input())
for i in range(1,K+1):
  for j in range(1,K+1):
    tmp = math.gcd(i,j)
    for k in range(1,K+1):
      ans += math.gcd(tmp,k)
print(ans)

Measured memory_bytes: 9176
#include<stdio.h>
int strln(char a[100000])
{
    int i;
    for(i=0; a[i]!='\0'; i++)
    {

    }
    return i;



}
int main()
{
    char a[100000],b[100000],c[100000];
    int l1,l2,l3;
    scanf("%s%s%s",a,b,c);
    l1=strln(a);
    l2=strln(b);
    l3=strln(c);
    if(a[l1-1]==b[0]&&b[l2-1]==c[0])
    {
        printf("YES\n");


    }
    else printf("NO\n");
    return 0;



}


Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
using namespace std;

int n, pos;
vector<int>pre, in, post;

void rec(int l, int r) {
	if (l >= r)return;
	int root = pre[pos++];
	int m = distance(in.begin(), find(in.begin(), in.end(), root));
	rec(l, m);
	rec(m + 1, r);
	post.push_back(root);
}

void solve() {
	pos = 0;
	rec(0, pre.size());
	for(int i = 0; i < n; i++) {
		if (i)cout << " ";
		cout << post[i];
	}
	cout << endl;
}

int main() {
	int k;
	cin >> n;
	
	for (int i = 0; i < n; i++) {
		cin >> k;
		pre.push_back(k);
	}

	for (int i = 0; i < n; i++) {
		cin >> k;
		in.push_back(k);
	}

	solve();

	return 0;
}

Measured memory_bytes: 3156