akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define vi vector<int>
#define ff first
#define ss second
#define file_se_input  freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define pp long long int
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define pb push_back
#define mp make_pair
#define pi 3.141592653589793238
#define eb emplace_back
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define zip(i,a,b) for(int i=a;i<b;i++)
#define rzip(i,a,b) for(int i=a;i>=b;i--)
#define ll unsigned long long int
#define test int t;cin>>t; while(t--)
#define um unordered_map
#define en '\n'
#define us unordered_set
typedef pair<int, int>     pii;
typedef pair<char, int>    pci;
typedef pair<char, char>   pcc;
typedef vector<pii>       vii;
typedef long double ld;
#define all(v) v.begin(), v.end()
#define INF (1e18+5)
#define inf (1e9+5)
#define mod 1000000007


bool check_prime(long long n)
{
	int flag = 0;
	for (long long i = 2; i * i <= n; i++)
	{
		if (n % i == 0)
		{
			flag = 1;
			break;
		}
	}
	if (n == 1)
		return false;
	else if (flag == 0 || n == 2 || n == 3)
	{
		return true;
	}
	else
	{
		return false;
	}

}

int BE(int x, int n, int m) //function to calculate x raise to power n modulo m
{
	int result = 1;
	while (n > 0)
	{
		if (n % 2 == 1)
			result = result * x % m;
		x = x * x % m;
		n = n / 2;
	}
	return result;
}

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	if (fopen("input.txt", "r"))
	{
		freopen ("input.txt" , "r" , stdin);
		freopen ("output.txt" , "w" , stdout);
	}
#endif
	//_______________________________-code starts-_______________________________________________

	int n, k;
	cin >> n >> k;
	int a[n], b[n];
	map<int, int>m;
	zip(i, 0, n)
	{
		cin >> a[i] >> b[i];
		m[a[i]] += b[i];
	}
	for (auto itr = m.begin(); itr != m.end(); itr++)
	{
		if (itr->ss < k)
		{
			k -= itr->ss;
		}
		else
		{
			cout << itr->ff << en;
			return 0;
		}
	}



	return 0;
}



Measured memory_bytes: 9132
package main

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

