akhauriyash/Code-Regression huggingface dataset:
/*---------------------------------

 @Author:   Dicer
 @DateTime: 2019-05-15 10:45:30

---------------------------------*/

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
inline ll qpow(ll a,ll b,ll mod){ll res=1;while(b){if(b&1)res = (res*a)%mod;a=(a*a)%mod;b>>=1;}return res;}
const double eps = 1e-8;
const int INF = 0x3f3f3f3f;
const int mod = 998244353;
const int MAXN = 2e5 + 7;

int main(int argc, char const *argv[])
{
	char b;
	cin >> b;
	if(b == 'A')	cout << 'T' << endl;	
	if(b == 'G')	cout << 'C' << endl;	
	if(b == 'C')	cout << 'G' << endl;	
	if(b == 'T')	cout << 'A' << endl;	
	return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
p = []
s = []
for i in range(m):
  p_i, s_i = input().split()
  p.append(int(p_i))
  s.append(s_i)

list_correct = [0] * n
list_pena = [0] * n
for i in range(m):
  if s[i] == "AC":
    if list_correct[p[i]-1] == 0:
      list_correct[p[i]-1] = 1
  else:
    if list_correct[p[i]-1] == 0:
      list_pena[p[i]-1] = list_pena[p[i]-1] + 1
      
sum_correct = sum(list_correct)
combined = [x * y for (x, y) in zip(list_correct, list_pena)]
sum_pena = sum(combined)

print (sum_correct, sum_pena)

Measured memory_bytes: 15688
import math

# N本の木, 自分の木から左右D本の木を監視できる, 全部で2D+1本の木を監視できる
N, D = map(int, input().split())

# 1人が監視できる本数
n = (2 * D) + 1

# 切り上げた数が答えになる
ans = math.ceil(N / n)
print(ans)

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

namespace CSharpSample01
{
    
    class Program
    {

        

        static void Main(string[] args) 
        {
            int N = int.Parse(Console.ReadLine());
            long[] data = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();

            long ans = 0;
            var dic = new Dictionary<long, int>();
            for(int i = 0; i < N; i++)
            {
                long u = data[i];

                if (!dic.ContainsKey(u)) dic[u] = 1;
                else dic[u]++;

            }

            foreach(var s in dic)
            {
                long key = s.Key;
                int cnt = s.Value;
                if (key == cnt)
                {
                    continue;
                }
                else if (key < cnt)
                {
                    ans += cnt - key;
                }
                else
                {
                    ans += cnt;
                }

            }

            Console.WriteLine(ans);

        }
    }
}


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

#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#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 LL INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL)INF;

const int MAX = 100100;

int A[MAX];

int main()
{
	//freopen("in.txt", "r", stdin);
	//ios::sync_with_stdio(false); cin.tie(0);

	int n;
	scanf("%d", &n);
	FOR (i, 0, n)
	{
		scanf("%d", &A[i]);
	}

	LL L = 2, R = 2;
	RFOR(i, n, 0)
	{
		L = (L + A[i] - 1) / A[i] * A[i];
		R = R / A[i] * A[i];

		if (L > R)
		{
			cout<<-1<<endl;
			return 0;
		}
		R += A[i] - 1;

	}

	cout<<L<<' '<<R<<endl;
}


Measured memory_bytes: 640
def gcd(x, y):
    while y > 0:
        x, y = y, x%y
    return x

n, m = map(int, input().split())
S = input()
T = input()
L = (n*m) // gcd(n, m)
c = 0

xs = L//n
xt = L//m
step = xs * xt

for i in range(0, L, step):
    if S[i//xs] != T[i//xt]:
        print(-1)
        exit()
print(L)




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

int main()
{
    string s;
    int n;
    cin >> n;
    getline(cin, s);
    cin >> s;
    int ans = 0;
    for( int i = 0; i + 2 < n; i++ )
    {
        if( s.substr(i, 3) == "ABC" ) ans++;
    }
    cout << ans;
}

Measured memory_bytes: 3632
def garden(fw):
    if len(fw) == 0:
        return 0
    if len(fw) == 1:
        return fw[0]
    else:
        fwmin = min(fw)
        fwmin_idx = fw.index(fwmin)
        fwl = [x - fwmin for x in fw[:fwmin_idx]]
        fwr = [x - fwmin for x in fw[fwmin_idx + 1:]]
        return garden(fwl) + fwmin + garden(fwr)

N = int(input())
h = [int(x) for x in input().split()]
print(garden(h))

Measured memory_bytes: 3064
#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<ld, ld> pdd;
const ll MOD = 1e9+7;
const ll MOD2 = 998244353;
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const string alpha = "abcdefghijklmnopqrstuvwxyz";

int main(){
    string s;
    cin >> s;
    int ans = 0;
    rep(i, s.size()){
        ans += s[i]-'0';
    }
    if(ans == 1) ans = 10;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
       
using namespace std;
typedef long long ll;
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 (b<a) { a=b; return 1; } return 0; }

int main() {
  int N;
  ll K;
  cin >> N >> K;
  vector<ll> A;

  int nZero = 0;
  for (int i = 0; i < (int)N; ++i) {
    ll e;
    cin >> e;
    if (e == 0) {
      ++nZero;
    } else {
      A.push_back(e);
    }
  }
  sort((A).begin(), (A).end());

  int M = A.size();

  function<ll(ll)> pairLTE = [&](ll m) {
    ll res = 0;
    int zeroI = distance(A.begin(), lower_bound((A).begin(), (A).end(), 0));
    if (m < 0) {
      int r = zeroI;
      for (int i = 0; i < (int)zeroI; ++i) {
        while (r < M && A[i] * A[r] > m) ++r;
        res += M - r;
      }
    } else {
      for (int l = zeroI, r = M - 1; l < M; ++l) {
        while (r > l && A[l] * A[r] > m) --r;
        if (r >= l) res += r - l;
      }
      for (int r = zeroI - 1, l = 0; r >= 0; --r) {
        while (r > l && A[l] * A[r] > m) ++l;
        if (r >= l) res += r - l;
      }
      res += ll(M) * nZero + ll(nZero) * (nZero - 1) / 2 + pairLTE(-1LL);
    }
    return res;
  };

  ll l = -1e18 - 1, r = 1e18;
  while (r - l > 1) {
    ll m = (l + r) / 2;
    if (pairLTE(m) < K) {
      l = m;
    } else {
      r = m;
    }
  }
  cout << r << endl;

  return 0;
}


Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
#define REP(i, n) for(ll (i) = 0; (i) < (n); (i)++)
#define REPR(i, n) for(ll (i) = (n); (i) >= 0; (i)--)
#define FOR(i, m, n) for(ll (i) = (m); (i) < (n); (i)++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()
#define _GLIBCXX_DEBUG

template <uint MD> struct ModInt {
    using M = ModInt;
    const static M G;
    uint v;
    ModInt(ll _v = 0) { set_v(uint(_v % MD + MD)); }
    M& set_v(uint _v) {
        v = (_v < MD) ? _v : _v - MD;
        return *this;
    }
    explicit operator bool() const { return v != 0; }
    M operator-() const { return M() - *this; }
    M operator+(const M& r) const { return M().set_v(v + r.v); }
    M operator-(const M& r) const { return M().set_v(v + MD - r.v); }
    M operator*(const M& r) const { return M().set_v(uint(ull(v) * r.v % MD)); }
    M operator/(const M& r) const { return *this * r.inv(); }
    M& operator+=(const M& r) { return *this = *this + r; }
    M& operator-=(const M& r) { return *this = *this - r; }
    M& operator*=(const M& r) { return *this = *this * r; }
    M& operator/=(const M& r) { return *this = *this / r; }
    bool operator==(const M& r) const { return v == r.v; }
    M pow(ll n) const {
        M x = *this, r = 1;
        while (n) {
            if (n & 1) r *= x;
            x *= x;
            n >>= 1;
        }
        return r;
    }
    M inv() const { return pow(MD - 2); }
    friend ostream& operator<<(ostream& os, const M& r) { return os << r.v; }
};
using Mint = ModInt<1000000007>;

const double PI = 3.14159265358979323846;

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

ll gcd(ll a, ll b) {
    return b != 0 ? gcd(b, a % b) : a;
}

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

int main()
{	
    int a[5];
    cin >> a[0] >> a[1] >> a[2] >> a[3] >> a[4];
    REP(i, 5){
        if(a[i] == 0) cout << i+1 << endl;
    }
}


Measured memory_bytes: 3628
# coding: utf-8
INF = 10 ** 20
MOD = 10 ** 9 + 7


def II(): return int(input())
def ILI(): return list(map(int, input().split()))


def read():
    H, W = ILI()
    N = II()
    a = ILI()
    return H, W, N, a


def solve(H, W, N, a):
    ans = [[None] * W for __ in range(H)] # [H][W]
    ind_a = 0
    a_count = 0
    color_a = list(range(1, N + 1))
    for h in range(H):
        if h % 2 == 0:
            for w in range(W):
                ans[h][w] = color_a[ind_a]
                a_count += 1
                if a_count == a[ind_a]:
                    ind_a += 1
                    a_count = 0
        else:
            for w in reversed(range(W)):
                ans[h][w] = color_a[ind_a]
                a_count += 1
                if a_count == a[ind_a]:
                    ind_a += 1
                    a_count = 0

    ans = [" ".join(map(str, ele)) for ele in ans]
    ans = "\n".join(ans)
    return ans


def main():
    params = read()
    print(solve(*params))


if __name__ == "__main__":
    main()


Measured memory_bytes: 3572
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BinaryHeap, HashMap};

#[allow(dead_code)]
type Graph = Vec<Vec<usize>>;

fn xor(a: usize) -> usize {
    if a & 1 == 0 {
        a ^ ((a / 2) % 2)
    } else {
        ((a + 1) / 2) % 2
    }
}

fn main() {
    input! {
        a: usize, b: usize,
    }
    println!("{}", xor(a - 1) ^ xor(b));
}


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

int main(void){
    int n;
    cin >> n;
    int a[n], b[n];
    ll ans = 0;

    rep(i, n + 1){
        cin >> a[i];
    }
    rep(i, n){
        cin >> b[i];
    }

    rep(i, n){
        ans += min(a[i], b[i]) + min(a[i+1], b[i] - min(a[i], b[i]));
        a[i+1] -= min(a[i+1], b[i] - min(a[i], b[i]));
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
K=int(input())
# a=int(input())
A,B=map(int,input().split(" "))
#a=[int(_) for _ in input().split(" ")]

ans="NG"
a=B-A

for i in range(A,B+1):
  #print(i)
  if i % K == 0:
    ans="OK"
    break

#print(a,b)
print(ans)

Measured memory_bytes: 9176
# ==================================================== #
# -*- coding: utf-8 -*
n, k = map(int, input().split())

arr = []
for i in range(n):
    a, b = map(int, input().split())
    arr.append((a, b))
arr = list(sorted(arr))

for i in range(n):
    k -= arr[i][1]
    if k <= 0:
        print(arr[i][0])
        break

Measured memory_bytes: 54744
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)

	N := nextInt()

	var as []int
	for i := 0; i < N; i++ {
		as = append(as, nextInt())
	}

	sort.Ints(as)

	alice := 0
	bob := 0
	t := 0
	for i := N-1; i >= 0; i-- {
		if t % 2 == 0 {
			alice += as[i]
		} else {
			bob += as[i]
		}
		t++
	}

	fmt.Println(alice - bob)
}

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

using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for (ll i = (ll)(n) - 1; i >= 0; i--)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1LL << 62)

