akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int top;
int S[1000];

void push(int x){
	S[++top] = x;//++x先赋值再自增 
} 

int pop(){
	top--;
	return S[top+1];
}

int main(){
	int a,b;
	top = 0;
	char s[100];
	while(scanf("%s", s) !=EOF){
		if(s[0] == '+'){
			a = pop();
			b = pop();
			push(a+b);
		}
		else if(s[0] == '-'){
			a = pop();
			b = pop();
			push(b-a);
		}
		else if(s[0] == '*'){
			a = pop();
			b = pop();
			push(a*b);
		}
		else{
			push(atoi(s));
		}
	}
	printf("%d\n",pop());
	
	return 0;
} 


Measured memory_bytes: 2708
#!/usr/bin/env python3

from pprint import pprint
from bisect import bisect_right
import math
import sys

sys.setrecursionlimit(10 ** 6)
INF = float('inf')


N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

sum_A = [0] * (N+1)
for i in range(N):
    sum_A[i+1] = sum_A[i] + A[i]
sum_B = [0] * (M+1)
for i in range(M):
    sum_B[i+1] = sum_B[i] + B[i]
# print(sum_A, sum_B)

res = 0
for i in range(N+1):
    time_A = sum_A[i]
    rest = K - time_A
    if rest < 0:
        continue
    j = bisect_right(sum_B, rest) - 1
    res = max(res, i + j)
print(res)

Measured memory_bytes: 120204
# AtCoder Beginner Contest 164
# B - Battle
# https://atcoder.jp/contests/abc164/tasks/abc164_b
(a, b, c, d) = gets.chomp.split.map(&:to_i)

turn = 0

while true
  break if a <=0 || c <= 0
  if turn % 2 == 0
    c -= b
  else
    a -= d
  end
  turn += 1
end

puts a > 0 ? 'Yes' : 'No'