func main() {
	sc := NewScanner()

	a := sc.ReadInt()
	b := sc.ReadInt()
	c := sc.ReadInt()
	k := sc.ReadInt()

	count := 0

	bBig := b
	for bBig <= a {
		bBig *= 2
		count++
	}

	cBig := c
	for cBig <= bBig {
		cBig *= 2
		count++
	}

	if count <= k {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

// from [my library](https://github.com/ikngtty/go-contestlib)
// -   math/simple

func Abs(x int) int {
	if x >= 0 {
		return x
	}
	return -x
}

func Min(values ...int) int {
	if len(values) == 0 {
		panic("no values")
	}

	min := values[0]
	for _, v := range values {
		if v < min {
			min = v
		}
	}
	return min
}

func Max(values ...int) int {
	if len(values) == 0 {
		panic("no values")
	}

	max := values[0]
	for _, v := range values {
		if v > max {
			max = v
		}
	}
	return max
}

func Pow(base, exponent int) int {
	if exponent < 0 {
		panic(fmt.Sprintf("exponent (%d) should not be a minus", exponent))
	}

	answer := 1
	for i := 0; i < exponent; i++ {
		answer *= base
	}
	return answer
}

func Ceil(divident, dividor int) int {
	if dividor == 0 {
		panic("dividor should not be 0")
	}

	quo := divident / dividor
	rem := divident % dividor

	if rem != 0 {
		if (divident > 0 && dividor > 0) ||
			(divident < 0 && dividor < 0) {
			return quo + 1
		}
	}
	return quo
}

// -   sortutil

func ReverseInts(a []int) {
	sort.Sort(sort.Reverse(sort.IntSlice(a)))
}

func ReverseStrings(a []string) {
	sort.Sort(sort.Reverse(sort.StringSlice(a)))
}

// -   io

type Scanner struct {
	bufScanner *bufio.Scanner
}

func NewScanner() *Scanner {
	bufSc := bufio.NewScanner(os.Stdin)
	bufSc.Split(bufio.ScanWords)
	bufSc.Buffer(nil, 100000000)
	return &Scanner{bufSc}
}

func (sc *Scanner) ReadString() string {
	bufSc := sc.bufScanner
	bufSc.Scan()
	return bufSc.Text()
}

func (sc *Scanner) ReadInt() int {
	bufSc := sc.bufScanner
	bufSc.Scan()
	text := bufSc.Text()

	num, err := strconv.Atoi(text)
	if err != nil {
		panic(err)
	}
	return num
}


Measured memory_bytes: 1776
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vll = vector<vl>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1e9+7;
const ll INF = 2e15;
template<class T> void print(const T& t){ cout << t << endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

int main(){
  ll a, b, c;
  cin >> a >> b >> c;
  ll num = c - a - b;
  if(num>0&&num*num>4*a*b){
    print("Yes");
  }
  else{
    print("No");
  }
}

Measured memory_bytes: 3604
#include<iostream>
#include<string>
using namespace std;
bool rev(string s){
for(int i=0;i<s.size();i++){
if(s[i]!=(s[s.size()-1-i])){
return 0;
}
}
return 1;
}
int main(){
string s;
int ans=0;
while(cin>>s){
if(rev(s)){
ans++;
}
}
cout<<ans<<endl;
return 0;
}

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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
ll max(ll a, ll b){ 
	if(a >= b) return a;
	else if(a < b) return b;
}

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

int main(){
	ll n;
	cin >> n;
	ll ans = n*800 - 200*(n/15);
	cout << ans << endl;
}

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

const ll inf = 1LL << 50;
const int MAX_N = 100100;

ll dp[MAX_N];
ll A[MAX_N],B[MAX_N];

int main(){ 
  
  int H,N; cin >> H >> N;
  
  for(int i = 0; i < N; i++){ 
    cin >> A[i] >> B[i];
  }
  
  for(int i = 0; i < MAX_N; i++){ 
    dp[i] = inf;
  }
  
  dp[0] = 0;
  
  for(int i = 0; i < N; i++){ 
    dp[A[i]] = min(dp[A[i]], B[i]);
  }
  
  
  
  for(int i = MAX_N-2; i >= 0; i--){
    
    dp[i] = min(dp[i],dp[i+1]);
    
  }
  
  // 次に更新
  

  
  for(int i = 0; i < MAX_N; i++){ 
    
    for(int j = 0; j < N; j++){ 
      if( i-A[j] >= 0){
      dp[i] = min(dp[i], dp[i-A[j]]+B[j]);
      }
    }
    
  }
  
  cout << dp[H] << endl;
  
  return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>

#define INIT_CAP 10
#define INF 1000000000

#define min(a, b) (((a) < (b)) ? (a) : (b))

const int di[4] = {-1, 0, 1, 0};
const int dj[4] = {0, 1, 0, -1};

typedef struct {
	int to, w;
} Edge;

typedef struct {
	Edge *elem;
	int cap, size;
} VecEdge;

typedef struct {
	int num;
	int d;
} PNumDis;

VecEdge adj[30 * 30 * 4];
PNumDis heap[30 * 30 * 4];
int hsize;
int d[30 * 30 * 4], idx[30 * 30 * 4];

void init(int n) {
	while (n--)
		adj[n] = (VecEdge){malloc(sizeof(Edge) * INIT_CAP), INIT_CAP, 0};
}

inline void add(int from, int to, int w) {
	if (adj[from].size == adj[from].cap) {
		adj[from].cap <<= 1;
		adj[from].elem = realloc(adj[from].elem, sizeof(Edge) * adj[from].cap);
	}
	adj[from].elem[adj[from].size++] = (Edge){to, w};
}

void freeAll(int n) {
	while (n--)
		free(adj[n].elem);
}

inline int calcNextIdx(int i) {
	return i * 2 + 1 + (i * 2 + 2 < hsize && heap[i * 2 + 1].d > heap[i * 2 + 2].d);
}

inline PNumDis delete(void) {
	int i;
	int nextIdx;
	const PNumDis root = heap[0], last = heap[--hsize];

	for (i = 0; i * 2 + 1 < hsize && last.d > heap[nextIdx = calcNextIdx(i)].d; i = nextIdx) {
		heap[i] = heap[nextIdx];
		idx[heap[i].num] = i;
	}
	heap[i] = last;
	idx[last.num] = i;

	return root;
}

inline void decreaseKey(int num, int d) {
	int i;

	for (i = idx[num]; i > 0 && d < heap[i - 1 >> 1].d; i = i - 1 >> 1) {
		heap[i] = heap[i - 1 >> 1];
		idx[heap[i].num] = i;
	}
	heap[i] = (PNumDis){num, d};
	idx[num] = i;
}

void dijkstra(int n, int s) {
	int i;

	for (i = 0; i < n; i++) {
		heap[i] = (PNumDis){i, INF};
		d[i] = INF;
		idx[i] = i;
	}
	hsize = n;

	d[s] = 0;
	decreaseKey(s, 0);
	while (hsize > 0) {
		const PNumDis fromP = delete();
		for (i = 0; i < adj[fromP.num].size; i++) {
			const Edge e = adj[fromP.num].elem[i];
			if (fromP.d + e.w < d[e.to]) {
				d[e.to] = fromP.d + e.w;
				decreaseKey(e.to, d[e.to]);
			}
		}
	}
}

int main(void) {
	int i, j, k, l;
	int w, h;

	while (scanf("%d %d", &w, &h), w) {
		int s[30][30];
		int c[4];

		for (i = 0; i < h; i++)
			for (j = 0; j < w; j++)
				scanf("%d", s[i] + j);

		for (i = 0; i < 4; i++)
			scanf("%d", c + i);

		init(h * w * 4);

		for (i = 0; i < h; i++)
			for (j = 0; j < w; j++)
				for (k = 0; k < 4; k++)
					for (l = 0; l < 4; l++) {
						int nd = k + l & 3;
						int ni = i + di[nd], nj = j + dj[nd];
						if (ni >= 0 && ni < h && nj >= 0 && nj < w)
							add(i * w * 4 + j * 4 + k, ni * w * 4 + nj * 4 + nd, l == s[i][j] ? 0 : c[l]);
					}

		dijkstra(h * w * 4, 1);

		printf("%d\n", min(d[(h - 1) * w * 4 + (w - 1) * 4 + 1], d[(h - 1) * w * 4 + (w - 1) * 4 + 2]));

		freeAll(h * w * 4);
	}

	return 0;
}

Measured memory_bytes: 1052
H,W = map(int,input().split())

s = []
bl = 0

for i in range(H):

    tmp = list(input())
    s.append(tmp)

for i in range(H):

    for j in range(W):

        if s[i][j] == "#":
            bl += 1

d = [[float("inf")] * W for i in range(H)]
d[0][0] = 1

from collections import deque
q = deque([(0,0)])

while len(q) > 0:

    now = q.popleft()
    x,y = now

    if s[x][y] == "#":
        continue

    if x != 0 and d[x-1][y] > d[x][y] + 1:
        d[x-1][y] = d[x][y] + 1
        q.append( (x-1,y) )

    if x != H-1 and d[x+1][y] > d[x][y] + 1:
        d[x+1][y] = d[x][y] + 1
        q.append( (x+1,y) )

    if y != 0 and d[x][y-1] > d[x][y] + 1:
        d[x][y-1] = d[x][y] + 1
        q.append( (x,y-1) )

    if y != W-1 and d[x][y+1] > d[x][y] + 1:
        d[x][y+1] = d[x][y] + 1
        q.append( (x,y+1) )

if d[-1][-1] == float("inf"):
    print (-1)
else:
    print (H*W - bl - d[-1][-1])
    

Measured memory_bytes: 41328
import sys
import math
import string
import fractions
import random
from operator import itemgetter
import itertools
import collections
from collections import deque
import copy
import heapq
from bisect import bisect, bisect_left, bisect_right

MOD = 10 ** 9 + 7
INF = float('inf')
input = lambda: sys.stdin.readline().strip()

sys.setrecursionlimit(10 ** 8)


def func(a, b):
    return a + b


class SegmentTree:
    """
    各ノードが半開区間に対応した完全二分木。
    子は親を半分にした区間を持つ。
    構築O(n), 区間に対する操作O(logn), 値の更新O(logn)
    区間に対する操作は最小値, 最大値, 区間に対する和など柔軟に変更して用いよう！
    """

    def __init__(self, x, init_val):  # 構築, init_valは配列の初期値(最小値のクエリならINF, 和なら0)
        self.init_val = init_val
        self.length = 2 ** ((len(x) - 1).bit_length())
        self.data = [init_val] * (2 + 1) * self.length
        for i in range(len(x)):
            self.data[i + self.length - 1] = x[i]
        for i in range(self.length - 2, -1, -1):
            self.data[i] = func(self.data[2 * i + 1], self.data[2 * i + 2])

    def teach_current_val(self, index):
        return self.data[index + self.length - 1]

    def replace(self, index, val):  # indexの値をvalに更新
        index += self.length - 1
        self.data[index] = val
        while index:
            index = (index - 1) // 2
            self.data[index] = func(self.data[2 * index + 1], self.data[2 * index + 2])

    def query(self, left, right):  # 半開区間の最小値等を求める, 葉からさかのぼっていくイメージ。
        if right <= left:
            return self.init_val
        left += self.length - 1  # self.dataの位置に合わせる。
        right += self.length - 2  # self.dataの位置に合わせる。半開区間
        ans = self.init_val
        while right > left + 1:
            if left & 1 == 0:  # if left_index%2 == 0:
                ans = func(ans, self.data[left])
            if right & 1 == 1:  # if right_index%2 == 1:
                ans = func(ans, self.data[right])
                right -= 1
            left //= 2
            right = (right - 1) // 2
        if left == right:
            ans = func(ans, self.data[left])
        else:
            ans = func(func(ans, self.data[left]), self.data[right])
        return ans


N, K = map(int, input().split())
a = [0] * (N + 1)
for i in range(N):
    a[i + 1] = int(input()) - K
a = list(itertools.accumulate(a))
cc = sorted(list(dict.fromkeys(a)))
c = collections.Counter(a)
for i in range(len(a)):
    if type(c[a[i]]) == int:
        c[a[i]] = [i]
    else:
        c[a[i]].append(i)
seg = SegmentTree([0] * (N + 1), 0)
ans = 0
for i in cc:
    for l in c[i]:
        ans += seg.query(0, l)
        seg.replace(l, 1)
print(ans)

Measured memory_bytes: 118368
#include "bits/stdc++.h"
#include "math.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define drep(i,a,b) for(ll i=(a);i>=(b);--i)
#define SIZE(a) int((a).size())
#define out(a) cout<<(a)<<endl;
const int INF=INT_MAX;
const int MAX = 510000;
const ll MOD = 1000000007;
ll fac[MAX], finv[MAX], inv[MAX];

int main(){
  string s,t,ans="UNRESTORABLE";cin>>s>>t;
  rep(i,0,s.size()-t.size()+1){
    bool ok=true;
    rep(j,0,t.size()){
      if(s[i+j]=='?'||s[i+j]==t[j])continue;
      else{ok=false;}
    }
    if(ok){
      ans=s;
      rep(j,0,t.size()){
        ans[i+j]=t[j];
      }
      rep(j,0,ans.size()){
        if(ans[j]=='?')ans[j]='a';
      }
      
    }
    
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T> void assign(V<T>& v, int n, const T& a = T()) { v.assign(n, a); }
template<class T, class... U> void assign(V<T>& v, int n, const U&... u) { v.resize(n); for (auto&& i : v) assign(i, u...); }

int main() {
  cin.tie(NULL); ios::sync_with_stdio(false);
  int k, n; cin >> k >> n;
  V<> res(n);
  if (k == 1) {
    for (int i = 0; i < (n + 1) / 2; i++) res[i] = 1;
  }
  else if (k & 1) {
    auto prev = [&] {
      int p = n - 1;
      while (res[p] == 0) p--;
      if (res[p] > 1) {
        res[p]--;
        for (int i = p + 1; i < n; i++) res[i] = k;
      } else {
        res[p] = 0;
      }
    };
    for (int i = 0; i < n; i++) res[i] = (k + 1) / 2;
    for (int i = 0; i < n / 2; i++) prev();
  } else {
    res[0] = k / 2;
    for (int i = 1; i < n ; i++) res[i] = k; 
  }
  for (int i = 0; i < n; i++) if (res[i]) cout << res[i] << ' ';
  cout << '\n';
}

Measured memory_bytes: 3456
#include <iostream>
#include <string>
#define ll long long
using namespace std;

int main() {
	string s, t;
	int l;
	bool flag = false;
	cin >> s >> t;
	for (int i = 0; i < s.size(); i++) {
		for (int j = 0; j < t.size() && (i + j) < s.size(); j++) {
			if (s[i + j] != t[j] && s[i + j] != '?')break;
			if (j == (t.size() - 1)) {
				flag = true;
				l = i;
			}
		}
	}
	if (flag) {
		for (int i = 0; i < s.size(); i++) {
			if (l == i) {
				for (int j = 0; j < t.size(); j++) {
					cout << t[j];
				}
				i += t.size() - 1;
			}
			else if (s[i] == '?')cout << "a";
			else cout << s[i];
		}
		cout << endl;
	}
	else {
		cout << "UNRESTORABLE" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
D, G = map(int, input().split())
PC = []
for i in range(D):
    p, c = list(map(int, input().split()))
    s = (i+1) * 100
    PC.append([p, c, s])

P = []
for i in range(2 ** D):
    b = format(i, 'b').zfill(D)
    P.append(b)

def get_high_score_q(p):
    if p.count('0') == 0:
        return None
    else:
        pos = []
        for i, pi in enumerate(p):
            if pi == '0':
                pos.append(i)
        return pos[-1]

ans = 10 ** 10
# P: ['00', '01', '10', '11']
for pi in P:
    # print('pi', pi)
    scores = 0
    probs = 0
    for i, b in enumerate(pi):
        if b == '0':
            pass
        elif b == '1':
            pc = PC[i]
            scores += pc[0] * pc[2] + pc[1]
            probs += pc[0]
        else:
            raise Exception()

    # print(scores, probs)
    if scores < G:
        q = get_high_score_q(pi)
        pc = PC[q]
        for i in range(pc[0]):
            scores += pc[2]
            probs += 1
            if scores >= G:
                break
    # print(scores, probs)
    if scores >= G:
        ans = min(ans, probs)

print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <tuple>
#include <algorithm>
using namespace std;

int main(void){
  int n, m;
  tuple<int, int, int> v[100000];
  vector<tuple<int, int, int>*> w;
  cin >> n >> m;
  for(int i = 0;i<m;i++){
    int a, b;
    cin >> a >> b;
    v[i] = make_tuple(a, b, -1);
  }
  for(int i = 0;i < m; i++){
    // cout << &v[i] << endl;
    w.push_back(&v[i]);
  }
  
  // for(auto q : w){
  //   auto a = *q;
  //   cout << get<0>(a) << " " << get<1>(a) << " " << get<2>(a) << endl;
  // }
  sort(w.begin(), w.end(), [](const tuple<int, int, int>* lhs, const tuple<int, int, int>* rhs) {
             if (get<0>(*lhs) != get<0>(*rhs)) return get<0>(*lhs) < get<0>(*rhs);
             return get<1>(*lhs) < get<1>(*rhs);
         });
  // cout << endl;
  // for(int i = 0;i < m; i++){
  //   cout << get<0>(v[i]) << " " << get<1>(v[i]) << " " << get<2>(v[i]) << endl;
  // }
  // for(auto q : w){
  //   auto a = *q;
  //   cout << get<0>(a) << " " << get<1>(a) << " " << get<2>(a) << endl;
  // }
  int prev = -1, ct = 1;
  for(auto q : w){
    // auto a = *q;
    if(prev != -1 && prev != get<0>(*q)) ct = 1;
    prev = get<0>(*q);
    *q = make_tuple(get<0>(*q),get<1>(*q),ct);
    // cout << get<2>(*q) << endl;
    // cout << get<0>(*q) << " " << get<1>(*q) << " " << get<2>(*q) << endl;
    ct++;
  }
  // cout << endl;
  for(int i = 0;i < m; i++){
    // cout << get<0>(v[i]) << " " << get<1>(v[i]) << " " << get<2>(v[i]) << endl;
    printf("%06d%06d\n", get<0>(v[i]), get<2>(v[i]));
  }
  // for(auto q : w){
  //   auto a = *q;
  //   cout << get<0>(a) << " " << get<1>(a) << " " << get<2>(a) << endl;
  // }
}

Measured memory_bytes: 3572
n=int(input())
a=[]
b=[]
for i in range(n):
    a.append(list(map(int,input().split())))
for i in range(n):
    for j in range(n):
        b.append(((a[i][0]-a[j][0])**2+(a[i][1]-a[j][1])**2)**0.5)
print((sum(b)/(len(b)-n))*(n-1))


Measured memory_bytes: 3060
# AOJ 590: One-Time Path
# Python3 2018.7.13 bal4u

INF = 0x7fffffff
import heapq
def dijkstra(V, to, start):
	dist = [INF]*V
	Q = []
	dist[start] = 0
	heapq.heappush(Q, (0, start))
	while Q:
		t, s = heapq.heappop(Q)
		if dist[s] < t: continue
		for e, cost in to[s]:
			if t <= cost and cost < dist[e]:
				dist[e] = cost
				heapq.heappush(Q, (cost, e))
	return dist

n, m = map(int, input().split())
n1 = n - 1
last = []
to = [[] for i in range(n)]
for i in range(m):
	a, b, c = map(int, input().split())
	a -= 1; b -= 1
	to[a].append((b, c))
	if b == n-1: last.append((a, c))

dist = dijkstra(n, to, 0)
if dist[n-1] >= INF: print(-1)
else:
	last.sort(key=lambda x:(-x[1]))
	for a, c in last:
		if dist[a] <= c: print(c); break



Measured memory_bytes: 43380
#include <iostream>
    #include <sstream>
    #include <iomanip>
    #include <cstdio>
    #include <cstdlib>
    #include <cmath>
    #include <cctype>
    #include <cstring>
    #include <vector>
    #include <list>
    #include <queue>
    #include <deque>
    #include <stack>
    #include <map>
    #include <set>
    #include <algorithm>
    #include <iterator>
    #include <bitset>
    #include <ctime>



    using namespace std;

    #define FOR(i,a,b) for(int i = (a); i < (b); i++)
    #define rep(i,n) FOR(i,0,n)
    #define RFOR(i,b,a) for(int i = (b) - 1; i>= (a); i--)
    #define ITER(it, a) for(typeof(a.begin()) it = a.begin(); it != a.end(); it++)
    #define FILL(a, value) memset(a, value, sizeof(a)

    #define SZ(a) (int)a.size()
    #define ALL(a) a.begin(), a.end()
    #define PB push_back
    #define MP make_pair

    typedef  long long LL;
    typedef vector<int> VI;
    typedef pair<int, int> PII;

    const double PI = acos(-1.0);
    const int INF = 1000 * 1000 * 1000 + 7;
    const LL LINF = INF * (LL)INF;

    const double EPS = 1e-7;
    const int MAX = 20 * 1000 + 47;
    const int MAS = 1e5 * 3;
    const int MOD = 1000 * 1000 * 1000 + 7;

    double DIST(double x1, double x2, double y1, double y2)
    {
        return sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1));
    }
    

    double dp[310][310][310]; 
    double zeroes[310][310][310]; 
        int main()
    {
        int n; 
        cin >> n;
        VI cnt(4); 
        rep(i, n)
        {
            int x;
            cin >> x;
            cnt[x] ++; 
        }
     //   cout << cnt[1] << " " << cnt[2] << cnt[3] << endl; 
        dp[cnt[1]][cnt[2]][cnt[3]] = 1; 
       RFOR(c, n + 1,0)
        {
           RFOR(b, n  +1,0)
            {
               RFOR(a, n + 1,0)
                {
                    if (a + b + c > n || a + b + c  ==  0 )
                    {
                        continue; 
                    }
                    double bd = (double)(n - (a + b + c)) / n;
                    double bd1 = bd / (1 - bd) + 1 ;
                    zeroes[a][b][c] += bd1 * dp[a][b][c] ; 
                    if (a != 0)
                    {
                        double x = (double)a / (a + b + c);
                        dp[a - 1][b][c] += dp[a][b][c] * x;
                        zeroes[a - 1][b][c] += zeroes[a][b][c] * x; 
                         
                    }
                    if (b != 0)
                    {
                        double x = (double)b / (a + b + c);
                        dp[a + 1][b-1][c] += dp[a][b][c] * x;
                        zeroes[a + 1][b- 1][c] += zeroes[a][b][c] * x;

                    }
                    if (c != 0)
                    {
                        double x = (double)c / (a + b + c);
                        dp[a ][b+1][c-1] += dp[a][b][c] * x;
                        zeroes[a ][b + 1][c -1] += zeroes[a][b][c] * x;

                    }
                }
            }
        }
        cout << fixed << setprecision(10) << zeroes[0][0][0];



    }










Measured memory_bytes: 452736
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;

typedef long long ll;
typedef vector<ll> vll;

const double PI=acos(-1.0);

int N; vll A;
void input()
{
    cin>>N;
    for(int i=0;i<N;++i){
        ll a; cin>>a; A.emplace_back(a);
    }
}

ll gcd(ll a, ll b)
{
    ll c=a%b;
    while(c!=0){
        a=b; b=c; c=a%b;
    }
    return b;
}

void solve()
{
    ll ans=gcd(A[0],A[1]);
    for(int i=2;i<N;++i){
        ans=gcd(ans,A[i]);
        if(ans==1) break;
    }
    cout<<ans<<endl;
}

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

Measured memory_bytes: 4248
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int n,i,j,now,nt[200010][26],f[200010];
char s[200010];
int main(){
	scanf("%s",s+1);
	n=strlen(s+1);
	f[n+1]=1;f[n+2]=0;
	for(i=0;i<26;i++)nt[n+1][i]=n+1;
	for(i=n;i;i--){
		for(j=0;j<26;j++)nt[i][j]=nt[i+1][j];
		nt[i][s[i]-'a']=i;
		f[i]=n+1;
		for(j=0;j<26;j++)f[i]=min(f[i],f[nt[i][j]+1]+1);
		//printf("%d %d\n",i,f[i]);
	}
	now=f[1];i=1;
	while(now--){
		for(j=0;j<26;j++)if(f[nt[i][j]+1]+1==f[i]){
			printf("%c",j+'a');i=nt[i][j]+1;break;
		}
	}
}

Measured memory_bytes: 21504
#include<iostream>
#include<map>
#include<vector>
#include<climits>
#include<algorithm>
using namespace std;

int main(){
    int N,M;
    cin >> N >> M;
    vector<int> H;
    map<int,vector<int>> mp;
    while(N!=0){
	int temp;
	cin >> temp;
	H.push_back(temp);
	N--;
    }
    while(M!=0){
	int key,val;
	cin >> key >> val;
	mp[key-1].push_back(val-1);
	mp[val-1].push_back(key-1);
	M--;
    }
    int res = 0;
    for(int i =0; i<H.size();i++){
	vector<int> link = mp[i];
	int mx = INT_MIN;
	for(auto x:link){
	    if(x!= i) mx = max(H[x],mx);
	}
	if(mx < H[i]) res++;
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 14300
#!/usr/bin/env python


def plse1(s, i):
    if i == 0:
        return s
    m = max(s[:i])
    if s[i] > m:
        s = plse1(s, i - 1)
        s[i] = 0
    else:
        s[i] += 1
    return s


n = int(input())
ss = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j']

s = [0] * n
while True:
    string = ''
    for i in range(n):
        string += ss[s[i]]
    print(string)
    s = plse1(s, n - 1)
    if s == [0] * n:
        break


Measured memory_bytes: 4340
#[allow(unused_imports)]
use std::char::*;
#[allow(unused_imports)]
use std::cmp::*;
use std::io::*;
use std::str::FromStr;
#[allow(unused_imports)]
use std::collections::*;

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

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")
}

#[derive(PartialEq, PartialOrd)]
pub struct Total<T>(pub T);

impl<T: PartialEq> Eq for Total<T> {}

impl<T: PartialOrd> Ord for Total<T> {
    fn cmp(&self, other: &Total<T>) -> std::cmp::Ordering {
        self.0.partial_cmp(&other.0).unwrap()
    }
}

#[allow(dead_code)]
const MAX:usize = 100006;
#[allow(dead_code)]
const INF_U32:u32 = 1 << 31;
#[allow(dead_code)]
const INF_I32:i32 = 1 << 30;
#[allow(dead_code)]
const INF_U64:u64 = 1 << 63;
#[allow(dead_code)]
const INF_I64:i64 = 1 << 62;


fn main() {
    let h:i32 = read();
    let w:i32 = read();
    let mut s:Vec<Vec<char>> = Vec::new();

    for _ in 0..h {
        let t:Vec<char> = read::<String>().chars().collect();
        s.push(t);
    }

    let dx:Vec<i32> = vec![0,1,0,-1];
    let dy:Vec<i32> = vec![-1,0,1,0];
    for i in 0..h {
        for j in 0..w {
            //debug!(i,j, s[i as usize][j as usize]);
            if s[i as usize][j as usize] == '.' {continue;}
            let mut f:bool = false;
            for k in 0..4 {
                let ny = i as i32 + dy[k as usize];
                let nx = j as i32 + dx[k as usize];
                //debug!(ny,nx);
                if nx < 0 || nx >= w || ny < 0 || ny >= h {
                    continue;
                }
                if s[ny as usize][nx as usize] == '#' { f = true; }
            }
            if !f {
                println!("No");
                return ();
            }
        }
    }

    println!("Yes");

}


Measured memory_bytes: 4352
#include <stdio.h>
#include <string.h>
#include <math.h>
int main(void){
    
    char s[101];
    int k;
    int j;
    long long ans=0;
    int min=0;
    int p=0;
    
    scanf("%s", s);
    scanf("%d", &k);
    
    for(int i=0; i<101; i++){
        
        if(s[i+1]=='\0'){
            
            j = i;
            p = 1;
            // printf("q"); // debug
            break;
            
        }
        
        if(s[i+2]=='\0'){
            
            j = i + 1;
            break;
            
        }
        
        if(s[i]==s[i+1]){
            
            ans += 1;
            i += 1;
            
        }
        
    }
    
    if(s[j-1]==s[j]&&p==0){
        
        ans += 1;
        
    } else if(s[j]==s[0]){
        
        ans += 1;
        min = 1;
        
        for(int q=0; q<=j; q++){
            
            if(s[q]!=s[q+1]){
                
                if(q%2==1){
                    
                    ans -= 1;
                    min -= 1;
                    
                }
                
                break;
                
            }
            
        }
        
    }
    
    ans *= k;
    ans -= min;
    
    if(j==0){
        
        ans = k / 2;
        
    } else if(j%2==0){
        
        for(int p=0; p<=j; p++){
            
            if(s[p]!=s[p+1]){
                
                break;
                
            }
            
            if(p>=j-1){
                
                ans = j + 1;
                ans *= k;
                ans /= 2;
                
            }
            
        }
        
    }
    
    printf("%lld", ans);
    
    return 0;
    
}

Measured memory_bytes: 128
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <cctype>
#include <algorithm>
#include <string>
using  namespace  std;
int main()
{
    long long int ar[12];
    for(int i=0;i<10;i++)
        cin>>ar[i];
    sort(ar,ar+10);
    cout<<ar[9]<<'\n'<<ar[8]<<'\n'<<ar[7]<<'\n';
    return 0;
}

Measured memory_bytes: 1172
#define _USE_MATH_DEFINES

#include "bits/stdc++.h"
using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<int, int> pii;
typedef vector<pii> vpii;

#define LL long long

 
 int main(){
 	int N, A[100000], count = 0;
 	cin >> N;
 	for(int i = 0; i < N; i++){
 		cin >> A[i];
 		count += A[i] % 2;
 	}
 	if(count % 2 == 0) cout << "YES" << endl;
 	else cout << "NO" << endl;
 }

Measured memory_bytes: 768
from collections import Counter
n = int(input())
a = list(map(int,input().split()))
b = []
for i, j in Counter(a).most_common():
	if j == 1:
		b.append(i)
aset = set(a)

dp = [0 for _ in range(10**6+1)]
for i in list(aset):
	for j in range(i*2, 10**6+1, i):
		dp[j] += 1

ans = 0
for i in b:
	if dp[i] == 0:
		ans += 1
print(ans)

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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int INF = 100000000;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int main(){
  string s,t;
  cin >> s >> t;
  reverse(s.begin(),s.end());
  reverse(t.begin(),t.end());
  //cout << s << endl << t << endl;
  int ans = INF;
  rep(i,s.size()-t.size()+1){
    string S=s.substr(i,t.size());
    //cout << S << endl;
    bool X = true;
    rep(j,t.size()){
      if(S[j]=='?') continue;
      if(S[j]!=t[j]) X = false;
    }
    if(X){
      ans = i;
      //cout <<  "i:" << i << "ans" << ans << endl;
      break;
    }
  }
  //cout <<  "ans:" <<  ans << endl;
  if(ans==INF) cout << "UNRESTORABLE" << endl;
  else{
    rep(i,t.size()){
      s[ans+i] = t[i];
    }
    for(int i=s.size()-1;i>=0;i--){
      if(s[i]=='?')  s[i] = 'a';
      cout << s[i];
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b)for(int i=(a);i<=(b);i++)
#define repR(i,n) for(int i=n;i>=0;i--)
#define P pair<int, int>
#define sz(x) x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<int>
#define COUT(x) cout<<(x)<<endl
#define MA map<int,int>
#define SE set<int>
#define PQ priority_queue<int>
#define PQR priority_queue<int,VE,greater<int>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl

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

using namespace std;
typedef long long ll;
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
bool compare_by_b(pair<int, int> a, pair<int, int> b) {
	if (a.second != b.second) {
		return a.second < b.second;
	}
	else {
		return a.first < b.first;
	}
}

const long long MOD = 1000000007;
const long long INF = 1LL << 50;
// pair -> vector<pair<int,int>> 
//		   AandB.push_back(make_pair(a[i],b[i]))

bool G[10][10];

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n, m; cin >> n >> m;
	rep(i, m) {
		int a, b; cin >> a >> b; a--; b--;
		G[a][b] = G[b][a] = true;
	}
	VE ord(n);
	rep(i, n)ord[i] = i;
	int res = 0;
	do {
		if (ord[0] != 0)break;
		bool ok = true;
		for (int i = 0; i + 1 < n; i++) {
			int from = ord[i];
			int to = ord[i + 1];
			if (!G[from][to])ok = false;
		}
		if (ok)res++;
	} while (next_permutation(ALL(ord)));
	COUT(res);
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
int n,a[200010];
ll x,y,ans=1000000000000000000ll;
ll Abs(ll x){
	return x<0 ? (-x) : x;
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;++i){
		scanf("%d",&a[i]);
		y+=(ll)a[i];
	}
	for(int i=1;i<n;++i){
		y-=(ll)a[i];
		x+=(ll)a[i];
		ans=min(ans,Abs(y-x));
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 896
#include <stdio.h>

int main(void)
{
	int a, b, c;
	int x, y = 0;

	scanf("%d%d%d", &a, &b, &c);

	for (x = a;x <= b;x++)
	{
		if (c%x == 0)
		{
			y++;
		}
	}
	printf("%d\n", y);

	return 0;
}


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

int main (){
    int i=1,k;
    char vet[16], a[4]={'A','C','L'};
    scanf("%d", &k);

    strcpy(vet, "ACL");

    while(i != k ){
        strcat(vet,a);
        k--;
    }
    printf("%s\n", vet);
    return 0;
}

Measured memory_bytes: 1664
#include <iostream>
#include <string>

int main(void) {
	// input
	std::string s;
	std::cin >> s;

	// to integer
	int i1, i2;
	i1 = (s[0] - '0') * 10 + (s[1] - '0');
	i2 = (s[2] - '0') * 10 + (s[3] - '0');

	bool is_i1_mm = false, is_i2_mm = false;
	if(i1 <= 12 && i1 >= 1) is_i1_mm = true;
	if(i2 <= 12 && i2 >= 1) is_i2_mm = true;

	// out
	std::string s_out;
	if(is_i1_mm && is_i2_mm) s_out = "AMBIGUOUS";
	else if(is_i1_mm && !is_i2_mm) s_out = "MMYY";
	else if(!is_i1_mm && is_i2_mm) s_out = "YYMM";
	else if(!is_i1_mm && !is_i2_mm) s_out = "NA";
	
	std::cout << s_out << std::endl;
	
	return 0;
}


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

int main() {
  int m, k;
  cin >> m >> k;

  if (k >= (1 << m)) {
    cout << -1 << endl;
    return 0;
  }
  if (m < 2 && k != 0) {
    cout << -1 << endl;
    return 0;
  }

  vector<int> r;
  if (k == 0) {
    for (int i = 0; i < (1 << m); i++) {
      r.push_back(i);
      r.push_back(i);
    }
  } else {
    for (int i = 0; i < (1 << m); i++) {
      if (i != k) r.push_back(i);
    }
    r.push_back(k);
    for (int i = (1 << m) - 1; i >= 0; i--) {
      if (i != k) r.push_back(i);
    }
    r.push_back(k);
  }

  for (auto e : r) cout << e << " ";
  cout << endl;
}


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

int main(){
    string s;
    cin >> s;
    int cnt = 0;
    rep(i, s.size()){
        if(s[i] == 'o') cnt++;
    }
    cout << 700+100*cnt << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1LL << 60;

int main() {
    int n; cin >> n;
    vector<int> x(n);
    vector<int> copy(n);
    for (int i = 0; i < n; i++) {
        scanf("%d", &x[i]);
    }
    
    for (int i = 0; i < n; i++) {
        copy[i] = x[i];
    }
    sort(copy.begin(), copy.end());
    int left = copy[n / 2 - 1];
    int right = copy[n / 2];
    
    for (int i = 0; i < n; i++) {
        if (x[i] <= left) {
            printf("%d\n", right);
        } else {
            printf("%d\n", left);
        }
    }
    return 0;
}

Measured memory_bytes: 3712
let split str delim =
  let rec doit s acc =
    match
      try Some (String.rindex s delim) with _ -> None
    with
    | None -> s :: acc
    | Some i ->
        let s1 = String.sub s 0 i in
        let s2 = String.sub s (i + 1) (String.length s - String.length s1 - 1) in
        doit s1 (s2 :: acc)
  in
  doit str []

let () =
  match List.map int_of_string (split (read_line ()) ' ') with
  | [n; k] -> begin
      let a = Array.init n (fun _ -> read_int ()) in
      let check p =
        let rec doit i j s =
          if i = n then n
          else if j >= k then i
          else
            let x = s + a.(i) in
            if x > p then doit i (j + 1) 0
            else doit (i + 1) j x
        in
        doit 0 0 0
      in
      let rec bin_search l r =
        if r < l then l
        else
          let m = (l + r) / 2 in
          if check m >= n then bin_search l (m - 1)
          else bin_search (m + 1) r
      in
      Printf.printf "%d\n" (bin_search 0 (100000 * 10000))
    end
  | _ -> exit 1

Measured memory_bytes: 5216
#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>;

const int HALF = 512;
const int MAX = 100000 + 1000;
vector<vector<int>> dp(HALF+1, vector<int>(MAX));
vector<int> V;
vector<int> W;

// 全探索する
// n:対象ノード,w:残りの重み,v:現在の価値
int dfs(int n, int w, int v){
    if(w < 0) return -1;
    if(n <= HALF) return dp[n][w] + v;
    int nw = W[n-1];
    int nv = V[n-1];
    int use = dfs(n/2, w-nw, v+nv);
    int notuse = dfs(n/2, w, v);
    return max(use, notuse);
}


int main(){
    int N;
    cin >> N;
    
    rep(i, N){
        int v, w;
        cin >> v >> w;
        V.push_back(v);
        W.push_back(w);
    }
    
    // 512個のノードまでナップザックDP
    for(int i = 1;i <= min(HALF, N);i++){
        int v, w;
        v = V[i-1], w = W[i-1];
        for(int j = 1;j < MAX;j++){
            dp[i][j] = dp[i/2][j];
            if(j-w < 0) continue;
            dp[i][j] = max(dp[i][j], dp[i/2][j-w] + v);
        }
    }
    int Q;
    cin >> Q;
    for(int i = 0;i < Q;i++){
        int ans, v, L;
        cin >> v >> L;
        ans = dfs(v, L, 0);
        cout << ans << endl;
    }
    return 0;
}



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

int main() {
    char c[3][3];

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

    cout << c[0][0] << c[1][1] << c[2][2];
    return 0;
}


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

#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define RFOR(i, a, b) for (int i = (b)-1; i >= int(a); --i)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, int(n) + 1)
#define RREP(i, n) RFOR(i, 0, n)
#define RREP1(i, n) RFOR(i, 1, int(n) + 1)
#define ALL(c) begin(c), end(c)

int _ = (
#ifndef LOCAL
    std::cin.tie(nullptr), std::ios::sync_with_stdio(false),
#endif
    std::cout.precision(10), std::cout.setf(std::ios::fixed));

using ll = long long;
using ull = unsigned long long;
using ld = long double;
template <typename T> using vec = std::vector<T>;
using namespace std;

int main() {
  ll N;
  cin >> N;
  unordered_map<ll, ll> m;
  REP(i, N) {
    ll D;
    cin >> D;
    m[D]++;
  }
  ll M;
  cin >> M;
  REP(i, M) {
    ll T;
    cin >> T;
    m[T]--;
  }
  cout << (all_of(ALL(m), [](const auto &p) { return p.second >= 0; }) ? "YES"
                                                                       : "NO")
       << endl;
  return 0;
}


Measured memory_bytes: 11376
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
mod2 = 998244353
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


class Prime():
    def __init__(self, n):
        self.M = m = int(math.sqrt(n)) + 10
        self.A = a = [True] * m
        a[0] = a[1] = False
        self.T = t = [2]
        for j in range(4, m, 2):
            a[j] = False
        for i in range(3, m, 2):
            if not a[i]:
                continue
            t.append(i)
            for j in range(i*i,m,i):
                a[j] = False
        self.ds_memo = {}
        self.ds_memo[1] = set([1])

    def is_prime(self, n):
        return self.A[n]

    def division(self, n):
        d = collections.defaultdict(int)
        for c in self.T:
            while n % c == 0:
                d[c] += 1
                n //= c
            if n < 2:
                break
        if n > 1:
            d[n] += 1
        return d

    # memo
    def divisions(self, n):
        if n in self.ds_memo:
            return self.ds_memo[n]

        for c in self.T:
            if n % c == 0:
                rs = set([c])
                for cc in self.divisions(n // c):
                    rs.add(cc)
                    rs.add(cc * c)
                self.ds_memo[n] = rs
                return rs

        rs = set([1, n])
        self.ds_memo[n] = rs
        return rs

    def sowa(self, n):
        r = 1
        for k,v in self.division(n):
            t = 1
            for i in range(1,v+1):
                t += math.pow(k, i)
            r *= t
        return r


def main():
    n = I()
    pr = Prime(n)
    d = pr.division(n)
    r = 0
    for c in d.values():
        for i in range(1,1000):
            if c < i:
                break
            r += 1
            c -= i

    return r

print(main())





Measured memory_bytes: 21824
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef vector<int> vi;
typedef pair<int, int> pi;
#define SQ(a) (a) * (a)
#define mod 1000000007
#define w(x) int x; cin>>x; while(x--)
#define deb(x) cout << #x << " = " << x << '\n'
#define deb2(x, y) cout << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")\n"
 
void solve(){
    string s,t;
    cin>>s;
    cin>>t;
    int mx=0;
    for(int i=0;i<s.length()-t.length()+1;i++){
        int count=0;
        for(int j=0;j<t.length();j++){
            if(s[i+j]==t[j]){
                count++;
            }
            
        }
        mx=max(count,mx);
    }
    cout<<t.length()-mx;
}
 
int main(int argc, char const *argv[])
{
 
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
 
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    solve();
    return 0;
}

Measured memory_bytes: 3644
// #pragma GCC optimize ("Ofast,unroll-loops")
// #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#define pb push_back
#define ff  first
#define ss second
#define tm1 first
#define tm2 second.first
#define tm3 second.second
#define sz(x) ll(x.size())
#define fill(x, v) memset(x, v, sizeof(x))
#define all(v) (v).begin(), (v).end()
#define FER(i,a,b) for(ll i=ll(a); i< ll(b); ++i)
#define IFR(i,a,b) for(ll i=ll(a); i>=ll(b); --i )
#define fastio ios_base::sync_with_stdio(0); cin.tie(0)
#define bas 987625403
#define sqr(x) (x)*(x)  
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef pair<ll, ll> ii;
typedef pair<ll, ii > tri;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> set_t;
#define trace(...) f(#__VA_ARGS__, __VA_ARGS__)
template<typename t> void f(const char* x, t&& val1){
    cout<<x<< " : "<<val1<<endl;
}
template<typename t1, typename... t2> void f(const char* x, t1&& val1, t2&&... val2){
    const char* xd=strchr(x+1, ',');
    cout.write(x, xd-x)<<" : "<<val1<<" | ";
    f(xd+1, val2...);
}

int main(){

	fastio;
	string cad;
	cin >> cad;
	reverse(cad.begin(),cad.end());
	ll w = 0, ans = 0;
	for(char c : cad){
		if(c == 'W') w++;
		else ans += w;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 720
a = []
for i in range(6):
    a.append(int(input()))
    
flag = True

for i in range(4):
    for j in range(i+1,5):
        if abs(a[i]-a[j]) > a[5]:
            flag = False
            break
if flag == True:
    print("Yay!")
else:
    print(":(")






Measured memory_bytes: 2940
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<numeric>
#include<map>


#define REP(i, n) for(int i = 0;i < n;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 FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

typedef long long int ll;


int main(){

    int n;
    cin >> n;
    vector<int> a(n);
    REP(i,n){
        cin >> a[i];
    }

    map<int,int> odd,even;

    REP(i,n){
        if(i % 2 == 0){
            even[a[i]]++;
        }else{
            odd[a[i]]++;
        }
    }

    int odd_maxi = 0,odd_maxi_num,odd_second_maxi = 0,odd_second_maxi_num = 0;
    int even_maxi = 0,even_maxi_num,even_second_maxi = 0,even_second_maxi_num = 0;

    for(auto itr:odd){
        if(odd_maxi < itr.second){
            odd_maxi = itr.second;
            odd_maxi_num = itr.first;
        }
    }

    for(auto itr:even){
        if(even_maxi < itr.second){
            even_maxi = itr.second;
            even_maxi_num = itr.first;
        }
    }
    for(auto itr:odd){
        if(odd_second_maxi < itr.second && itr.first != odd_maxi_num){
            odd_second_maxi = itr.second;
            odd_second_maxi_num = itr.first;
        }
    }
    for(auto itr:even){
        if(even_second_maxi < itr.second && itr.first != even_maxi_num){
            even_second_maxi = itr.second;
            even_second_maxi_num = itr.first;
        }
    }

    int ans = 0;
    

    if(odd_maxi_num != even_maxi_num){
        ans = n/2-odd_maxi + n/2-even_maxi;
    }else{
        int tmp = n/2-odd_maxi + n/2-even_second_maxi;
        int tmp2 = n/2-odd_second_maxi + n/2-even_maxi;
        ans = min(tmp,tmp2);
    }
    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 5376
#include <stdio.h>

int main(void){
    int counter = 0;
    char a[4], b[4];
    scanf("%s %s", a, b);
    if (a[0] == b[0]){
        counter++;
    }
    if (a[1] == b[1]){
        counter++;
    }
    if (a[2] == b[2]){
        counter++;
    }
    printf("%i\n", counter);
}

Measured memory_bytes: 128