#define PI (acos(-1))
#define print(x) cout << x << endl
 
ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll countDigit(ll n) { return floor(log10(n) + 1); } 
typedef pair <ll,ll> P;
static const ll dy[4] = {0,1,0,-1}, dx[4] = {1,0,-1,0};

template <typename T> 
ostream& operator<<(ostream& os, const vector<T>& v) 
{ 
    for (int i = 0; i < (int)v.size(); ++i) { 
        os << v[i]; 
        if (i != (int)v.size() - 1) 
            os << " "; 
    } 
    return os; 
}

int main()
{
    ll N;
    cin >> N;
    vector<ll> A(N);
    rep(i, N) { 
        cin >> A[i];
    }
    rep(i, N) {
      if (A[i] % 2 == 0 && (A[i] % 3 != 0  && A[i] % 5 != 0)) {
        print("DENIED");
        return 0;
      }
    }
    print("APPROVED");
    return 0;
}

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

int main () {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a (n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort (a.begin(), a.end());
  double ans = a[0];
  for (int i = 1; i < n; i++) {
    ans += a[i];
    ans /= 2;
  }
  cout << fixed << setprecision(10) << ans << '\n';
  return 0;
}



Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#include <algorithm>
#include <bitset>
#include <complex>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#include <cassert>
#include <functional>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template<typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template<typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010

vector<ll> factmemo, factmemoInv;
ll factmemoMod = -1;

ll factorial(int n, int M) {
  if (factmemoMod == M) return factmemo[n];
  if (n <= 1) return 1;

  ll res = 1;
  for (int i = 1; i <= n; i++) res = res * i % M;
  return res;
}

ll power(ll k, ll n, int M) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * k % M;
    k = k * k % M;
    n /= 2;
  }
  return res;
}

