akhauriyash/Code-Regression huggingface dataset:
#coding:utf-8

import sys
from collections import defaultdict

if __name__ == "__main__":
    N, M = map(int, input().split(" "))

    V = set()
    E = []
    for i in range(M):
        a, b, c = map(int, input().split(" "))
        V.add(a)
        V.add(b)
        E.append((a, b, -c))

    dist = defaultdict(lambda :10**20 + 1)
    pre = {}
    dist[1] = 0


    for i in range(1, len(V)):
        for edge in E:
            u = edge[0]
            v = edge[1]

            if dist[v] > dist[u] + edge[2]:
                dist[v] = dist[u] + edge[2]
                pre[v] = u

    is_cycle = False
    cycle_node = []
    for edge in E:
        u = edge[0]
        v = edge[1]
        if dist[u] + edge[2] < dist[v]:
            is_cycle = True
            cycle_node.append(u)

    is_inf = False
    if is_cycle:
        route_node = N
        while route_node != 1:
            route_node = pre[route_node]
            if route_node in cycle_node:
                is_inf = True
                break


    if is_inf:
        print ("inf")
    else:
        print (-dist[N])


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

int main() {
int n,m;cin>>n>>m;
int a[n];
map<int,int> count;
vector<int> num;
rep(i,n){
 cin>>a[i];
 count[a[i]]++;
}
for(auto p:count){
 num.push_back(p.second);
}
sort(all(num));
int ans=0;
if(num.size()>m){
    for(int i=0;i<num.size()-m;i++){
        ans+=num[i];
    }
}
else ans=0;
cout<<ans<<endl;
}

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

int main() {
    int r, D, x;
    cin >> r >> D >> x;

    rep(i, 10) {
        x = r*x - D;
        cout << x << endl;
    }

    return 0;
}

Measured memory_bytes: 256
// 解き直し.
// https://img.atcoder.jp/data/arc/058/editorial.pdf
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
#define repex(i, a, b, c) for(int i = a; i < b; i += c)
#define repx(i, a, b) repex(i, a, b, 1)
#define rep(i, n) repx(i, 0, n)
#define repr(i, a, b) for(int i = a; i >= b; i--)
const LL MOD = 1e9 + 7;
LL dp[41][1 << 16];
LL mPow10[41];

int main(){
    
    // 1. 入力情報.
    int N, X, Y, Z;
    scanf("%d %d %d %d", &N, &X, &Y, &Z);
    
    // 2. 10 の 冪乗 を 保存.
    mPow10[0] = 1;
    rep(i, 40) mPow10[i + 1] = mPow10[i] * 10, mPow10[i + 1] %= MOD;
    
    // 3. XYZ を 含まない文字列の数をカウント(解説通り).
    int mask  = (1 << (X + Y + Z - 1)) - 1;
    int xMask = 1 << (X + Y + Z - 1);
    int yMask = 1 << (Y + Z - 1);
    int zMask = 1 << (Z - 1);
    dp[0][0] = 1;
    repx(i, 1, N + 1){
        // 前回以前の情報に, 今回出現情報(1 ～ 10) を 結合.
        rep(n, 10){
            int cur = 1 << n; // 現在見ている数列の値.
            rep(bef, 1 << 16){
                // 3-1. 評価対象.
                int eva = (bef << (n + 1)) + cur;
                
                // 3-2. 前回以前が, XYZ と 等しい場合は, Skip.
                if((eva & xMask) && (eva & yMask) && (eva & zMask)) continue;
                
                // 3-3. 前回以前が, XYZ と 等しくない場合は, 更新.
                int j = mask & eva;
                dp[i][j] += dp[i - 1][bef];
                dp[i][j] %= MOD;
            }
        }
    }
    
    // 4. 出力.
    LL ans = 0;
    rep(j, 1 << 16) ans += dp[N][j], ans %= MOD; 
    ans = (MOD + mPow10[N] - ans) % MOD;
    printf("%lld\n", ans);
    return 0;
    
}

Measured memory_bytes: 24304
// ?????¬???????????¬?????? (????°????)

#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
typedef pair<int, int> pii;
typedef pair<double, int> pdi;
typedef long long ll;
constexpr ll INF = 1001001001001001LL;
constexpr ll MOD = 1000000007LL;

int N;
double R, theta;
int x[25], y[25];
vector<pdi> to[25][25];
double rec[25][25][10001];

// ??´??? ab ??¨ ac ?????????
double dot(int a, int b, int c) {
    int px = x[b] - x[a], qx = x[c] - x[a];
    int py = y[b] - y[a], qy = y[c] - y[a];
    return px * qx + py * qy;
}

// ???????????? ab ?????????
double absvec(int a, int b) {
    double px = x[b] - x[a], py = y[b] - y[a];
    return sqrt(px*px + py*py);
}

// ??§???????????´???
double to_rad(double t) {
    return M_PI * t / 180.0;
}

struct Elem {
    int cur, prev, res;
};

bool operator<(const Elem &a, const Elem &b) {
    return rec[a.cur][a.prev][a.res] > rec[b.cur][b.prev][b.res];
}

