akhauriyash/Code-Regression huggingface dataset:
fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock()};
    let a: usize = sc.read();
    let s: String = sc.read();
    if a < 3200 {
        println!("red");
    }
    else {
        println!("{}", s);
    }

}

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

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr> (&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n')
            .take_while(|&b| b != b' ' && b != b'\n')
            .collect::<Vec<_>>();
        unsafe{ std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}

Measured memory_bytes: 4352
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

int main(){

    int N;
    cin >> N;
    int a = 0, b = 0, c = 0;
    for(int i = 0; i < N; i++){
        int t;
        cin >> t;
        if(t % 4 == 0)a++;
        else if(t % 2 == 0)b++;
        else c++;
    }
    if(a >= c - (b==0?1:0))cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
n = int(input())
t = 0
for i in range(1, n+1):
  if i % 2 == 1:
    s = 1
    for j in range(1, i//2 + 1):
      if i % j == 0:
        s += 1
    if s == 8:
      t += 1
print(t)

Measured memory_bytes: 9108
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include<limits.h>
#include<iomanip>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define check(v) rep(i,v.size()) cout << v[i] << " ";\
cout << endl
#define INF 1e8
typedef long long ll;
using namespace std;
//オーバーフローに気をつけろよおおおおおお
//確認忘れるなよおおおおおお

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, k, q; cin >> n >> k >> q;
    vector<int> v(n,0);
    rep(i,q) {
        int num; cin >> num;
        num--;
        v[num]++;
    }
    rep(i,n) {
        int minas = q - v[i];
        if(k-minas>0) cout << "Yes" << endl;
        else cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <typeinfo>
#include <cxxabi.h>
#ifdef LOCAL
  #include "dbgtoki.hpp"
  #define DUMP(i) dump((string)TOSTRING(i), demangle(typeid(i).name()), __LINE__ , i) 
#else
  #define DUMP(i) 
#endif
 
#define TOSTRING(x) #x
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(s) (s).begin(), (s).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()) , v.end());

using namespace std;
typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;

struct Edge{
public:
  int from,to,cost;
  Edge(){}
  Edge(int _from,int _to,int _cost){
    from = _from;
    to = _to;
    cost = _cost;
  }
};

typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

const int EPS = 1e-9;
const int MOD = 1e9+7;


int main (){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vi C(n-1),S(n-1),F(n-1);
  REP(i,n-1){
    int c,s,f;
    cin >> C[i] >> S[i] >> F[i];
  }
  REP(i,n-1){
    int time = 0;
    FOR(j,i,n-1){
      time = max(time,S[j]);
      if((time-S[j]) % F[j] != 0)time += F[j] - ((time-S[j]) % F[j]);
      DUMP(time);
      DUMP(C[j]);
      time += C[j];
    }
    cout << time << endl;
  }
  cout << 0 << endl;
  return 0;
}



Measured memory_bytes: 256
num = input()

strs = []

for i in range(int(num)):
  strs.append(input())

strs.sort()

b = ""
cnt = 0
max = -1
maxstr = set()

for s in strs:
  if b == s:
    cnt += 1
  else:
    cnt = 0
  if cnt > max:
    max = cnt
    maxstr.clear()
    maxstr.add(s)
  elif cnt == max:
    maxstr.add(s)
  b = s

ls = list(maxstr)
ls.sort()
for m in ls:
  print(m)

Measured memory_bytes: 29632
_ = int(input())
isEven = True
l1 = map(int, input().split())
count = 0
l2 = []
while isEven:
    for i in l1:
        if i % 2 == 0:
            l2.append(i / 2)
        else:
            isEven = False
            break
    if isEven:
        l1 = l2.copy()
        l2 = []
        count = count + 1
print(count)

Measured memory_bytes: 3060
import sys
import math
import bisect
from heapq import heappush, heappop,heappushpop
from collections import defaultdict

S = input()
T = input()
lenS = len(S)
lenT = len(T)
F1 = [False]*26
F2 = [False]*26
alpha = 'abcdefghijklmnopqrstuvwxyz'
for i in range(lenS):
    F1[alpha.index(S[i])] = True
for i in range(lenT):
    F2[alpha.index(T[i])] = True
for i in range(26):
    if not F1[i] and F2[i]:
        print(-1)
        sys.exit()

ind = S.index(T[0])
ans = ind+1
for i in range(1,lenT):
    S = S[ind+1:] + S[:ind+1]
    ind = S.index(T[i])
    ans += ind+1

print(ans)

Measured memory_bytes: 3980
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define pb push_back
#define ALL(obj) (obj).begin(), (obj).end()

using namespace std;
long A,B;

long check(long n){
    long k = 4;
    long sum = 0;
    if(n % 4 == 1 || n % 4 == 2) sum ++;
    
    while(n >= k/2){
        if(n % k % 2 == 0 && n % k >= k/2) sum += k/2;
        k *= 2;
    }
    return sum;
}

int main(){
    cin >> A >> B;
    
    long ans = check(B)^check(A-1);
    
    cout << ans << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,x=0;
  cin>>n;
  vector<int> p(n);
  for(int i=0;i<n;++i) cin>>p[i];
  sort(p.begin(),p.end(),greater<int>());
  while(p[x]>=(x+1)&&x<n) x++;
  cout<<x<<endl;
  return 0;
}



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

typedef unsigned long long ll;

ll S;
ll p[20] = {1};
ll num[20] = {};

ll digit(ll n){
    ll res = 0;
    ll m = n;
    while(m>0){
        res++;
        m /= 10;
    }
    return res;
}

ll id(ll n){
    ll res = ((n-1)/3+(n-1)/5)*4;//n-1までのFizzBuzzの数
    ll d = digit(n);
    for(ll i=1;i<d;i++){//d-1桁目までの数字の数
        res += i*num[i];
    }
    ll a = (n-1)/3-(p[d-1]-1)/3+(n-1)/5-(p[d-1]-1)/5-((n-1)/15-(p[d-1]-1)/15);//d桁のn-1までのFizzBuzzの数
    res += d*(n-p[d-1]-a);
    return res+1;
}

int main(){
    cin >> S;
    for(int i=1;i<=18;i++){
        p[i] = p[i-1]*10;
        ll a = (p[i]-1)/3-(p[i-1]-1)/3+(p[i]-1)/5-(p[i-1]-1)/5-((p[i]-1)/15-(p[i-1]-1)/15);
        num[i] = p[i]-p[i-1]-a;
    }
    ll l = 1,r = 1e18;
    while(l+1<r){
        ll m = (l+r)/2;
        if(id(m)<=S) l = m;
        else r = m;
    }
    string ans = "";
    for(ll i=l;i<=l+10;i++){
        if(i%3==0 && i%5==0) ans += "FizzBuzz";
        else if(i%3==0) ans += "Fizz";
        else if(i%5==0) ans += "Buzz";
        else ans += to_string(i);
    }
    cout << ans.substr(S-id(l),20) << endl;
}


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

template <int& MOD_> struct modnum {
	static constexpr int& MOD = MOD_;
	//static_assert(MOD_ > 0, "MOD must be positive");

private:
	using ll = long long;

	int v;

	static int minv(int a, int m) {
		a %= m;
		assert(a);
		return a == 1 ? 1 : int(m - ll(minv(m, a)) * ll(m) / a);
	}

public:

	modnum() : v(0) {}
	modnum(ll v_) : v(int(v_ % MOD)) { if (v < 0) v += MOD; }
	explicit operator int() const { return v; }
	friend std::ostream& operator << (std::ostream& out, const modnum& n) { return out << int(n); }
	friend std::istream& operator >> (std::istream& in, modnum& n) { ll v_; in >> v_; n = modnum(v_); return in; }

	friend bool operator == (const modnum& a, const modnum& b) { return a.v == b.v; }
	friend bool operator != (const modnum& a, const modnum& b) { return a.v != b.v; }

	modnum inv() const {
		modnum res;
		res.v = minv(v, MOD);
		return res;
	}
	friend modnum inv(const modnum& m) { return m.inv(); }
	modnum neg() const {
		modnum res;
		res.v = v ? MOD-v : 0;
		return res;
	}
	friend modnum neg(const modnum& m) { return m.neg(); }

	modnum operator- () const {
		return neg();
	}
	modnum operator+ () const {
		return modnum(*this);
	}

	modnum& operator ++ () {
		v ++;
		if (v == MOD) v = 0;
		return *this;
	}
	modnum& operator -- () {
		if (v == 0) v = MOD;
		v --;
		return *this;
	}
	modnum& operator += (const modnum& o) {
		v += o.v;
		if (v >= MOD) v -= MOD;
		return *this;
	}
	modnum& operator -= (const modnum& o) {
		v -= o.v;
		if (v < 0) v += MOD;
		return *this;
	}
	modnum& operator *= (const modnum& o) {
		v = int(ll(v) * ll(o.v) % MOD);
		return *this;
	}
	modnum& operator /= (const modnum& o) {
		return *this *= o.inv();
	}

	friend modnum operator ++ (modnum& a, int) { modnum r = a; ++a; return r; }
	friend modnum operator -- (modnum& a, int) { modnum r = a; --a; return r; }
	friend modnum operator + (const modnum& a, const modnum& b) { return modnum(a) += b; }
	friend modnum operator - (const modnum& a, const modnum& b) { return modnum(a) -= b; }
	friend modnum operator * (const modnum& a, const modnum& b) { return modnum(a) *= b; }
	friend modnum operator / (const modnum& a, const modnum& b) { return modnum(a) /= b; }
};

int MOD;
using num = modnum<MOD>;

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int N; cin >> N >> MOD;

	vector<vector<num>> dp(3*N+1, vector<num>(3*N+1, num(0)));
	dp[0][0] = 1;
	for (int i = 0; i < 3*N; i++) {
		for (int c = 0; c <= i/2; c++) {
			if (i+1 <= 3*N) {
				dp[i+1][c] += dp[i][c];
			}
			if (i+2 <= 3*N) {
				dp[i+2][c+1] += dp[i][c] * num(i+1);
			}
			if (i+3 <= 3*N) {
				dp[i+3][c+1] += dp[i][c] * num(i+1) * num(i+2);
			}
		}
	}

	num ans = 0;
	for (int i = 0; i <= N; i++) {
		ans += dp[3*N][i];
	}
	cout << ans << '\n';

	return 0;
}


Measured memory_bytes: 141184
import math

D, G = map(int, input().split())
P = [list(map(int, input().split())) for _ in range(D)]

ret = 10000
for i in range(1 << D):
    buf = 0
    s = 0
    for k in range(D):
        if i & (1 << k):
            buf += P[k][0]
            s += P[k][0] * (k + 1) * 100 + P[k][1]
    if s < G:
        f = False
        for k in reversed(range(D)):
            if not i & (1 << k):
                t = math.ceil((G - s) / ((k + 1) * 100))
                if t <= P[k][0] - 1:
                    buf += t
                    f = True
                    break
        if not f:
            continue
    ret = min(ret, buf)

print(ret)


Measured memory_bytes: 3064
S = input()
Q = int(input())
Qlist = [list(input().split()) for _ in range(Q)]
toplist=[]
backlist=[]
Flag=1

i=0
while i<Q:
    if Qlist[i][0]=="1":
        Flag*=-1
    else:
        #check=Qlist[i][2]
        if Qlist[i][1]=="1" and Flag==-1:
            backlist.append(Qlist[i][2])
        elif Qlist[i][1]=="1" and Flag==1:
            toplist.append(Qlist[i][2])
        elif Qlist[i][1]=="2" and Flag==-1:
            toplist.append(Qlist[i][2])
        elif Qlist[i][1]=="2" and Flag==1:
            backlist.append(Qlist[i][2])
    i+=1
if Flag==1:
    #print(toplist)
    #print(S)
    #print(backlist)
    print("".join(toplist[::-1])+S+"".join(backlist))
else:
    #print(backlist[::-1])
    #print(S)
    #print(toplist[::-1])
    print("".join(backlist[::-1])+S[::-1]+"".join(toplist))

Measured memory_bytes: 33028
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
using ll = long long;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

#ifdef LOCAL
#define show(x) cerr << "LINE" << __LINE__ << " : " << #x << " = " << (x) << endl
#define dump(x) cerr << "LINE" << __LINE__ << " : " << #x << " = {";  \
	for(auto v: x) cerr << v << ","; cerr << "}" << endl;
#else
#define show(x) true
#define dump(x) true
#endif

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);		//DON'T USE scanf/printf/puts !!
	cout << fixed << setprecision(20);
	
	int H,W,K; cin >> H >> W >> K;
	V<string> s(H);
	rep(i,H) cin >> s[i];
	VV<int> ans(H,V<int>(W,-1));
	V<bool> isH(H);
	rep(i,H){
		rep(j,W) if(s[i][j] == '#') isH[i] = true;
	}
	VV<int> h2hs(H);
	{
		int from = 0;
		rep(i,H) if(isH[i]){
			for(int j=from;j<=i;j++) h2hs[i].pb(j);
			from = i+1;
		}
		for(int j=from;j<H;j++) h2hs[from-1].pb(j);
	}
	int I = 0;
	rep(x,H) if(!h2hs[x].empty()){
		V<int> w;
		for(int i: h2hs[x]){
			rep(j,W) if(s[i][j] == '#') w.pb(j);
		}
		sort(all(w));
		int K = w.size(); w.pb(W);
		VV<int> ws(K);
		rep(i,w[0]) ws[0].pb(i);
		rep(j,K){
			for(int a=w[j];a<w[j+1];a++) ws[j].pb(a);
		}
		rep(k,K){
			for(int i: h2hs[x]) for(int j: ws[k]) ans[i][j] = I;
			I++;
		}
	}
	rep(i,H){
		rep(j,W) cout << ans[i][j]+1 << " ";
		cout << endl;
	}
}