void initFactorial(int n, int M) {
  factmemo.assign(n + 1, 0);
  factmemoInv.assign(n + 1, 0);
  factmemoMod = M;
  factmemo[0] = 1;
  for (int i = 1; i <= n; i++) factmemo[i] = factmemo[i - 1] * i % M;
  factmemoInv[n] = power(factmemo[n], M - 2, M);
  for (int i = n; i > 0; i--) factmemoInv[i - 1] = factmemoInv[i] * i % M;
}

//nCm nPm nHm (mod M)

/*Combination*/
ll C(int n, int m, int M) {
  if (n < m) return 0;
  if (m == 0 || n == m) return 1;

  if (factmemoMod == M)
    return factmemo[n] * factmemoInv[m] % M * factmemoInv[n - m] % M;

  ll numer = factorial(n, M);
  ll denom = factorial(m, M) * factorial(n - m, M) % M;

  denom = power((int)denom, M - 2, M);

  return numer * denom % M;
}
/*Permutation*/
ll P(int n, int m, int M) {
  if (n < m) return 0;
  if (m == 0) return 1;

  if (factmemoMod == M)
    return factmemo[n] * factmemoInv[n - m] % M;

  ll numer = factorial(n, M);
  ll denom = factorial(n - m, M);

  denom = power((int)denom, M - 2, M);

  return numer * denom % M;
}
/*Combination with Repetitions*/
ll H(int n, int m, int M) {
  if (n == 0 && m == 0) return 1;
  return C(n + m - 1, m, M);
}

int main() {
  int N, K;

  cin >> N >> K;

  initFactorial(N + 1, mod);

  ll ans = 0;
  for (int i = 0; i <= min(N, K); i++) {
    int r = N - i;
    ans += C(N, i, mod) * C(N - 1, i, mod) % mod;
  }

  cout << ans % mod << endl;

  return 0;
}


Measured memory_bytes: 3328
<?php

$sc = new Scanner();

$s = $sc->next();

$len = strlen($s) - 2;
$list = [];
for($i = 0; $i < $len; $i++) {
    $n = $s[$i] . $s[$i+1] . $s[$i+2];
    $list[] = (int)$n;
}
$min = 10 << 10;
foreach($list as $n) {
    $min = min($min, abs($n - 753));
}
echo $min . PHP_EOL;

class Scanner {
    private $arr = [];
    private $count = 0;
    private $pointer = 0;
    public function next() {
        if($this->pointer >= $this->count) {
            $str = trim(fgets(STDIN));
            $this->arr = explode(' ', $str);
            $this->count = count($this->arr);
            $this->pointer = 0;
        }
        $result = $this->arr[$this->pointer];
        $this->pointer++;
        return $result;
    }
    public function hasNext() {
        return $this->pointer < $this->count;
    }
    public function nextInt() {
        return (int)$this->next();
    }
    public function nextDouble() {
        return (double)$this->next();
    }
}


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