signed main() {
    cin >> N >> R >> theta;
    double val = cos( to_rad(theta) );
    rep(i,0,N) cin >> x[i+1] >> y[i+1];

    repq(i,1,N) repq(j,1,N) {
        if(i == j) continue;
        repq(k,1,N) {
            if(i == k || j == k) continue;
            double temp = - dot(i, j, k) / absvec(i, j) / absvec(i, k);
            if(val <= temp) to[i][j].push_back(pdi(absvec(i, k), k));
        }
    }

    // ????????????????????§????????????
    repq(i,2,N) {
        to[1][0].push_back(pdi(absvec(1, i), i));
    }

    rep(i,0,25) rep(j,0,25) rep(k,0,10001) rec[i][j][k] = INF;
    rec[1][0][0] = 0.0;

    priority_queue<Elem> q;
    q.push(Elem{1, 0, 0});

    while(!q.empty()) {
        Elem t = q.top(); q.pop();
        for(auto x : to[t.cur][t.prev]) {
            int nx = x.second; double cost = x.first;
            if(rec[nx][t.cur][t.res+1] > rec[t.cur][t.prev][t.res] + cost) {
                if(rec[t.cur][t.prev][t.res] + cost > R) continue;
                rec[nx][t.cur][t.res+1] = rec[t.cur][t.prev][t.res] + cost;
                q.push(Elem{nx, t.cur, t.res+1});
            }
        }
    }

    int ans = 0;
    repq(i,1,N) repq(j,1,N) rep(k,0,10001) {
        if(rec[i][j][k] == INF) continue;
        chmax(ans, k);
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

int main()
{
  int N; cin >> N;
  vector<char> S(N);
  for (int i = 0; i < N; ++i) {
    cin >> S[i];
  }

  if (find(S.begin(), S.end(), 'Y') == S.end()) {
    cout << "Three";
  } else {
    cout << "Four";
  }
}

Measured memory_bytes: 256
# input = sys.stdin.readline
from bisect import *
from collections import *
from heapq import *
# import functools
# import itertools
# import math
H,N=map(int,input().split())
AB=[list(map(int,input().split())) for i in range(N)]
#AB=sorted(AB,key=lambda x:x[1])
A=H+10**4+1
dp=[10**9 for i in range(H+10**4+1)]
dp[0]=0
for a,b in AB:
    for i in range(1,A):
        if i>=a:
            dp[i]=min(dp[i-a]+b,dp[i])

print(min(dp[H:]))


Measured memory_bytes: 44632
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cassert>

using namespace std;
typedef long long LL;
template <typename F, typename S> std::ostream& operator<<(ostream& os, const pair<F,S>& p) {
    os << "(" << p.first << "," << p.second << ")"; return os; }
template <typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "["; for(const T& a: v){ os << a << ", "; } os << "]"; return os; }
template <typename K, typename V> ostream& operator<<(ostream& os, const map<K,V>& m) {
    os << "{"; for(const auto& p: m){ os << p.first <<":"<< p.second << ", "; } os << "]"; return os; }


// import here

void dfs(LL node, LL parent, vector<vector<LL>>& edge, vector<LL>& ref_cnt, vector<LL>& max_child, LL depth){
    max_child[depth] = max(max_child[depth], ref_cnt[node]-1);
    for(LL next: edge[node]){
        if(next == parent) continue;
        dfs(next, node, edge, ref_cnt, max_child, depth+1);
    }
}


pair<LL,LL> solve(LL root, vector<LL>& ref_cnt, vector<vector<LL>>& edge){
    LL n = edge.size();
    vector<LL> max_child(n+1);
    dfs(root, root, edge, ref_cnt, max_child, 0);
    max_child[0] = ref_cnt[root];
    //cerr << max_child << endl;

    LL total_leaf = 1;
    LL max_depth = 0;
    for(LL n_child: max_child){
        if(n_child <= 0) break;
        total_leaf *= n_child;
        max_depth += 1;
    }

    return pair<LL, LL>(max_depth+1, total_leaf);
}


pair<LL,LL> solve2(LL root1, LL root2, vector<LL>& ref_cnt, vector<vector<LL>>& edge){
    LL n = edge.size();
    vector<LL> max_child(n+1);
    dfs(root1, root2, edge, ref_cnt, max_child, 0);
    dfs(root2, root1, edge, ref_cnt, max_child, 0);
    max_child[0] = max(ref_cnt[root1]-1, ref_cnt[root2] - 1);
    //cerr << max_child << endl;

    LL total_leaf = 1;
    LL max_depth = 0;
    for(LL n_child: max_child){
        if(n_child <= 0) break;
        total_leaf *= n_child;
        max_depth += 1;
    }

    return pair<LL, LL>(max_depth+1, total_leaf*2);
}


int main(){
    LL n;
    cin >> n;
    vector<vector<LL>> edge(n);
    vector<LL> ref_cnt(n);
    for(LL i = 0; i < n-1; ++i){
        LL u, v;
        cin >> u >> v;
        --u; --v;
        edge[u].push_back(v);
        edge[v].push_back(u);
        ref_cnt[u] += 1;
        ref_cnt[v] += 1;
    }

    vector<pair<LL,LL>> res_list;
    for(LL i = 0; i < n; ++i){
        pair<LL,LL> res = solve(i, ref_cnt, edge);
        //cerr << i << " : " << res << endl;
        res_list.push_back(res);
        for(LL j: edge[i]){
            pair<LL,LL> res = solve2(i, j, ref_cnt, edge);
            //cerr << i << ", " << j << " : " << res << endl;
            res_list.push_back(res);
        }
    }
    sort(res_list.begin(), res_list.end());
    cout << res_list[0].first << " " << res_list[0].second << endl;
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define REP(i,a,b) for(int i=(a),ed=(b);i<=ed;++i)
#define DREP(i,a,b) for(int i=(a),ed=(b);i>=ed;--i)
typedef long long ll;
inline int read(){
    register int x=0,f=1;register char ch=getchar();
    while(!isdigit(ch)){if(ch=='-')f=0;ch=getchar();}
    while(isdigit(ch)){x=x*10+(ch^'0');ch=getchar();}
    return f?x:-x; 
}

const int N=5e5+10,inf=0x3f3f3f3f;
int n,k,a[N],b[N],ind[N];
vector<int> E[N];
priority_queue<int,vector<int>,greater<int> > q;

namespace SegmentTree{
#define ls(p) p<<1
#define rs(p) p<<1|1
    int tr[N<<2];
    inline void pushup(int p){tr[p]=min(tr[ls(p)],tr[rs(p)]);}
    inline void Build(int p,int l,int r){
        tr[p]=inf;if(l==r)return;
	int mid=(l+r)>>1;
	Build(ls(p),l,mid),Build(rs(p),mid+1,r);
    }
    inline void Insert(int p,int l,int r,int pos,int v){
	if(l==r){tr[p]=v;return;}
	int mid=(l+r)>>1;
	if(mid>=pos)Insert(ls(p),l,mid,pos,v);
	else Insert(rs(p),mid+1,r,pos,v);
	pushup(p);
    }
    inline int Query(int p,int l,int r,int L,int R){
	if(L>R)return inf;
	if(L<=l&&r<=R)return tr[p];
	int mid=(l+r)>>1,ans=inf;
	if(L<=mid)ans=min(ans,Query(ls(p),l,mid,L,R));
	if(mid<R)ans=min(ans,Query(rs(p),mid+1,r,L,R));
	return ans;
    }
}using namespace SegmentTree;

int main(){
    //freopen("in.in","r",stdin);
    n=read(),k=read();REP(i,1,n)a[i]=read(),b[a[i]]=i;
    Build(1,1,n);
    DREP(i,n,1){
	int p=Query(1,1,n,max(1,b[i]-k+1),b[i]-1);
	if(p^inf)E[b[i]].push_back(b[p]),++ind[b[p]];
	p=Query(1,1,n,b[i]+1,min(n,b[i]+k-1));
	if(p^inf)E[b[i]].push_back(b[p]),++ind[b[p]];
	Insert(1,1,n,b[i],i);
    }
    REP(i,1,n)if(!ind[i])q.push(i);
    int cnt=0;
    while(q.size()){
	int u=q.top();q.pop();
	a[u]=++cnt;
	for(int v:E[u])
	    if(!--ind[v])q.push(v);
    }
    REP(i,1,n-1)printf("%d\n",a[i]);
    printf("%d",a[n]);
    return 0;
}


Measured memory_bytes: 44672
// "bits/stdc++.h" {{{
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <sstream>
#include <numeric>
#include <array>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <cassert>
#include <cctype>
#include <cfloat>
#include <climits>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <limits>
#include <typeinfo>
#include <initializer_list>
#include <bitset>
#include <chrono>
#include <functional>
#include <tuple>
#include <typeindex>
#include <utility>
#include <string>
#include <regex>
// }}}

// Begin {{{
using namespace std;

#define all(x) x.begin(), x.end()
#define rep(i, n) for (i64 i = 0; i < (n); ++i)
#define reps(i, s, n) for (i64 i = (s); i <= (n); ++i)
#define VAR(Type, ...) Type __VA_ARGS__; IN(__VA_ARGS__)
#define Float(x) OUTN(fixed, setprecision(x));

using i64 = int_fast64_t;
using pii = pair<i64, i64>;

template <class A, class B>
inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }

template <class A, class B>
inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;

// IN
void IN() {}
template <class Head, class... Tail>
void IN(Head&& head, Tail&&... tail) {
  cin >> head;
  IN(forward<Tail>(tail)...);
}

// OUTS
void OUTS() {}
template <class Head, class... Tail>
void OUTS(Head&& head, Tail&&... tail) {
  cout << head << " \n"[sizeof...(tail)==0];
  OUTS(forward<Tail>(tail)...);
}

template <class T>
void OUTS(vector<T> &vec) { for (auto &e : vec) cout << e << " \n"[&e==&vec.back()]; }

template <class T>
void OUTS(vector<vector<T>> &df) { for (auto &vec : df) OUTS(vec); }

// OUTL
void OUTL() {}
template <class Head, class... Tail>
void OUTL(Head&& head, Tail&&... tail) {
  cout << head << "\n";
  OUTL(forward<Tail>(tail)...);
}

template <class T>
void OUTL(vector<T> &vec) { for (auto &e : vec) cout << e << "\n"; }

// OUTN
void OUTN() {}
template <class Head, class... Tail>
void OUTN(Head&& head, Tail&&... tail) {
  cout << head;
  OUTN(forward<Tail>(tail)...);
}

template <class T>
void OUTN(vector<T> &vec) { for (auto &e : vec) cout << e; }
// }}} End

signed main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  VAR(int, h, w);
  reps(i, 1, h) {
    char c = 'A';
    rep(j, w) {
      VAR(string, s);
      if (s == "snuke") OUTN(c, i, "\n");
      c++;
    }
  }
  return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>

namespace gaw
{
	const int N=201000;

	int s[N],t[N],n;

	void solve()
	{
		scanf("%d",&n);
		for(int i=1;i<=n;i++)scanf("%d",s+i),t[i]=s[i];
		int a,b;

		std::nth_element(s+1,s+n/2,s+n+1),a=s[n/2];
		std::nth_element(s+1,s+n/2+1,s+n+1),b=s[n/2+1];

		for(int i=1;i<=n;i++)
			printf("%d\n",t[i]<=a?b:a);
	}
}

int main()
{
	gaw::solve();
	return 0;
}


Measured memory_bytes: 3712
import sys
input = sys.stdin.readline

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

sum = 0
for i in range(N):
    d1 = min(A[i], B[i])
    A[i] -= d1
    B[i] -= d1
    sum += d1
    d2 = min(A[i+1], B[i])
    A[i+1] -= d2
    B[i] -= d2
    sum += d2

print(sum)



Measured memory_bytes: 89216
import bisect

lis = [1, 13]

str = input()
tp = int(str[:2])
bt = int(str[2:])

tplo = bisect.bisect_right(lis, tp)
btlo = bisect.bisect_right(lis, bt)

if tplo == 1:
    if btlo == 1:
        jd = 2
    else:
        jd = 1
else:
    if btlo == 1:
        jd = 0
    else:
        jd = 3

judge = ["YYMM", "MMYY", "AMBIGUOUS", "NA"]

print(judge[jd])


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b;
    char c,k,l;
    cin>>a;
    k=cin.get();
    cin>>c;
    l=cin.get();
	cin>>b; 
    if(c=='+')
    cout<<a+b<<endl;
    else if(c=='-')
    cout<<a-b<<endl;
}

