akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <map>
using namespace std;

struct recipe{
	string n;
	vector<string> vs;
};

int main(){
	int n, m;
	int cost;
	string name;
	while(cin >> n){
		if(n == 0) break;
		map<string, int> costs;
		for(int i = 0; i < n; i++){
			cin >> name >> cost;
			costs[name] = cost;
		}
		cin >> m;
		vector<recipe> vr;
		for(int i = 0; i < m; i++){
			recipe r;
			int j;
			cin >> r.n;
			cin >> j;
			for(int k = 0; k < j; k++){
				cin >> name;
				r.vs.push_back(name);
			}
			vr.push_back(r);
		}
		for(int i = 0; i < n; i++){
			for(vector<recipe>::iterator iter = vr.begin(); 
				iter != vr.end(); iter++)
			{
				int cost = 0;
				for(vector<string>::iterator it = (*iter).vs.begin();
					it != (*iter).vs.end(); it++)
				{
					cost += costs[*it];
				}
				if(cost < costs[(*iter).n])
					costs[(*iter).n] = cost;
			}
		}
		cin >> name;
		cout << costs[name] << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

int n;
vvi g;

int dfs(int v){
	if(g[v].empty()) return 0;
	vi a;
	for(auto u:g[v]) a.push_back(dfs(u));
	sort(a.rbegin(),a.rend());
	int m=0;
	for(int i=0;i<a.size();i++) m=max(m,a[i]+i+1);
	return m;
}

int main(){
	cin>>n;
	g=vvi(n);
	for(int i=1;i<n;i++){
		int A;
		cin>>A;
		g[A-1].push_back(i);
	}
	cout<<dfs(0)<<endl;
}

Measured memory_bytes: 15104
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    sc.close();
    String A[] = { "SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT" };
    for (int i = 0; i < A.length; i++) {
      if (S.equals(A[i])) {
        System.out.println(7 - i);
        break;
      }
    }

  }
}


Measured memory_bytes: 23124
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>