int main(){
  

  int64_t x,y;
  cin>>x>>y;
  
  int64_t answer=1;
  
  while (2*x<=y){
    x*=2;
    answer++;
  }
  
  cout<<answer<<endl;
  
    
    
    

      
  
    

  
  
    
  
  
  
}

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

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 
using vs = vector<string>;
using vvs = vector<vs>; 
using vc = vector<char>;
using vvc = vector<vc>; 
using vb = vector<bool>;
using vvb = vector<vb>; 

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; }
const long long INF = 1LL << 60;
typedef pair<int, int> PR;

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define fr(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}
ll keta(ll x){
  ll n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;//繰り返し二乗法
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
ll kaijo(ll x){
  ll z=1;
  if(x==0){
    return 1;
  }
  while(x>0){
    z *=x;
    z %=MOD;
    x--;
  }
  return z;
}
ll yakusu_num(ll n){
  vl yakusu(n+1,1);
  for(ll i=2;i*i<=n;i++){ 
    while(n%i==0){
      n /=i;
      yakusu[i]++;
    }
  }
  if(n!=1)yakusu[n]++;
  ll num=1;
  for(ll i=0;i <=n;i++){
    num*=yakusu[i];
  }
  return num;
}
 

//cout<<""<<endl;
int main(){
  ll N,M;cin>>N>>M;
  vl A(N),B(N);
  vvl G(100001);
  rep(i,N){
    cin>>A[i]>>B[i];
    G[A[i]].pb(B[i]);
  }
  ll ans=0;
    priority_queue<ll> qu;
  for(int i=1;i<=M;i++){
    for(int j=0;j<G[i].size();j++){
      ll r=G[i][j];
      qu.push(r);
    }
    if(!qu.empty()){
      ll p=qu.top();
      qu.pop();
      ans +=(ll)p;
    }
    
  }

  cout<<ans<<endl;
}





Measured memory_bytes: 10260
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    LL N,M; cin >> N >> M;
    map<LL,LL> mp;
    VL A(N);
    REP(i,N) {
        cin >> A[i];
        A[i] *= -1;
        mp[A[i]]++;
    }
    REP(i,M){
        LL B,C;
        cin >> B >> C;
        C *= -1;
        mp[C] += B;
    }
    LL ans = 0;
    LL rem = N;
    for(auto p : mp){
        if(p.second >= rem){
            ans += p.first * rem;
            break;
        }
        else{
            ans += p.first * p.second;
            rem -= p.second;
        }
    }
    cout << -ans << endl;


}

Measured memory_bytes: 13568
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <cstdlib>
#include <math.h>

using namespace std;

typedef long long ll;
#define rep(i, n) for(long (i) = 0; (i) < (long) (n); (i)++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,a,b) for(long i=(a);i<(b);i++)
#define rrep1(i,a,b) for(long i=(a);i<=(b);i++)
#define rrrep(i,a,b) for(long i=(a);i>=(b);i--)
#define define pb push_back
#define ALL(obj) (obj).begin(), (obj).end()
#define X first
#define Y second
#define vi vector<int>
#define vl vector<ll>
#define vvi vector<vector<int> >
#define vpl vector<pair<long, long> >
#define vppl vector<pair<long, pair<long, long> > >

const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
const ll LINF = 1e18;

int printYes() {
    cout << "Yes" << endl;
    return 0;
}

int printNo() {
    cout << "No" << endl;
    return 0;
}

int ans;

int printAns() {
    cout << ans << endl;
    return 0;
}


int pow(int x) {
	if (x == 0) {
		return 1;
	}
	else {
		return pow(x - 1) * 2;
	}
}