Measured memory_bytes: 256
#include <string>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
using namespace std;
char A[9],B[9];
#define I(s)strtol(s.c_str(),NULL,10)
string S(int i,int L){sprintf(A,"%%0%dd",L),sprintf(B,A,i);return B;}
int main(){
	int a,i;
	for(;scanf("%d",&a),a;printf(a?"%d\n":"NA\n",i)){
		for(i=0;a&&a!=6174;i++){
			string t=S(a,4),s;
			sort(t.begin(),t.end());
			s=t;
			reverse(s.begin(),s.end());
			a=I(s)-I(t);			
		}
	}
}

Measured memory_bytes: 1104
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
 
using namespace std;

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

    int h, w, a, b;
    cin >> h >> w >> a >> b;
    string s;
    string t;
    for (int i = 0; i < w; i++) {
    	s.push_back((i < a) + '0');
    	t.push_back((i >= a) + '0');
    }
    for (int i = 0; i < h; i++) {
    	cout << ((i < b) ? t : s) << '\n';
    }
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
 
const double pi = 3.141592653589793238462643383279;
 
 
using namespace std;
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
 
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#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())
 
 
//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007
 
 
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
 
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
const double EPS = 1E-8;
 
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)

// ここから編集
template<typename T = int> struct BIT{
  vector<T> node;

  int N;
  BIT(int n){
    N = n;
    node.resize(N+1);
  }

  void add(int i, T x){
    i++;
    while(i <= N){
      node[i] += x;
      i += (i & -i);
    }
  }

  T sum(int i){
    T res = 0;
    while(i > 0){
      res += node[i];
      i -= (i & -i);
    }
    return res;
  }

  

};

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

    int N, K; cin >> N >> K;
    vector<int> v(N);
    REP(i,N)cin >> v[i];
    sort(all(v));
    int a=0;
    for(int i=0; i<K; i++){
      a += v[i];
    }
    cout << a << endl;
    return 0;
}


