akhauriyash/Code-Regression huggingface dataset:
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <string>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
using namespace std;
struct edge { int to, cost; };
typedef vector<vector<edge>> AdjList;
AdjList graph;
typedef pair<int, int> P;
const int INF = 10000000;
vector<int> dist;
vector<int> prever;
int idx[100][100];
void dijkstra(int n, int s) {
	dist = vector<int>(n, INF);
	prever = vector<int>(n, -1);
	dist[s] = 0;
	priority_queue<P, vector<P>, greater<P>> que;
	que.push(P(0, s));
	while (!que.empty()) {
		P p = que.top();
		que.pop();
		int v = p.second;
		if (dist[v] < p.first) {
			continue;
		}
		for (int i = 0; i < graph[v].size(); i++) {
			edge e = graph[v][i];
			if (dist[e.to] > dist[v] + e.cost) {
				dist[e.to] = dist[v] + e.cost;
				prever[e.to] = v;
				que.push(P(dist[e.to], e.to));
			}
		}
	}
}
vector<int> get_path(int t) {
	vector<int> path;
	for (; t != -1; t = prever[t]) {
		path.push_back(t);
	}
	reverse(path.begin(), path.end());
	return path;
}
int main(void) {
	int N, M;
	cin >> N >> M;
	graph = AdjList(N);
	bool used[1000];
	for (int i = 0; i < M; i++) {
		int a, b, c;
		cin >> a >> b >> c;
		a--; b--;
		graph[a].push_back({ b, c });
		graph[b].push_back({ a, c });
		used[i] = false;
		idx[a][b] = i;
		idx[b][a] = i;
	}
	for (int i = 0; i < N; i++) {
		dijkstra(N, i);
		for (int j = 0; j < N; j++) {
			vector<int> ans = get_path(j);
			for (int k = 0; k < ans.size() - 1; k++) {
				used[idx[ans[k]][ans[k + 1]]] = true;
				
			}
		}
	}
	int result = 0;
	for (int i = 0; i < M; i++) {
		if (!used[i]) {
			result++;
		}
	}
	cout << result << endl;
	return 0;
}


Measured memory_bytes: 384
N,M,C = map(int, input().split())
B = list(map(int,input().split()))
count = 0
for i in range(N):
  A = list(map(int,input().split()))
  sum = 0
  for j in range(M):
    sum += A[j]*B[j]
  sum += C
  if sum > 0:
    count += 1
print(count)

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

#define debug(x) cerr << #x << " = " << x << endl;
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define FOR(it, b, e) for (typeof(b) it = (b); it != (e); ++it)
#define MSET(c, v) memset(c, v, sizeof(c))

const int INF = 0x3F3F3F3F; 
const int NEGINF = 0xC0C0C0C0;
const int NULO = -1;
const ll mod = 1e9 + 7;
const double EPS = 1e-10;

inline int cmp(double x, double y = 0) 
{  
  if(fabs(x - y) < EPS)
    return 0;
  return x > y ? 1 : -1;
}

ll exp(ll a, ll b)
{
  ll ans = 1;
  while(b)
  {
    if(b & 1)
      ans = (ans * a) % mod;
    a = (a * a) % mod;
    b >>= 1;
  }
  return ans;
}

const int maxn = 2e5 + 10;

int a[maxn], v[maxn];

int main()
{
  ios::sync_with_stdio(0);
  int n;
  cin >> n;
  
  for(int i = 1 ; i <= n ; i++)
  {
    cin >> a[i];
  } 
  vector<int>ans;
  for(int i = n ; i >= 1 ; i--)
  {
    int sum = 0;
    for(int j = i; j <= n; j += i)
      sum += v[j];
    if(sum % 2 != a[i])
    {
      v[i] = 1;
      sum++;
    }
    if(v[i])
      ans.push_back(i);
  }
  cout << ans.size() << endl;
  for(const auto &c : ans)
    cout << c << ' ';
  cout << endl;

  return 0;
}

Measured memory_bytes: 5236
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define FORL(i,x) for(int i=head[x];i;i=nxt[i])
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define PB push_back
#define MP make_pair
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }



int main() {
  int N,M;
  scanf("%d%d", &N,&M);
  
  cout << (1900*M+100*(N-M))*pow(2,M) << endl;

}



Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
import collections
import copy
import heapq
from collections import defaultdict
from heapq import heappop, heappush
import random
input = sys.stdin.readline

##### リストの 二分木検索 #####
# bisect_left(lists, 3)
# bisect_right(lists, 3)

##### プライオリティキュー #####
# heapq.heapify(a) #リストaのheap化
# heapq.heappush(a,x) #heap化されたリストaに要素xを追加
# heapq.heappop(a) #heap化されたリストaから最小値を削除＆その最小値を出力

# heapq.heappush(a, -x) #最大値を取り出す時は、pushする時にマイナスにして入れよう
# heapq.heappop(a) * (-1) #取り出す時は、-1を掛けて取り出すこと

##### タプルリストのソート #####
# sorted(ans) #(a, b) -> 1st : aの昇順, 2nd : bの昇順
# sorted(SP, key=lambda x:(x[0],-x[1])) #(a, b) -> 1st : aの昇順, 2nd : bの降順
# sorted(SP, key=lambda x:(-x[0],x[1])) #(a, b) -> 1st : aの降順, 2nd : bの昇順
# sorted(SP, key=lambda x:(-x[0],-x[1])) #(a, b) -> 1st : aの降順, 2nd : bの降順

# sorted(SP, key=lambda x:(x[1])) #(a, b) -> 1st : bの昇順
# sorted(SP, key=lambda x:(-x[1])) #(a, b) -> 1st : bの降順

def main():

	#N = int(input())
	N, X = map(int, input().split(" "))
	L = list(map(int, input().split(" ")))

	ans = 1
	to = 0

	for i in L:
		to += i
		if to > X:
			break
		ans += 1

	print(ans)



if __name__ == "__main__":
	main()

Measured memory_bytes: 4848
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <list>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define sz(x) int(x.size())

typedef long long ll;

using namespace std;

/*******-c++14 don't include-*******/
template<typename T>
T gcd(T a, T b){if( b == 0)return a; return gcd(b, a%b); }
template<typename T>
T lcm(T a, T b){return a*b/gcd(a,b); }
/*******---------------------*******/

static const int INTINF = (2147483647);
static const ll LLINF = (1ll<<32);
static const int MAX = 100001;