int main(int argc, char const *argv[])
{
    int N;
    cin >> N;
    double ans = 0;
    rep(i,N) {
        string a;
        double b;
        cin >> b >> a;
        if (a == "BTC") {
            b *= 380000;
        }
        ans += b;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
import sys

while True:
    try:
        x1,y1,x2,y2,x3,y3,x4,y4 = (float(x) for x in input().split(" "))
        ans = "NO"
        if x1 == x2:
            if y3 == y4:
                ans = "YES"
        else:
            if x3 == x4:
                if y1 == y2:
                    ans = "YES"
            else:
                k1 = (y2 - y1) / (x2 - x1)
                k2 = (y4 - y3) / (x4 - x3)
                if(abs((k1 * k2) + 1) < 1e-10):
                    ans = "YES"
        print(ans)
    except:
        break


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

using namespace std;

int main()
{
	long long amount;
  cin>>amount;
  
  long long now=100;
  int years=0;
  
  while(now<amount)
  {
    now+=now/100;
    years++;
  }
  
  cout<<years<<"\n";
  
  return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define p (int)(1e9 + 7)

int MOD(int a){
	return (a %= p) >= 0 ? a : a + p;
}

signed main(){
	int N, K, i, j, k;
	scanf("%lld%lld", &N, &K);
	vector<vector<vector<int>>> dp(N + 1, vector<vector<int>>(N + 1, vector<int>(N * N + 1, 0)));
	dp[0][0][0] = 1;
	for(i = 0; i < N; i++){
		for(j = 0; j <= i; j++){
			for(k = 0; k <= N * N; k++){
				if(k + 2 * j <= N * N){
					dp[i + 1][j][k + 2 * j] = MOD(dp[i + 1][j][k + 2 * j] + (1 + 2 * j) * dp[i][j][k]);
				}
				if(0 <= j - 1 && 0 <= k + 2 * j - 2 && k + 2 * j - 2 <= N * N){
					dp[i + 1][j - 1][k + 2 * j - 2] = MOD(dp[i + 1][j - 1][k + 2 * j - 2] + j * j * dp[i][j][k]);
				}
				if(j + 1 <= N && k + 2 * j + 2 <= N * N){
					dp[i + 1][j + 1][k + 2 * j + 2] = MOD(dp[i + 1][j + 1][k + 2 * j + 2] + dp[i][j][k]);
				}
			}
		}
	}
/*	for(i = 0; i <= N; i++){
		for(j = 0; j <= N; j++){
			for(k = 0; k <= N * N; k++){
				printf("dp[%lld][%lld][%lld] = %lld\n", i, j, k, dp[i][j][k]);
			}
		}
		printf("\n");
	}
*/	printf("%lld\n", dp[N][0][K]);
	return 0;
}

Measured memory_bytes: 52224
#include <iostream>
#include <list>
#include <vector>

struct TNode
{
	int Index;
	bool Visited;
	std::list<TNode*> Target;
	
	int ClockStart;
	int ClockEnd;
	
	TNode(int AIndex)
	: Index(AIndex), Visited(false), ClockStart(0), ClockEnd(0)
	{
	}
	
	void Visit(int& Clock)
	{
		if(Visited) return;
		Visited = true;
		ClockStart = Clock;
		++Clock;
		for(std::list<TNode*>::iterator It = Target.begin(); It != Target.end(); ++It){
			(*It)->Visit(Clock);
		}
		ClockEnd = Clock;
		++Clock;
	}
};

class TGraph
{
	std::vector<TNode*> FNodes;
public:
	TGraph(int Count)
	: FNodes(Count)
	{
		for(int i = 0; i < Count; ++i){
			FNodes[i] = new TNode(i + 1);
		}
	}
	
	~TGraph()
	{
		for(unsigned int i = 0; i < FNodes.size(); ++i){
			delete FNodes[i];
		}
	}
	
	void InputNode(int Index, int BranchCount)
	{
		for(int i = 0; i < BranchCount; ++i){
			int Target;
			std::cin >> Target;
			FNodes[Index - 1]->Target.push_back(FNodes[Target - 1]);
		}
	}
	
	void DepthFirstSearch()
	{
		int Clock = 1;
		for(unsigned int i = 0; i < FNodes.size(); ++i){
			FNodes[i]->Visit(Clock);
		}
	}
	
	void OutputClocks()const
	{
		for(unsigned int i = 0; i < FNodes.size(); ++i){
			std::cout << FNodes[i]->Index      << " "
			          << FNodes[i]->ClockStart << " "
			          << FNodes[i]->ClockEnd   << std::endl;
		}
	}
};

int main()
{
	int Count;
	std::cin >> Count;
	TGraph Graph(Count);
	for(int i = 0; i < Count; ++i){
		int Index;
		std::cin >> Index;
		int BranchCount;
		std::cin >> BranchCount;
		Graph.InputNode(Index, BranchCount);
	}
	Graph.DepthFirstSearch();
	Graph.OutputClocks();
	return 0;
}

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


int main(){

    std::string str;

    cin >> str;

    if(str == "ABC")
    {
        cout << "ARC";
    }else
    {
        cout << "ABC";
    }
    

    return 0;
}


Measured memory_bytes: 3592
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

int powM(int x, int n){
    if(n == 0){
        return 1;
    }
    if(n % 2 == 0){
        return powM(x * x % MOD, n / 2);
    }
    return powM(x, n-1) * x % MOD;
}

int factM(int n){
    static vector<int> t = {1};

    if((int)t.size() > n){
        return t[n];
    }

    for(int i = t.size(); i <= n; i++){
        t.push_back(t[i-1] * i % MOD);
    }
    return t[n];
}

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

    vector<int> a(n);
    rep(i, n) cin >> a[i];

    vector<int> p(n+1);
    int all = factM(n) % MOD;
    rep(i, n){
        p[i+1] = (p[i] + all * powM(i+1, MOD-2) % MOD) % MOD;
    }

    int ans = 0;
    rep(i, n){
        ans = (ans + a[i] * ((MOD + p[i+1] + p[n-i] - p[1]) % MOD) % MOD) % MOD;
    }
    cout << ans << endl;

    return 0;
}


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

int main() {
int n;
cin >> n;
vector<int> d(n);
for(int i=0;i<n;i++)cin>>d[i];
int ans=0;
for(int i=0;i<n;i++){
for(int j = i + 1; j < n; j++) {
ans += d[i] * d[j];
}
}
cout << ans << endl;
return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define MOD 1000000007
#define PI 3.141592653589793

int main(){
    int a, b;
    char op;
    cin >> a >> op >> b;
    if(op == '+')
        cout << a + b << endl;
    else
        cout << a - b << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int got = 0;
int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    string s; cin>>s;
    for(int i = 0; i < s.length()-1; i++){
        if(s[i]=='A' && s[i+1] == 'C'){
            cout<<"Yes";
            got = 1;
            break;
        }
    }
    if(!got)cout<<"No";
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>

int main(void)
{
    int a, b, c;

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

    if (a > b) {
        int tmp = a;
        a = b;
        b = tmp;
    }

    if (a > c) {
        int tmp = c;
        c = a;
        a = tmp;
    }

    if (b > c) {
        int tmp = b;
        b = c;
        c = tmp;
    }


    printf("%d %d %d\n", a, b, c);

    return 0;
}

Measured memory_bytes: 2724
/*input
??????
coder
*/
#include <bits/stdc++.h>
using namespace std;
const long long md=1e9+7;
long long a[1000005],n;
string s,t;
bool check(int idx){
	for(int i=0;i<t.size();++i)
		if(s[idx+i]!='?' && s[idx+i]!=t[i])
			return false;
	return true;
}
int main(){
	#ifdef ONLINE_JUDGE
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	#endif
	long long q,m,k,h,ans=0,sum=0,p,x,y;
	cin>>s>>t;
	for(int i=s.size()-t.size();i>=0;--i){
		if(check(i)){
			string res;
			for(int j=0;j<i;++j) res+=(s[j]=='?'?'a':s[j]);
			for(int j=0;j<t.size();++j) res+=t[j];
			for(int j=i+t.size();j<s.size();++j) res+=(s[j]=='?'?'a':s[j]);
			return cout<<res,0;
		}
	}
	cout<<"UNRESTORABLE";
}

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

typedef long long ll;
using namespace std;

ll N;
vector<string> s(50);
vector<ll> t(50);
string X;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    ll sum = 0;
    for (int i = 0; i < N; i++) {
        cin >> s[i] >> t[i];
        sum += t[i];
    }
    cin >> X;

    ll sm = 0;
    for (int i = 0; i < N; i++) {
        sm += t[i];
        if (X == s[i]) {
            break;
        }
    }
    
    cout << sum - sm << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define lb(x) (x&-(x))
const int N = 101010;
priority_queue<int> q;
int main(){
	int tmp,n;
	rep(i,0,3)	{scanf("%d",&tmp);q.push(tmp);}
	scanf("%d",&n);
	rep(i,0,n)
	{
		int tmpp=q.top();
		q.pop();
		tmpp*=2;
		q.push(tmpp);
	}
	int sum=0;
	while(!q.empty())
	{
		sum+=q.top();
		q.pop();
	}
	cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
// --------------------------------------------------------
#define FOR(i,l,r) for (int i = (l); i < (r); ++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define MIN(c) *min_element(ALL(c))
#define MAX(c) *max_element(ALL(c))
#define SUM(c) accumulate(ALL(c), 0)
#define SUMLL(c) accumulate(ALL(c), 0LL)
#define SZ(c) ((int)(c).size())
#define debug(x) cerr << #x << " = " << (x) << '\n';
using P = pair<int,int>;
using VP = vector<P>;
using VVP = vector<VP>;
using VS = vector<string>;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<ll>;
using VVLL = vector<VLL>;
using VB = vector<bool>;
using VVB = vector<VB>;
using VD = vector<double>;
using VVD = vector<VD>;
static const double EPS = 1e-10;
static const double PI  = acos(-1.0);
static const ll MOD = 1000000007;
// static const ll MOD = 998244353;
static const int INF = 1 << 30;
// static const ll INF = 1LL << 62;
// --------------------------------------------------------


ll pow(ll x, ll n, ll mod) {
    ll res = 1;
    if (n > 0) {
        res = pow(x, n / 2, mod);
        if (n % 2 == 0) res = (res * res) % mod;
        else res = (((res * res) % mod) * x) % mod;
    }
    return res;
}


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);

    ll N; cin >> N;

    ll a = (MOD + pow(10, N, MOD) - pow(9, N, MOD)) % MOD;
    ll b = pow(8, N, MOD);
    ll ans = (MOD + a + a + b - pow(10, N, MOD)) % MOD;
    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 3608
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i=0;i < (int)(n);i++)


int main(){
   int n,d,x;
   int ans = 0;
   cin >> n >> d >> x;
   rep(i,n){
      int tmp;
      cin >> tmp;
      int now = 1;
      int id = 0;
      while(now <= d){
         ans++;
         id++;
         now = id*tmp+1;
         
      }
   }
   cout << ans + x << endl;
   return 0;
}



Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    while(true) {
        int sum;
        cin >> sum;
        if(!sum) break;
        for(int i = 0; i < 9; ++i) {
            int n;
            cin >> n;
            sum -= n;
        }
        cout << sum << endl;
    }
    return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define cs const
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
#define ll long long 
#define bg begin

namespace IO{

cs int rlen=1<<22|1;
char *ib,*ob,ibuf[rlen];
inline char gc(){
	(ib==ob)&&(ob=(ib=ibuf)+(fread(ibuf,1,rlen,stdin)));
	return (ib==ob)?EOF:*ib++;
}
inline int read(){
	char ch=gc();
	int res=0;bool f=0;
	while(!isdigit(ch))f=ch=='-',ch=gc();
	while(isdigit(ch))res=(res*10)+(ch^48),ch=gc();
	return f?-res:res;
}

}
using IO::read;

template<typename tp>inline void chemx(tp &a,tp b){(a<b)?(a=b):0;}
template<typename tp>inline void chemn(tp &a,tp b){(a>b)?(a=b):0;}

cs int mod=1e9+7;
inline int add(int a,int b){return a+b>=mod?a+b-mod:a+b;}
inline int dec(int a,int b){return a<b?a-b+mod:a-b;}
inline int mul(int a,int b){return (ll)a*b%mod;}
inline void Add(int &a,int b){a=a+b>=mod?a+b-mod:a+b;}
inline void Dec(int &a,int b){a=a<b?a-b+mod:a-b;}
inline void Mul(int &a,int b){a=(ll)a*b%mod;}
inline int ksm(int a,int b,int res=1){for(;b;b>>=1,Mul(a,a))if(b&1)Mul(res,a);return res;}
inline int Inv(int x){return ksm(x,mod-2);}

struct mat{
	int a[3][3];
	void clear(){memset(a,0,sizeof(a));}
	friend inline mat operator *(cs mat &a,cs mat &b){
		mat c;c.clear();
		for(int i=0;i<3;i++)
		for(int k=0;k<3;k++)
		for(int j=0;j<3;j++)
		Add(c.a[i][j],mul(a.a[i][k],b.a[k][j]));
		return c;
	}
	void I(){clear();a[0][0]=a[1][1]=a[2][2]=1;}
	friend inline mat operator ^(mat a,int b){
		mat c;c.I();
		for(;b;b>>=1,a=a*a)if(b&1)c=c*a;return c;
	}
	void write(){
		for(int i=0;i<3;i++,puts(""))
		for(int j=0;j<3;j++)cout<<a[i][j]<<" ";
	}
};
cs int N=100005;
int n,m,d[N];
int main(){
	#ifdef Stargazer
	freopen("lx.in","r",stdin);
	#endif
	n=read(),m=read();
	for(int i=1;i<=m;i++)d[i]=read();
	mat res;res.I();
	mat a;
	a.a[0][0]=1,a.a[1][0]=1,a.a[2][0]=1;
	a.a[0][1]=0,a.a[1][1]=1,a.a[2][1]=2;
	a.a[0][2]=0,a.a[1][2]=0,a.a[2][2]=1;
	mat b=a;
	b.a[0][2]++,b.a[1][2]++,b.a[2][2]++;
	for(int i=1;i<=m;i++){
		res=res*(b^(d[i]-d[i-1]-1));
		res=res*a;
	}
	if(d[m]<n)res=res*(b^(n-d[m]));
	cout<<res.a[2][0]<<'\n';return 0;
}

Measured memory_bytes: 1536
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        long k = sc.nextLong();
        HashMap<Long, Long> map = new HashMap<>();
        HashSet<Long> keys = new HashSet<>();
        for(int i = 0; i < n; i++) {
            long a = sc.nextLong();
            long b = sc.nextLong();
            map.put(a, map.getOrDefault(a, 0L) + b);
            keys.add(a);
        }
        Long[] array = new Long[keys.size()];
        keys.toArray(array);
        Arrays.sort(array);
        for(int i = 0; i < keys.size(); i++) {
            long key = array[i];
            long num = map.get(key);
            k -= num;
            if(k <= 0) {
                System.out.println(key);
                break;
            }
        }
    }
}



Measured memory_bytes: 99688
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;

#define MAXN (2000*2010)
bitset<MAXN> bs;

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

	int n, i, j, k, s, ans;
	cin >> n;
	vector<int> a(n);
	s = 0;
	for (i = 0; i < n; i++) {
		cin >> a[i];
		s += a[i];
	}

	bs.reset();
	bs[0] = 1;
	for (i = 0; i < n; i++) {
		bs |= (bs << a[i]);
	}

	for (i = (s + 1) / 2;; i++) {
		if (bs[i]) {
			ans = i;
			break;
		}
	}
	cout << ans << "\n";
	   	 
	return 0;
}


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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;