Measured memory_bytes: 1280
#include<iostream>
#include<sstream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<complex>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cassert>
using namespace std;

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define each(i,c) for(__typeof(c.begin()) i=c.begin();i!=c.end();i++)
#define pb push_back
#define mp make_pair
#define all(c) c.begin(),c.end()
#define dbg(x) cerr<<__LINE__<<": "<<#x<<" = "<<(x)<<endl

typedef vector<int> vi;
typedef pair<int,int> pi;
typedef long long ll;
const int inf=(int)1e9;
const double EPS=1e-9, INF=1e12;

int n;
map<vi, int> dp;
int rec(vi &v, int sum, int pos){
	if(sum == 0 && pos == 0 && dp.count(v)) return dp[v];
	if(pos == 9) return sum == 10 ? 1 + rec(v, 0, 0) : 0;
	
	int res = rec(v, sum, pos + 1);
	for(int i = 1; i <= v[pos] && sum + (pos + 1) * i <= 10; i++){
		v[pos] -= i;
		res = max(res, rec(v, sum + (pos + 1) * i, pos + 1));
		v[pos] += i;
	}
	if(sum == 0 && pos == 0) dp[v] = res;
	return res;
}

int main(){
	while(cin >> n, n){
		dp.clear();
		vi v(9);
		int ans = 0;
		rep(i, n){
			int t;
			cin >> t;
			v[t - 1]++;
		}
		rep(i, 4){
			int t = min(v[i], v[8 - i]);
			ans += t;
			v[i] -= t;
			v[8 - i] -= t;
		}
		ans += v[4] / 2;
		v[4] %= 2;
		cout << ans + rec(v, 0, 0) << endl;
	}
	return 0;
}