int main() {
  std::string str;
  std::cin >> str;
  std::string keyence = "keyence";
  int lidx = 0;
  int ridx = 6;
  for (int i = 0; i < str.size(); ++i) {
    if (str[i] == keyence[lidx])
      ++lidx;
    else
      break;
  }
  for (int i = str.size() - 1; i >= 0; --i) {
    if (str[i] == keyence[ridx])
      --ridx;
    else
      break;
  }
  if (lidx > ridx)
    std::cout << "YES" << std::endl;
  else
    std::cout << "NO" << std::endl;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
# vim: set fileencoding=utf-8

# pylint: disable=unused-import, invalid-name, missing-docstring, bad-continuation


"""Module docstring
"""

import functools
import heapq
import itertools
import logging
import math
import random
import string
import sys
from argparse import ArgumentParser
from collections import defaultdict, deque
from copy import deepcopy
from typing import Dict, List, Optional, Set, Tuple


def solve(values: List[str], nb: int) -> int:
    sum_v = sum(values)
    if sum_v <= nb:
        return nb - sum_v
    return -1


def do_job():
    "Do the work"
    LOG.debug("Start working")
    # N = int(input())
    N, _M = map(int, input().split())
    values = list(map(int, input().split()))
    result = solve(values, N)
    print(result)


def print_output(testcase: int, result) -> None:
    "Formats and print result"
    if result is None:
        result = -1
    print("Case #{}: {}".format(testcase + 1, result))
    # 6 digits float precision {:.6f} (6 is the default value)
    # print("Case #{}: {:f}".format(testcase + 1, result))


def configure_log(log_file: Optional[str] = None) -> None:
    "Configure the log output"
    log_formatter = logging.Formatter(
        "%(asctime)s - %(filename)s:%(lineno)d - " "%(levelname)s - %(message)s"
    )
    if log_file:
        handler = logging.FileHandler(filename=log_file)
    else:
        handler = logging.StreamHandler(sys.stdout)
    handler.setFormatter(log_formatter)
    LOG.addHandler(handler)


LOG = None
# for interactive call: do not add multiple times the handler
if not LOG:
    LOG = logging.getLogger("template")
    configure_log()


def main(argv=None):
    "Program wrapper."
    if argv is None:
        argv = sys.argv[1:]
    parser = ArgumentParser()
    parser.add_argument(
        "-v",
        "--verbose",
        dest="verbose",
        action="store_true",
        default=False,
        help="run as verbose mode",
    )
    args = parser.parse_args(argv)
    if args.verbose:
        LOG.setLevel(logging.DEBUG)
    do_job()
    return 0


if __name__ == "__main__":
    import doctest

    doctest.testmod()
    sys.exit(main())


class memoized:
    """Decorator that caches a function's return value each time it is called.
    If called later with the same arguments, the cached value is returned, and
    not re-evaluated.
    """

    def __init__(self, func):
        self.func = func
        self.cache = {}

    def __call__(self, *args):
        try:
            return self.cache[args]
        except KeyError:
            value = self.func(*args)
            self.cache[args] = value
            return value
        except TypeError:
            # uncachable -- for instance, passing a list as an argument.
            # Better to not cache than to blow up entirely.
            return self.func(*args)

    def __repr__(self):
        """Return the function's docstring."""
        return self.func.__doc__

    def __get__(self, obj, objtype):
        """Support instance methods."""
        return functools.partial(self.__call__, obj)


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

using namespace std;


int main()
{
 int n;
 cin >> n;
 vector<double>p(n);
 for(int i=0;i<n;++i){
    cin >> p[i];
 }
 vector<vector<double> >dp(n+1,vector<double>(n+1,0));
 double ans=0;
 dp[0][0]=1;
 for(int i=1;i<=n;++i){
    for(int j=0;j<=n;++j){
        dp[i][j] = p[i-1]*dp[i-1][j-1] + (1-p[i-1])*dp[i-1][j];
    }
 }

 for(int i=n;i>n/2;--i)
    ans+=dp[n][i];
  cout <<fixed << setprecision(10)<<ans<<endl;
  return 0;
}

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



int main(){
    ll N, M; cin >> N >> M; 
    vector<vector<ll>> G(N);
    for(ll i = 0; i < M; i++){
        ll v, w; cin >> v >> w;
        v--;w--;
        G[v].push_back(w);
    }
    ll S, T; cin >> S >> T; S--; T--;

    vector<vector<ll>> Dist(3, vector<ll>(N));
    for(ll i = 0; i < 3; i++){
        for(ll j = 0; j < N; j++) Dist[i][j] = -1;
    }

    queue<pair<ll, ll>> Q;
    Q.push(make_pair(0, S));
    Dist[0][S] = 0;
    while(!Q.empty()){
        auto q = Q.front(); Q.pop();
        ll x = q.second;
        ll c = q.first;
        ll nc = (c+1)%3;
        //cout << x << "    " << c << endl;
        for(auto v : G[x]){
            //cout << x << "  " << c << "         " << v <<"  " << nc << endl;
            if(Dist[nc][v] == -1){
                Dist[nc][v] = Dist[c][x]+1;
                Q.push(make_pair(nc, v));
            }
        }
    }
    if(Dist[0][T] != -1) cout << Dist[0][T]/3 << endl;
    else cout << -1 << endl;


}

Measured memory_bytes: 8832
using DataStructures
parseline(str) = parse.(Int, split(str))
const inf = typemax(Int)
const direction_walk = [[0, 1], [0, -1], [1, 0], [-1, 0]]
const direction_warp = [[i, j] for i in -2:2, j in -2:2 if [i, j]≠[0,0] && [i, j]∉direction_walk]
function WizardInMaze()
    data = readlines()
    H, W = parseline(data[1])
    start = parseline(data[2])
    goal = parseline(data[3])
    S = zeros(Int, H, W)
    for h in 1:H
        S[h, :] = [d=='.' ? 0 : 1 for d in data[3+h]]
    end
    queue = Deque{Vector{Int}}()
    push!(queue, start)
    que_dist = Deque{Int}()
    push!(que_dist, 0)
    cost = fill(inf, H, W)
    cost[start[1], start[2]] = 0
    while !isempty(queue)
        node = popfirst!(queue)
        now = popfirst!(que_dist)
        now > cost[node[1], node[2]] && continue
        for edge in 0:1
            direction = edge==0 ? direction_walk : direction_warp
            for d in direction
                h, w = node + d
                !(1≤h≤H) && (h = min(max(h, 1), H))
                !(1≤w≤W) && (w = min(max(w, 1), W))
                next_cost = cost[node[1], node[2]] + edge
                S[h, w]≡0 && (cost[h, w] > next_cost) && (
                    edge==0 ? (pushfirst!(queue, [h, w]);pushfirst!(que_dist, next_cost)) : (push!(queue, [h, w]);push!(que_dist, next_cost)); 
                    cost[h, w] = next_cost
                )
            end
        end
    end
    ans = cost[goal[1], goal[2]]==inf ? -1 : cost[goal[1], goal[2]]
    println(ans)
end
WizardInMaze()

Measured memory_bytes: 281976
#include <stdio.h>
#include <stdlib.h>
typedef struct
{    
    char suit;
    int num;
    int index;
}Card;

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

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

	}
}

int isStable(Card A[], int n)
{
	int i;
	for (i = 0; i < n - 1; i++) {
		if (A[i].num == A[i + 1].num&&A[i].index > A[i + 1].index) return 0;
	}
	return 1;
}
int main(int argc, char** argv) {
    int size,i,j;
    scanf("%d\n",&size);
    Card card[size+1];
    for(i = 1; i< size+1; i++)
    {
        scanf( " %c%d", &card[i].suit, &card[i].num);
        card[i].index = i;
    }
    quicksort(card, 1, size);
    int right = isStable(card, size);
    if(right == 1)
        printf("Stable\n");
    else
        printf("Not stable\n");
    
    
     for(i= 1; i<size+1;i++)
    {
        printf("%c %d\n", card[i].suit, card[i].num);
    }
    return (EXIT_SUCCESS);
}





Measured memory_bytes: 2860
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric, std.container, std.range;

void main()
{
    auto N = readln.chomp.to!int;
    auto as = new int[](N);
    auto bs = new int[](N);
    foreach (i, p; readln.split.to!(int[])) {
        as[p-1] = i.to!int+1;
        bs[p-1] = i.to!int+1;
    }
    foreach (i; 0..N) {
        if (i) {
            as[i] += as[i-1];
            bs[N-i-1] += bs[N-i];
        }
    }
    writeln(as.to!(string[]).join(" "));
    writeln(bs.to!(string[]).join(" "));
}

Measured memory_bytes: 4996
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,n) for(ll i=0;i<(n);++i)
#define REPR(i,n) for(ll i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

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

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