#define INF INT_MAX/3

#define MAX_N 1000

int n,m;
string a[111],b[111];

int main(){
	cin.sync_with_stdio(false);
	cin>>n>>m;
	rep(i,n)cin>>a[i];
	rep(i,m)cin>>b[i];
	rep(i,n)rep(j,n){
		bool ok=true;
		rep(k,m)rep(l,m){
			if(i+k>=n||j+l>=n){
				ok=false;
				break;
			}
			if(a[i+k][j+l]!=b[k][l])ok=false;
		}
		if(ok){
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	cout<<"No"<<endl;
	return 0;
}


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

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
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; }
typedef long long ll;

const long long INF = 1LL << 60;

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

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

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

    int tmp;

    if (n == 2) {
        tmp = gcd(num[0], num[1]);
    }
    else {
        tmp = gcd(num[0], num[1]);
        tmp = gcd(tmp, num[2]);
    }

    repd(i, 1, tmp + 1) {
        if (tmp % i == 0) {
            cout << i << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 3116
#include<iostream>
int main(){
  int a,b;
  std::cin >> a >> b;
  int c=1;
  int i;
  for(i=1;i<100;i++){
    c+=a-1;
    if(c>=b) break;
  }
  
  if(b==1) std::cout << 0;
  else std::cout << i;
}

Measured memory_bytes: 256
n = gets.to_i
if n <= 9
  puts n
  exit
elsif 10 <= n && n <= 99
  puts 9
  exit
elsif 100 <= n && n <= 999
  puts 9 + (n-100+1)
  exit
elsif 1000 <= n && n <= 9999
  puts 9 + 900
  exit
elsif 10000 <= n && n <= 99999
  puts 9 + 900 + (n-10000+1)
  exit
else
  puts 90909
  exit
end


Measured memory_bytes: 1788
def main():
    n = int(input())
    A = [list(map(int, input().split())) for i in range(n)]
    A = [[j for j in range(n) if A[i][j]] for i in range(n)]
    p = 10**9+7
    DP = [0 for s in range(1 << n)]
    DP[0] = 1
    for s in range(1, 1 << n):
        l = bin(s).count('1')
        for i in A[l-1]:
            if (1 << i) & s:
                DP[s] = (DP[s]+DP[~(1 << i) & s]) % p
    print(DP[(1 << n)-1])
main()

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

int main()
{
    int data[2005];
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>data[i];
    }
    sort(data,data+n);
    int res=0;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            for(int k=j+1;k<n;k++){
                if(data[i]+data[j]>data[k]){
                    res++;
                }
            }
        }
    }
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 384
N = int(input())
P = list(map(int,input().split(' ')))
num = 0
for i in range(1,N-1):
  if min(P[i-1],P[i+1]) < P[i]  and P[i] <max(P[i-1],P[i+1]):
    num += 1
print(num)

Measured memory_bytes: 3060
n, d = gets.split.map(&:to_f)
x = []
while line = gets
  x << line.split.map(&:to_f)
end
count = 0                                      
for i in 0..n-2
  for j in i+1..n-1
    distance = 0
    for k in 0..d-1
      distance += (x[i][k] - x[j][k]) ** 2     
    end
    count += 1 if (distance ** 0.5) % 1.0 == 0 
  end
end
puts count

Measured memory_bytes: 1788
#include <stdio.h>
#define MAX 100000
#define SENTINEL 2000000000

struct Card {
  char suit;
  int value;
};

struct Card L[MAX/2+2], R[MAX/2+2];

void merge(struct Card A[], int n, int left, int mid, int right) {
  int i, j, k;
  int n1 = mid - left;
  int n2 = right - mid;
  for(i=0;i<n1;i++) L[i] = A[left + i];
  for(i=0;i<n2;i++) R[i] = A[mid  + i];
  L[n1].value = R[n2].value = SENTINEL;
  i = j = 0;
  for(k=left; k<right; k++) {
    if(L[i].value <= R[j].value) {
      A[k] = L[i++];
    } else {
      A[k] = R[j++];
    }
  }
}

void mergeSort(struct Card A[], int n, int left, int right) {
  if(left+1 < right) {
    int mid = (left+right) / 2;
    mergeSort(A,n,left,mid);
    mergeSort(A,n,mid, right);
    merge(A,n,left,mid,right);
  }
}

int partition(struct Card A[], int n, int p, int r) {
  int i, j;
  struct Card t, x;
  x = A[r];
  i = p-1;
  for(j=p; j<r; j++) {
    if(A[j].value <= x.value) {
      i++;
      t=A[i]; A[i]=A[j]; A[j]=t;
    }
  }
  t=A[i+1]; A[i+1]=A[r]; A[r]=t;
  return i+1;
}

void quickSort(struct Card A[], int n, int p, int r) {
  int q;
  if(p<r) {
    q = partition(A,n,p,r);
    quickSort(A,n,p,q-1);
    quickSort(A,n,q+1,r);
  }
}

int main() {
  int n, i, v;
  struct Card A[MAX], B[MAX];
  char S[10];
  int stable = 1;

  scanf("%d", &n);

  for(i=0;i<n;i++) {
    scanf("%s %d",S,&v);
    A[i].suit =  B[i].suit  = S[0];
    A[i].value = B[i].value = v;
  }

  mergeSort(A,n,0,n);
  quickSort(B,n,0,n-1);

  for(i=0;i<n;i++) {
    // マージソートとクイックソートの結果を比べる
    if(A[i].suit != B[i].suit) stable = 0;
  }

  if(stable==1) printf("Stable\n");
  else printf("Not stable\n");
  for(i=0;i<n;i++) {
    printf("%c %d\n",B[i].suit,B[i].value);
  }

  return 0;
}


Measured memory_bytes: 4060
#include <bits/stdc++.h>
using namespace std;
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}
#ifdef __LOCAL
#define debug(x) cerr << __LINE__ << ": " << #x << " = " << (x) << '\n'
#define debugArray(x, n)                                      \
  cerr << __LINE__ << ": " << #x << " = {";                   \
  for (long long hoge = 0; (hoge) < (long long)(n); ++(hoge)) \
    cerr << ((hoge) ? "," : "") << x[hoge];                   \
  cerr << "}" << '\n'