int main(int argc, const char * argv[]) {
    // input from txt
    
    /////////
    //write//
    /////////
    
    string str;
    cin >> str;
    stack<int> s;
    
    ll res = 0;
    rep(i, str.length()){
        int u = str[i]-'0';
        if(!s.empty()){
        int top = s.top();
            if(top != u){
                s.pop();
                res += 2;
            }
            else s.push(u);
        }
        else s.push(u);
    }
    
    cout << res << endl;
    
    return 0;
}


Measured memory_bytes: 768
// qdd on Jan 19, 2019

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

const int MAXN = 1e5 + 7;

int a[MAXN];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    sort(a, a + n);
    int ans = INT_MAX;
    for (int i = 0; i + k <= n; i++) {
        ans = min(ans, a[i + k - 1] - a[i]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 640
# coding: utf-8
import sys
#from operator import itemgetter
sysread = sys.stdin.buffer.readline
read = sys.stdin.buffer.read
#from heapq import heappop, heappush
#from collections import defaultdict
sys.setrecursionlimit(10**7)
import math
#from itertools import product, accumulate, combinations, product
#import bisect
import numpy as np
#from copy import deepcopy
#from collections import deque
#from decimal import Decimal
#from numba import jit

INF = 1 << 50

def fill(h, H, W, S, MAP, marker):
    if not '#' in S[h]:
        return MAP, marker
    idxes = [i for i, s in enumerate(S[h]) if s == '#']
    upper = h
    for hh in range(h-1, 0 , -1):
        if MAP[hh][idxes[0]] == 0:
            upper = hh
        else:
            break
    down = h

    for hh in range(h+1, H+1):
        if '#' in S[hh]:
            break
        else:
            down = hh
    left = 1
    for idx in idxes:
        MAP[upper:down+1, left:idx+1] = marker
        marker += 1
        left = idx+1
    MAP[upper:down+1, left:W+1] = marker-1
    return MAP, marker



def run():
    H, W, K = map(int, input().split())
    S = ['0' * (W+2)]
    up = INF
    down = 0
    for i in range(1,H+1):
        s = input()
        if '#' in s:
            down = i
            if up == INF:
                up = i

        s = '0' + s + '0'
        S.append(s)
    S.append('0' * (W+2))
    #for s in S:
    #    print(s)

    MAP = np.zeros((H+2, W+2), dtype = np.int32)

    marker = 1
    for h in range(1, H+1):
        #print(h)
        MAP, marker = fill(h, H,W, S, MAP, marker)
        #print(MAP)


    for h in range(1, H+1):
        ans = [str(s) for s in MAP[h, 1:W+1]]
        print(' '.join(ans))

    #print(MAP)

if __name__ == "__main__":
    run()

Measured memory_bytes: 27516
#include <iostream>
#include <algorithm>
#include <vector>
#include <functional>
#include <sstream>
#include <cstdio>
#include <stack>
using namespace std;

// Sum of Integers(0030)
int n, s;

int solve(int i, int sum, int c)
{
	if (c == n) {
		if (sum == s)
			return 1;
		return 0;
	}

	if (i > 9)
		return 0;

	return solve(i+1, sum+i, c+1) + solve(i+1, sum, c);
}

int main()
{
	while (cin >> n >> s) {
		if (n == 0 && s == 0)
			break;
		cout << solve(0, 0, 0) << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define all(a) (a).begin(), (a).end()
 
 
int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  cout << min(A, B) + min(C, D) << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <sstream>
#include <string.h>
#include <vector>
#include <map>
#include <algorithm>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <limits>
#include <iomanip>
#include <ctype.h>
#define _USE_MATH_DEFINES
#include <iostream>
#include <math.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, char> pic;
#define bit(x,v) ((ll)x << v)

const ll INF = 1000000007;
const int MAX = 210000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; 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;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
int pr[100010];
void uini(int n) {
	for (size_t i = 0; i <= n; i++)
	{
		pr[i] = i;
	}
}

int parent(int x) {
	if (x == pr[x]) return x;
	return pr[x] = parent(pr[x]);
}

bool unit(int x, int y) {
	int px = parent(x);
	int py = parent(y);

	if (px == py) return false;
	if (px < py) {
		pr[py] = px;
	}
	else {
		pr[px] = py;
	}
	return true;
}

ll bit[200010];
int max_n = 200000;
int pm = 0;
void add(int x) {

	while (max_n >= x)
	{
		bit[x]++;
		x += x & -x;
	}
}
void sub(int x) {
	while (max_n >= x)
	{
		bit[x]--;
		x += x & -x;
	}
}
ll merge(ll *a, int left, int mid, int right) {
	ll n1 = mid - left;
	ll n2 = right - mid;
	vector<int> L(n1 + 1);
	vector<int> R(n2 + 1);
	for (size_t i = 0; i < n1; i++)
	{
		L[i] = a[left + i];
	}
	for (size_t i = 0; i < n2; i++)
	{
		R[i] = a[mid + i];
	}

	L[n1] = INF;
	R[n2] = INF;
	ll i = 0;
	ll j = 0;
	ll r = 0;
	for (size_t k = left; k < right; k++)
	{
		if (L[i] <= R[j]) {
			a[k] = L[i];
			i++;
		}
		else {
			a[k] = R[j];
			r += n1 - i;
			j++;
		}
	}
	return r;
}
ll mergeSort(ll *a, int left, int right) {
	ll res = 0;
	if (left + 1 < right) {
		int mid = (left + right) / 2;
		res = mergeSort(a, left, mid);
		res += mergeSort(a, mid, right);
		res += merge(a, left, mid, right);
	}
	return res;
}
int partition(int *a, int p, int r) {
	int x = a[r];
	int i = p - 1;
	for (size_t j = p; j < r; j++)
	{
		if (a[j] <= x) {
			i++;
			swap(a[i], a[j]);
		}
	}
	swap(a[i + 1], a[r]);
	return i + 1;
}
void solv() {
	int n;
	cin >> n;
	int a[100010];
	for (size_t i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	int x = partition(a, 0, n - 1);
	for (size_t i = 0; i < n; i++)
	{
		if (i > 0) cout << " ";
		if (x == i) {
			cout << "[" << a[i] << "]";
		}
		else cout << a[i];
	}
	cout << endl;
}
int main() {
	//	COMinit();
	solv();
	return 0;
}



Measured memory_bytes: 3472
#include <bits/stdc++.h>
#define rep(i,x,n) for(int i=x; i<(int)(n); i++)
#define rep_eq(i,x,n) for(int i=x; i<=(int)(n); i++)
using namespace std;

using ll=long long;

int main() {
  int N; cin >>N;
  int ans=0;
  if (N%1000!=0) ans=1000-N%1000;
  cout <<ans <<endl;
  return 0;
}


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

int main(){
  int N;cin>>N;
  N%=10;
  if(N==3) cout<<"bon"<<endl;
  else if(N==0 || N==1 || N==6 || N==8) cout<<"pon"<<endl;
  else cout<<"hon"<<endl;
}

Measured memory_bytes: 3648
#include <algorithm>
#include <iostream>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

int main(int argc, char const *argv[]) {
  int n;
  cin >> n;
  int a[n], b[n];
  rep(i, n) {
    cin >> a[i];
    b[i] = a[i];
  }
  sort(b, b + n);
  int count = 0;
  rep(i, n) if (a[i] != b[i]) count++;
  if (count <= 2)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}


Measured memory_bytes: 256
function stack(A) {
  let arr = [];
  for (let i = 0; i < A.length; i++) {
    let v = A[i];
    if (v == "+") {
      arr.push(arr.pop() + arr.pop());
      continue;
    }
    if (v == "-") {
      arr.push(-1 * arr.pop() + arr.pop());
      continue;
    }
    if (v == "*") {
      arr.push(arr.pop() * arr.pop());
      continue;
    }
    arr.push(Number(v));
  }
  console.log(Number(arr));
}
const lines = require("fs").readFileSync("/dev/stdin", "utf8").split("\n");
const ary = lines[0].split(" ");
stack(ary);




Measured memory_bytes: 15388
#include<stdio.h>
int main(){
    int N,x;
    scanf("%d",&N);
    if(400<=N && N<600){
        x = 8;
    }else if(600<=N && N<800){
        x = 7;
    }else if(800<=N && N<1000){
        x = 6;
    }else if(1000<=N && N<1200){
        x = 5;
    }else if(1200<=N && N<1400){
        x = 4;
    }else if(1400<=N && N<1600){
        x = 3;
    }else if(1600<=N && N<1800){
        x = 2;
    }else if(1800<=N && N<2000){
        x = 1;
    }
    printf("%d\n",x);
    return 0;
}

Measured memory_bytes: 1732
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int N = scanner.nextInt();
        int K = scanner.nextInt();

        long[] H = new long[N];

        for (int i = 0 ; i < N ; i++) {
            H[i] = scanner.nextLong();
        }

        Arrays.sort(H);

        long total = 0L;
        for (int i = 0 ; i < N - K ; i++) {
            total += H[i];
        }

        System.out.println(total);
    }
}


Measured memory_bytes: 61616
#include <bits/stdc++.h>
 
#define ll          long long
#define ld          long double
#define pb          push_back
#define pf          push_front
#define mp          make_pair
#define pll         pair<ll,ll>
#define vl          vector<ll>
#define sl          set<ll> 
#define vll         vector<pll>
#define ml          map<ll,ll>
#define mll         map<pll,ll>
#define all(a)      a.begin(),a.end()
#define x           first
#define y           second
#define sz(x)       (ll)x.size()
#define dl          '\n'
#define mod         (ll)1000000007
#define lp(i,a,b)   for(ll i=a;i<b;++i)
#define lpr(i,a,b)  for(ll i=a;i>=b;i--)
#define lpd(i,x)    for(auto i:x)
#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
ll inf = (ll)1e18;
ld pi = 3.141592653589;
using namespace std;

ll bpow(ll x, ll v) {   
    if (v == 0)
        return 1 % mod;
    if (v % 2 == 1)
        return (x * bpow(x, v - 1)) % mod;
    ll r = bpow(x, v / 2);
    return (r * r) % mod;   
}

ll solve(){ 
    string a; cin>>a;
    deque<char> d;
    lp(i,0,sz(a)) d.pb(a[i]);
    ll q,i=0,c=0; cin>>q;
    while(q--){
        ll p; cin>>p;
        if(p == 2){
            ll f; cin>>f;
            char g; cin>>g;
            if(c%2 and f==1) d.pb(g);
            else if(c%2) d.pf(g);
            if(c%2==0 and f==1) d.pf(g);
            else if(c%2==0) d.pb(g); 
        }
        else c++;
    }
    if(c%2)
    {
        for(auto i = d.rbegin();i!=d.rend();i++)
            cout<<*i;
    }
    else {
        lpd(i,d) cout<<i;
    }
}

int main(){
    ios
    ll t=1; 
    //cin>>t;
    while(t--){
        solve();
    }
}

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

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> v(n);
  for (int i = 0; i < n; i++) {
    cin >> v.at(i);
  }
  
  sort(v.begin(), v.end());
  
  
  int a = 0;
  
  for (int i = 0; i < k; i ++) {
    a += v.at(i);
  }
  
  cout << a << endl;

}

Measured memory_bytes: 3632
import sys
import math
import itertools

n=int(input())
t,a=list(map(int,input().split()))
h=list(map(int,input().split()))
min = 100000
ans = 0
for i in range(n):
    temp = t - (h[i] * 0.006)
    if min > abs(a - temp):
        min = abs(a - temp)
        ans = i
print(ans + 1)

Measured memory_bytes: 3188
S = input()
l = len(S)
p = [0] * l

i = 0
while i < l - 1:
    si = i
    while S[i] == 'R':
        i += 1

    d = (i - si) // 2
    p[i - 1] += d
    p[i] += d
    if (i - si) & 1:
        p[i - 1] += 1

    i += 1
i = l - 1
while i > 0:
    si = i
    while S[i] == 'L':
        i -= 1
    d = (si - i) // 2
    p[i + 1] += d
    p[i] += d
    if (i - si) & 1:
        p[i + 1] += 1

    i -= 1

print(' '.join(map(str, p)))

Measured memory_bytes: 52848
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <time.h>
#include <cstdlib>
#include <cmath>
#include <fstream>
#include <iomanip>
using namespace std;

int main() {
    int n;
    int data[1000] = {0};
    double avg, total;
    while (1) {
        cin >> n;
        if (n == 0) break;
        total = 0;
        for (int i = 0; i < n; i++) {
            cin >> data[i];
            total += data[i];
        }
        avg = total / n * 1.0;
        total = 0;
        for (int j = 0; j < n; j++) {
            total += pow(data[j] - avg, 2.0) / n * 1.0;
        }
        printf("%.10f\n", sqrt(total));
    }
    return 0;
}

Measured memory_bytes: 3208
#include <bits/stdc++.h>
using namespace std;
#define rep(i,ini,n) for(int i=ini;i<n;i++)
#define _rep(i,ini,n) for(int i=ini;i>=n;i--)
#define ToEnd(a) a.begin(),a.end()
uint64_t MOD=1000000007;

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

    string Q="keyence";
    int fidx,lidx;

    int idx=0;
    rep(i,0,S.size()){
        fidx=i;
        if(i>=Q.size() || S.at(i)!=Q.at(i)) break;
    }

    idx=Q.size()-1;
    _rep(i,S.size()-1,0){
        lidx=i;
        int qidx=i-(S.size()-Q.size());
        if(qidx<0 || S.at(i)!=Q.at(qidx)) break;
    }

    string ans="YES";
    if(lidx>=fidx && Q!=S.erase(fidx,lidx-fidx+1)) ans="NO";
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int64_t MOD=1000000007;
const long long INF = 1LL<<60;

int main() {
  int N,X,Y; cin>>N>>X>>Y;
  vector<int64_t> A(N,0);
  for(int i=1;i<N;i++){
    for(int j=i+1;j<=N;j++){
      auto k=min(j-i,min(abs(i-X)+abs(j-Y)+1,abs(i-Y)+abs(j-X)+1));
      A.at(k)++;
    }
  }
  rep(i,N-1){
    cout<<A.at(i+1)<<endl;
  }
}


Measured memory_bytes: 3636
k = int(input())

l = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(l[k-1])


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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;

#define INF (1LL << 60)
#define MOD 1000000007

#define REP(i,m,n) for(ll (i)=(m),i_len=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define pb push_back

mat permutation(vec A)
{
    mat X;
    ll c = 0;
    queue<pair<vec,vec>> Q;
    Q.push({{},A});
    while(!Q.empty()) {
        auto p = Q.front(); Q.pop();
        vec U = p.first, V = p.second;
        if(SZ(V) == 0) X.pb(U);
        else {
            REP(i,0,SZ(V)) {
                U.pb(V[i]);
                vec _V;
                REP(j,0,SZ(V)) {
                    if(i != j) _V.pb(V[j]);
                }
                Q.push({U, _V});
                U.pop_back();
            }
        }
    }
    return X;
}


int main()
{
    ll N;
    cin >> N;
    vec P(N), Q(N);
    REP(i,0,N) cin >> P[i];
    REP(i,0,N) cin >> Q[i];

    vec R(N);
    REP(i,0,N) R[i] = i + 1;
    
    mat X = permutation(R);
    ll a, b, c = 1;
    FORR(V,X) {
        if(P == V) a = c;
        if(Q == V) b = c;
        ++c;  
    }
    PR(abs(a-b));

    return 0;
}

/*



*/

Measured memory_bytes: 7736
#include "bits/stdc++.h"
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 REP(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) std::cout << x << '\n'
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define sz(x) ((int)(x).size())
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INF = (int)1e9;
const ll  inf = (ll)1e18;
const int mod = 1000000007;
const int MAX_N = 100010;
const double PI = acos(-1);

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

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

	//dp[i][h]:i種類の魔法でhダメージ与える消費魔力の最小値
	vector<vector<ll>> dp(n + 1, vector<ll>(h + 1, INF));
	dp[0][0] = 0;

	for (int i = 0; i < n; i++) {
		for (int j = 0; j <= h; j++) {
			//魔法を使わないとき
			chmin(dp[i + 1][j], dp[i][j]);

			//魔法を使うとき
			chmin(dp[i + 1][min(j + a[i], h)]
				, dp[i + 1][j] + b[i]);
		}
	}

	out(dp[n][h]);

	return 0;
}

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

using lli = int64_t;
using vi = vector<lli>;
using vvi = vector<vi>;

void dfs(vvi& g, vi& col, lli n, lli m, lli k, lli c)
{
    if(col[k] > -1)
    {
        if(col[k] != c)
        {
            lli ans = n * (n - 1) / 2 - m;
            cout << ans << endl;
            exit(0);
        }

        return;
    }

    col[k] = c;

    for(auto x : g[k])
        dfs(g, col, n, m, x, !c);
}

int main()
{
    ios_base::sync_with_stdio(0);

    lli n, m; cin >> n >> m;

    vvi g(n + 1);

    for(int i = 0; i < m; i++)
    {
        int a, b; cin >> a >> b;

        g[a].push_back(b);
        g[b].push_back(a);
    }

    vi col(n + 1, -1);

    dfs(g, col, n, m, 1, 0);

    vi a(2);

    for(int i = 1; i <= n; i++)
    {
        assert(col[i] > -1);

        a[col[i]]++;
    }

    lli ans = a[0] * a[1] - m;

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

Measured memory_bytes: 7680
#include<stdio.h>
int main(void)
{
    int N, K, P, b, i;
	
	scanf("%d",&N);
	for(i=0;i<N;i++){
	    scanf("%d",&K);
	    scanf("%d",&P);
		b=K%P;
	if (b==0){
	   b=P;
	}
	printf("%d\n",b);
	}
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+5;
int n,m,ans=0,father[N],sum[N];
int Findfather(int x){
    return father[x]==x?x:father[x]=Findfather(father[x]);
}

void Union(int x,int y){
    x=Findfather(x),y=Findfather(y);
    if(x!=y) father[y]=x,sum[x]+=sum[y];
}

void init(){
    for(int i=0;i<=n;i++)
        father[i]=i,sum[i]=1;
}

int main(){
    cin>>n>>m;
    init();
    while(m--){
        int u,v;
        cin>>u>>v;
        Union(u,v);
    }
    for(int i=1;i<=n;i++) if(Findfather(i)==i) ans=max(ans,sum[i]);
    cout<<ans;
}


Measured memory_bytes: 5436
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>

using ll = long long;

using namespace std;

int main() {
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    while (a >= b) {
        b <<= 1;
        k--;
    }
    while (b >= c) {
        c <<= 1;
        k--;
    }
    cout << (k >= 0 ? "Yes" : "No") << '\n';
    return 0;
}

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

int main() {
	int n;
	cin >> n;
	for (int i = 0; i <= n / 4; i++) {
		if ((n - (4*i)) % 7 == 0) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n , a[101] , b = 0 , c = 0;
    cin >> n;
    for ( int i = 0 ; i < n ; i++ ) {
        cin >> a[i];
        b += a[i];
    }
    b = round( 1.0 * b / n );
    for ( int i = 0 ; i < n ; i++ ) c += ( a[i] - b ) * ( a[i] - b );
    cout << c << endl;
}






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

int main()
{
	int n, m;
	while (cin >> n >> m, n | m) {
		vector<int> a(n);
		for (int i = 0; i < n; i++) {
			cin >> a[i];
		}
		int res = -1;
		for (int i = 0; i < n; i++) {
			for (int j = i + 1; j < n; j++) {
				if (a[i] + a[j] <= m) {
					res = max(res, a[i] + a[j]);
				}
			}
		}
		if (res == -1) puts("NONE");
		else printf("%d\n", res);
	}
	return 0;
}



Measured memory_bytes: 3132
def main():
    import sys
    readline = sys.stdin.readline
    # readlines = sys.stdin.readlines
    H, N = map(int, input().split())
    M = [tuple(map(int, readline().split())) for _ in range(N)]
    INF = float('inf')
    dp = [INF] * (H + 1)
    dp[0] = 0
    
    for i in range(N):
        a, b = M[i]
        for j in range(H):
            nj = min(H, j + a)
            dp[nj] = min(dp[nj], dp[j] + b)

    print(dp[H])


if __name__ == "__main__":
    main()


Measured memory_bytes: 46172
#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <cmath>
#include <string>
#include <unordered_map>


int main (void) {
  int N, M; std::cin >> N >> M;
  std::vector<std::pair<int,int>> P(M);

  for(int i=0; i<M; i++){
    std::cin >> P[i].first >> P[i].second;
  }

  std::sort(P.begin(), P.end(),
      [](std::pair<int,int> x, std::pair<int,int> y) {return x.second < y.second;} );


  std::list<int> tmp; tmp.push_back(P[0].second-1);
  for(int i=1; i<M; i++){
    if ( P[i].first <= tmp.back() && tmp.back() < P[i].second ) {
    }
    else {
      tmp.push_back(P[i].second-1);
    }
  }

  std::cout << tmp.size() << std::endl;
  return 0;
}

Measured memory_bytes: 1024
A, B, C=map(int, input().split())
# A=好きな曲を聴くための費用
# B=所持金
# C=満足するのに必要な回数

if A*C<=B:
  print(C)
else:
    if A*C>B:
        print(B//A)
    else:
        print("0")


Measured memory_bytes: 2940
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
typedef pair<ll, ll> PLL;
typedef vector<int> VI;
typedef vector<char> VC;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<ll> VLL;
typedef vector<PLL> VP;
const static int INF = 1000000000;
const static int MOD = 1000000007;
const int dx[4]={1, 0, -1, 0};
const int dy[4]={0, 1, 0, -1};
#define rep(i,n) for (ll i=0; i<(ll)(n); i++)
#define repd(i,n) for (ll i=n-1; i>=0; i--)
#define rept(i,m,n) for(ll i=m; i<n; i++)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define PF push_front
#define PB push_back
#define SORT(V) sort((V).begin(), (V).end())
#define RVERSE(V) reverse((V).begin(), (V).end())
#define paired make_pair
#define PRINT(V) for(auto v : (V)) cout << v << " "
//charを整数に
int ctoi(char c) { if (c >= '0' && c <= '9') { return c - '0'; } return 0; }
// 累積和 for (int i = 0; i < N; ++i) s[i+1] = s[i] + a[i]; 
void cum_sum(int N,vector<double> a, vector<double> &s){ for(int i=0; i<N; i++){ s[i+1]=s[i]+a[i];}}
//ユークリッドの控除法
ll gcd(ll a,ll b){
    if(b == 0) return a;
    return gcd(b,a%b);
}
//最小公倍数
ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b; // Be careful not to overflow
}
//素数判定
bool is_prime(long long n) {
    if (n <= 1) return false;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p == 0) return false;
    }
    return true;
}
int getdigit(ll num){
    unsigned digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}
//空白文字も入力 getline(cin, S);
//桁数指定 setprecision
ll N;
int ans=0;
void dfs(ll x, int a, int b, int c){
    if(x>N){
        return;
    }
    if(a&b&c) ans++;
    dfs(10*x+3,1,b,c);
    dfs(10*x+5,a,1,c);
    dfs(10*x+7,a,b,1);
}
int main()
{
    cin >> N;
    dfs(0,0,0,0);
    cout << ans << endl;
}

Measured memory_bytes: 256
K = int(input())
N=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(N[K-1])

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>

using ll = long long;

int main() {
    ll n, m;
    std::cin >> n >> m;
    std::vector<std::pair<ll, ll>> vec;
    for (ll i = 0; i < n; i++) {
        ll a, b;
        std::cin >> a >> b;
        vec.push_back(std::make_pair(a, b));
    }
    std::sort(vec.begin(), vec.end());
    ll accumulator = 0;
    ll price = 0;
    for (ll i = 0; i < n; i++) {
        if (accumulator + vec[i].second <= m) {
            accumulator += vec[i].second;
            price += (vec[i].first * vec[i].second);
        }
        else if (accumulator + vec[i].second > m) {
            ll need_num = m - accumulator;
            accumulator += need_num;
            price += (vec[i].first * need_num);
        }
        if (accumulator == m) {
            std::cout << price << std::endl;
            return 0;
        }

    }
}


Measured memory_bytes: 2420
#include<iostream>
#include<cstdio>
using namespace std;
const int p=131;
int hashr[333],hashc[333],n,pw[333],ans;
char c[333][333];
bool check()
{
	for (int i=1;i<=n;i++)
	{
		if (hashr[i]!=hashc[i]) return 0;
	}
	return 1;
}
int main()
{
	scanf("%d",&n);
	pw[0]=1;
	for (int i=1;i<=n;i++) pw[i]=pw[i-1]*p;
	for (int i=1;i<=n;i++)
	{
		getchar();
		for (int j=1;j<=n;j++)
		scanf("%c",&c[i][j]);
	}
	for (int i=1;i<=n;i++)
	{
		for (int j=1;j<=n;j++)
		{
			hashr[i]=hashr[i]*p+c[i][j];
		}
		for (int j=1;j<=n;j++)
		{
			hashc[i]=hashc[i]*p+c[j][i];
		}
	}
	for (int i=1;i<=n;i++)
	{
		for (int j=1;j<=n;j++)
		{
			if (check()) ans++;
			for (int k=1;k<=n;k++)
			{
				hashr[k]=(hashr[k]-pw[n-1]*c[k][j])*p+c[k][j];
			}
			int t=hashc[1];
			for (int k=1;k<n;k++) hashc[k]=hashc[k+1];
			hashc[n]=t;
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 384
from collections import defaultdict

def gen(N, S, W):
    g = S
    for i in range(N):
        yield (g//7) % 10
        if g % 2 == 0:
            g //= 2
        else:
            g = (g//2) ^ W

def solve():
    N, S, W, Q = map(int, input().split())
    if N == 0:
        return False
    bs = list(gen(N, S, W))
    ans = 0
    if Q == 2 or Q == 5:
        cnt = 0
        for i in range(N):
            b = bs[i]
            if b != 0:
                cnt += 1
            if b % Q == 0:
                ans += cnt
    else:
        rev10 = pow(10, Q-2, Q)
        D = defaultdict(int)
        D[0] = 1
        s = 0; v = 1
        first = 1
        for i in range(N):
            b = bs[i]
            if first and b == 0:
                continue
            s = (s + v * b) % Q
            v = v * rev10 % Q
            ans += D[s]
            if i < N-1 and bs[i+1] != 0:
                D[s] += 1
            first = 0
    print(ans)
    return True

while solve():
    ...


Measured memory_bytes: 19704
#include<cstdio>
using namespace std;
int main(){
  
  int n,dosu[6]={};
  double a;
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    scanf("%lf",&a);
    if(a < 165){
      dosu[0]++;
    }
    else if(a < 170){
      dosu[1]++;
    }
    else if(a < 175){
      dosu[2]++;
    }
    else if(a < 180){
      dosu[3]++;
    }
    else if(a < 185){
      dosu[4]++;
    }
    else dosu[5]++;
  }

  for(int i=0;i<6;i++){
    printf("%d:",i+1);
    for(int j=0;j<dosu[i];j++){
      putchar('*');
    }
    putchar('\n');
  }
  
  return (0);
}

Measured memory_bytes: 2732
#include <iostream>
#include <vector>
#include <string>
using namespace std;
void chmax(int &a, int b) { if (a < b) a = b; }

int main() {
    int N; string S; cin >> N >> S;

    int res = 0;
    vector<vector<int> > dp(N+1, vector<int>(N+1, 0));
    for (int i = N-1; i >= 0; --i) {
        for (int j = N-1; j > i; --j) {
            if (S[i] == S[j]) chmax(dp[i][j], dp[i+1][j+1] + 1);
            chmax(res, min(dp[i][j], j-i));
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 101164
#include <stdio.h>
int main(void)
{
	int t[4],n[4],a[4],i;
	for(i=0;i<4;i++){
		scanf("%d %d",&t[i],&n[i]);
		if(t[i]==1){
			a[i]=6000*n[i];
		}
		else if(t[i]==2){
			a[i]=4000*n[i];
		}
		else if(t[i]==3){
			a[i]=3000*n[i];
		}
		else if(t[i]==4){
			a[i]=2000*n[i];
		}
	}
	for(i=0;i<4;i++){
		printf("%d\n",a[i]);
	}
	return 0;
}


Measured memory_bytes: 2120
s = input()

alt_01 = int('01' * (len(s)//2) + '0' * (len(s)%2), 2)
alt_10 = int('10' * (len(s)//2) + '1' * (len(s)%2), 2)

bin_s = int(s, 2)
xor_01 = bin_s ^ alt_01
xor_10 = bin_s ^ alt_10

print(min(format(xor_01, 'b').count('1'), format(xor_10, 'b').count('1')))


Measured memory_bytes: 3316
#include "bits/stdc++.h"
using namespace std;

int main() {
  int N,M;
  cin >> N;
  vector<string> s(N);
  map<string,int> red;
  for(int i=0;i<N;i++){
    cin >> s.at(i);
    if(red.count(s.at(i))){
      red.at(s.at(i))++;
    }else{
      red[s.at(i)] = 1;
    }
  }
  cin >> M;
  vector<string> t(M);
  map<string,int> blue;
  for(int i=0;i<M;i++){
    cin >> t.at(i);
    if(blue.count(t.at(i))){
      blue.at(t.at(i))++;
    }else{
      blue[t.at(i)] = 1;
    }
  }
  int tmp = 0;
  for(auto p : red){
    auto key = p.first;
    int value = p.second;
    if(blue.count(key)){
      value -= blue.at(key);
    }
    if(value > tmp){
      tmp = value;
    }
  }
  cout << tmp << endl;
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
const int N=2000005;
int cnt,i,j,w[N],g[N],nxt[N],lst[N];
char s[N],t[N];
bool vis[N];
int main()
{
	scanf("%s",s+1);
	for(i=1;s[i];++i)
		if(s[i]!=s[i-1])
			t[++cnt]=s[i];
	for(i=1;i<=cnt;++i)
		w[t[i]]++;
	g[0]='A',g[1]='B',g[2]='C';
	if(w[g[1]]<w[g[0]])
		swap(g[0],g[1]);
	if(w[g[2]]<w[g[0]])
		swap(g[0],g[2]);
	if(w[g[2]]<w[g[1]])
		swap(g[1],g[2]);
	nxt[0]=1;
	for(i=1;i<cnt;++i)
	{
		nxt[i]=i+1;
		lst[i+1]=i;
	}
	lst[0]=cnt;
	for(i=nxt[0];i&&w[g[2]]>w[g[1]];i=nxt[i])
		if(t[i]==g[2]&&t[lst[i]]!=t[nxt[i]])
		{
			--w[g[2]];
			nxt[lst[i]]=nxt[i];
			lst[nxt[i]]=lst[i];
		}
	for(i=nxt[0];i;i=nxt[i])
	{
		if(t[i]==g[2]&&t[lst[i]]==g[0]&&t[nxt[i]]==g[0]&&w[g[2]]>w[g[1]])
		{
			--w[g[2]];
			--w[g[0]];
			nxt[lst[lst[i]]]=nxt[i];
			lst[nxt[i]]=lst[lst[i]];
		}
		else if((t[i]==g[1]&&t[lst[i]]==g[2]||t[i]==g[2]&&t[lst[i]]==g[1])&&t[lst[lst[i]]]!=t[nxt[i]]&&w[g[2]]>w[g[0]])
		{
			--w[g[1]];
			--w[g[2]];
			nxt[lst[lst[i]]]=nxt[i];
			lst[nxt[i]]=lst[lst[i]];
		}
	}
	if(w[g[1]]==w[g[0]]&&w[g[2]]==w[g[0]])
	{
		for(i=nxt[0];i;i=nxt[i])
			printf("%c",t[i]);
	}
	return 0;
}


Measured memory_bytes: 19712
#include <bits/stdc++.h>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define COUT(x) cout<<(x)<<"\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define REP(i, n) for(int i=0;i<n;i++)
#define YES(x) cout<<(x?"YES":"NO")<<"\n"
#define Yes(x) cout<<(x?"Yes":"No")<<"\n"
#define dump(x) cout<<#x<<" = "<<(x)<<"\n"
#define endl "\n"
using G = vector<vector<int>>;
using M = map<int,int>;
using P = pair<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int,vector<int>,greater<int>>;
using V = vector<int>;
using ll = long long;
using edge = struct { int to; int cost; };
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; }
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main() {
  IOS;
  int n,k; cin >> n >> k;
  string s; cin >> s;

  int ans=0;
  REP(i,n-1) if (s[i+1] == s[i]) ans++;
  COUT( min(ans+2*k, n-1) );
  return 0;
}

Measured memory_bytes: 3772
#include <iostream>
#include <cmath>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <iterator>
#include <unordered_map>
#include <unordered_set>
#include <sstream>
#include <tuple>
#include <fstream>
#include <numeric>

using namespace std;

#define fori(t) for(int i = 0; i < t; ++i)
#define forj(n) for(int j = 0; j < n; ++j)
#define fork(n) for(int k = 0; k < n; ++k)
#define forai(a) for(auto i : a)
#define foraj(a) for(auto j : a)
#define forak(a) for(auto k : a)
#define forp(s, n, d) for(int p = s; p < n; p += d)
#define fast cin.tie(0); cout.tie(0); std::ios_base::sync_with_stdio(0);
#define pb(a) push_back(a);
#define pob(a) pop_back(a);
#define sorti(a) sort(a.begin(), a.end());
#define sortm(a, n) sort(a, a + n);
#define reversi(a) reverse(a.begin(), a.end());
#define fi first
#define se second
#define yes cout << "YES\n";
#define no cout << "NO\n";
#define ans(a) cout << a << '\n';
#define res(a, n) a.resize(n);
#define read(a, n) a.resize(n); fori(n) cin >> a[i];
//#define int long long
//#define double long double

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef pair<long long, long long> llll;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<pair<int, int>> vii;
typedef vector<pair<int, pair<int, int>>> viii;
typedef pair<int, pair<int, int>> iii;
typedef vector<pair<long long, long long>> vllll;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef pair<char, char> cc;
typedef pair<pair<char, char>, char> ccc;
typedef vector<char> vc;
typedef pair<int, char> ic;
typedef pair<ii, char> iic;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef set<int> si;
typedef set<ii> sii;

const int INF = 2147483647;
const ll LONGINF = 9223372036854775807;
const ll MOD = 998244353;

vi a;

void solve()
{
    int n, k;
    cin >> n >> k;
    read(a, n)
    for (int i = k; i < n; ++i)
    {
        if (a[i - k] < a[i]) ans("Yes")
        else ans("No")
    }
}

signed main()
{
    fast
    bool mult = false;
    if (mult)
    {
        int t;
        cin >> t;
        while (t--) solve();
    }
    else solve();
}


Measured memory_bytes: 3964
#include <bits/stdc++.h>
#define mp make_pair
#define ff first
#define ss second
 
using namespace std;
using vi=vector<int>;
using pii=pair<int, int>;
using ull=unsigned long long;
using ll=long long;
 
int main()
{
	ll r, D, x; cin >> r >> D >> x;

	for (int i = 1; i <= 10; i++){
		x = r*x  - D; 
		cout << x << "\n";
	}
}


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

using namespace std;

const int MAX_N = 100010;
const int MOD = 1000000007;
typedef long long Int;

Int fac[MAX_N + 1];
Int inv[MAX_N + 1], ifac[MAX_N + 1];

Int comb(int n, int r)
{
  if (n < 0 || r < 0) return 0;
  if (n < r) return 0;
  Int ret = 1;
  ret = (ret * fac[n]) % MOD;
  ret = (ret * ifac[r]) % MOD;
  ret = (ret * ifac[n - r]) % MOD;
  return ret;
}

int main()
{
  int n;
  int pos[MAX_N + 1];
  
  scanf("%d", &n);
  
  inv[1] = 1;
  fac[0] = ifac[0] = 1;
  fac[1] = ifac[1] = 1;
  for (int i = 2; i <= n; i++) {
    fac[i] = (fac[i - 1] * i) % MOD;
    inv[i] = (inv[MOD % i] * (MOD - MOD / i)) % MOD;
    ifac[i] = ifac[i - 1] * inv[i] % MOD;
  }
  
  fill(pos, pos + n + 1, -1);
  int a, b, c;
  for (int i = 0; i <= n; i++) {
    int x;
    scanf("%d", &x);
    if (~pos[x]) {
      a = pos[x];
      b = i - pos[x] - 1;
      c = n - i;
    }
    pos[x] = i;
  }
  
  for (int i = 1; i <= n + 1; i++) {
    Int ans = comb(n - 1, i);
    ans = (ans + comb(n - 1, i - 2)) % MOD;
    ans = (ans + 2 * comb(n - 1, i - 1)) % MOD;
    ans = (ans + MOD - comb(a + c, i - 1)) % MOD;
    printf("%lld\n", ans);
  }
  
  return 0;
}


Measured memory_bytes: 3840
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>

using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, s, n) for (int i = (s); i <= (n); i++)
typedef long long ll;

bool isPrime(int num)
{
	bool ret = true;

	if (num == 2) ret = true;
	else if (num % 2 == 0) ret = false;
	else {
		for (int i = 3; i * i <= num; i += 2) {
			if (num % i == 0) {
				ret = false;
				break;
			}
		}
	}

	return ret;
}

int main()
{
	int n, num;
	int ans = 0;

	cin >> n;
	rep(i, n) {
		cin >> num;
		if (isPrime(num)) ans++;
	}
	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 3088
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int price,many,psum=0,msum=0,count=0;
    double avg;
    
    while(scanf("%d,%d",&price,&many)!=EOF){
        count++;
        psum+=price*many;
        msum+=many;
    }
    avg=(double)msum/(double)count;
    avg=(avg*10+5)/10;
    printf("%d\n",psum);
    printf("%d\n",(int)avg);
    return 0;
}

Measured memory_bytes: 1800
//我是菜鸡
#include<bits/stdc++.h>
#define _for(i,a,b) for(int i = (a);i<(b);++i)
#define _defor(i,a,b) for((i) = (a);(i)<(b);++i)
#define _rfor(i,a,b) for(int i = (a);i>(b);--i)
#define _sfor(p,st) for(auto p:st)
using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;
const int maxn = 1e2 + 5;
const ll MOD = 1e9 + 7;
const double ext = 1e-6;
void deprint() {
	//ofstream cout("E:\\acm dream\\debug.txt");
	return;
}
int main() {
	//ifstream cin("E:\\acm dream\\in.txt");
	//ofstream cout("E:\\acm dream\\out.txt");
	//srand((unsigned)time(nullptr));
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	int n, x;
	while (cin >> n) {
		bool flag = true;
		_for(i, 0, n) {
			cin >> x;
			if (x % 2 == 0) {
				if (x % 3 != 0 && x % 5 != 0)flag = false;
			}
		}
		if (flag)cout << "APPROVED\n";
		else cout << "DENIED\n";
	}
	return 0;
}

Measured memory_bytes: 256
array = gets.chomp.split(' ').map(&:to_f)
a = array[0]
b = array[1]
c = array[2]
d = array[3]
sol = array[4]
max = array[5]

maxwat_divbyA = max / (a * 100.0)

ans1 = 0
ans2 = 0
maxconc = 0

for na in 0..maxwat_divbyA.to_i do
  maxwat_divbyB = (max - 100 * na * a) / (b * 100.0)
  for nb in 0..maxwat_divbyB.to_i do
    watamount = 100 * na * a + 100 * nb * b
    maxsug = watamount * sol / 100.0
    maxsug_divbyC = maxsug / c
    for nc in 0..maxsug_divbyC.to_i do
      maxsug_divbyD = (maxsug - nc * c) / d
      for nd in 0..maxsug_divbyD.to_i do
        sugamount = nc * c + nd * d
        conc = 100 * sugamount / (watamount + sugamount)
        if conc >= maxconc && watamount + sugamount <= max
          ans1 = watamount + sugamount
          ans2 = sugamount
          maxconc = conc
        end
      end
    end
  end
end

print "#{ans1.to_i} #{ans2.to_i}\n"


Measured memory_bytes: 1788
#include<stdio.h>
//#include<math.h>
int ifcl(int p0[2],int p1[2],int p2[2],int p3[2]){
  long long x0=p1[0]-p0[0],x1=p2[0]-p0[0],x2=p3[0]-p0[0],x3=x2-x1,x4=x0-x1,x5=-x1;
  long long y0=p1[1]-p0[1],y1=p2[1]-p0[1],y2=p3[1]-p0[1],y3=y2-y1,y4=y0-y1,y5=-y1;
  long long x7=p3[0]-p1[0],y7=p3[1]-p1[1]/*,y3=y2-y1,y4=y0-y1,y5=-y1*/;
  
  long long c1=(x0*y1-y0*x1)*(x0*y2-y0*x2),c2=(x3*y4-y3*x4)*(x3*y5-y3*x5);
  long long d1=x1*(x4)+y1*(y4),d2=x2*x7+y2*y7,d3=x1*x2+y1*y2,d4=(x4)*x7+(y4)*y7;
  if(c1==0&&c2==0)return (d1<0&&d2>0&&d3>0&&d4<0)?0:1;
  return (c1<=0&&c2<=0)?1:0;
}
int main(){
  int p[4][2],n,i;
  scanf("%d",&n);
  while(n--){
    for(i=0;i<8;i++)scanf(" %d",&p[i/2][i%2]);
    printf("%d\n",ifcl(p[0],p[1],p[2],p[3]));
  }
  return 0;
}

Measured memory_bytes: 600
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define PI 3.14159265358979323

//void quick(int *,long long,long long);
//int comp(char *a,char *b);

int main(){
	
	int a,a1=0,a2=0,a3=0,i;
	
	for(i=0;i<10;i++){
		scanf("%d",&a);
		if(a>=a1){
			a3=a2;
			a2=a1;
			a1=a;
		}else if(a>=a2){
			a3=a2;
			a2=a;
		}else if(a>=a3)
			a3=a;
	}
	printf("%d\n%d\n%d\n",a1,a2,a3);
	//for(i=0;i<=10000000000;i++);
	return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>

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

using namespace std;

int main()
{
    int n;
    while(cin >> n && n)
    {
        map<int,pair<int,int> > m;
        m[0] = make_pair(0,0);

        rep(i,n-1) {
            int id,dir;
            cin >> id >> dir;

            pair<int,int> p = m[id];
            if(dir == 0) p.first--;
            if(dir == 1) p.second--;
            if(dir == 2) p.first++;
            if(dir == 3) p.second++;

            m[i+1] = p;
        }

        int xmin = 0,xmax = 0,ymin = 0,ymax = 0;
        map<int,pair<int,int> >::iterator ite;
        for(ite = m.begin();ite != m.end();ite++) {
            pair<int,int> p = ite->second;

            xmin = min(xmin,p.first);
            xmax = max(xmax,p.first);
            
            ymin = min(ymin,p.second);
            ymax = max(ymax,p.second);
        }

        cout << xmax - xmin + 1 << " " << ymax - ymin + 1 << endl;
    }

    return 0;
}

Measured memory_bytes: 1208
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i=a; i<n; i++)
#define RREP(i, a, n) for(ll i=n-1; i>=a; i--)
typedef long long ll;
const ll mod =1e9+7;
const ll inf =1e18;
using namespace std;

ll n, k;
ll h[101010];
int main() {
    cin>>n>>k;
    REP(i, 0, n) cin>>h[i];

    sort(h, h+n);
    ll mn=inf;
    REP(i, 0, n-k+1){
        mn=min(mn, h[i+k-1]-h[i]);
    }
    cout<<mn<<endl;
    return 0;
}

Measured memory_bytes: 1024
import sys
from collections import deque
import bisect
import copy
import heapq
import itertools
import math
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
mod = 10 ** 9 + 7

def read_values(): return map(int, input().split())
def read_index(): return map(lambda x: int(x) - 1, input().split())
def read_list(): return list(read_values())
def read_lists(N): return [read_list() for n in range(N)]


def main():
    H, W, M = read_values()
    T = [tuple(read_index()) for _ in range(M)]   

    HT = [0] * H
    WT = [0] * W
    for h, w in T:
        HT[h] += 1
        WT[w] += 1

    hm = max(HT)
    wm = max(WT)
    hs = set(h for h, v in enumerate(HT) if v == hm)
    ws = set(w for w, v in enumerate(WT) if v == wm)
    if len(hs) * len(ws) > M:
        print(hm + wm)
        return
    m = 0
    for h, w in T:    
        if h in hs and w in ws:
            m += 1

    print(hm + wm - (1 if len(hs) * len(ws) == m else 0))


if __name__ == "__main__":
    main()



Measured memory_bytes: 184300