int main(int argc, char const *argv[]) {
    ll n,m,k; cin>>n>>m>>k;
    vector<ll> a(n), b(m);
    vector<ll> sa(n+1), sb(m+1);
    rep(i,n) cin>>a[i];
    rep(i,m) cin>>b[i];

    rep(i,n) sa[i+1] = sa[i]+a[i];
    rep(i,m) sb[i+1] = sb[i]+b[i];

    int ans = 0;
    rep(i,n+1) {
        int tmp = 0;
        //cout << "i = " << i << '\n';
        ll x = sa[i];
        //cout << "x = " << x << '\n';
        if (x > k) continue;
        ll rest = k-x;
        //cout << "rest = " << rest << '\n';
        auto itr = upper_bound(sb.begin(), sb.end(), rest);
        tmp += i;
        int idx = itr-sb.begin();
        --idx;
        tmp += idx;
        //cout << "idx = " << idx << '\n';
        //cout << "tmp = " << tmp << '\n';

        chmax(ans, tmp);
    }

    cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 9592
N,M = map(int,input().split())

NN = ['A']*N
mujun = 0

for m in range(M):
    si,ci = map(int,input().split())
    if NN[si-1] == 'A':
        NN[si-1] = ci
    else:
        if NN[si-1] == ci:
            pass
        else:
            mujun = 1
            break
            
if mujun == 0:
    AA = []
    for n in range(N):
        if n == 0:
            if NN[n] == 'A':
                if N == 1:
                    AA.append('0')
                else:
                    AA.append('1')
            else:
                AA.append(str(NN[n]))
        else:
            if NN[n] == 'A':
                AA.append('0')
            else:
                AA.append(str(NN[n]))

    if AA[0] == '0' and len(AA) > 1:
        mujun = 1
    
if mujun == 1:
    print('-1')
else:
    print(''.join(AA))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#include<stack>
#include<numeric>
using namespace std;

#define ll long long
#define endl "\n"
#define pb push_back
#define mp make_pair

int solve()
{
    string a,s,t;
    cin>>s;
    cin>>t;
    
    ll n=t.size();
    
    a=s+t[n-1];
    
    
    if(a==t)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    

    return 0;
}

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

    /*ll t;
    cin>>t;
    while(t--)*/
        solve();

    return 0;
}


Measured memory_bytes: 3612
#include <ctype.h>
#include <limits.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <tgmath.h>

int main(int argc, char **argv)
{
    int n;
    int s[10][10] = {{0}};
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) {
        int a = i % 10;
        int b = 0;
        int w = i;
        while (w) {
            b = w;
            w /= 10;
        }
        s[a][b]++;
    }
    long t = 0;
    for (int i = 1; i <= n; i++) {
        int a = i % 10;
        int b = 0;
        int w = i;
        while (w) {
            b = w;
            w /= 10;
        }
        t += s[b][a];
    }
    printf("%ld\n", t);
    return EXIT_SUCCESS;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(t) t.begin(), t.end()
#define inrange(i, a, b) (((i)>= min((a), (b))) && ((i) <= max((a), (b))))
#define show(x) cout << #x << " is " << x << "\n";
typedef vector<ll> vi;
#define fi first
#define se second
const ll inf = 9e18;
const ll mod = 1e9 + 7;

void print(ll a[], ll n){for(ll i=0;i<n;i++){cout<<a[i]<<" ";}cout<<"\n";}
ll power(ll x, ll y, ll M = inf){
    ll ans = 1;
    x %= M;
    while(y){
        if(y&1)
            ans = (x * ans) % M;

        x = (x * x) % M;
        y >>= 1;
    }
    return ans;
}
ll modInverse(ll n) {return power(n, mod-2, mod);}
inline ll mul(ll a, ll b){ return (a * b) % mod; }
inline ll sub(ll a, ll b){ ll c = a - b; if(c < 0) c += mod; return c; }
inline ll add(ll a, ll b){ ll c = a + b; if(c > mod) c -= mod; return c; }
inline ll divi(ll a, ll b){ return mul(a, modInverse(b)); }

//const ll N = 1e5 + 1;
//vector<ll> adj[N];
//bool visited[N];

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

	ll a, b, c, k;
	cin>>a>>b>>c>>k;
	if(k<=a) cout<<k;
	else if(k <= a+b) cout<<a;
	else if(k<= a+b+c) cout<<a-(k-a-b);


	return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
const int mod = 1000000007;
using ll = long long;
using namespace std;

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