#define debugMatrix(x, h, w)                                         \
  cerr << __LINE__ << ": " << #x << " =\n";                          \
  for (long long hoge = 0; (hoge) < (long long)(h); ++(hoge)) {      \
    cerr << ((hoge ? " {" : "{{"));                                  \
    for (long long fuga = 0; (fuga) < (long long)(w); ++(fuga))      \
      cerr << ((fuga ? ", " : "")) << x[hoge][fuga];                 \
    cerr << "}" << (hoge + 1 == (long long)(h) ? "}" : ",") << '\n'; \
  }
#else
#define debug(x) (void(0))
#define debugArray(x, n) (void(0))
#define debugMatrix(x, h, w) (void(0))
#endif

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  int T;
  cin >> T;
  while (T--) {
    long long N, a, b, c, d;
    __int128_t A, B, C, D;
    cin >> N >> a >> b >> c >> d;
    A = a;
    B = b;
    C = c;
    D = d;
    map<long long, __int128_t> memo;
    function<__int128_t(long long)> rec = [&](long long n) {
      if (n == 1) return D;
      if (memo.count(n)) return memo[n];
      __int128_t ret = LLONG_MAX;
      ret = min(ret,
                rec((n + 1) / 2) + min(A + D * (n % 2), D * ((n + 1) / 2)));
      ret = min(ret,
                rec((n + 2) / 3)
                    + min(B + D * ((3 - n % 3) % 3), D * ((n + 2) / 3) * 2));
      ret = min(ret,
                rec((n + 4) / 5)
                    + min(C + D * ((5 - n % 5) % 5), D * ((n + 4) / 5) * 4));
      if (n % 120 != 0) ret = min(ret, rec(n - 1) + D);
      return memo[n] = ret;
    };
    cout << (long long)rec(N) << '\n';
  }
  return 0;
}