Measured memory_bytes: 7772
#include <iostream>
using namespace std;
int n,s,spn;
void sp(int ne,int ns,bool* flag)
{
	if (ne > n) return;
	if (ne == n && ns == s) spn++;
    for(int i=0;i<10;++i){
        if(!flag[i]){
            flag[i]=true;
            sp(ne+1,ns+i,flag);
			flag[i] = false;
		}
    }
}

int perm(int n)
{
	return (n ? n * perm(n - 1) : 1);
}

int main()
{
    while(1)
    {
        cin>>n>>s;if(!n)return 0;
        spn=0;
        bool flag[10]={false};
        sp(0,0,flag);
        spn /= perm(n);
        cout<<spn<<endl;
    }
    return 0;
}

Measured memory_bytes: 1160
class Node
  def initialize(node)
    @node = node
    @parent = -1
    @degree = 0
    @sibling = -1
    @left = -1
    @right = -1
    @depth = 0
    @height = 0
  end

  def who_am_i
    if parent == -1
      'root'
    elsif left == -1 && right == -1
      'leaf'
    else
      'internal node'
    end
  end

  def to_s
    "node #{node}: parent = #{parent}, sibling = #{sibling}, degree = #{degree}, depth = #{depth}, height = #{height}, #{who_am_i}"
  end

  attr_accessor :node, :parent, :left, :right, :depth, :sibling, :height, :degree
end

class BinaryTree
  def initialize(k)
    @node_list = []
    k.times do |i|
      node_list << Node.new(i)
    end
  end

  def create_node(index, left, right)
    node_list[index].left = left
    node_list[index].right = right
    if left != -1
      node_list[left].parent = index
      node_list[left].sibling = right
    end
    if right != -1
      node_list[right].parent = index
      node_list[right].sibling = left
    end
  end

  def eval_depth(index)
    return 0 if node_list[index].parent == -1
    eval_depth(node_list[index].parent) + 1
  end

  def eval_height(index)
    return 0 if node_list[index].left == -1 && node_list[index].right == -1
    left = node_list[index].left
    right = node_list[index].right
    left_height = eval_height(left)
    right_height = eval_height(right)
    if left_height > right_height
      left_height + 1
    else
      right_height + 1
    end
  end

  def eval_degree(index)
    count = 0
    node = node_list[index]
    count += 1 if node.left != -1
    count += 1 if node.right != -1
    count
  end

  def search_root_node
    node_list.each do |node|
      node.parent = -1 if node.parent.nil?
    end
  end

  attr_reader :node_list