Measured memory_bytes: 3656
if __name__ == "__main__":
    A, V= list(map(int, input().split()))
    B, W= list(map(int, input().split()))
    T = int(input())
    C = abs(A-B)
    X = V-W
    if C <= T*X:
        print("YES")
    else:
        print("NO")

Measured memory_bytes: 9180
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int n = input.nextInt();
        double k = input.nextDouble();
        if (k <= (Math.ceil(n/2.0))){
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }
}

Measured memory_bytes: 25044
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()

from collections import defaultdict, deque, Counter
from sys import exit
import heapq
import math
import fractions
import copy
from itertools import permutations
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

from itertools import permutations
from math import factorial, hypot

N, K = getNM()
A = getList()
mi = min(A)
miindex = []
for i in range(N):
    if A[i] == mi:
        miindex.append(i)
ans = 1000000
for i in miindex:
    rang = K - 1
    opt1 = (i + rang - 1) // rang
    newi = opt1 * rang + 1
    opt2 = ((N - newi) + rang - 1) // rang
    ans = min(ans, opt1 + opt2)
print(ans)

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

using namespace std;

using ll = long long;
constexpr ll MOD = 998244353;
constexpr ll INF = 1e18;

int main() {
    ll n, m, i, j, k,s;
    cin >> n >> s;
    vector<ll> A(n);
    for(auto &x:A){
        cin >> x;
    }
    ll dp[n+1][s+1];
    for(i=0;i<=n;i++){
        for(j=0;j<=s;j++){
            dp[i][j]=0;
        }
    }
    dp[0][0]=1;
    for(i=0;i<n;i++){
        for(j=0;j<s+1;j++){
            (dp[i+1][j]+=((2*dp[i][j])%MOD))%=MOD;
            if(j+A[i]<=s){
                dp[i+1][j+A[i]]+=dp[i][j];
                dp[i+1][j+A[i]]%=MOD;
            }
        }
    }
    cout << dp[n][s] << endl;
    return 0;
}

Measured memory_bytes: 73892
import itertools
import math
import string
import collections
from collections import Counter
from collections import deque
import sys
sys.setrecursionlimit(2*10**5)
INF = 2**60


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


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]
N, W = map(int, input().split())
w = []
v = []
for _ in range(N):
    ww, vv = map(int, input().split())
    w.append(ww)
    v.append(vv)
dp = [[0]*(W+1) for j in range(N+1)]
for i in range(N):
    for sum_w in range(W+1):
        if w[i] <= sum_w:
            dp[i+1][sum_w] = max(dp[i][sum_w], dp[i][sum_w-w[i]]+v[i])
        else:
            dp[i+1][sum_w] = dp[i][sum_w]
# print(dp)
print(dp[N][W])


Measured memory_bytes: 120300
#include <algorithm>
#include <bitset>
#include <iomanip>
#include <ios>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>

using namespace std;

int main()
{
    int A, B, C;
    cin >> A >> B >> C;
    if (A == B) {
        cout << C;
    } else if (B == C) {
        cout << A;
    } else {
        cout << B;
    }
    cout << "\n";
}

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