int main(){
	ll a, b, c, d; cin >> a >> b >> c >> d;
	cout << ( b - (b/c + b/d - b/(lcm(c, d))) ) - ( (a-1) - ((a-1)/c + (a-1)/d - (a-1)/(lcm(c, d))) ) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod * mod;
constexpr int MAX = 100010;

int main(){
    int n;
    scanf("%d", &n);
    int a[n];
    rep(i, n) scanf("%d", &a[i]), --a[i];
    int ans = 0;
    rep(i, n) ans += (a[a[i]] == i);
    printf("%d\n", ans / 2);
}

Measured memory_bytes: 640
#include <iostream>

long long int arr[100010];
long long int sum;

int main(){
    int n;
    int q;
    int b, c;
    int a;
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
    {
        scanf("%d", &a);
        arr[a]++;
        sum += a;
    }
    scanf("%d", &q);
    for (int i = 0; i < q; i++)
    {
        scanf("%d %d", &b, &c);
        sum = sum + arr[b] * (c - b);
        arr[c] += arr[b];
        arr[b] = 0;
        printf("%lld\n", sum);
    }
}

Measured memory_bytes: 4612
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define Rep(i,n) for(intl i=0;i<(intl)(n);i++)
#define Rep1(i,n) for(intl i=1;i<(intl)(n)+1;i++)
#define vec vector
#define fi first
#define se second
#define pub push_back
#define pob pop_back
#define SortA(v) sort(v.begin(), v.end())
#define SortD(v) sort(v.rbegin(), v.rend())
#define All(a) (a).begin(),(a).end()
using intl = int64_t;
using vi = vec<intl>;
using vvi = vec<vi>;
using pi = pair<intl,intl>;
using vpi = vec<pi>;
vec<intl> dx = {0, 1, 0, -1, 1, 1, -1, -1};
vec<intl> dy = {1, 0, -1, 0, 1, -1, 1, -1};
constexpr intl INF = 9223372036854775807;


int main(){
  intl A;
  long double B;
  cin >>A>>B;
  B += 0.0001;
  intl b = B*100;
  cout <<A*b/100;
}

Measured memory_bytes: 3764
#include<iostream>
#include<vector>

using namespace std;

int main(){

    int N,s;
    cin >> N;

    vector<int> H(N);

    for(int i=0;i<H.size();i++){
        cin >> H[i];
    }

    int view = 1;

    for(int i=1;i<H.size();i++){
        int k = 0;

        for(int j=0;j<i;j++){
            if(H[i]<H[j]){break;}
            
            k++;
        }

        if(k==i){
            view++;
        }
    }

    cout << view << endl;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
a.sort()

for i in range(1, len(a)):
    while 0 != a[i - 1]:
        r = a[i] % a[i - 1]
        a[i] = a[i - 1]
        a[i - 1] = r
print(a[-1])


Measured memory_bytes: 14252
#include<bits/stdc++.h>
using namespace std;
int main()
{
    char s[101];
    cin>>s;
    for(int i=0;i<strlen(s);i+=2){
        if(s[i]=='L'){
            cout<<"No"<<endl;
            return 0;
        }
    }
    for(int i=1;i<strlen(s);i+=2){
        if(s[i]=='R'){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}


Measured memory_bytes: 256
using System;

class calc{
    public int add(int a, int b){
        return a+b;
    }
    public int sub(int a, int b){
        return a-b;
    }
    public int mul(int a, int b){
        return a*b;
    }
    public int div(int a, int b){
        return a/b;
    }
}

class Cal{
    public static void Main(){
        calc c = new calc();
        int a,b;
        String op;
        bool flag = true;
        while(flag){
            String[] str = Console.ReadLine().Split(' ');
            a = int.Parse(str[0]);
            b = int.Parse(str[2]);
            op = str[1];
            switch (op){
                case "+":
                    Console.WriteLine(c.add(a,b));
                    break;
                case "-":
                    Console.WriteLine(c.sub(a,b));
                    break;
                case "*":
                    Console.WriteLine(c.mul(a,b));
                    break;
                case "/":
                    Console.WriteLine(c.div(a,b));
                    break;
                case "?":
                    flag = false;
                    break;
                default:
                    break;
            }
        }
    }
}


Measured memory_bytes: 15952
import numpy as np

#入力
n = int(input())

#3の倍数をFに変更
def multiples_3(matrix):
    #列ベクトルを削除(3列目)
    m_de = np.delete(fizzbuzz_list,2, axis=1)
    #Fの列ベクトルを作成
    f_list = np.zeros(j).reshape(-1, 1)
    #結合
    result = np.concatenate([m_de, f_list], 1)
    return result

#列を計算(繰り上げ)
j = -(-n // 3)

#1からnまでの配列を作成
fizzbuzz_list = np.arange(1,n+1)
#要素数
before_size = fizzbuzz_list.size
#3*n行列に変更
fizzbuzz_list.resize((j,3))

#3の倍数をFに変更
fizzbuzz_list = multiples_3(fizzbuzz_list)

#5の倍数をBに変更
n_b_1 = np.arange(3,j,5)
n_b_2 = np.arange(1,j,5)

fizzbuzz_list[n_b_1,0] = 0
fizzbuzz_list[n_b_2,1] = 0

#15の倍数をFBに変更
n_fb = np.arange(4,j,5)
fizzbuzz_list[n_fb,2] = 0

sum = 0
sum = np.sum(fizzbuzz_list)
print(int(sum))


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

int main(){

    long long n;
    cin >> n;

    long long sum = 0;
    long long t = 0;
    while(sum < n){
        t += 1;
        sum += t;
    }

    cout << t << endl;

}

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

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

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

int main()
{
    ll N, K;
    cin >> N >> K;
    cout << N - K + 1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
main()
{int t,a,b,c,d[99999],j=0,i;
cin>>a>>b;
for(i=0;i<b;i++)
{
    cin>>d[i];
    j+=d[i];
}
if(j>a)
    cout<<"-1"<<endl;
else

    cout<<a-j<<endl;
    return 0;
}


Measured memory_bytes: 3644
x,n=[int(x) for x in input().split()]
if n==0:
  print(x)
else:
  p=[int(x) for x in input().split()]
  ans=[]
  Flag=False
  while ans==[]:
    for i in range(105):
      if x-i not in p:
        ans.append(x-i)
        Flag=True
        break
      elif x+i not in p:
        ans.append(x+i)
        Flag=True
        break
    if Flag:
      break
  print(min(ans))

Measured memory_bytes: 9196
import sys
import heapq
def input(): return sys.stdin.readline().rstrip()

def main():
    X, Y, Z, K = map(int, input().split())
    A, B, C = [sorted(map(int, input().split()), reverse=True) for _ in range(3)]

    hp = []
    heapq.heappush(hp, (- A[0] - B[0] - C[0], 0, 0, 0))
    exists = set([(0, 0, 0)])
    for _ in range(K):
        v, x, y, z = heapq.heappop(hp)
        print(-v)
        if x + 1 < X and (x + 1, y, z) not in exists:
            heapq.heappush(hp, (v + A[x] - A[x+1], x + 1, y, z))
            exists.add((x + 1, y, z))
        if y + 1 < Y and (x, y + 1, z) not in exists:
            heapq.heappush(hp, (v + B[y] - B[y+1], x, y + 1, z))
            exists.add((x, y + 1, z))
        if z + 1 < Z and (x, y, z + 1) not in exists:
            heapq.heappush(hp, (v + C[z] - C[z+1], x, y, z + 1))
            exists.add((x, y, z + 1))

if __name__ == '__main__':
    main()


Measured memory_bytes: 4976
#include<iostream>
using namespace std;
int main() {
	int n;
	cin >> n;
	int h = 0;
	int m = 0;
	int s = 0;
	h = n / 3600;
	m = (n % 3600) / 60;
	s = (n % 3600) % 60;
	cout << h << ":" << m << ":" << s << endl;
	return 0;
}


Measured memory_bytes: 3116
#include <iostream>
#include <string>
using namespace std;
int main(void){
    int at, bt, ct, ai, bi, ci, mugen = 0, ima;
    string sa, sb, sc, winner;
    cin >> sa;
    cin >> sb;
    cin >> sc;
    at = sa.size();
    bt = sb.size();
    ct = sc.size();
    ai = bi = ci = 0;
    ima = 'a';
    while (mugen == 0) {
        if (ima == 'a') {
            ima = sa[ai];
            ai++;
            if (ai > at) {
                winner = "A";
                break;
            }
        }
        else if (ima == 'b') {
            ima = sb[bi];
            bi++;
            if (bi > bt) {
                winner = "B";
                break;
            }
        }
        else {
            ima = sc[ci];
            ci++;
            if (ci > ct) {
                winner = "C";
                break;
            }
        }
    }
    cout << winner;
    return 0;
}


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

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define all(x) x.begin(),x.end()


int main()
{
	int n; cin >> n;
	vector<int> p(n), q(n), x(n);
	rep(i, n)cin >> p[i];
	rep(i, n)cin >> q[i];
	rep(i, n)x[i] = i + 1;
	int i, a, b;
	i = 1;
	do
	{
		if (x == p)a = i;
		if (x == q)b = i;
		++i;
	} while (next_permutation(all(x)));
	cout << abs(a - b) << endl;
}

Measured memory_bytes: 256
#include <iostream>
//#include <iomanip>
#include <string>
//#include <vector>
//#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
//using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;
//#define all(v) v.begin(),v.end()
//ll mod = 1000000007 ;
//long double pie = acos(-1) ;
//ll INF = 1000000000000 ;

//void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void fix_cout(){cout << fixed << setprecision(20) ;}

int main(){
	string s,t ;
	cin >> s >> t ;
	ll n = t.size() ;
	for(int i=s.size()-n;i>=0;i--){
		bool ok = true ;
		for(int j=0;j<n;j++){
			if(s.at(i+j)!='?'&&s.at(i+j)!=t.at(j)){
				ok = false ;
				break ;
			}
		}
		if(ok){
			for(int j=0;j<n;j++){
				s.at(i+j) = t.at(j) ;
			}
			for(int j=0;j<s.size();j++) cout << (s.at(j)=='?'?'a':s.at(j)) ;
			cout << endl ;
			return 0 ;
		}
	}
	cout << "UNRESTORABLE\n" ;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a, b;
    cin >> a >> b;
    int ans = a;
    if(a > b) ans--;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll W, H, x, y;
  cin >> W >> H >> x >> y;
  cout << double(W*H)/2.0;
  cout << " ";
  if (2*x == W && 2*y == H) {
    cout << 1 << endl;
  } else {
    cout << 0 << endl;
  }
}

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

bool examine(int n, int i)
{
    while ( 0 < n)
    {
        if (n % 10 == i)
            return false;
        n = n / 10;
    }
    return true;
}

int main()
{
    ios::sync_with_stdio(false);
    int a[10], n, sum;
    cin >> sum >> n;
    for (int i = 0; i < n ;++i)
        cin >> a[i];
    
    int high = sum * 10;
    while (sum < high)
    {
        bool flag = true;
        for (int i = 0; i < n; ++i)
        {
            flag = examine(sum, a[i]);
            if (! flag)   break;
        }

        if (flag)
        {
            cout << sum << endl;
            return 0;
        }
        else    
            ++sum;
    }
    return 0;
}

Measured memory_bytes: 256
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

v,e = mi()

path = []

for i in range(e):
    a = li()
    path.append([a[2], a[0], a[1]])

path.sort()

class UnionFind:
    def __init__(self,n):
        self.n = n
        self.d = [-1] * n

    def find(self, x):
        if(self.d[x] < 0):
            return x
        self.d[x] = self.find(self.d[x])
        return self.d[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if(x == y):
            return False
        if(self.d[x] > self.d[y]):
            x, y = y, x
        self.d[x] += self.d[y]
        self.d[y] = x
        return True

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def size(self,x):
        return -self.d[self.find(x)]

uf = UnionFind(v)

ans = 0
for i in path:
    w = i[0]
    s = i[1]
    t = i[2]
    if uf.same(s,t):
        pass
    else:
        uf.union(s,t)
        ans += w


print(ans)


Measured memory_bytes: 24760
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <sstream>
#include <stdio.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>
#include <iomanip>

using namespace std;

#define Rep(i,a,b) for(int i = a; i < b; i++)
#define rep(i,b) Rep(i,0,b)
#define allof(a) (a).begin(), (a).end()

typedef long long ll;
const int inf = 1e9 + 7;
const ll infll = 1ll << 60ll;
const ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

namespace {  // 名前なし名前空間
	// gcd, lcm は C++17 でstdに標準入りしたので言語のバージョンに注意
	// 最大公約数
	ll gcd(ll a, ll b) {
		if (b == 0) return a;
		return gcd(b, a % b);
	}

	// 最小公倍数
	ll lcm(ll a, ll b) {
		return a / gcd(a, b) * b;
	}
}

int main() {

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

	// 小さいのから順にじゃないか
	priority_queue<double, vector<double>, greater<int>> pq;
	rep(i, n) pq.push(v[i]);

	while (pq.size() != 1) {
		// 最も小さいのを二つ取り出す
		double f = pq.top();
		pq.pop();
		double s = pq.top();
		pq.pop();
		pq.push((f + s) / 2.0);
	}

	cout << fixed << setprecision(10) << pq.top() << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
 public class Main{
    public static void main(String args[]){
      Scanner in = new Scanner(System.in);
      int x = in.nextInt();
      int y = in.nextInt();
      int menseki = x * y;
      int syuu = (x + y) * 2;
      System.out.println(""+menseki+" "+syuu+"");
    }
  }

Measured memory_bytes: 26244
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int min = sc.nextInt();
        int k = 1;

        int now = 0;
        for(int i = 1 ; i < n ; i++){
            now = sc.nextInt();
            if(now <= min){
                min = now;
                k++;
            }
        }
        System.out.println(k);
    }
}

Measured memory_bytes: 64424
import sys

sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return list(map(int, sys.stdin.readline().split()))
def II(): return int(sys.stdin.readline())
def LS(): return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]

import math

def main():
    a, b, x = LI()
    r = a*a*b - x

    if r < x:
        h = r *2 / a / a
        print(math.degrees(math.atan(h/a)))
    else:
        h = x *2 / a / b
        print(90 - math.degrees(math.atan(h/b)))


if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<int,int>
#define pb push_back
#define vec vector <int>
#define ub upper_bound
#define lb lower_bound
#define bs binary_search
#define bg begin()
#define en end()
#define endl "\n"
#define ff first
#define ss second
#define all(x) x.bg,x.en
#define fill(a,b) memset(a,b,sizeof(a))
#define fr(i,n) for(int i=0;i<n;i++)
#define rp(i,a,b) for(int i=a;i<b;i++)
#define rr(i,a,b) for(int i=a;i>=b;i--)
#define ft(it,x) for(auto it : x)
#define dbg(x) cout<<#x<<" "<<x<<endl;
#define dbga(arr,n) cout<<#arr<<": "; rp(tt,0,n) cout<<tt<<" "<<arr[tt].ff<<" "<<arr[tt].ss<<endl; cout<<endl;
#define mapi map<int,int>
#define test(t) int t;cin>>t;while(t--)
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define int long long
const int mod=1e9+7,mex=1e12,md=998244353;
signed main()
{
	fast
	int n,x,y;
	cin>>n>>x>>y;
	int ans[n]={0};
	rp(i,1,n+1)
	{
		rp(j,i+1,n+1)
		{
			int z=min(j-i,abs(x-i)+abs(y-j)+1);
			ans[z]++;
		}
	}
	rp(i,1,n) cout<<ans[i]<<endl;
}

Measured memory_bytes: 256
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**9)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n,m = na()
a = [-1]*n

for i in range(m):
	s,c = na()
	if a[s-1] == -1 or a[s-1] == c:
		a[s-1] = c
	else:
		print(-1)
		exit()

if a[0] == 0 and n > 1:
	print(-1)
	exit()
elif a[0] == -1:
	a[0] = 1
	if n == 1:
		a[0] = 0

a = list(reversed(a))
ans = 0

for j in range(len(a)):
	k = a[j]*(10**j) if a[j] >= 0 else 0
	ans += k

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define __ ios_base::sync_with_stdio(0);cin.tie(0);
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(),x.end()
#define forn(i,a,n) for(int i=a; i < n; i++)
typedef long long int lli;
typedef long double Double;
typedef pair<int,int> pii;
typedef vector<lli> vi;
typedef vector<vi> vvi;
#define MAXN 3005
const int mod = 1e9+7;
lli dp[MAXN][MAXN];
int main(){__
	int n;
	cin >> n;
	dp[0][1] = 1ll;
	for(int i =1; i < n; i++){
		char c;
		cin >> c;
		if(c == '>'){
			lli sum = 0ll;
			for(int j = i+1; j >=1; j--){
				sum = (sum + dp[i-1][j]) % mod;
				dp[i][j] = (dp[i][j] + sum) % mod;
			}
			/*
			for(int j =1; j <=i+1; j++){
				for(int k = i+1; k >= j; k--){
					dp[i][j] = (dp[i][j] + dp[i-1][k]) % mod;
				}
			}
			*/
		}
		else{
			lli sum = 0ll;
			for(int j =1; j <= i+1; j++){
				dp[i][j] = (dp[i][j] + sum) % mod;
				sum = (sum + dp[i-1][j]) % mod;
			}
			/*
			for(int j=1; j <=i+1; j++){
				for(int k= 1; k < j; k++){
					dp[i][j] = (dp[i][j] + dp[i-1][k]) % mod;
				}
			}
			*/
		}
	}

	lli ans = 0ll;
	for(int i =1; i <= n; i++){
		ans = (ans + dp[n-1][i]) % mod;
	}
	cout << ans % mod << endl;
	return 0;
}


Measured memory_bytes: 68992
use io::*;
use proconio::{fastout, input};
use std::*;

#[fastout]
fn main() {
    input! {
        N: usize,
        A: [isize; N],
        qSize: usize,
        Q: [(isize, isize); qSize]
    }
    let mut sum = A.iter().sum::<isize>();
    let mut m: collections::HashMap<isize, isize> = collections::HashMap::new();
    for a in A {
        *m.entry(a).or_default() += 1;
    }
    for (b, c) in Q.into_iter() {
        let rem = match m.remove(&b) {
            Some(count) => count,
            None => 0,
        };
        *m.entry(c).or_default() += rem;
        sum += (c - b) * rem;
        println!("{}", sum);
    }
}


Measured memory_bytes: 9516
#include<bits/stdc++.h>
#define M 1000000007
#define pi ld(acos(-1.0))
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,n) for(int i=1;i<(int)(n);i++)
#define repp(i,a,b)  for(int i=a;i<=(int)(b);i++)
#define Repp(i,a,b)  for(int i=a;i>=(int)(b);i--)
#define cs ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fi first
#define se second
#define ii pair<int,int>
#define bye(x) {cout<<x;return 0;}
typedef long long ll;
typedef long double ld;
using namespace std;

int main() {
    cs
    int n,m,x,y;cin>>n>>m;
    x=1;y=m&1?m:m+1;
    while(x!=m/2+1) {
        cout<<x<<' '<<y<<'\n';
        x++;y--;
    }
    x=m&1?m+1:m+2;
    y=2*m+1;
    while(x<y) {
        cout<<x<<' '<<y<<'\n';
        x++;y--;
    }
    
}

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

using namespace std;
 
#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back
 
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<bool> VB;

int main() {
    int n,m;
    cin >> n >> m;
    if(n == m ) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


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

int main(void){
    int i,j,k;
    int N;
    int B[200];
    int A[200];
    long long answer = 0;
    
    scanf("%d",&N);
    for(i = 0;i < N - 2;i++){
        scanf("%d\n",&B[i]);
    }
    scanf("%d",&B[i]);
    
    
    for(i = 0;i < N-1;i++){
        if(i != 0){
            if(A[i] > B[i]){
                A[i] = B[i];
            }
            A[i+1] = B[i];
        }else{
            A[i] = B[i];
            A[i+1] = B[i];
        }
    }
    
    for(i = 0;i < N;i++){
        answer += A[i];
    }
    
    
    printf("%lld\n",answer);
    
    return 0;
}













Measured memory_bytes: 128
#!/usr/bin python3
# -*- coding: utf-8 -*-

from collections import deque

N, C = map(int,input().split())
Mx = 10**5+1
sch = [[0]*Mx for _ in range(C)]
scht = [0]*Mx
plist = [[] for _ in range(C)]
for _ in range(N):
    s, t, c = map(int,input().split())
    plist[c-1].append((s,t))
for c, p in enumerate(plist):
    p.sort()
    prevt = 0
    for s, t in p:
        if prevt == s:
            sch[c][prevt] = 0
        else:
            sch[c][s] = 1
        sch[c][t] = -1
        prevt = t
    for i in range(1, Mx):
        if sch[c][i]==1:
            scht[i-1]+=1
        if sch[c][i]==-1:
            scht[i]-=1

for i in range(1, Mx):
    scht[i] += scht[i-1]

print(max(scht))


Measured memory_bytes: 47520
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,_6,_7,_8,NAME,...) NAME
#define pr(...) cerr<< GET_MACRO(__VA_ARGS__,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__) <<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
#define prArr(a) {cerr<<(#a)<<"={";int i=0;for(auto t:(a))cerr<<(i++?", ":"")<<t;cerr<<"}"<<endl;}
using namespace std;
using Int = long long;
using _int = int;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<60)+1e9; // ~ 1.15 * 1e18
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T1, class T2> ostream& operator<<(ostream& o,pair<T1,T2> p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T1, class T2, class T3> ostream& operator<<(ostream& o,tuple<T1,T2,T3> t){
  return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
template<class T1, class T2> istream& operator>>(istream& i,pair<T1,T2> &p){return i>>p.first>>p.second;}
template<class T> ostream& operator<<(ostream& o,vector<T> a){Int i=0;for(T t:a)o<<(i++?" ":"")<<t;return o;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(T &t:a)i>>t;return i;}



signed main(){
  srand((unsigned)time(NULL));
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);
  while(1){
    int T, D, L;
    cin>>T>>D>>L;
    if( T == 0 && D == 0 && L == 0) break;
    vector<int> A(T);
    cin>>A;

    int ans = 0;
    int counter = 0;
    for(int i=0;i<T;i++){
      int t = A[i];
      if(counter) ans++, counter--;
      if(t >= L) counter = D;
      
    }

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



Measured memory_bytes: 3576
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <map>

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;

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

using namespace std;

const ll BIG = 1000000007LL;

int inputValue(){
    int a;
    cin >> a;
    return a;
};

template<typename T>
void inputArray(T* p, int a){
    rep(i, a){
        cin >> p[i];
    }
};

template<typename T>
void inputVector(vector<T> * p, int a){
    rep(i, a){
        T input;
        cin >> input;
        p -> push_back(input);
    }
}

template <typename T>
void output(T a, int precision = 0) {
    if(precision > 0){
        cout << setprecision(precision)  << a << "\n";
    }
    else{
        cout << a << "\n";
    }
}

const int Max = 55;
int N;
ll x[Max], y[Max];
map<pair<ll, ll>, int> counts;

int main(int argc, const char * argv[]) {
    cin >> N;
    rep(i, N) {
        cin >> x[i] >> y[i];
    }

    rep(i, N) {
        rep(j, N) {
            if (i == j) continue;
            ll diffx = x[i] - x[j];
            ll diffy = y[i] - y[j];
            // if (diffx < 0) {
            //     diffx *= -1;
            //     diffy *= -1;
            // }
            counts[make_pair(diffx, diffy)] += 1;
        }
    }

    int maxc = 0;
    for (auto& c : counts)
    {
        //printf("%lld, %lld, %d\n", c.first.first, c.first.second, c.second);
        if (c.second > maxc) {
            maxc = c.second;
        }
    }

    output(N - maxc);

    return 0;
}

Measured memory_bytes: 384
#include<iostream>
using namespace std;
int main(){
 	int n,x,t;
  	cin>>n>>x>>t;
  	int r = n%x;
  	if(r==0){
      cout<<(n/x)*t<<endl;
    }else if(x<n){
      cout<<(n/x)*t + t <<endl;
    }else{
      cout<<t<<endl;
    }
	return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
int main(){
    int i,n,x,a,b,mn,mx,ans;
    cin>>n;
    vector<int>v1,v2;
    for(i=0;i<n;i++){
        cin>>a>>b;
        v1.push_back(a);
        v2.push_back(b);
    }
    sort(v1.begin(),v1.end());
    sort(v2.begin(),v2.end());
    if(n%2){x=n/2;
        mn=v1[x];mx=v2[x];
    }else{
        x=n/2;
        mn=v1[x];
        mx=v2[x];
        x--;
        mn+=v1[x];
        mx+=v2[x];
        //mn/=2;
       // mx/=2;
    }
   // cout<<mx<<" "<<mn<<endl;
    ans=mx-mn+1;
    cout<<ans;
    return 0;
}

Measured memory_bytes: 5024
#include<bits/stdc++.h>
using namespace std;
int n;
double X[55],Y[55];
double dist(double x1,double x2,double y1,double y2){
	return sqrt(double((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)));
}
double dist(double x,double y){
	double rad=0.00;
	for(int i=1;i<=n;i++){
		rad=max(rad,dist(X[i],x,Y[i],y));
	}
	return rad;
}
double func(double x){
	double le=0,ri=1000,mid1,mid2,f1,f2,ans;
	for(int i=1;i<=1000;i++){
		mid1=le+(ri-le)/3;mid2=ri-(ri-le)/3;
		f1=dist(x,mid1);f2=dist(x,mid2);
		if(f1<f2){ans=f1;ri=mid2;}
		else{ans=f2;le=mid1;}
	}
	return ans;
}
int main(){
	#ifdef FILIN
		#ifndef LOCAL
			freopen(FILIN,"r",stdin);
			freopen(FILOUT,"w",stdout);
		#endif
	#endif
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>X[i]>>Y[i];
	} 
	//ternary search
	double le=0,ri=1000,mid1,mid2,f1,f2,ans;
	for(int i=1;i<=1000;i++){
		mid1=le+(ri-le)/3;mid2=ri-(ri-le)/3;
		f1=func(mid1);f2=func(mid2);
		if(f1<f2){ans=f1;ri=mid2;}
		else{ans=f2;le=mid1;}
	}
	cout<<fixed<<setprecision(20)<<ans<<endl;
	return 0;
}


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

using namespace std;

#define fori(x) for (int i = 0; i < x; ++i)
#define forj(x) for (int j = 0; j < x; ++j)

int main() {
	int n;long long k;
	int a[200000];
	cin >> n>>k;
	fori(n){cin>>a[i];--a[i];}//町とアクセス番号が違うため-1
	bool c[200000]={};
	long long *l=new long long[200000];//
	fori(200000){l[i]=0;}
	
	int now=0;

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

	//c[0]=true;l[0]=0;//出発
	for(long long i=0;i<=n+1;++i){
		if(c[now]){
			long long num=(k-i)%(i-l[now]);//この地点からあと何回
			for(long long j=0;j<num;++j){
				now=a[now];
			}
			break;
		}else{
			c[now]=true;
			l[now]=i;
		}
		now=a[now];
	}
	cout<<now+1;
	delete[] l;
	return 0;
}

Measured memory_bytes: 6172
args = []
line_count = gets.to_i
line_count.times do |i|
  line = gets
  x = line.split.sort.map(&:to_i).sort!
  if (x[0]**2 + x[1]**2 == x[2]**2)
    puts 'YES'
  else
    puts 'NO'
  end
end

Measured memory_bytes: 6108
n, m = map(int, input().split())

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

uf = UnionFind(n+1)
A = [0]*m
B = [0]*m
for i in range(m):
    A[i], B[i] = sorted(map(int, input().split()))
    uf.union(A[i], B[i])
print(uf.group_count()-2)
    


Measured memory_bytes: 18320