end

n = gets.to_i
tree = BinaryTree.new n
n.times do
  input = gets.split(' ').map(&:to_i)
  tree.create_node input[0], input[1], input[2]
end
tree.node_list.each do |node|
  node.depth = tree.eval_depth node.node
  node.height = tree.eval_height node.node
  node.degree = tree.eval_degree node.node
end

puts tree.node_list.map(&:to_s)



Measured memory_bytes: 6884
n,m=map(int,input().split())
x=-1
s=[-1]*n
f=1
for i in range(m):
  a,b=map(int,input().split())
  if a==1:
    if b==0 and n!=1:
      f=0
      break
  if s[a-1]==-1:
    s[a-1]=b
  else:
    if s[a-1]!=b:
      f=0
      break
if f:
  for i in range(n):
    if s[i]==-1:
      if i or n==1:
        s[i]=0
      else:
        s[i]=1
  t=''
  for i in s:
    t+=str(i)
  x=int(t)
print(x)

Measured memory_bytes: 38384
//In The Name of Allah
#include <bits/stdc++.h>

using namespace std;

const int N = 1e5 + 10;

int a[N], L[N], R[N];

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int n;
    cin >> n;
    for (int i = 1; i <= n; i ++)
        cin >> a[i];
    for (int i = 1; i <= n; i ++)
        L[i] = __gcd(L[i - 1], a[i]);
    for (int i = n; i >= 1; i --)
        R[i] = __gcd(R[i + 1], a[i]);
    int ans = 0;
    for (int i = 1; i <= n; i ++)
        ans = max(ans, __gcd(L[i - 1], R[i + 1]));
    cout << ans;
    return 0;
}

Measured memory_bytes: 1408
import java.io.*;
import java.util.*;

public class Main {

    static ArrayList<Edge>[] adj;
    static int n;
    static int[] res;

    public static void main(String[] args) throws Exception {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        n = Integer.parseInt(in.readLine());
        adj = new ArrayList[n+1];
        for (int i = 0; i <= n; i++) {
            adj[i] = new ArrayList<>();
        }
        res = new int[n];
        for (int i = 0; i < n-1; i++) {
            StringTokenizer st = new StringTokenizer(in.readLine());
            int a = Integer.parseInt(st.nextToken());
            int b = Integer.parseInt(st.nextToken());
            adj[a].add(new Edge(b, i));
            adj[b].add(new Edge(a, i));
        }

        dfs(1, 0, -1);

        int max = 0;
        for (int i = 0; i < n; i++) {
            max = Math.max(res[i], max);
        }

        System.out.println(max);
        for (int i = 0; i < n-1; i++) {
            System.out.println(res[i]);
        }
    }

    static void dfs(int u, int prev, int prevColor) {
        int last = 0;
        for (Edge e : adj[u]) {
            if (e.v == prev) {
                continue;
            }
            last++;
            if (last == prevColor) {
                last++;
            }
            dfs(e.v, u, last);
            res[e.id] = last;
        }
    }

    static class Edge {
        int v, id;
        public Edge(int v, int id) {
            this.v = v;
            this.id = id;
        }
    }

}
/*


 */

Measured memory_bytes: 63908
#include<stdio.h>

#define M 10000

int main(){
  int n,s[M],q,t[M],c=0;
  int i,j;

 
  scanf("%d",&n);
  for(i=0 ; i<n ; i++)scanf("%d",&s[i]);
  scanf("%d",&q);
  for(i=0 ; i<q ; i++)scanf("%d",&t[i]);


  
  for(j=0 ; j<q ; j++){
  i = 0;
  s[n] = t[j];
  while(s[i] != t[j]) i++;
  if(i != n) c++;
  }
  
  printf("%d\n",c);

  return 0;
}

  
    