int main() {
  long long int N, A, B, C, D;
  string S;

  cin >> N >> A >> B >> C >> D;
  cin >> S;

  for(int i = A; i < C; i++) {
    if(S[i] == S[i+1] && S[i] == '#') {
      cout << "No";
      return 0;
    }
  }
  for(int i = B; i < D; i++) {
    if(S[i] == S[i+1] && S[i] == '#') {
      cout << "No";
      return 0;
    }
  }
  if(C < D) cout << "Yes";

  else if(C > D) {
    bool flag = false;
    for(int i = B - 1; i < D; i++) {
      if(S[i] == S[i-1] && S[i] == S[i+1] && S[i] == '.') flag = true;
    }
    if(flag) cout << "Yes";
    else cout << "No";
  }
  else cout << "No";
  return 0;
}


Measured memory_bytes: 640
#include<stdio.h>
int main()
{
	int H,W,i,j;
	while(1)
	{
		scanf("%d %d",&H,&W);

		if(H==0 && W==0)
		{
			break;
		}
		for(i=0;i<H;i++)
		{
			for(j=0;j<W;j++)
			{
				printf("#");
			}
			printf("\n");
		}
		printf("\n");
	}
	return 0;
}

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

int main() {
  vector<int> a(5);
  int time = 0;
  int rem = 10;
  for(int i=0; i<5; i++) {
    cin >> a.at(i);
    if(a.at(i) % 10 == 0) {
      time += a.at(i);
    } else {
      time += ((a.at(i) / 10 + 1) * 10);
      int temp = a.at(i) % 10;
      rem = min(rem, temp);
    }
  }
  time -= 10-rem;
  cout << time << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define x first
#define y second
#define int int long long // 2e9 & 9e18
using namespace std; const int inf = numeric_limits<int>::max();
struct __io{__io(){ios_base::Init i; ios_base::sync_with_stdio(0); cin.tie(0);}} __io; // fast I/O
#ifdef LOCAL // setting up print debugging (yes lol)
template<class K, class V>ostream& operator<<(ostream&s,const pair<K,V>&p){s<<'<'<<p.x<<", "<<p.y<<'>';return s;}
template<class T, class=typename T::value_type, class=typename enable_if<!is_same<T,string>::value>::type>
ostream& operator<<(ostream&s,const T&v){s<<'[';for(auto&x:v){s<<x<<", ";}if(!v.empty()){s<<"\b\b";}s<<']';return s;}
void __prnt(){cerr<<endl;} template<class T, class...Ts>void __prnt(T&&a,Ts&&...etc){cerr<<a<<' ';__prnt(etc...);}
#define print(...) __prnt(__VA_ARGS__)
#else
#define print(...)
#endif

int mod = 1000000007;

int amin(int n, int k) {
    return (k * (k-1) / 2) % mod;
}
int amax(int n, int k) {
    return (k * (2 * n - k + 1) / 2) % mod;
}

signed main() {
    int n, k;
    cin >> n >> k;
    int ans = 1;
    int subans;
    for (int i = k; i <= n; ++i) {
        subans = amax(n, i) - amin(n, i) + 1;
        subans = (subans + mod) % mod;
        ans = (ans + subans) % mod;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3652
n = int(input())
x, y = [0]*n, [0]*n
for i in range(n):
    x[i], y[i] = map(int, input().split())

kyi = 0
for i in range(n-1):
    for j in range(i+1,n):
        kyi += ((x[i]-x[j])**2 + (y[i]-y[j])**2)**0.5

print(kyi * 2 / n)

Measured memory_bytes: 3188
#include <iostream>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <string>
#include <cmath>
#include <cstdio>
#include <cctype>
#include <ctime>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <complex>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cwchar>
#include <cwctype>
#include <exception>
#include <locale>
#include <numeric>
#include <new>
#include <stdexcept>
#include <limits>
#include <valarray>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <list>
#include <utility>
#include <bitset>
#include <algorithm>
#include <functional>
using namespace std;
#define sc second
#define fs first
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define ABS(a) (((a)>0)?(a):(-(a)))
typedef long long LL;
typedef pair < int , int > pii;
const LL MOD=1000000007;
int arr[305][305],n,m,cnt[305],ptr[305];
bool del[305],have[305][305],sel[305];
bool check(int key){
	memset(del,0,sizeof(del));
	memset(ptr,0,sizeof(ptr));
	int xb,x2,mp=-1;
	for(xb=0;xb<m;xb++) sel[xb]=1;
	while(1){
		bool got;
		memset(cnt,0,sizeof(cnt));
		mp=-1;
		for(xb=0;xb<n;xb++){
		//	printf("%d\n",ptr[xb]);
			while(ptr[xb]<m && !sel[arr[xb][ptr[xb]]]) {
				ptr[xb]++;
			}
		//	printf("%d\n",ptr[xb]);
			if(ptr[xb]<m)cnt[arr[xb][ptr[xb]]]++;
		}
		for(xb=0;xb<m;xb++){
			if(cnt[xb]>key){
				mp=xb;
				break;
			}
		}
		if(mp==-1) break;
		sel[mp]=0;
	}
	for(xb=0;xb<m;xb++) if(sel[xb]) return 1;
	return 0;
}
int main(){
	scanf("%d%d",&n,&m);
	int xb,x2;
	for(xb=0;xb<n;xb++){
		for(x2=0;x2<m;x2++) {
			scanf("%d",&arr[xb][x2]); 
			arr[xb][x2]--;
			have[xb][arr[xb][x2]]=1;
		}
	}
	int low=0,hgh=n,mid;
	while(low<hgh){
		mid=((low+hgh)>>1);
		if(check(mid)) hgh=mid; else low=mid+1;
	}
	printf("%d\n",low);
	//for(xb=0;xb<=n;xb++) printf("%d ",check(xb));
	return 0;
}

Measured memory_bytes: 640
#include<algorithm>
#include<iostream>
#include<numeric>
#include<vector>
#include<string.h>

void solve( std::vector<int> v, int n, bool ans[] )
{
	if( !std::accumulate( v.begin(), v.end(), 0 ) ){
	 	ans[n] = true;
		return;
	}
	
	for( int i = 1; i <= 9; i++ ){
	 	if( v[i] >= 3 ){
		 	v[i] -= 3;
			solve( v, n, ans );
			v[i] += 3;
		}
	}
	
	for( int i = 1; i <= 7; i++ ){
	 	if( v[i] && v[i+1] && v[i+2] ){
		 	v[i]--;
			v[i+1]--;
			v[i+2]--;
			solve( v, n, ans );
			v[i]++;
			v[i+1]++;
			v[i+2]++;
		}
	}
	
	return;
}

int main()
{
	char str[20];

	while( std::cin >> str ){
		std::vector<int> v;
		bool ans[10] = {0};
		
		for( int i = 0; i < 10; i++ ) v.push_back( 0 );
		
	 	for( int i = 0; i < strlen( str ); i++ ){
			v[ str[i] - '0' ]++;
		}
		
		for( int i = 1; i <= 9; i++ ){
			if( v[i] == 4 ) continue;
			else{
				v[i]++;
				for( int j = 1; j <= 9; j++ ){
					if( v[j] >= 2 ){
					 	v[j] -= 2;
						solve( v, i, ans );
						v[j] += 2;
					}
				}
				v[i]--;
			}
		}
		
		if( !std::count( ans + 1, ans + 10, true ) ){
		 	std::cout << 0 << std::endl;
		}
		else{
			bool flag = true;
		 	for( int i = 1; i <= 9; i++ ){
				if( ans[i] ){
					if( flag ){
						flag = false;
					}
					else{
						std::cout << " ";
					}
					std::cout << i;
				}
			}
			std::cout << std::endl;
		}
	}

 	return 0;
}

Measured memory_bytes: 1196
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  ll n,m;
  cin >> n >> m;
  ll ans = [&]{
    if(n==1&&m==1) return 1LL;
    if(n==1||m==1) return max(n,m)-2;
    return (n-2)*(m-2);
  }();
  cout << ans << endl;
}


Measured memory_bytes: 256
package main

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

func main() {
	sc := NewScanner()
	N, K := sc.NextInt(), sc.NextInt()

	if N >= K*2-1 {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}

}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


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

using namespace std;
using ll = long long;

int main()
{
    int n, k;

    cin >> n >> k;

    vector<int> w(n);
    for (int i = 0; i < n; ++i) cin >> w[i];

    auto check = [&](int capacity)
    {
        ll i {};
        for (int j = 0; j < k; ++j)
        {
            ll sum {};
            while (i < n && sum + w[i] <= capacity)
            {
                sum += w[i];
                i++;
            }

            if (i == n) return true;

        }
        return false;
    };

    ll left = 0, right = 100000 * 10000;
    while (right - left > 1)
    {
        ll mid = (left + right) / 2;
        if (check(mid)) right = mid;
        else left = mid;
    }


    cout << right << endl;

    return 0;
}

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

int main() {
    int a, b;
    cin >> a >> b;
    if (a == 1) a = 14;
    if (b == 1) b = 14;
    if (a > b)
        cout << "Alice" << endl;
    else if (a < b)
        cout << "Bob" << endl;
    else
        cout << "Draw" << endl;

    return 0;
}


Measured memory_bytes: 3616
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception {
        // TODO ?????????????????????????????????????????????
        
        boolean first=true;
        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
            String line;
            while ((line = br.readLine()) != null) {
            	int s=Integer.parseInt(line);
            	System.out.println(s/3600+":"+(s/60)%60+":"+s%60);
            	break;
            }
        }
    }
}