Measured memory_bytes: 27936
from collections import deque
n,k=map(int,input().split())
s=input()
w=[]
f=s[0]
ans=chk=0
d=deque([])
for i in s:
    if i!=f:
        if f=='0': chk*=-1
        w.append(chk)
        f=i
        chk=1
    else:
        chk+=1
if f=='0': chk*=-1
w.append(chk)

chk=0
for i in w:
    if i>0 or k>0:
        if i<0: k-=1
        chk+=abs(i)
        d.append(i)

    elif k>0:
        chk+=abs(i)
        k-=1
        d.append(i)
    else:
        x=d.popleft()
        chk-=abs(x)
        if x>0:
            x=d.popleft()
            chk-=abs(x)
        chk+=abs(i)
        d.append(i)

    ans=max(ans,chk)

print(ans)


Measured memory_bytes: 75628
import random as ra
import copy
import time

start_time = time.time()

D = int(input())
c = list(map(int,input().split()))
s = [list(map(int,input().split())) for i in range(D)]
t = [ra.randint(1,26) for i in range(D)]


### 得点計算用
#t = [int(input()) for i in range(D)]
def cal_point(t):
    score = 0
    last = [0]*26
    for d in range(D):
        score += s[d][t[d]-1]
        last[t[d]-1] = d+1
        for i in range(26):
            score -= c[i]*(d+1-last[i])
    #print(score)
    return score
max_score = 0
optimal_t = copy.deepcopy(t)
#M = 10**5
while (time.time()-start_time)<1.9:
#for i in range(M):
    d = ra.randint(1,D)
    q = ra.randint(1,26)
    t[d-1] = q
    now = cal_point(t)
    if now > max_score:
        optimal_t = copy.deepcopy(t)
        max_score = now

print(*optimal_t,sep='\n')


Measured memory_bytes: 10068