Measured memory_bytes: 2104
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cstring>
#include <cctype>
using namespace std;
int main(){
	int a,b;
	cin>>a>>b;
	if(a+b==15)puts("+");
	else if(a*b==15)puts("*");
	else puts("x");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using P = pair<ll,ll>;
ll H,W;

bool onBoard(int y,int x){
    if(y>=0 && y<H && x>= 0 && x<W){
        return true;
    }
    return false;
}


int main() {
    cin >> H >> W;
    vector<string> S(H);
    for(int i=0;i<H;i++){
        cin >> S[i];
    }
    bool alreadyChecked[H][W];
    for(int i=0;i<H;i++)for(int j=0;j<W;j++){
        alreadyChecked[i][j] = false;
    }
    int dy[] = {1,0,-1,0};
    int dx[] = {0,1,0,-1};
    ll ans =0;
    for(int sy =0;sy < H;sy++)for(int sx = 0;sx<W;sx++){
        if(S[sy][sx] == '.' || alreadyChecked[sy][sx]){
            continue;
        }
        // cerr <<"sy=" << sy <<"sx="<<sx << endl;
        ll sameNum =1;
        ll whiteNum = 0;
        queue<P> q;
        q.push(P(sy,sx));
        alreadyChecked[sy][sx] = true;
        while(!q.empty()){
            P p = q.front();q.pop();
            for(int i=0;i<4;i++){
                ll ny = p.first + dy[i];
                ll nx = p.second + dx[i];
                // cerr <<"ny=" <<ny <<"nx=" << nx << endl;
                if(!onBoard(ny,nx) || alreadyChecked[ny][nx] || (S[p.first][p.second] == S[ny][nx])){
                    continue;
                }
                
                if(S[ny][nx] == '#'){
                    sameNum++;
                }else{
                    whiteNum++;
                }
                alreadyChecked[ny][nx] = true;
                q.push(P(ny,nx));
            }
        }
        // cerr <<"sameNum=" << sameNum <<"whiteNum=" << whiteNum << endl;
        ans += (sameNum * whiteNum);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
n=int(input())
dp=[0,0,0]
for i in range(n):
    a=list(map(int,input().split()))
    dpn=[0,0,0]
    for j in range(3):
        
        for k in range(3):
            if(j!=k):
                dpn[k]=max(dpn[k],dp[j]+a[k])
        
    dp=dpn.copy()
    #print(dpn)
print(max(dp))


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
 
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 (a>b) { a=b; return 1; } return 0; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

int main(){
    string s;
    cin>>s;
    int w,l;
    w=l=0;
    rep(i,s.size()){
        if(s[i]=='o')w++;
        else l++;
    }
    int rem=(int)15-s.size();
    if((rem+w)>=8)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}

Measured memory_bytes: 256
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
    
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		String s = sc.next();
		
		// 計算
		String result = "Yes";
		int n = s.length();
		String l = s.substring(0, (n-1)/2);
		String r = s.substring((n-1)/2 + 1);
		StringBuilder sbs = new StringBuilder(s);
		String revs = sbs.reverse().toString();
		StringBuilder sbl = new StringBuilder(l);
		String revl = sbl.reverse().toString();
		StringBuilder sbr = new StringBuilder(r);
		String revr = sbr.reverse().toString();
		if(!revs.equals(s)) result = "No";
		if(!revl.equals(l)) result = "No";
		if(!revr.equals(r)) result = "No";
		
		
		// 出力
		System.out.println(result);
		
	}
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x)  x.begin(),x.end()
#define vi vector<int>
#define vll vector<ll>
#define print(x) for(auto it=x.begin();it!=x.end();it++) cout<<*it<<' '; cout<<'\n';
#define debug(a,b,c) cout << a << " " << b << " " << c << endl;
#define in(x,n) for(int e=0;e<n;e++){int y;cin>>y;x.pb(y);}
#define inl(x,n) for(int e=0;e<n;e++){ll y;cin>>y;x.pb(y);}
#define lower(sl)  transform(sl.begin(), sl.end(), sl.begin(), ::tolower); 

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	//code
	int h,w,k;
	cin >> h >> w >>k;
	vector<string> s;
	for(int i=0;i<h;i++){
		string x;cin >> x;s.pb(x);
	}
	int res = 0;
	for(int i=0;i<(1<<h);i++){
		for(int j=0;j<(1<<w);j++){
			int black = 0;
			for(int x=0;x<h;x++){
				for(int y=0;y<w;y++){
					if(((i>>x)&1)==0 and ((j>>y)&1)==0 and s[x][y]=='#'){
						black +=1;
					}
				}
			}
			if(black == k){
				res += 1;
			}
		}
	}
	cout << res;
}


Measured memory_bytes: 3664
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <random>
#include <cassert>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 2e5 + 10;
int a[N];
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	string str;
	cin >> str;
	cout << str.front() << str.length() - 2 << str.back() << endl;
	return 0;
}

Measured memory_bytes: 256
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n;
    cin>>n;
    int a[n][3];
    for(int i=0; i<n; i++) {
        cin>>a[i][0]>>a[i][1]>>a[i][2];
    }
    vector<vector<int>> dp(n, vector<int> (3,0));
    for(int i=0; i<n; i++) {
        if(i==0) {
            for(int j=0; j<3; j++) {
                dp[i][j] = a[i][j];
            }
        } else {
            /*if(i==1) {
                for(int j=0; j<3; j++) {
                    dp[i][j] = a[i][j] + max(dp[i-1][0],max(dp[i-1][1],dp[i-1][2]));
                }   
            } else(*/ {
                dp[i][0] = a[i][0] + max(dp[i-1][1],dp[i-1][2]);
                //dp[i][0] = max(dp[i][0], a[i][0] + a[i-1][0] + max(dp[i-2][1],dp[i-2][2]));
                dp[i][1] = a[i][1] + max(dp[i-1][0],dp[i-1][2]);
                //dp[i][1] = max(dp[i][1], a[i][1] + a[i-1][1] + max(dp[i-2][0],dp[i-2][2]));
                dp[i][2] = a[i][2] + max(dp[i-1][0],dp[i-1][1]);
                //dp[i][2] = max(dp[i][2], a[i][2] + a[i-1][2] + max(dp[i-2][0],dp[i-2][1]));
            }
        }
    }
    /*for(int i=0; i<n; i++) {
        for(int j=0; j<3; j++) {
            cout<<dp[i][j]<<" ";
        }
        cout<<endl;
    }*/
    cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
    return 0;
}


Measured memory_bytes: 6912
#include "bits/stdc++.h"
using namespace std;
const int INF = 1 << 30;

int main() {
	int N;
	cin >> N;
	vector<int>A(N);
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
	}
	long long ans = -1e18;
	for (int i = 1; i < N - 1; ++i) {//C
		long long score = 0;
		set<int>s;
		for (int x = 0;; ++x) {//K
			//範囲外
			if (N - 1 - x * i < 0) {
				break;
			}
			//範囲外
			if ((x * i) >= N) {
				break;
			}
			//aの確認
			int a = N - 1 - i * x;
			if (a <= 0) {
				break;
			}
			//bの確認
			int b = a - i;
			if (b <= 0) {
				break;
			}
			//重複チェック
			if (s.count(x * i)) {
				break;
			}
			s.insert(x*i);
			//重複チェック
			if (s.count(N - 1 - x * i)) {
				break;
			}
			s.insert(N - 1 - x * i);
			//計算
			score += A[x * i];
			score += A[N - 1 - x * i];
			ans = max(ans, score);
		}
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 8280
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        int n = sc.NextInt();
        int m = sc.NextInt();

        long answer = 0;

        long cost = (1900 * m) + (100 * (n - m));

        answer = cost * (int)Math.Pow(2, m);

        Console.WriteLine(answer);
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}


Measured memory_bytes: 13140
#include<stdio.h>