Measured memory_bytes: 24328
nk = list(map(int, input().split()))
N = nk[0]
K = nk[1]
p = list(map(int, input().split()))



def max_cal(max_p,sum_p):
    if(max_p < sum_p):
        max_p = sum_p
    return max_p

if __name__ == '__main__':
    max_p = 0
    sum_p = 0
    for k in range(K):
        sum_p = sum_p + p[k]
        max_p = max_cal(max_p, sum_p)
    #print(sum_p)
    for j in range(1,N-K+1):
        sum_p = sum_p - p[j-1] + p[j+K-1]
        max_p = max_cal(max_p, sum_p)
    #print(max_p)
    print((max_p+K)/2)

Measured memory_bytes: 25060
import sys
from collections import defaultdict

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def main():
    inf = 10 ** 14
    n, m = MI()
    ee = []
    # スコアの正負を逆にし、最小値を求める問題に置き換える
    for _ in range(m):
        a, b, c = MI()
        a, b = a - 1, b - 1
        ee.append([a, b, -c])
    # ベルマン・フォードで最小スコアを計算
    # n-1回やっても更新があるということは負の閉路があるということ
    # 負の閉路がなければ答えを出力して終了
    score = [inf] * n
    score[0] = 0
    for _ in range(n):
        change = False
        for a, b, c in ee:
            if score[a] + c < score[b]:
                score[b] = score[a] + c
                change = True
        if not change:
            print(-score[n - 1])
            exit()
    # 負の閉路がある場合は、その影響がゴールまで届くかをチェック
    reachable = [False] * n
    for _ in range(n):
        for a, b, c in ee:
            if reachable[a]:reachable[b]=True
            if score[a] + c < score[b]:
                score[b] = score[a] + c
                reachable[b] = True
        if reachable[n - 1]:
            print("inf")
            exit()
    print(-score[n-1])