Measured memory_bytes: 14320
#include <iostream>
#include <vector>
#include <limits>
using namespace std;
using Int = long long;
#define REP(i,n) for(int i=0;i<n;i++)
int main()
{
    int N; cin >> N;
    int sum = 0;
    REP(i, N) {
        int l, r;
        cin >> l >> r;
        sum += r - l + 1;
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repo(j,o,n) for(int j=o;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define pb(a) push_back(a)
#define eraser(v,i) (v).erase(v.begin()+(i))
#define pbpair(a,b) push_back(make_pair(a,b))
#define MOD 1000000007
#define INF 9223372036854775807
#define pairint pair<int,int>
int num[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
bool uru(int checkyear){if(checkyear%4==0){if(checkyear%100!=0||checkyear%400==0)return true;}return false;}
int gcd( int x, int y ){return y ? gcd(y, x%y) : x;}
signed main()
{
  int x=0,y=0,z=0,w=0,n=0,m=0,a=0,b=0;
  std::cin >> x;
  if(x%2==0)std::cout << x/2-1 << '\n';
  else std::cout << x/2 << '\n';
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>

int main(void){
    int i, j, YES, a;
    char S[105], T[105];
    scanf("%s\n%s", S, T);
    for(i=0; i<strlen(S); i++){
        YES=1;
        for(j=0; j<strlen(S); j++){
            if((i+j)>=strlen(S)) a=i+j-strlen(S);
            else a=i+j;
            if(S[a]!=T[j]) YES=0;
        }
        if(YES){
            printf("Yes\n");
            return 0;
        }
    }
    printf("No\n");
    return 0;
}


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

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

  int a[1000000];
  int n = s;
  int i = 0;
  a[i] = n;

  while (true) {
    i += 1;
    if (n % 2 == 0) {
      n = n / 2;
    } else {
      n = 3 * n + 1;
    }

    for (int j = 0; j < i; j++) {
      if (a[j] == n) {
        cout << i + 1 << endl;
        return 0;
      }
    }
    a[i] = n;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1000000007;
const LL LINF=1LL<<60;
const int INF=1<<30;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};


vector<LL> divi(LL K){
    vector<LL> v;
    for(LL i=1;i*i<=K;i++){
        if(K%i) continue;
        v.pb(i);
        v.pb(K/i);
    }
    sort(ALL(v));
    v.erase(unique(ALL(v)),v.end());
    return v;
}



int main(){
    LL n;cin >> n;
    LL ans = 0;
    auto p = divi(n);
    for (int i = p.size()-1; i > 0; i--) {
        LL m = p[i] - 1;
        LL a = n/m;
        if(a<m) ans += m;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for (int (i) = 1; (i) <= (n); (i++))
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
#define printd(x) printf("%.12f\n", ans);
template<class T> bool chmin(T& a, const T& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> bool chmax(T& a, const T& b) {if (a < b) {a = b; return 1;} return 0;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main(void) {
    int n, m;
    cin >> n >> m;
    vector<ll> a(n);
    rep (i, n) cin >> a[i];
    vector<pair<ll, ll>> cb(m);
    rep (i, m) cin >> cb[i].se >> cb[i].fi;

    sort(rng(a));
    sort(rrng(cb));

    vector<ll> use;
    for (int i = 0; i < m; i++) {
        if (use.size() >= n) break;
        rep (j, cb[i].se) use.pb(cb[i].fi);
    }

    //sort(rrng(use));
    rep (i, n) use.pb(0);

    ll ans = 0;
    rep (i, n) ans += max(a[i], use[i]);

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


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

using namespace std;

using ll = long long;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector< vector<int> > v(n);
	for (int i = 0; i < n; i++) {
		int a, b, c;
		cin >> a >> b >> c;
		v[i] = {a, b, c};
	}

	vector< vector<int> > dp(n, vector<int>(3, 0));
	dp[0] = v[0];
	for (int i = 0; i < n - 1; i++) {
		for (int j = 0; j < 3; j++) {
			for (int k = 0; k < 3; k++) {
				if (k == j) continue;
				dp[i + 1][k] = max(dp[i + 1][k], dp[i][j] + v[i + 1][k]);
			}
		}
	}

	cout << *max_element(dp[n - 1].begin(), dp[n - 1].end()) << endl;
	return 0;
}

Measured memory_bytes: 11264
#![allow(unused_imports)]
#![allow(non_snake_case, unused)]

use std::cmp::*;
use std::collections::*;
use std::ops::*;

macro_rules! eprint {
	($($t:tt)*) => {{
		use ::std::io::Write;
		let _ = write!(::std::io::stderr(), $($t)*);
	}};
}
macro_rules! eprintln {
	() => { eprintln!(""); };
	($($t:tt)*) => {{
		use ::std::io::Write;
		let _ = writeln!(::std::io::stderr(), $($t)*);
	}};
}
macro_rules! dbg {
	($v:expr) => {{
		let val = $v;
		eprintln!("[{}:{}] {} = {:?}", file!(), line!(), stringify!($v), val);
		val
	}}
}

macro_rules! mat {
	($($e:expr),*) => { Vec::from(vec![$($e),*]) };
	($($e:expr,)*) => { Vec::from(vec![$($e),*]) };
	($e:expr; $d:expr) => { Vec::from(vec![$e; $d]) };
	($e:expr; $d:expr $(; $ds:expr)+) => { Vec::from(vec![mat![$e $(; $ds)*]; $d]) };
}

macro_rules! ok {
	($a:ident$([$i:expr])*.$f:ident()$(@$t:ident)*) => {
		$a$([$i])*.$f($($t),*)
	};
	($a:ident$([$i:expr])*.$f:ident($e:expr$(,$es:expr)*)$(@$t:ident)*) => { {
		let t = $e;
		ok!($a$([$i])*.$f($($es),*)$(@$t)*@t)
	} };
}

pub fn readln() -> String {
	let mut line = String::new();
	::std::io::stdin().read_line(&mut line).unwrap_or_else(|e| panic!("{}", e));
	line
}

macro_rules! read {
	($($t:tt),*; $n:expr) => {{
		let stdin = ::std::io::stdin();
		let ret = ::std::io::BufRead::lines(stdin.lock()).take($n).map(|line| {
			let line = line.unwrap();
			let mut it = line.split_whitespace();
			_read!(it; $($t),*)
		}).collect::<Vec<_>>();
		ret
	}};
	($($t:tt),*) => {{
		let line = readln();
		let mut it = line.split_whitespace();
		_read!(it; $($t),*)
	}};
}

macro_rules! _read {
	($it:ident; [char]) => {
		_read!($it; String).chars().collect::<Vec<_>>()
	};
	($it:ident; [u8]) => {
		Vec::from(_read!($it; String).into_bytes())
	};
	($it:ident; usize1) => {
		$it.next().unwrap_or_else(|| panic!("input mismatch")).parse::<usize>().unwrap_or_else(|e| panic!("{}", e)) - 1
	};
	($it:ident; [usize1]) => {
		$it.map(|s| s.parse::<usize>().unwrap_or_else(|e| panic!("{}", e)) - 1).collect::<Vec<_>>()
	};
	($it:ident; [$t:ty]) => {
		$it.map(|s| s.parse::<$t>().unwrap_or_else(|e| panic!("{}", e))).collect::<Vec<_>>()
	};
	($it:ident; $t:ty) => {
		$it.next().unwrap_or_else(|| panic!("input mismatch")).parse::<$t>().unwrap_or_else(|e| panic!("{}", e))
	};
	($it:ident; $($t:tt),+) => {
		($(_read!($it; $t)),*)
	};
}

pub fn main() {
	let _ = ::std::thread::Builder::new().name("run".to_string()).stack_size(32 * 1024 * 1024).spawn(run).unwrap().join();
}

const MOD: u32 = 1_000_000_007;
const INF: i64 = std::i64::MAX;

pub trait SetMinMax {
	fn setmin(&mut self, v: Self) -> bool;
	fn setmax(&mut self, v: Self) -> bool;
}
impl<T> SetMinMax for T where T: PartialOrd {
	fn setmin(&mut self, v: T) -> bool {
		*self > v && { *self = v; true }
	}
	fn setmax(&mut self, v: T) -> bool {
		*self < v && { *self = v; true }
	}
}

fn solve() {
	let n = read!(usize);
	let a = read!([usize]);
	let mut b = vec![0;n];
	for i in 0..n {
		b[a[i]-1] = i+1;
	}
	for i in 0..n {
		print!("{} ", b[i]);
	}
}

fn run() {
    solve();
}

Measured memory_bytes: 11132
#include <bits/stdc++.h>
#define ll long long
#define BUF 1e5
#define INF 1 << 30
constexpr ll mod = 1e9 + 7;
using namespace std;
ll A, B, C, D, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

int main() {
    cin >> N;
    vector<pair<int, int>> ab(N);
    for (int i = 0; i < N; i++) {
        cin >> A >> B;
        ab[i] = {B, A};
    }
    sort(ab.begin(), ab.end());
    int sm = 0;
    for (int i = 0; i < N; i++) {
        sm += ab[i].second;
        if (sm > ab[i].first) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
long long int gcd(long long int a, long long int b){
	return (b > 0)? gcd(b, a % b) : a ;
}
int main(){
long long int N, X; 
cin >> N >> X; 
long long int G = gcd(N, X); 
cout << 3 * (N - G); 
}

Measured memory_bytes: 256
from collections import Counter
from enum import Enum


class Color(Enum):
    GRAY = (1, 399)
    BROWN = (400, 799)
    GREEN = (800, 1199)
    LIGHTBLUE = (1200, 1599)
    BLUE = (1600, 1999)
    YELLOW = (2000, 2399)
    ORANGE = (2400, 2799)
    RED = (2800, 3199)
    RAINBOW = (3200, 4800)

    @classmethod
    def from_rate(cls, rate):
        colors = {cls.GRAY, cls.BROWN, cls.GREEN, cls.LIGHTBLUE, cls.BLUE, cls.YELLOW, cls.ORANGE, cls.RED, cls.RAINBOW}
        for color in colors:
            lower, upper = color.value
            if lower <= rate <= upper:
                return color
        else:
            raise ValueError


N = int(input())
rates = tuple(map(int, input().split(' ')))
colors = [Color.from_rate(rate) for rate in rates]
counter = Counter(colors)
to_red = len([0 for color in counter.keys() if color != Color.RAINBOW])
r_max = counter[Color.RAINBOW]

max_colors = to_red + r_max
min_colors = max(1, to_red)
print(min_colors, max_colors)


Measured memory_bytes: 9604
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("fast-math")
#include<bits/stdc++.h>

#define endl '\n'
#define dbg(a) cout << #a << " := " << (a) << endl
#define all(a) (a).begin(), (a).end()
#define len(a) (int) (a).size()
#define forn(i, n) for (int (i) = 0; (i) < (n); ++(i))
using namespace std;

void solve();

signed main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    solve();
}

const int maxn = 1 << 18;
int a[maxn];
int mx1[maxn], mx2[maxn];
inline void upd (int val, int i){
    if (val >= mx1[i]){
        swap(mx1[i], mx2[i]);
        mx1[i] = val;
    } else if (val > mx2[i]){
        mx2[i] = val;
    }
}


const int INF = (int) 2e9 + 7;
inline void solve() {
    int n; cin >> n; forn (i, 1 << n) cin >> a[i];
    for (int i = 0; i < maxn; ++i) mx1[i] = mx2[i] = -INF;
    for (int mask = 0; mask < (1 << n); ++mask) {
        for (int s = mask;; s = (s - 1) & mask) {
            upd(a[s], mask);
            if (s == 0) break;
        }
    }
    int res = -INF;

    for (int i = 1; i < 1 << n; ++i){
        res = max(res, mx1[i] + mx2[i]);
        cout << res << endl;
    }
}

Measured memory_bytes: 6144
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

const int K = 30;
const int INF = 1e9 + 239;

int solve(vector<int> a, vector<int> b, int L, int R) {
	if (L > R) {
		return 0;
	}
	sort(b.begin(), b.end());
	auto cnt = [&](int l, int r) {
		int cc = upper_bound(b.begin(), b.end(), r) - lower_bound(b.begin(), b.end(), l);
		return cc & 1;
	};
	int xr = 0;
	for (auto t : a) {
		xr ^= cnt(L - t, R - t);
	}
	return xr;
}

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

	int n;
	cin >> n;
	vector<int> a(n);
	vector<int> b(n);
	for (auto &t : a) {
		cin >> t;
	}
	for (auto &t : b) {
		cin >> t;
	}
	int ans = 0;
	for (int bt = 0; bt < K; bt++) {
		vector<int> na = a;
		vector<int> nb = b;
		for (auto &t : na) {
			t %= (2 << bt);
		}
		for (auto &t : nb) {
			t %= (2 << bt);
		}
		int c = 0;
		c ^= solve(na, nb, (1 << bt), (2 << bt) - 1);
		c ^= solve(na, nb, (3 << bt), INF);
		if (c) ans |= 1 << bt;
	}
	cout << ans << endl;
}


Measured memory_bytes: 6988
import math

n,d = list(map(int,input().split()))
x = [list(map(int,input().split())) for i in range(n)]
count = 0

for i in range(n):
  for j in range(i+1,n):
    ans = 0
    for k in range(d):
      ans += abs(x[i][k]-x[j][k])**2
    if math.sqrt(ans) % 1 == 0:
      count += 1
    
print(count)

Measured memory_bytes: 3060
#include <stdio.h>

int main(void) {
  int X[5];
  int D[5];
  int small = 10;
  int Idx = 0;

  for(int i = 0; i < 5; i++) {
    scanf("%d", &X[i]);
    D[i] = X[i] % 10;
    if(D[i] != 0 && (small > D[i])) {
      small = D[i];
      Idx = i;
    }
  }

  int SUM = 0;
  for(int i = 0; i < 5; i++) {
    if(i == Idx || D[i] == 0) 
      SUM += X[i];
    else
      SUM += (X[i] + (10 - D[i]));
  }
  printf("%d\n", SUM);
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(n);++i)
const int INF =1001001001;
using ll=long long;
using P = pair<int,int>;
using Graph =vector<string>;
Graph field;
queue<P> q;

int main() {
  string ab;
  cin >>ab;
  if(ab=="A"||ab=="B"||ab=="C"||ab=="D"||ab=="E"||ab=="F"||ab=="G"||ab=="H"||ab=="I"||ab=="M"||ab=="N"||ab=="L"||ab=="O"||ab=="P"||ab=="Q"||ab=="R"||ab=="S"||ab=="T"||ab=="U"||ab=="V"||ab=="W"||ab=="X"||ab=="Y"||ab=="Z"||ab=="I"||ab=="M"||ab=="N"||ab=="L"||ab=="O"||ab=="P"||ab=="Q"||ab=="R"){
    cout<<"A"<<endl;
  }else{
    cout<<"a"<<endl;
  }
}


Measured memory_bytes: 3628
#include <stdio.h>

int main(void)
{
    int i;
    int j;
    int ans;

    for (i = 1; i <= 9; i++) {
        for (j = 1; j <= 9; j++) {
            ans = i * j;
            printf("%dx%d=%d\n", i, j, ans);
        }
    }
    return 0;
}

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

int main() {
  int n,i,j;
  cin >> n;
  vector<int> a(n+1),b;
  b=vector<int>(n+1,0);
  for(i=0;i<n;i++){
    cin >> a.at(i+1);
  }
  i=1;
  j=0;
  while(1){
    b.at(i)=1;
    i=a[i];
    j++;
    if(i==2){
      cout << j << endl;
      break;
    }
    if(b[i]==1){
      cout << "-1" << endl;
      break;
    }
  }
}

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

int main(){
   int a, b;
   cin >> a;
   cin >> b;
   if(a == 1 && b == 2 || a == 2 && b == 1) cout << 3 << endl;
   else if(a == 1 && b == 3 || a == 3 && b == 1) cout << 2 << endl;
   else cout << 1 << endl;
}

Measured memory_bytes: 3516
#C
import math
import itertools
n = int(input())
n_list = [x+1 for x in range(n)]
num = math.factorial(n)
n_per = list(itertools.permutations(n_list))
p_list = []
for i in range(n):
    x,y = map(int, input().split())
    p_list.append([x, y])
p_sum = 0
for keiro in n_per:
    p_min_sum = 0
    #print(keiro)
    for p_n in range(n-1):
        #print(keiro[p_n])
        #print(p_list[keiro[p_n]-1])
        p_1 = math.sqrt((p_list[keiro[p_n]-1][0] - p_list[keiro[p_n + 1] - 1][0])**2 + (p_list[keiro[p_n]-1][1] - p_list[keiro[p_n + 1] - 1][1])**2)
        p_min_sum += p_1
    p_sum += p_min_sum
print(p_sum / num)

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

int main() {
  int A, B, sum;
  cin >> A >> B;
  for(; A <= B; A++) {
    if (A / 10000 == A % 10 && A / 1000 % 10 == A / 10 % 10) {
      sum++;
    }
  }
  cout << sum << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <string.h>
using namespace std;

#define ISEQ(c) (c).begin(), (c).end()
typedef long long ll;

int main() {
  while (true) {
    int N;
    cin >> N;
    if (N == 0) break;
    vector<int> x, y;
    x.push_back(0);
    y.push_back(0);
    int dx[4] = {-1, 0, 1, 0};
    int dy[4] = {0, -1, 0, 1};
    for (int i = 0; i < N-1; i++) {
      int n, d;
      cin >> n >> d;
      x.push_back(x[n]+dx[d]);
      y.push_back(y[n]+dy[d]);
    }
    sort(x.begin(), x.end());
    sort(y.begin(), y.end());
    cout << x[x.size()-1] - x[0]+1 << " " << y[y.size()-1] - y[0] +1 << endl;
  }
}

Measured memory_bytes: 1220
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;

void Main() {
  ll n;
  R n;
  ll ans=MAXL;
  for(ll i=1; i*i<=n; i++) {
    if(n%i==0) ans=min(ans,(i-1)+(n/i-1));
  }
  pr(ans);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <queue> 
using namespace std;
 
class Process{
    public:
        string name;
        int time;
};
 
int main(){
    int num, quantum;
    cin >> num >> quantum;
    queue<Process> process;
    
    while(num--){
        Process p;
        cin >> p.name >> p.time;
        process.push(p);
    }
    int total = 0;
    while (!process.empty()){
        Process p = process.front();
        process.pop();
        if (p.time <= quantum){
            total += p.time;
            cout << p.name << " " << total << endl;
        } else {
            total += quantum;
            p.time -= quantum;
            process.push(p);
        }
    }
    return 0;
}



Measured memory_bytes: 6348
#include <stdio.h>
 
int main() {
  int i, n, x;
  scanf("%d", &n);
  for (i = 1; i <= n; i++) {
    x = i;
    if (x % 3 == 0) {
      printf(" %d", i);
      continue;
    }
    for (;;) {
      if (x % 10 == 3) {
        printf(" %d", i);
        break;
      }
      x /= 10;
      if (!x) break;
    }
  }
  printf("\n");
  return 0;
}


Measured memory_bytes: 2044
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  long long D;
  cin >> N >> D;
  int ans = 0;
  for (int i = 0; i < N; i++){
    long long x, y;
    cin >> x >> y;
    if (x * x + y * y <= D * D){
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3620
#include <stdio.h>

int main() {
	static int kk[100001];
	static char composite[100001];
	int q, a, b, x;

	scanf("%d", &q);
	for (a = 2; a * a <= 100000; a++) {
		if (composite[a])
			continue;
		for (b = a * a; b <= 100000; b += a)
			composite[b] = 1;
	}
	kk[1] = 0;
	for (x = 3; x <= 100000; x += 2)
		kk[x] = kk[x - 2] + (!composite[x] && !composite[(x + 1) / 2]);
	while (q--) {
		int l, r;

		scanf("%d%d", &l, &r);
		printf("%d\n", kk[r] - kk[l - 2]);
	}
	return 0;
}


Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define put(a) cout<<a<<"\n"
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }

int main() {
	string s;
	cin >> s;
	int n = s.size();
	REP(i, n-8) {
		cout << s[i];
	}
	put("");
	return 0;
}


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

int main() {
    string str;
    cin >> str;
    vector<vector<int>> vec(10, vector<int>(200001));
    rep(i, 10){
        vec[i][0] = i;
    }
    rep(i, 10){
        for(int j=1; j<200001; j++){
            vec[i][j] = (vec[i][j-1] * 10) % 2019;
        }
    }
    int sum = 0;
    ll zeros = 0;
    map<int, int> mp2019;
    for(int i=0; i<str.length(); i++){
        sum += vec[str[str.length()-1-i]-'0'][i];
        sum %= 2019;
        mp2019[sum]++;
        if(sum == 0) zeros++;
    }
    ll res = 0;
    rep(i, 2019){
        res += mp2019[i]*(mp2019[i]-1)/2;
    }
    cout << res+zeros << endl;
    return 0;
}

Measured memory_bytes: 12056
#include <bits/stdc++.h>
#include <stdio.h>
#include <algorithm>
using namespace std;
#define r(i,n) for(long i=0;i<n;i++)
#define rn(i,n) for(long i=1;i<=n;i++)

int main(void){
  int n,k,q;
  cin>>n>>k>>q;
  vector<int> a(n,0);

  int x;
  r(i,q){
    cin>>x;
    a.at(x-1)++;
  }

  r(i,n){
    //cout<<a.at(i)<<endl;
    if(a.at(i)+k-q>0)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
  }



  return 0;
}


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

int main(int argc, char *argv[]){
    int a,b;
    double m,h,c;
    cin >> a >> b >> h >> m;
    double phi=3.141592653589793;
    h=h/6+m/360;
    m=m/30;
    double x=h-m;
    if(x<0) x*=-1;
    if(x>1) x=2-x;
    x=x*phi;
    c=a*a+b*b-2*a*b*cos(x);
    c=pow(c,0.5);
    cout << fixed << setprecision(15) << c << endl;
    return 0;
}

Measured memory_bytes: 4356
#include <bits/stdc++.h>
#pragma GCC optimize("O3")

#define fi first
#define se second
#define ep emplace
#define eb emplace_back
#define mp make_pair
#define pi pair<int,int>
#define vi vector<int>
#define vpi vector<pair<int,int>>
#define vll vector<ll>
#define vpll vector<pair<ll,ll>>
#define endl '\n'

#define si(v) int((v).size())
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i) 
#define rep2(i, n, m) for (ll i = n; i <= (ll)(m); ++i)
#define rep3(i, n, m) for (ll i = n; i >= (ll)(m); --i)

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

using ll = long long;
using ld = long double;
using namespace std;

constexpr ll MOD = 1000000007;

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

  char c; cin >> c;
  if (isupper(c)) cout << "A" << endl;
  else cout << "a" << endl;

  return (0);
}


Measured memory_bytes: 3620
// #pragma GCC optimize("unroll-loops", "omit-frame-pointer", "inline")
// #pragma GCC option("arch=native", "tune=native", "no-zero-upper")
// #pragma GCC
// target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize("tree-vectorize","openmp","predictive-commoning")
// #pragma GCC option("D_GLIBCXX_PARALLEL","openmp")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
// #define int long long
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000               // 2e9
#define LLINF 2000000000000000000ll  // 2e18 (llmax:9e18)
#define fi first
#define sec second
#define all(x) (x).begin(), (x).end()
#define sq(x) ((x) * (x))
#define dmp(x) cerr << #x << ": " << x << endl;

template <class T>
void chmin(T &a, const T &b) {
  if (a > b) a = b;
}
template <class T>
void chmax(T &a, const T &b) {
  if (a < b) a = b;
}

template <class T>
using MaxHeap = priority_queue<T>;
template <class T>
using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template <class T>
vector<T> vect(int len, T elem) {
  return vector<T>(len, elem);
}

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << p.fi << ',' << p.sec;
  return os;
}
template <class T, class U>
istream &operator>>(istream &is, pair<T, U> &p) {
  is >> p.fi >> p.sec;
  return is;
}
template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) {
    os << vec[i];
    if (i + 1 < vec.size()) os << ' ';
  }
  return os;
}
template <class T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) is >> vec[i];
  return is;
}
void fastio() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout << fixed << setprecision(20);
}

#define endl "\n"

void solve() {
  int k;
  int a, b;
  cin >> k >> a >> b;
  for (int i = a; i <= b; i++) {
    if (i % k == 0) {
      cout << "OK" << endl;
      return;
    }
  }
  cout << "NG" << endl;
  return;
}

signed main() {
  fastio();
  solve();
  // int t; cin >> t; while(t--)solve();

  // int t; cin >> t;
  // for(int i=1;i<=t;i++){
  //   cout << "Case #" << i << ": ";
  //   solve();
  // }
  return 0;
}


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

int main()
{
    int i, n;
    i = 1;
    while (cin >> n)
    {
        if (n== 0)
        {
            break;
        }
        cout << "Case " << i << ": " << n << endl;
        i++;
    }

    return 0;
}



Measured memory_bytes: 3120
#include<bits/stdc++.h>
using namespace std;
#define maxn 105
int f[maxn],N,D,X;
int main(){
	cin>>N>>D>>X;
	for(register int i=1;i<=N;++i)scanf("%d",&f[i]);
	int ans=X;
	for(register int i=1;i<=N;++i){
		for(register int j=1;j<=D;j+=f[i])++ans;
	}cout<<ans<<endl;
	return 0;
}


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

using namespace std;

//#define DEBUG

int N, K;
long long prefix[200005];
map <int, int> occurences;
long long ans;
int toBeDeleted[200005];

int main()
{
    scanf("%d%d", &N, &K);
    prefix[0] = 0;
    for (int i = 1; i <= N; i++)
    {
        scanf("%lld", prefix + i);
        prefix[i] += prefix[i - 1];
    }

    #ifdef DEBUG
    printf("Prefix sums:\n");
    for (int i = 0; i <= N; i++)
    {
        printf("%d ", prefix[i]);
    }
    printf("\n");
    #endif // DEBUG

    ans = 0;
    occurences[0] = 1;
    if (K <= N) toBeDeleted[K] = 0;
    for (int i = 1; i <= N; i++)
    {
        if (i >= K) occurences[toBeDeleted[i]]--;
        int cur = (prefix[i] - i) % K;
        if (i + K <= N)
        {
            toBeDeleted[i + K] = cur;
        }
        ans += occurences[cur];

        #ifdef DEBUG
        printf("(prefix[%d] - %d) %% %d = %d\n", i, i, K, cur);
        printf("Occurences[%d]: %d\n\n", cur, occurences[cur]);
        #endif // DEBUG

        occurences[cur]++;
    }
    printf("%lld", ans);
}


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

int binarySearch(int S[],int n,int T){
  int l=0,m;
  int r=n;
  while(l<r){
    m=(l+r)/2;
    if(S[m]==T)return 1;
    else if(T<S[m])r=m;
    else l=m+1;
  }
  return 0;
}

int main(){
  int i,c=0;
  int n,q,T;
  int *S;

  scanf("%d",&n);
  S = (int*)malloc(sizeof(int)*n);
  for(i=0;i<n;i++){
    scanf("%d",&S[i]);
  }
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&T);
    if(binarySearch(S,n,T)==1)c++;
  }
printf("%d\n",c);

return 0;
}


Measured memory_bytes: 2100
#include <iostream>
#include <sstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <stdio.h>

using namespace std;

//typedefリスト
typedef vector<int> vint;
typedef vector<string> vstr;


int main(void) {
	long long int X, Y, Z,num;
	cin >> X >> Y >> Z;
	num = X - Z;
	cout << num / (Y + Z) << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
	int x, y, i, j;
	char str[101][101];
	scanf("%d%d", &y, &x);
	for (i=0; i < y ;i++) {
		scanf("%s", str[i]);
		printf("%s\n%s\n", str[i], str[i]);
	}
	return 0;
}

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

using namespace std;

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    cout << fixed << setprecision(10) << 1.0 * (n - (n / 2)) / n << "\n"; 

    return 0;
}

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

using ll = long long;
static const ll MOD = 1e9 + 7;

// 繰り返し自乗法(x^nをmで割った余り) O(logn)
ll power(ll x, ll n, ll m) {
  ll res = 1;
  if (n > 0) {
    res = power(x, n / 2, m);
    if (n % 2 == 0) res = (res * res) % m;
    else res = (((res * res) % m) * x) % m;
  }
  return res;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  ll n;
  cin >> n;
  
  ll ans = power(10, n, MOD);
  ans -= 2 * power(9, n, MOD);
  ans = (ans + MOD * 2) % MOD;
  ans += power(8, n, MOD);
  ans %= MOD;
  
  cout << ans << '\n';
}

Measured memory_bytes: 3644
#include <iostream>
#include <cmath>
#include <cstdio>
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;

int main(){
    ll a,b;
    cin>>a>>b;
    if(a-(b*2)>0){
        cout<<a-(b*2)<<endl;
    }else{
        cout<<0<<endl;
    }
}

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

mt19937 mt(time(nullptr));
// uniform_int_distribution< int > rand_int(0, 10) // rand[0, 10] inclusive

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed;
  ul n;
  cin >> n;
  vector< tuple< ul, ul > > v;
  for (ul i=0; i<n; ++i) {
    ul a, b;
    cin >> a >> b;
    v.push_back(make_tuple(b, a));
  }
  sort(v.begin(), v.end());
  ul working = 0;
  for (ul i=0; i<n; ++i) {
    ul a=get<1>(v[i]), b=get<0>(v[i]);
    working += a;
    if (working > b) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 6512
/*
ID: zhaowei10
TASK:
LANG: C++
*/
#include <algorithm>
#include <array>
#include <climits>
#include <cmath>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

#define pb push_back
#define MOD 1000000007
#define FOR(i, j, k, l) for (s32 i = j; i < k; i += l)
#define RFOR(i, j, k, l) for (s32 i = j; i >= k; i -= l)
#define REP(i, j) FOR(i, 0, j, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define ALL(x) x.begin(), x.end()
#define MEAN(a, b) min(a, b) + (abs(b - a) >> 1)
#define FASTIO()    \
  cin.tie(nullptr); \
  ios::sync_with_stdio(false);

typedef int64_t s64;
typedef uint64_t u64;
typedef int32_t s32;
typedef uint32_t u32;
typedef float f32;
typedef double f64;
typedef pair<s32, s32> II;
typedef pair<s64, s64> LL;
typedef vector<s32> VI;
typedef vector<II> VII;
typedef vector<char> VC;
typedef vector<VII> VVII;
typedef priority_queue<s32> PQI;
typedef priority_queue<s32, VI, greater<s32>> PQIA;
typedef priority_queue<s64> PQL;
typedef priority_queue<II> PQII;
typedef priority_queue<II, VII, greater<II>> PQIIA;
typedef priority_queue<LL> PQLL;
typedef unordered_set<s32> USI;
typedef unordered_set<s64> USL;
typedef set<II> SII;
typedef multiset<s32> MSI;

template <typename T, typename U>
inline void amin(T &x, U y) {
  if (y < x) x = y;
}
template <typename T, typename U>
inline void amax(T &x, U y) {
  if (x < y) x = y;
}

template <typename T>
inline s32 ndigits(T x) {
  s32 r = 0;
  while (x) {
    x /= 10;
    ++r;
  }
  return r;
}

int main() {
  FASTIO();
  string a, b;
  cin >> a >> b;
  cout << b << a;
}

Measured memory_bytes: 888
import sys
input = sys.stdin.readline
import math

MOD = 10**9+7
N = int(input())
F = []
zero_v = 0
inf = 0
zero = 0
for _ in range(N):
  x,y = map(int,input().split())
  if x==0 and y==0:
    zero_v += 1
  elif x==0:
    inf += 1
  elif y==0:
    zero += 1
  else:
    G = math.gcd(abs(x),abs(y))
    F.append((x//G,y//G))

all_keys = set()

for x,y in F:
  if x*y >0:
    if x>0:
      all_keys.add((x,y))
    else:
      all_keys.add((-x,-y))
  x,y = -y,x
  if x*y >0:
    if x>0:
      all_keys.add((x,y))
    else:
      all_keys.add((-x,-y))

all_dic = {k:[0,0] for k in all_keys}

for x,y in F:
  if x*y > 0:
    if x>0:
      all_dic[(x,y)][0] += 1
    else:
      all_dic[(-x,-y)][0] += 1
  else:
    if x>0:
      all_dic[(-y,x)][1] += 1
    else:
      all_dic[(y,-x)][1] += 1

ans = (pow(2,inf,MOD)) + (pow(2,zero,MOD))-1
ans %= MOD

for k in all_keys:
  P,N = all_dic[k]
  ans *= (pow(2,P,MOD)) + (pow(2,N,MOD))-1
  ans %= MOD


ans += zero_v-1

print(ans%MOD)


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

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

    bool ok = false;
    for(int i=1;i<=9;i++){
        for(int j=1;j<=9;j++){
            if(i*j==n) ok = true;
        }
    }
    if(ok) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.lang.*;
public class Main{

public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        StringBuilder sb=new StringBuilder();
       int n=s.nextInt();
       int[] arr=new int[n];
       for(int i=0;i<n;i++){arr[i]=s.nextInt();}
        int[] dp=new int[n];
      dp[1]=Math.abs(arr[1]-arr[0]);
      for(int i=2;i<n;i++){
        dp[i]=Math.min(Math.abs(arr[i]-arr[i-1])+dp[i-1],Math.abs(arr[i]-arr[i-2])+dp[i-2]);
      }
      System.out.println(dp[n-1]);
    }
}
    
  












Measured memory_bytes: 50672
#include <iostream>
#include <vector>
#include <cstring>
#include <queue>
using namespace std;

vector<int> g[205];

bool ok = true;
bool use[205];
int di[205];
vector<int> ans[205];

void dfs(int v, int prev,int d) {
  
  if(use[v]) {
    if((d - di[v]) % 2 == 1) {
      ok = false;
      return;
    }
    return;
  }
  
  use[v] = true;
  di[v] = d;
  for(int i = 0; i < g[v].size(); i++){
    int u = g[v][i];
    if(u == prev) continue;
    dfs(u,v,d+1);
  }
  return;
} 
  

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

  for(int i = 0; i < n; i++) {
      string s;
      cin >> s;
      for(int j = 0; j < s.size(); j++) {
	if(s[j] == '1') {
	  g[i].push_back(j);
	}
      }
  }

  dfs(0,-1,0);

  if(!ok) {
    cout << -1 << endl;
    return 0;
  }

  int a = 0;
  for(int i = 0; i < n; i++) {
 
  for(int j = 0; j < 205; j++) use[j] = false;
  for(int j = 0; j < 205; j++) ans[j].clear();
  use[i] = true;
  ans[0].push_back(i);
  int k = 0;
  while(ans[k].size() != 0) {
    for(int j = 0; j < ans[k].size(); j++) {
      int v = ans[k][j];
      for(int l = 0; l < g[v].size(); l++) {
	int u = g[v][l];
	if(use[u]) continue;
	use[u] = true;
	ans[k+1].push_back(u);
      }
    }
    k++;
    
  }
  a = max(a,k);
  }		      
  cout << a << endl;
}


Measured memory_bytes: 512
N = int(input())
Ds = [int(x) for x in input().split()]
M = int(input())
Ts = [int(x) for x in input().split()]\

ND = {}
for D in Ds:
    if not D in ND:
        ND[D] = 0
    ND[D] += 1
NT = {}
for T in Ts:
    if not T in NT:
        NT[T] = 0
    NT[T] += 1

ans = True
for T in NT.keys():
    if not T in ND:
        ans = False
        break
    if NT[T] > ND[T]:
        ans = False
        break

print("YES" if ans else "NO")


Measured memory_bytes: 56788
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

int main() {
    string s;
    cin >> s;

    ll j = 0;
    rep(i, 9) {
        if("AKIHABARA"[i] == s[j]) {  // AKIHABARAのi文字目とsのj文字目が一致していたら
            j++;  // jを1増やしてsのj+1文字目を調べる
        }
        else if("AKIHABARA"[i] != 'A') {  // AKIHABARAのi文字目とsのj文字目が'A'以外で一致していないならダメ
            out("NO");
            re0;
        }
    }

    if(j == s.size()) {  // sの文字を全て調べていたらok
        out("YES");
    }
    else {  // まだsの文字を全て調べていなかったらダメ
        out("NO");
    }
    
    re0;
}

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

int main()
{
    int n, k;
    cin>>n>>k;
    vector<int> h(n), dp(n,INT_MAX);
    for(auto& x:h) cin>>x;
    dp[0] = 0;
    for(int i=0; i<n; i++)
    {
        for(int j=1; j<=k; j++)
        {
            if( i-j<0 ) break;
            dp[i] = min( dp[i],abs(h[i]-h[i-j])+dp[i-j] );
        }
    }
    cout<<dp[n-1]<<"\n";
}

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

int main()
{
	int k, x;

	cin >> k >> x;
	for (int i = 0; i < k; i++)
	{
		cout << x - k+1+i << " ";
	}
	for (int i = 1; i < k; i++)
	{
		cout << x+i << " ";
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string.h>
#include <iomanip>
#include <math.h>
#include <algorithm>
#include <vector>
#include <map>
#include <tuple>
#include <queue>
using namespace std;

typedef long long ll;

#define INF 100000000;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define eps 1.0e-14;

ll combination(ll n,ll r){
	ll a = 1,b = 1;
	for (int i = n; i > n - r; i--){
		a *= i;
	}
	for (int i = r; i > 0; i--){
		b *= i;
	}
	return (a / b);
}

ll nc2(ll x){
	return (((x) * (x - 1)) / 2);
}

int main(){
	int n; cin >> n;
	map<int, int> mp;
	ll ans = 0;
	int a[200006];
	int b[200006];
	rep(i,n){
		cin >> a[i];
		b[i] = a[i];
	}
	sort(a, a + n);
	int cnt = 1;
	rep(i, n - 1){
		if(a[i] == a[i+1]){
			cnt++;
			if (i == n - 2){
				mp.emplace(make_pair(a[i],cnt));
			}
			continue;
		}else{
			mp.emplace(make_pair(a[i],cnt));
			cnt = 1;
			if (i == n - 2){
				mp.emplace(make_pair(a[i],cnt));
				mp.emplace(make_pair(a[i + 1],1));
			}
		}
	}
	
	for(const auto &value : mp){
		ans += nc2(value.second);
	}

	rep(i,n){
		ll mem = ans;
		//cout << mp[a[i]] << endl;
		ans -= nc2(mp[b[i]]);
		ans += nc2(mp[b[i]] - 1);
		cout << ans << endl;
		ans = mem;
	}
	return 0;
}


Measured memory_bytes: 9856
#include <iostream>

using namespace std;

int main()
{
	int ans_10000 = -1, ans_5000 = -1, ans_1000 = -1;
	int n, y, remain_y;
	cin >> n >> y;

	for (int i = 0; i <= n; i++) {
		for (int j = 0; j <= n - i; j++) {
			if (i * 10000ll + j * 5000ll + (n - i - j) * 1000ll == y) {
				ans_10000 = i;
				ans_5000 = j;
				ans_1000 = n - i - j;
			}
		}
	}

	cout << ans_10000 << " " << ans_5000 << " " << ans_1000 << endl;


    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
typedef long long ll;
int main()
{
  ll l,r;cin >> l >> r;
  if(r-l>=2018) cout << 0 << "\n";
  else{
    ll in=3000;
    for(ll i=l;i<=r;++i)
      for(ll j=l;j<=r;++j){
	if(i==j) continue;
	in = min(in,(i*j)%2019);
      }
    cout << in << "\n";
  }

  return 0;
}


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

#include <atcoder/dsu>
#include <boost/range/adaptors.hpp>
#include <boost/range/combine.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

int main() {
    int64_t n, q;
    cin >> n >> q;

    atcoder::dsu d(n);

    for (auto _ : irange(0L, q)) {
        int64_t t, u, v;
        cin >> t >> u >> v;

        if (t == 0) {
            d.merge(u, v);
        } else {
            cout << (int)d.same(u, v) << endl;
        }
    }
}

Measured memory_bytes: 3944
#include <bits/stdc++.h>
using namespace std;
int main(){
    int A, B, Price;
    cin >> A >> B;
    if(A < 13 && A > 5)
        Price = B/2;
    else if(A >= 13)
         {
              Price = B;
         }
    else if(A <= 5)
         Price = 0;
    cout << Price << endl;}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <map>
#include <cmath>
#include <vector>
#include <queue>
#pragma GCC optimize(2)
using namespace std;
typedef long long LL;
const LL N = 30005;

LL h,n,ans;
LL a[30005],b[30005];
LL dp[300005];

int main(){
	ios::sync_with_stdio(false);
	memset(dp,0x3f,sizeof(dp)); dp[0] = 0;
	cin >> h >> n;
	for(LL i = 1;i <= n;i ++) cin >> a[i] >> b[i];
	for(LL i = 1;i <= N;i ++){
		for(LL j = 1;j <= n;j ++){
			if(i >= a[j]) dp[i] = min(dp[i],dp[i - a[j]] + b[j]);
		}
	}
	ans = dp[h];
	for(LL i = h;i <= N;i ++) ans = min(ans,dp[i]);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2688
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vec;
typedef vector<vec> mat;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define revrep(i, n) for(ll i = (n)-1; i >= 0; i--)
#define pb push_back
#define f first
#define s second
ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}
ll max3(ll a, ll b, ll c){return max(a, max(b, c));};
ll min3(ll a, ll b, ll c){return min(a, min(b, c));};
ll max4(ll a, ll b, ll c, ll d){return max(max(a, b), min(c, d));};
ll min4(ll a, ll b, ll c, ll d){return min(min(a, b), min(c, d));};
ll max5(ll a, ll b, ll c, ll d, ll e){return max(max(a, b), max3(c, d, e));};
ll min5(ll a, ll b, ll c, ll d, ll e){return min(min(a, b), min3(c, d, e));};

const ll INFL = 1LL << 60;//10^18 = 2^60
const int INF = 1 << 30;//10^9
ll MOD = 1000000007;
//ll MOD = 998244353;

vector<ll> dy = {0, 0, 1, -1, 1, 1, -1, -1, 0};
vector<ll> dx = {1, -1, 0, 0, 1, -1, 1, -1, 0};


ll pow_long(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x;
    k /= 2;
  }
  return res;
}
ll pow_mod(ll x, ll k){
  x %= MOD; x += MOD; x %= MOD;
  ll res = 1;
  while(k > 0){
    if(k % 2){
      res *= x; res %= MOD;
    }
    x *= x; x %= MOD;
    k /= 2;
  }
  return res;
}

ll inverse(ll x){return pow_mod(x, MOD - 2);};

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

ll lcm(ll x, ll y){return x / gcd(x, y) * y;};

ll kai_mod(ll x){
  if(x == 0) return 1;
  return x * kai_mod(x-1) % MOD;
}

/*
//コンビネーション
const int MAXcomb = 200010;
ll fac[MAXcomb], finv[MAXcomb], inv[MAXcomb];
//facはn!,finvは1/n!
//invは逆元
void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAXcomb; i++){
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
ll comb(int n, int k){
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * finv[k] % MOD * finv[n-k] % MOD;
}
*/

int main(){
  ll N;
  string S;
  cin >> N >> S;
  ll Q;
  cin >> Q;
  rep(query, Q){
    ll k;
    cin >> k;
    ll ans = 0;
    ll M = 0, C = 0, num = 0;

    rep(i, k){
      if(S[i] == 'M') M++;
      else if(S[i] == 'C'){
        C++;
        num += M;
      }
    }

    rep(i, N-k+1){
      if(S[i] == 'D') ans += num;
      else if(S[i] == 'M'){
        num -= C;
        M--;
      }else if(S[i] == 'C'){
        C--;
      }
      if(S[i+k] == 'M') M++;
      else if(S[i+k] == 'C'){
        C++;
        num += M;
      }
    }

    for(ll i = N-k+1; i < N; i++){
      if(S[i] == 'D') ans += num;
      else if(S[i] == 'M'){
        num -= C;
        M--;
      }else if(S[i] == 'C'){
        C--;
      }
    }
    cout << ans << endl;
  }
}


Measured memory_bytes: 1412
#[allow(unused_imports)]
use {
    proconio::{fastout, input, marker::*},
    std::ops::*,
    std::cmp::*,
    std::collections::*,
};

#[fastout]
fn main() {
    input! {
        n: usize,
        a: [usize; n]
    }
    let mut ans = 0;
    let mut now = a[0];
    for i in 1..n {
        if a[i] < now {
            ans += now - a[i];
        } else {
            now = a[i];
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 5588
#include <iostream>
using namespace std;
typedef long long ll;
int main(void){
    ll n,ans;
    cin >> n;
    if(n==0) ans = 1;
    else if(n==1) ans = 2;
    else if(n==2) ans = 1;
    else ans = 0;
    cout << ans << endl;
}



Measured memory_bytes: 3076