int main(void){
  char s[27];
  int al[26]={0};
  scanf("%s",s);
  for(int i = 0;s[i]!='\0';i++){
    al[s[i] - 'a']++;
    if(al[s[i] - 'a'] > 1){
      printf("no\n");
      return 0;
    }
  }
  printf("yes\n");
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const lint mod = 256;
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl((lint)(n))
#define fcout cout << fixed << setprecision(15)
#define highest(x) (63 - __builtin_clzl(x))
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
lint power(lint base, lint exponent, lint module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ lint root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position mv[4] = {{0, -1}, {1, 0}, {0, 1}, {-1, 0}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); } string to_string(string x){ return x; }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + " "; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr first, itr last){ for(auto i = first; i != last; i++){ cin >> (*i); } }
template<class T> T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }} template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct combination{ vector<lint> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } lint C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };
template<class itr> bool next_sequence(itr first, itr last, int max_bound){ itr now = last; while(now != first){ now--; (*now)++; if((*now) == max_bound){ (*now) = 0; }else{ return true; } } return false; }

int N;
vector<lint> A;

lint dp[114514][2];

lint ans(int now, bool is_fliped){
    if(dp[now][is_fliped] != -1){
        return dp[now][is_fliped];
    }else if(now == N - 1){
        if(is_fliped){
            return dp[now][is_fliped] = -A[now];
        }else{
            return dp[now][is_fliped] = A[now];
        }
    }else if(is_fliped){
        return dp[now][is_fliped] = max(ans(now + 1, false) - A[now], ans(now + 1, true) + A[now]);
    }else{
        return dp[now][is_fliped] = max(ans(now + 1, false) + A[now], ans(now + 1, true) - A[now]);
    }
}

int main(){
    cin >> N;
    A.resize(N);
    cins(all(A));
    memset(dp, -1, sizeof(dp));
    cout << ans(0, false) << endl;
}

Measured memory_bytes: 7552
#include <bits/stdc++.h>
using namespace std;
#define SZ(a) ((int)(a).size())
typedef long long int64;
const int maxn= 300009;
int T[maxn<<2];
void upd(int rt,int l,int r,int p,int v){
  if(l==r){
    T[rt]=v;return;
  }
  int mid=(l+r)>>1;
  if(p<=mid)upd(rt<<1,l,mid,p,v);
  else upd(rt<<1|1,mid+1,r,p,v);
  T[rt]=max(T[rt<<1],T[rt<<1|1]);
}
int query(int rt,int l,int r,int ll,int rr){
  if(ll<=l&&rr>=r)return T[rt];
  int mid=(l+r)>>1,res=0;
  if(ll<=mid)res=max(res,query(rt<<1,l,mid,ll,rr));
  if(rr>mid)res=max(res,query(rt<<1|1,mid+1,r,ll,rr));
  return res;
}
int main(){
#ifdef LOCAL
  freopen(".a.in", "r", stdin);
#endif
  ios_base::sync_with_stdio(false),cout.tie(0),cin.tie(0);
  int n,k;cin>>n>>k;
  for(int i=0;i<n;++i){
    int t;cin>>t;
    int L=max(0,t-k),R=min(300000,t+k);
    upd(1,0,300000,t,query(1,0,300000,L,R)+1);
  }
  cout<<query(1,0,300000,0,300000);
  
  return 0;
}
//2020.09.26 20:07:16


Measured memory_bytes: 7792
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define test() ull t;cin>>t;while(t--)
#define pb push_back
#define mkp make_pair
#define nl cout<<endl
#define MOD 1000000007
#define loop(i,start,end) for(int i=start;i<end;i++)
#define N 100001
#define oa(a,n) for(int i=0;i<n;i++)cout<<a[i]<<" ";nl;
#define ov(a) for(int i=0;i<a.size();i++)cout<<a[i]<<endl;
#define pi M_PI
int main()
{
    fastio();
    int n;cin>>n;
    if(n<10)
    {
        cout<<n;
    }
    else if(n<100)
    {
        cout<<9;
    }
    else if(n<1000)
    {
        cout<<10+(n-100);
    }
    else if(n<10000)
    {
        cout<<909;
    }
    else if(n<100000)
    {
        cout<<910+(n-10000);
    }
    else
        cout<<90909;


    return 0;
}    

Measured memory_bytes: 256
let N=Int(readLine()!)!,A=readLine()!.characters.split(" ").map{Int(String($0))!}
var ope=0,ans=1
for i in 1..<N{
  let tmp=A[i]-A[i-1]
  if tmp>0{
    if ope<0{
      ans++
      ope=0
    }else{
      ope=tmp
    }
  }else if tmp<0{
    if ope>0{
      ans++
      ope=0
    }else{
      ope=tmp
    }
  }
}
print(ans) 

Measured memory_bytes: 7596
#include <iostream>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <set>
#include <map>
#include <cassert>
#include <numeric>
#include <string>
#include <cstring>
#include <cmath>
using namespace std;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
	#define eprintf(...) 42
#endif

typedef long long int int64;

const int N = (int) 1e5 + 100;
vector <int> g[N];


const int D = 11;
pair <int, int> color[N][D];

int main(int,  char **)
{
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
#endif


	int n, m;
	scanf("%d%d", &n, &m);
	for (int i = 0; i < m; i++)
	{
		int a, b;
		scanf("%d%d", &a, &b);
		a--;
		b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}

	for (int i = 0; i < n; i++)
		for (int j = 0; j < D; j++)
			color[i][j] = make_pair(-1, 0);

	int q;
	scanf("%d", &q);
	for (int i = 0; i < q; i++)
	{
		int v, d, c;
		scanf("%d%d%d", &v, &d, &c);
		v--;
		color[v][d] = make_pair(i, c);
	}

	for (int d = D - 1; d > 0; d--)
	{
		for (int v = 0; v < n; v++)
		{
			if (color[v][d].first == -1) continue;
			for (int to : g[v] )
				color[to][d - 1] = max(color[to][d - 1], color[v][d] );
		}
	}

	for (int v = 0; v < n; v++)
	{
		auto ans = color[v][0];
		for (int i = 0; i < D; i++)
		{
			ans = max(ans, color[v][i] );
		}
		printf("%d\n", ans.second);
	}
	return 0;
}