main()


Measured memory_bytes: 3688
#include<bits/stdc++.h>
#include<stdio.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define pb                  push_back
#define arr                 vector<ll>
#define mem(x,val)          memset(x,val,sizeof(x))
#define vp                  vector<pair<ll,ll>>
#define matrix              vector<vector<ll> >
#define digit(x)            floor(log10(x))+1
#define debug(x)            cerr << #x << " is " << x << endl;
#define all(a)              a.begin(),a.end()
#define fixed               setprecision(15)
// ll dx[]={-1,1,0,0},dy[]={0,0,-1,1}; 4 Sides
//ll dx[]={-1,1,-1,1,0,0,-1,1} , dy[]={-1,1,0,0,-1,1,1,-1};    8 Sides
using namespace std;
ll maxx = INT_MIN;
ll minx = INT_MAX;
arr read(ll n){
    arr a;
    for (ll i=0;i<n;i++){
        ll x;
        cin>>x;
        a.pb(x);
    }
    return a;
}
int main(){
  ll n;
  cin>>n;
  arr a = read(n);
  ll ans=0;
  for (ll i=0;i<n-2;i++){
      for (ll j=i+1;j<n-1;j++){
          for (ll k=j+1;k<n;k++){
              if (a[i]+a[j]>a[k] and a[j]+a[k]>a[i] and a[k]+a[i]>a[j] and a[i]!=a[j] and a[j]!=a[k] and a[i]!=a[k]){
               //   cout<<a[i]<<" "<<a[j]<<" "<<a[k]<<endl;
                  ans++;
              }
          }
      }
  }
  cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3608
import math

N=int(input())
D,X=map(int,input().split())
A=[0]*N
B=[0]*N
for i in range(N):
  A[i]= int(input())
  B[i]= int(math.ceil(D/A[i]))
  #print(A[i],B[i])
  
print(sum(B)+X)

Measured memory_bytes: 3060
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define lop(i, n) for(i=0; i<n; i++)

int main()
{
	int a, b, c, d;
	scanf("%d %d %d %d", &a, &b, &c, &d);
	
	while(c>=0){
		c-=b;
		if(c<=0){ printf("Yes"); return 0; }
		a-=d;
		if(a<=0){ printf("No"); return 0; }
	}
return 0;
}

Measured memory_bytes: 1732
fn main() {
    let stdin = std::io::stdin();
    let mut sc = Scanner::new(stdin.lock());
    // p = a + b
    // kp + c (0 <= c <= a)
    // 60t + c
    let a: usize = sc.read();
    let b: usize = sc.read();
    let c: usize = sc.read();

    let p = a + b;

    let add = 60 % p;
    let base = c % p;
    if base <= a {
        println!("{}", c);
        return;
    }
    for t in 1..10000 {
        let cur = (add * t + base) % p;
        if cur <= a {
            println!("{}", 60 * t + c);
            return;
        }
    }
    println!("-1");
}

pub struct Scanner<R> {
    reader: R,
}

impl<R> Scanner<R> {
    pub fn new(reader: R) -> Scanner<R> {
        Scanner { reader }
    }
}

fn is_whitespace(b: u8) -> bool {
    b == b' ' || b == b'\n' || b == b'\r' || b == b'\t'
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        let buf = std::io::Read::bytes(self.reader.by_ref())
            .map(|b| b.expect("Read failed"))
            .skip_while(|&b| is_whitespace(b))
            .take_while(|&b| !is_whitespace(b))
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error")
    }

    pub fn read_vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }

    pub fn read_chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}



Measured memory_bytes: 5028
void main() {
	auto N = ri;
	auto H = readAs!(int[]);
	auto arr = new int[](N);
	arr.back = H.back;
	foreach_reverse(i; 0..N-1) arr[i] = min(arr[i+1], H[i]);
	foreach(i, v; H) {
		if(v - 1 > arr[i]) {
			writeln("No");
			return;
		}
	}
	writeln("Yes");
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}

Measured memory_bytes: 4532
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e9)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
#define i_7 (long long)(1e9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;

bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}

int main(){
  
  int n,h,w;
  cin>>n>>h>>w;
  int a[n],b[n];
  int ans = 0;
  REP(i,n){
    cin>>a[i]>>b[i];
    if(a[i]>=h && b[i]>=w){
      ans++;
    }
  }
  cout<<ans<<endl;
  return 0;
}


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

using namespace std;
const int MAXN = 1e5 + 5;

int a, b, c, d;
char str[500];

int main(int argc, char* argv[]) {
    int T;
    scanf("%d", &T);
    while (T--) {
        scanf("%s", str);
        if (str[0] == 'A')
            a++;
        else if (str[0] == 'W')
            b++;
        else if (str[0] == 'T')
            c++;
        else if (str[0] == 'R')
            d++;
    }
    printf("AC x %d\nWA x %d\nTLE x %d\nRE x %d\n", a, b, c, d);
    return 0;
}

Measured memory_bytes: 3788
// Ref ABC 172 B
using System;
using System.Collections.Generic;
using System.Linq;
// using System.Text;

class Program
{
    static void Main()
    {
        string S = Console.ReadLine();
        string T = Console.ReadLine();
        var z = S.Zip(T, (first, second) => new char[] { first, second });
        int ans = 0;
        foreach (var v in z) if (v[0] == v[1]) ans++;
        Console.WriteLine(ans);
        return;
    }
}

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