Measured memory_bytes: 15096
#include <stdio.h>
#include <stdbool.h>

int A[20];
int n;

bool solve(int, int);
  
int main(){
  int i, j, q;
  int m[200];

  scanf("%d",&n);
  for(i = 0; i < n; i++) scanf("%d",&A[i]);
  scanf("%d",&q);
  for(i = 0; i < q; i++) scanf("%d",&m[i]);

  for(i = 0; i < q; i++){
    if(solve(0,m[i])){
	printf("yes\n");
    }
    else printf("no\n");
  }
 
  return 0;
}
   
bool solve(int k, int m){
  bool res = true;

  if(m == 0){
    return true;
  }
  if(k >= n){
    return false;
  }
  
  res = solve(k + 1, m) || solve(k + 1, m - A[k]);
  
  return res;
  
}  



Measured memory_bytes: 2108
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef double db;
typedef vector <ll> vll;
typedef pair <ll, ll> pll;
#define pb push_back
#define mp make_pair
#define MAX 1000000
#define mod 1000000007
#define all(_) _.begin(), _.end()
#define F first
#define S second
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
ll dp[105][105][2];
ll cal(string &s, ll index, ll num, ll k, bool f)
{
    // cout << index << ' ' << num << ' ' << f << endl;
    if(dp[index][num][f] != -1)
        return dp[index][num][f];
    if(index == s.size())
        return (num == k ? 1 : 0);
    else if(num > k)
        return 0;
    ll ans = 0;
    for(ll i = 0; i < s[index] - '0'; i++)
    {
        if(!i)
            ans += cal(s, index + 1, num, k, true);
        else
            ans += cal(s, index + 1, num + 1, k, true);
    }
    ans += cal(s, index + 1, (num + (s[index] - '0' > 0 ? 1 : 0)), k, f);
    if(f)
    {
        for(ll i = s[index] - '0' + 1; i <= 9; i++)
        {
            if(!i)
                ans += cal(s, index + 1, num, k, true);
            else
                ans += cal(s, index + 1, num + 1, k, true);
        }       
    }
    dp[index][num][f] = ans;
    return ans;
}
int main()
{
    ios_base :: sync_with_stdio(false);
    cin.tie(NULL), cout.tie(NULL);
    string s;
    ll i, k;
    cin >> s >> k;
    memset(dp, -1, sizeof dp);
    cout << cal(s, 0, 0, k, false) << endl;
    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
using vll=vector<ll>;
using vi=vector<int>;
using vvi=vector<vector<int>>;
using vb=vector<bool>;
using pii=pair<int,int>;
using vpii=vector<pair<int,int>>;

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

//pow(llpow,modpow)
template<class T> ll llpow(ll x,T n){ll ans=1;if(x==0)ans=0;while(n){if(n&1)ans*=x;x*=x;n>>=1;}return ans;}
long long modpow(long long a, long long n, long long mod) {long long res = 1;while (n > 0) {if (n & 1) res = res * a % mod;a = a * a % mod;n >>= 1;}return res;}
//最大公約数
template<class T> inline T gcd(T x,T y){if(y==0)return x; else {return gcd(y,x%y);}}
//最小公倍数
template<class T> inline T lcm(T x,T y){return x/gcd(x,y)*y;}
//逆元
long long modinv(long long a, long long m) {long long b = m, u = 1, v = 0;while (b) {long long t = a / b;a -= t * b; swap(a, b);u -= t * v; swap(u, v);}u %= m;if (u < 0) u += m;return u;}

#define rep(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)
//試験導入
#define irep(i, end_i, begin_i) for (ll i = (ll)begin_i-1; i >= (ll)end_i; i--)

long long INF = 1LL<<60;
int main( ){
    ll n;
    cin>>n;
    ll k;
    cin>>k;
    ll res=0;
    rep(i,1,n+1){
        ll q=n/i;
        ll rem=n%i;
        res+=q*max(0LL,i-k);
        res+=max(0LL,rem-k+1);
    }
    //a==1のとき
    if(k==0)res-=n;
    cout<<res<<endl;
    return 0;
}




Measured memory_bytes: 256
N,C,K = map(int,input().split())
T = [int(input()) for i in range(N)]
T.sort()
busCount = 0
pCount = 0
time = 0
firstTime = 0
for i in range(N):
    time = T[i]
    if firstTime == 0:
        firstTime = T[i]
        busCount += 1
    pCount += 1
    if time > firstTime + K:
        firstTime = T[i]
        busCount += 1
        pCount = 1
        continue
    if pCount == C:
        firstTime = 0
        pCount = 0
print(busCount)

Measured memory_bytes: 80948
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//template <typename T, typename cmp=less<T>> using oset =tree<T, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
#define inf 100000000000000000
#define ll long long 
#define pb push_back
#define f first
#define s second
#define mod 1000000007
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define test ll t ; cin>>t; while(t--)
void mahakal(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	freopen("error.txt","w",stderr);
	#endif
}
int main(){
	//mahakal(),fast;
	
	ll n ;
	cin>> n ;
	queue<ll> q;
	for(ll i=1 ; i<=9 ;i++)q.push(i);
	while(n>1){
		ll ps=q.front();q.pop();
		// cerr<<ps<<" ";
		if(ps%10!=0)q.push(10*ps+ps%10-1);
		q.push(10*ps+ps%10);
		if(ps%10!=9)q.push(10*ps+ps%10+1);
		n--;
	}
	cout<<q.front()<<endl;
	return 0;
}

Measured memory_bytes: 1792
//-- Araz Jabrayilov --
//-- araz17---zuna#1041 --

#include <bits/stdc++.h>

#define ll long long
#define endl '\n'
#define F first
#define S second

using namespace std;

///int a[1005];

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

    ll x = 0;
    ll y = 0;
    int res = 0;

    cin >> x >> y;

    while(x <= y){
        res++;

        ///cout << x << endl;

        x *= 2;
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
using ull = unsigned long long;
#define REP(i,n) for (ll i = 0; i < (n); ++i)
#define RREP(i, n) for (ll i = (n) - 1; i >= 0; --i)
#define ALL(v) (v).begin(), (v).end()
template<class T>
using reverse_priority_queue = priority_queue<T, vector<T>, greater<T>>;

const string YES = "Yes";
const string NO = "No";

int main(){
    ll n, d;
    cin >> n >> d;
    vector<array<ll, 2>> p(n);
    vector<ll> x(n), y(n);
    REP(i, n){
        cin >> p.at(i).at(0) >> p.at(i).at(1);
    }

    two_sat ts(n);

    REP(i, n){
        for(ll j = i + 1; j < n; ++j){
            REP(k1, 2){
                REP(k2, 2){
                    if(abs(p.at(i).at(k1) - p.at(j).at(k2)) < d){
                        ts.add_clause(i, (bool)(1 - k1), j, (bool)(1 - k2));
                    }
                }
            }
        }
    }

    if(!ts.satisfiable()){
        cout << NO << endl;
        return 0;
    }
    cout << YES << endl;

    vector<bool> ans = ts.answer();
    REP(i, n){
        cout << p.at(i).at(ans.at(i)) << endl;
    }
    return 0;
}


Measured memory_bytes: 3732
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
 
const double EPS = 1e-10;
const ll INF = 100000000;
const ll MOD = 1000000007;

ll n, k;
ll a[100];
ll dp[100001];

int main() {
    cin >> n >> k;
    rep(i,n) cin >> a[i];
    dp[0] = -1;
    for (int i = 1; i <= k; i++) {
        rep(j,n) {
            if (a[j] > i) continue;
            if (dp[i-a[j]] == -1) {
                dp[i] = 1;
            }
        }
        if (dp[i] == 0) dp[i] = -1;
    }
    if (dp[k] > 0) puts("First");
    else puts("Second");
}



Measured memory_bytes: 1024
#include <stdio.h>

int main(void)
{
    int i, j, cnt, n1, n2, sum = 0;
    int A[1000000], B[1000000];

    scanf("%d", &n1);
    for (i = 0; i < n1; i++)
    {
        scanf("%d", &A[i]);
    }

    scanf("%d", &n2);
    for (j = 0; j < n2; j++)
    {
        scanf("%d", &B[j]);
    }

    for (j = 0; j < n2; j++)
    {
        cnt = 0;
        for (i = 0; i < n1; i++)
        {
            if (A[i] == B[j] && cnt == 0)
            {
                sum += 1;
                cnt += 1;
            }
        }
    }

    printf("%d\n", sum);
    return 0;
}


Measured memory_bytes: 2048
S = input()

a = sum([1 for i in range(len(S)) if S[i] == "0" and i % 2 == 0 or  
                                     S[i] == "1" and i % 2 == 1])
b = sum([1 for i in range(len(S)) if S[i] == "1" and i % 2 == 0 or  
                                     S[i] == "0" and i % 2 == 1])
print (min(a,b))

Measured memory_bytes: 3956
n,m=gets.split.map(&:to_i)
a=m.times.map{gets.split.map(&:to_i)}
(0..10**n).each do |i|
  s=i.to_s
  next if s.size!=n
  flag=true
  a.each do |i,j|
    flag=false if s[i-1]!=j.to_s
  end
  if flag
    p i
    exit
  end
end
p -1

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

using namespace std;

int main () {

	ios_base::sync_with_stdio(false); cin.tie(NULL); 	
		
	int n, m; 
	cin >> n >> m;

	map <int,int> wa;
	vector< bool > closed(n + 1, false);

	for (int i = 0; i < m; ++i) {
		int pi; string si;
		cin >> pi >> si;

		if (si == "WA") {
			if (!closed[pi]) {
				++wa[pi];
			}
		}
		else { //si == AC
			if (!wa.count(pi))
				wa[pi] = 0;
			
			closed[pi] = true;
		}
	}

	int wrong = 0, correct = 0;

	for (auto it : wa) {
		if(closed[it.first]) {
			wrong += it.second;
			++correct;
		}
	}

	cout << correct << ' ' << wrong << '\n';

	return 0;
}
 


Measured memory_bytes: 4992
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}

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

  ll N;
  vector<ll> T,A;
  vector<pair<ll,ll> > moutainf, moutainb;//hight, possible

  cin >> N;
  rep(i,N){ll inp; cin >> inp; T.pb(inp);}
  rep(i,N){ll inp; cin >> inp; A.pb(inp);}

  rep(i,N){moutainf.pb(mp(0,0));}
  rep(i,N){moutainb.pb(mp(0,0));}
  
  ll before = 0;
  rep(i,N){
    if(T[i]!=before){
      moutainf[i] = mp(T[i],1);
    }
    else{
      moutainf[i] = mp(T[i],T[i]);
    }
    before = T[i];
  }

  before = 0;
  rep(i,N){
    ll j = N-i-1;
    ll hight = A[j];
    if(hight != before){
      moutainb[j] = mp(hight,1);
    }
    else moutainb[j] = mp(hight,hight);
    before = hight;
  }

  ll ans = 1;

  
  
  rep(i,N){
    if(moutainf[i].second!=moutainb[i].second){//可能性が違うけど
      if((moutainf[i].second==1 && moutainf[i].first > moutainb[i].first) || (moutainb[i].second==1 && moutainb[i].first > moutainf[i].first)){
	cout << 0 << endl;
	return 0;
      }
    
      ans *= min(moutainf[i].second, moutainb[i].second);
    }
    else{//可能性が同じ状況で
      if(moutainf[i].second == 1)//どっちも1で
	if(moutainf[i].first != moutainb[i].first){ //可能の結果が違うと言ってたら
	  cout << 0 << endl;
	  return 0;
	}
      ans *= moutainf[i].second;
    }
    ans%=MOD;
  }

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


Measured memory_bytes: 6512