ll num[200005];
int den2[200005];
int den5[200005];
int main() {
#ifdef LOCAL_EXEC
//  freopen("sample.in", "r", stdin);
#else
  ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#endif

  int n;
  cin >> n;
  int count[300][300] = {};
  ll ans = 0;
  int min2 = 0, min5 = 0;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    num[i] = 0;
    for (int j = 0; j < s.size(); ++j) {
      if (s[j] == '.') {
        den2[i] = den5[i] = s.size() - j - 1;
        continue;
      }
      num[i] = 10*num[i] + s[j] - '0';
    }
    // cout << num[i] << ' ' << den2[i] << ' ' << den5[i] << '\n';
    while (num[i] % 2 == 0) {
      num[i] /= 2;
      den2[i]--;
    }
    while (num[i] % 5 == 0) {
      num[i] /= 5;
      den5[i]--;
    }
    for (int j = -den2[i]; j >= min2; j--) {
      for (int k = -den5[i]; k >= min5; k--) {
        ans += count[j + 100][k + 100];
      }
    }
    // cout << i << ' ' << ans << "; " << den2[i] << ' ' << den5[i] << '\n';
    min2 = min(min2, den2[i]);
    min5 = min(min5, den5[i]);
    count[den2[i] + 100][den5[i] + 100]++;
  }

  cout << ans << '\n';


	return 0;
}

Measured memory_bytes: 7052
from collections import deque

S=deque(list(input()))
Q=int(input())

kkk=1
for i in range(Q):
    Query=list(input().split())
    if Query[0]=="1":
        kkk*=-1
    else:
        num,F,C=Query
        if F=="1":
            if kkk==1:
                S.appendleft(C)
            else:
                S.append(C)
        else:
            if kkk==-1:
                S.appendleft(C)
            else:
                S.append(C)
S=list(S)
if kkk==-1:
    print("".join(S[::-1]))
else:
    print("".join(S))

Measured memory_bytes: 72296
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll                long long int
#define ld                long double
#define pb                push_back
#define mk                make_pair
#define in(i,a,n)         for(ll i=0;i<n;++i) cin>>a[i];
#define out(i,a,n)        for(ll i=0;i<n;++i) cout<<a[i]<<" ";
#define sz                size()
#define all(c)            c.begin(), c.end()
#define rall(c)           c.rbegin(), c.rend()
#define loop(i,a,b)       for(ll i=a;i<b;i++)
#define rloop(i,a,b)      for(ll i=a;i>b;i--)
#define F                 first
#define S                 second
#define deb(x) cout << #x << " " << x << endl
#define inf INT_MAX
const ll N = 100010;
const ll MOD = 1e9+7;
ll mod(ll n) {
    return (n % MOD + MOD) % MOD;
}


void solve(){
    int N, X;
    cin >> X >> N;
    map<int, int> hash;
    for(int i=0;i<N;i++){
        int a;
        cin >> a;
        hash[a] = 1;
    }
    int ans = 0, diff = inf;
    for(int i=0;i<=101;i++){
        if(hash[i] == 0){
            if(abs(X - i) < diff){
                ans = i;
                diff = abs(X - i);
            }
        }
    }
    cout << ans;
}

int main(){
    fast
    int T=1;
    //cin >> T;
    for(int i=0;i<T;i++) solve();
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
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; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    ll N;
    cin >>N;
    vector<Pi>E(100005);
    vector<Pi>O(100005);
    rep(i,100005){
        E[i].second=i;
        O[i].second=i;
    }
    rep(i,N){
        ll v;
        cin>>v;
        if(i%2==0){
            E[v].first++;
        }else{
            O[v].first++;
        }
    }
    sort(all(E));
    reverse(all(E));
    sort(all(O));
    reverse(all(O));
    ll om = 0;
    ll em = 0;
    ll ans;
    if(E[0].second != O[0].second){
        ans = N-E[0].first-O[0].first;
    }else{
        ans = N-max(E[0].first+O[1].first,E[1].first+O[0].first);
    }

    cout << ans << endl;


    return 0;
    

}

Measured memory_bytes: 6404
#include <bits/stdc++.h>
#define pb push_back
#define ppb pop_back
#define fi first
#define se second
#define mid ((x + y) / 2)
#define left (ind * 2)
#define right (ind * 2 + 1)
#define mp make_pair
#define timer ((double)clock() / CLOCKS_PER_SEC)
#define endl "\n"
#define spc " "
#define d1(x) cerr<<#x<<":"<<x<<endl
#define d2(x, y) cerr<<#x<<":"<<x<<" "<<#y<<":"<<y<<endl
#define d3(x, y, z) cerr<<#x<<":"<<x<<" "<<#y<<":"<<y<<" "<<#z<<":"<<z<<endl
#define fast_io() ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;

typedef long long int lli;
typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef pair<double, double> dd;

const int N = (int)(1e6 + 5);
const int LOG = (int)(20);

int n, x, ar[N];

int main() {
	fast_io();
	// freopen("inp.in", "r", stdin);
	
	cin >> n >> x;
	if(x == 1 || x == 2 * n - 1) {
		cout << "No";
		return 0;
	}
	cout << "Yes" << endl;
	if(n == 2) {
		cout << "1 2 3" << endl;
		return 0;
	}
	if(x + 2 <= 2 * n - 1) {
		ar[n] = x;
		ar[n + 1] = x - 1;
		ar[n + 2] = x + 1;
		ar[n - 1] = x + 2;
	}
	else {
		ar[n] = x;
		ar[n + 1] = x + 1;
		ar[n + 2] = x - 1;
		ar[n - 1] = x - 2;	
	}
	int cur = 0;
	for(int i = 1; i <= 2 * n - 1; i++) {
		if(ar[i] != 0)
			continue;
		cur++;
		if(cur == x - 1)
			cur = x + 3;
		ar[i] = cur;
	}
	for(int i = 1; i <= 2 * n - 1; i++)
		cout << ar[i] << spc;
}

Measured memory_bytes: 2304