akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

using Weight = int;
struct Edge {
	int s, d; Weight w;
	Edge() {};
	Edge(int s, int d, Weight w) : s(s), d(d), w(w) {};
};
bool operator<(const Edge &e1, const Edge &e2) { return e1.w < e2.w; }
bool operator>(const Edge &e1, const Edge &e2) { return e2 < e1; }
inline ostream &operator<<(ostream &os, const Edge &e) { return (os << '(' << e.s << ", " << e.d << ", " << e.w << ')'); }

using Edges = vector<Edge>;
using Graph = vector<Edges>;
using Array = vector<Weight>;
using Matrix = vector<Array>;

void addArc(Graph &g, int s, int d, Weight w = 1) {
	g[s].emplace_back(s, d, w);
}
void addEdge(Graph &g, int a, int b, Weight w = 1) {
	addArc(g, a, b, w);
	addArc(g, b, a, w);
}

auto bfs = [&](const Graph &g, int s, Array &dist) {
	int n = g.size();
	vector<bool> vis(n);
	vector<int> prev(n, -1);
	dist.assign(n, INF); dist[s] = 0;
	using State = tuple<Weight, int, int>;
	queue<State> q;
	q.emplace(0, s, -1);
	while (q.size()) {
		Weight d; int v, p; tie(d, v, p) = q.front(); q.pop();
		vis[v] = true;
		prev[v] = p;
		for (auto &e : g[v]) {
			if (vis[e.d])continue;
			if (dist[e.d] > dist[v] + e.w) {
				dist[e.d] = dist[v] + e.w;
				q.emplace(dist[e.d], e.d, v);
			}
		}
	}
	return prev;
};

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N; cin >> N;
	Graph g(N);
	vector<int> a(N - 1), b(N - 1), c(N - 1); rep(i, 0, N - 1) {
		cin >> a[i] >> b[i] >> c[i];
		a[i]--, b[i]--;
		addEdge(g, a[i], b[i], c[i]);
	}
	int Q, K; cin >> Q >> K; K--;
	Array dist;
	bfs(g, K, dist);
	rep(i, 0, Q) {
		int x, y; cin >> x >> y; x--, y--;
		cout << dist[x] + dist[y] << endl;
	}
	return 0;
}

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

int main() {
    int N;
    cin >> N;
    vector<int> P(N + 1, 0);
    for (int i = 0; i < N - 1; i++) {
        int x;
        scanf("%d", &x);
        P[x]++;
    }

    for (int i = 1; i <= N; i++) {
        printf("%d\n", P[i]);
    }

    return 0;
}

Measured memory_bytes: 4052
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
mod=10**9+7

N=I()
d=[0]*N
for i in range(N):
    d[i]=I()
    
d.sort()
ans=N
for i in range(N-1):
    if d[i+1]==d[i]:
        ans-=1
        
print(ans)




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

int contar (string w, string chk) {
  int ans = 0;
  size_t pos = 0;
  while ((pos = w.find(chk, pos)) != string::npos) {
    ans++;
    pos++;
  }
  return ans;
}

int main () {
  int n, A = 0, BA = 0, B = 0, ans = 0;
  string  best;
  cin >> n;
  for (int i = 0; i < n; i++) {
    string w;
    cin >> w;
    if (w[0] == 'B' && w[w.length() - 1] == 'A') BA++;
    else if (w[0] == 'B') B++;
    else if (w[w.length() - 1] == 'A') A++;
    ans += contar(w, "AB");
  }
  


  if (A > 0) {
    best += 'A';
    A--;
  }

  while (BA > 0) {
    best += "BA";
    BA--;
  }

  
  while (true) {
    if (B <= 0) break;
    best += 'B';
    B--;
    if (A <= 0) break;
    best += 'A';
    A--;
  }
  
  //cout << best << '\n';

  
  cout << contar(best, "AB") + ans << '\n';
  return 0;
}

Measured memory_bytes: 256
parseInt(x)=parse(Int, x)
parseMap(x::Array{SubString{String},1})=map(parseInt, x)
function eval(a::Tuple{Int,Int},b::Tuple{Int,Int})
	if a[2]<b[2]
		1
	elseif a[2]==b[2]
		0
	else
		-1
	end
end

function hpush(h::Array{Tuple{Int,Int},1},x::Tuple{Int,Int})
	push!(h,x)
	if length(h) > 1
		l = length(h)
		k = l>>1
		while eval(x,h[k])==1&&k>=1
			tmp = h[k]
			h[k] = x
			h[l] = tmp
			k = max(k>>1,1)
			l = l>>1
		end
	end
end

function hpop(h::Array{Tuple{Int,Int},1})
	x = h[1]
	z = pop!(h)
	if !isempty(h)
		h[1] = z
		k = 1
		l = length(h)
		while k <= l
			if 2*k>l
				break
			elseif 2*k+1>l
				if eval(z,h[2*k])>=0
					break
				else
					tmp = h[2*k]
					h[2*k] = z
					h[k] = tmp
					k = 2*k
				end
			else
				if eval(z,h[2*k])>=0&&eval(z,h[2*k+1])>=0
					break
				else
					t = eval(h[2*k],h[2*k+1])>=0?2*k:2*k+1
					tmp = h[t]
					h[t] = z
					h[k] = tmp
					k = t
				end
			end
		end
	end
	x
end


function dijkstra(e::Array{Array{Tuple{Int,Int},1},1},k)
	dis = -ones(Int, length(e))
	h = Array{Tuple{Int,Int},1}()
	push!(h,(k,0))
	while !isempty(h)
		v,w = hpop(h)
		dis[v] = dis[v]<0?w:min(dis[v],w)
		for i in 1:length(e[v])
			if dis[e[v][i][1]]<0　|| dis[e[v][i][1]]>w+e[v][i][2]
				dis[e[v][i][1]] = w+e[v][i][2]
				hpush(h,(e[v][i][1],w+e[v][i][2]))
			end
		end
	end
	dis
end
function main()
	n,m,s,t = readline() |> split |> parseMap
	e = [Tuple{Int,Int}[] for i in 1:n]
	f = [Tuple{Int,Int}[] for i in 1:n]
	for i in 1:m
		u,v,a,b = readline() |> split |> parseMap
		push!(e[u],(v,a))
		push!(f[u],(v,b))
		push!(e[v],(u,a))
		push!(f[v],(u,b))
	end
	da = -ones(Int, length(e))
	h = Array{Tuple{Int,Int},1}()
	push!(h,(s,0))
	while !isempty(h)
		v,w = hpop(h)
		da[v] = da[v]<0?w:min(da[v],w)
		for i in 1:length(e[v])
			if da[e[v][i][1]]<0　|| da[e[v][i][1]]>w+e[v][i][2]
				da[e[v][i][1]] = w+e[v][i][2]
				hpush(h,(e[v][i][1],w+e[v][i][2]))
			end
		end
	end
	db = -ones(Int, length(f))
	h = Array{Tuple{Int,Int},1}()
	push!(h,(t,0))
	while !isempty(h)
		v,w = hpop(h)
		db[v] = db[v]<0?w:min(db[v],w)
		for i in 1:length(f[v])
			if db[f[v][i][1]]<0　|| db[f[v][i][1]]>w+f[v][i][2]
				db[f[v][i][1]] = w+f[v][i][2]
				hpush(h,(f[v][i][1],w+f[v][i][2]))
			end
		end
	end
	mx = zeros(Int,n)
	mx[n] = 10^15-da[n]-db[n]
	for i in n-1:-1:1
		mx[i]=max(mx[i+1],10^15-da[i]-db[i])
	end
	for i in 1:n
		println(mx[i])
	end
end

main()

Measured memory_bytes: 229812
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <map>
#include <functional>
#include <cmath>
#include <cstdint>
#include <mutex>
#include <thread>
#include <bitset>

using namespace std;

int main()
{
	int n, c,a[200000];
	cin >> n;
	for (int i = 0; i < n; i++)
		a[i] = 0;

	for (int i = 0; i < n - 1; i++)
	{
		cin >> c;
		a[c - 1] ++;
	}
	for (int i = 0; i < n; i++)
	{
		cout << a[i] << '\n';
	}

	return 0;
}

Measured memory_bytes: 4416
#include <cassert>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <complex>
#include <chrono>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#include <random>
#include <memory>
#include <utility>
#include <limits>
#include "limits.h"
 
#define rep(i, a, b) for (long long (i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(...) std::cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

void debug_out(){std::cerr<<std::endl;}

template<typename Head,typename... Tail>
void debug_out(Head h,Tail... t){
  std::cerr<<" "<<h;
  debug_out(t...);
}
 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (int i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}
 
template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}
 
long long pow_mod(long long a, long long b, long long mod=-1) {
  if(b==0)return 1;
  if ((a == 0)||(mod!=-1&&(a+mod)%mod==0)) {
    return 0;
  }
  long long x = 1;
  while (b > 0) {
    if (b & 1) {
      x = (mod!=-1)?(x * a) % mod:x*a;
    }
    a = (mod!=-1)?(a * a) % mod:a*a;
    b >>= 1;
  }
  return x;
}
 
// const long long MOD = 998244353;
const long long MOD = 1e9 + 7;

using ll = long long;
using P=std::pair<long long,long long>;



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

  ll n,q;
  std::cin>>n>>q;

  struct Event{
    ll time,mode,x;
  };

  std::vector<Event> seg;

  rep(i,0,n){
    ll s,t,c;
    std::cin>>s>>t>>c;
    seg.push_back({s-c,1,c});
    seg.push_back({t-c,-1,c});
  }

  std::sort(all(seg),[](const Event& a,const Event& b)->bool{
    return (a.time!=b.time)?(a.time<b.time):(a.mode<b.mode);
  });

  ll now=0;
  std::set<ll> stop;

  rep(_,0,q){
    ll a;
    std::cin>>a;

    while(now<2*n&&seg[now].time<=a){
      if(seg[now].mode==1){
        stop.insert(seg[now].x);
      }else{
        stop.erase(seg[now].x);
      }
      now++;
    }

    if(stop.empty()){
      std::cout<<-1<<"\n";
    }else{
      std::cout<<*stop.begin()<<"\n";
    }
  }

  return 0;
}

Measured memory_bytes: 20968
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <sstream>
 
using namespace std;

vector<string> vec_splitter(string s) {
  s += ',';
  vector<string> res;
  while(!s.empty()) {
    res.push_back(s.substr(0, s.find(',')));
    s = s.substr(s.find(',') + 1);
  }
  return res;
}
void debug_out(
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused)) int idx,
__attribute__ ((unused)) int LINE_NUM) { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
  if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
  stringstream ss; ss << H;
  cerr << args[idx] << " = " << ss.str();
  debug_out(args, idx + 1, LINE_NUM, T...);
}

#ifndef ONLINE_JUDGE
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif
 
#define MOD 1000000007
#define A first
#define B second
#define all(x) (x).begin(), (x).end

typedef long long ll;
 
inline int mulmd(ll a, ll b){
  ll ret = (a * b) % MOD;
  return (int) ret;
}
 
inline int power(ll x, ll y, int m){
  ll res = 1;
  x = x % m;
  while(y > 0){
    if(y & 1){
      res = mulmd(res, x);
    }
    y = y >> 1;
    x = mulmd(x, x);
  }
  return (int) res;
}
 
inline int submd(ll a, ll b){
  ll ret = (a - b);
  if(ret < 0) ret += MOD;
  return (int) ret;
}
 
inline int addmd(ll a, ll b){
  ll ret = (a + b) % MOD;
  return (int) ret;
}
 
inline int invPow(ll a){
  return power(a, MOD - 2, MOD);
}
 
inline int divmd(ll a, ll b){
  ll ret = mulmd(a, invPow(b));
  return (int) ret;
}
 
const int N = 1e5 + 5;

int arr[N];
int cnt[N];

void solve(){
  int n;
  cin >> n;
  ll s = 0;
  for(int i = 0; i < n; i++) cin >> arr[i], cnt[arr[i]]++, s += arr[i];
  int q;
  cin >> q;
  while(q--){
    int b, c;
    cin >> b >> c;
    int diff = c - b;
    s += diff * cnt[b];
    cnt[c] += cnt[b];
    cnt[b] = 0;
    cout << s << "\n";
  }
}

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t;
  t = 1;
  //cin >> t;
  while(t--){
    solve();
  }
}



Measured memory_bytes: 4328
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i < (int)(n); i++)
#define Sort(a) sort(a.begin(), a.end())
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;} return false;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;} return false;}

bool flag = false;

/*
A:答えの配列
N:答えの文字列の長さ
max_:いままで出てきた数字の種類
vn:一個前に出た数字
*/
void dfs(vector<int> &A, int N, int max_, int vn) {
    if (A.size() == N) {
        //答えの出力
        for(int a : A) {
            //数字列を文字列に変換
            char s = 'a'+a;
            cout << s;
        }
        cout << endl;
        return;
    }
    //max_:いままで出てきたアルファベット+1種類しか出ないようにする変数
    //flag:一週目かどうかの判定
    if(max_ < vn+1 && flag) max_ = vn+1;
    
    //全探索
    for (int v = 0; v <= max_; ++v) {
        flag = true;
        A.push_back(v);
        dfs(A, N, max_, v);
        A.pop_back();
    }
}

int main(){
    int n;
    cin >> n;
    vi A;
    dfs(A, n, 0, 0);
    return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < n; i++)
using namespace std;
typedef long long ll;

int main() {
    int N; cin >> N;
    vector<int> A(N), B(N), C(N);
    REP(i, 0, N) cin >> A[i] >> B[i] >> C[i];

    int dp[3][N + 1];
    REP(i, 0, 3) dp[i][0] = 0;

    REP(i, 0, N) {
        REP(j, 0, 3) {
            if (j == 0) {
                dp[j][i + 1] = max(dp[1][i], dp[2][i]) + A[i];    
            }
            if (j == 1) {
                dp[j][i + 1] = max(dp[0][i], dp[2][i]) + B[i];    
            }
            if (j == 2) {
                dp[j][i + 1] = max(dp[0][i], dp[1][i]) + C[i];    
            }
        }
    }
    cout << max(max(dp[0][N], dp[1][N]), dp[2][N]) << endl;
    return 0;
}

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


long long luc
(int x, vector<long long> &memo) {
  if (x == 0) return 2;
  if (x == 1) return 1; 
  if (memo.at(x) != 0) return memo.at(x);
  return memo.at(x) = luc
  (x - 1, memo) + luc
  (x - 2, memo);
}

int main() {
  int n;
  cin >> n;
  vector<long long> memo(n+1);
  memo[0] = 2;
  memo[1] = 1;
  luc
  (n, memo);

  cout << memo.at(n) << endl;
  
}


Measured memory_bytes: 256
n,w = map(int,input().split())
ww = [0]*n
vv = [0]*n
dp = [[0]*(w+1) for _ in range(n+1)]

for i in range(n):
  ww[i],vv[i] = map(int,input().split())      
  
for i in range(1,n+1):
  for j in range(1,w+1):
    dp[i][j] = dp[i-1][j]
    if j - ww[i-1] >= 0:
      dp[i][j] = max(dp[i][j], \
                     dp[i-1][j-ww[i-1]] + vv[i-1])        

print(dp[-1][-1])      

Measured memory_bytes: 120428
N,M=map(int,input().split())
listH=list(map(int,input().split()))
listN=[0]*N
for i in range(M):
  A,B=map(int,input().split())
  if listH[A-1]>listH[B-1]:
    listN[B-1]=-1
  if listH[A-1]<listH[B-1]:
    listN[A-1]=-1
  if listH[A-1]==listH[B-1]:
    listN[A-1]=-1
    listN[B-1]=-1   
ans=0    
for i in listN:
  if i>=0:
    ans+=1
print(ans)

Measured memory_bytes: 20132
#include <bits/stdc++.h>
#define typeof(x) __typeof__(x)
#define int long long int
#define double long double
#define mod(x) ((x % MOD) + MOD) % MOD
#define REP(i,a,b) for(int i=(a);i<(b);++i)
#define RREP(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define ALL(c) (c).begin(),(c).end()
#define RALL(c) (c).rbegin(),(c).rend()
#define SZ(c) (int)((c).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define LB(c,x) (int)(lower_bound(ALL(c),x)-(c).begin())
#define UB(c,x) (int)(upper_bound(ALL(c),x)-(c).begin())
#define COUNT(c,x) (UB(c,x)-LB(c,x))
#define UNIQUE(c) SORT(c); (c).erase(unique(ALL(c)),(c).end());
#define COPY(c1,c2) copy(ALL(c1),(c2).begin())
#define EXIST(s,e) (s).find(e)!=(s).end()
#define PB push_back
#define MP make_pair
#define vec vector
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define NL cerr << endl;

using namespace std;

typedef pair<int,int> P;
struct edge { int from, to; int cost; };
ostream& operator << (ostream& s, const edge& e) {
   s << "(" << e.from << "->" << e.to << ": " << e.cost << ")";
   return s;
}
bool operator< (const edge &edge1, const edge &edge2){
   return edge1.cost < edge2.cost;
};

const int INF = 1e18;
const int MOD = 1e9+7;

template<typename T> ostream& operator << (ostream& s, const vector<T>& v) {
   s << "[";
   for (int i = 0; i < v.size(); i++) { s << v[i]; if (i < v.size() - 1) s << " "; }
   s << "]";
   return s;
}
template<typename T> ostream& operator << (ostream& s, const set<T>& se) {
   s << "{";
   for (auto i = se.begin(); i != se.end(); ++i) {
      s << *i;
      if (next(i) != se.end()) s << ", ";
   }
   s << "}";
   return s;
}
template<typename T1, typename T2> ostream& operator << (ostream& s, const pair<T1,T2>& p) {
   s << "(" << p.first << "," << p.second << ")";
   return s;
}
template<typename T1, typename T2> ostream& operator << (ostream& s, const map<T1,T2>& m) {
   s << "{";
   for (auto i = m.begin(); i != m.end(); ++i) {
      s << i->first << ":" << i->second;
      if (next(i) != m.end()) s << ", ";
   }
   s << "}";
   return s;
}

signed main()
{
   int N; cin >> N;
   string A, B, C; cin >> A >> B >> C;

   int ans = 0;
   REP(i, 0, N) {
      set<char> s;
      s.insert(A[i]);
      s.insert(B[i]);
      s.insert(C[i]);
      ans += SZ(s)-1;
   }
   cout << ans << endl;
   return 0;
}


Measured memory_bytes: 256
L, R = map(int, input().split())

Lq = L // 2019
l = L % 2019
Rq = R // 2019
r = R % 2019

if Lq != Rq:
    print(0)
else:
    ans = 2019
    for i in range(l,r):
        for j in range(i+1, r+1):
            ans = min(ans, (i*j) % 2019)

    print(ans)

Measured memory_bytes: 41708
A, B, C, D = map(int, input().split())

takahashi = 0
aoki = 0

while C > 0:
  C -= B
  takahashi += 1
  
while A > 0:
  A -= D
  aoki += 1
  
if takahashi <= aoki:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 9136
//#include <ext/pb_ds/assoc_container.hpp>
#include <bits/stdc++.h>
using namespace std;
//using namespace __gnu_pbds;
//template <class c, class cmp = less<c> > using ordered_set = tree<c, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;



  #define IOS ios_base::sync_with_stdio(false);cin.tie(NULL); 

  #define ff first
  #define ss second
  #define pb push_back
  #define pf push_front
  #define mp make_pair
  #define in insert
  #define ld long double


  #define TRACE
  #ifdef TRACE
  #define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
  template <typename Arg1>
  void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
  }
  template <typename Arg1, typename... Args>
  void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
  }
  #else
  #define trace(...) 1
  #endif
  template<class T> ostream& operator<<(ostream &os, vector<T> V) {os << "[ "; for(auto v : V) os << v << " "; return os << "]";}
  template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {return os << "(" << P.first << "," << P.second << ")";}
  template <typename T,typename U>pair<T,U> operator+(const pair<T,U> & l,const std::pair<T,U> & r) { return {l.first+r.first,l.second+r.second};}
  typedef long long int ll;

  typedef vector<int> vi;
  typedef vector<ll> vl;
  typedef vector<vi> vvi;
  typedef vector<vl> vvl;
  typedef pair<int,int> pii;
  typedef pair<ll,ll> pll;
  typedef vector<pii> vpii;
  typedef vector<pll> vpll;
  const ll mod =1e9+7;
  const ll MAX_NODES =200001;
  const ll MAX_LOG =50;
  const ll maxn = 400000+10;
  #define endl '\n'
  ll power(ll x, ll n) {
      ll res = 1;
      for (; n > 0; n >>= 1) {
      if (n & 1) res = (res * x) % mod;
      x = (x * x) % mod;
      }
      return res;
  }
int main()
{

	IOS
	int n;
	cin>>n;
	cout<<(n+1)/2;	


}
 
  


  
  




Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<math.h>
#include<algorithm>
#include<string>
#define pi 3.14159
using namespace std;


int main() {
	int a[5], temp;
	for (int i = 0; i < 5; i++) cin >> a[i];
	for (int i = 0; i < 4; i++) {
		for(int j = i + 1; j < 5; j++) {
			if(a[i] < a[j]) {
				temp = a[i];
				a[i] = a[j];
				a[j] = temp;
			}
		}
	}
	for (int i = 0; i < 5; i++) {
		if(i == 4) cout << a[i] <<endl;
		else cout << a[i] << ' ';
	}
	

	return 0;
}

Measured memory_bytes: 1164
#include<cstdio>
#include<cstdlib>
using namespace std;
int main(){
	
	double xA,yA,xB,yB,xC,yC,xD,yD;
	
	while(scanf("%lf%lf%lf%lf%lf%lf%lf%lf",&xA,&yA,&xB,&yB,&xC,&yC,&xD,&yD) != EOF){
		
		double a,b,c,d;
		
		a = (yA-yB);
		b = (xA-xB);
		c = (yC-yD);
		d = (xC-xD);
		
		(a*c + b*d == 0) ? puts("YES") : puts("NO");
	}
	
	return 0;
}

Measured memory_bytes: 1040
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>

using namespace std;

int n;
int sh, sm, ss, th, m, ts;
vector<pair<int,int> > tim;

int main(){
    
    while(cin >> n, n){
        
        tim.clear();
        for(int i = 0; i < n; i++){
            scanf("%d:%d:%d %d:%d:%d", &sh, &sm, &ss, &th, &m, &ts);
            tim.push_back(make_pair(th*60*60+m*60+ts,sh*60*60+sm*60+ss));
            //cout << tim[i].second << ' ' << tim[i].first << endl;
        }
        sort(tim.begin(),tim.end());
        
        int mcnt = 0;
        for(int i = 0; i < n; i++){
            int cnt = 0;
            for(int j = i+1; j < n;j++){
                if(tim[i].first > tim[j].second) cnt++;
            }
            mcnt = max(mcnt, cnt);
        }
        cout << mcnt + 1 << endl;
    }
}

Measured memory_bytes: 1372
//abc148_e.cpp
//Sun Dec 22 20:45:56 2019

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

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

	if (n%2==1){
		cout << 0 << endl;
	}else {
		ll ans = 0;
		ll counted = 0;
//		for (ll i=1;i<=18;i++){
//			ll waru = pow(10,i);
//			ll temp = n/waru;
//			ans += temp;
//		}
		for (ll i=1;i<28;i++){
			ll waru = pow(5,i)*2;
			ll temp = n/waru;
			ans += temp;
//			cout << i << " " << temp << endl;
		}
		cout << ans << endl;
	}

}

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


typedef long long ll;
#define reg register
#define rep(i,a,b) for(int i=a,i##end=b;i<=i##end;++i)
#define drep(i,a,b) for(int i=a,i##end=b;i>=i##end;--i)


char IO;
inline ll rd(){
	ll s=0,f=0;
	while(!isdigit(IO=getchar())) if(IO=='-') f=1;
	do s=(s<<1)+(s<<3)+(IO^'0');
	while(isdigit(IO=getchar()));
	return f?-s:s;
}


const int N=2e5+10;

int a,b,c;


int main(){
	b=rd(),a=rd();
	rep(i,a-b+1,a+b-1) printf("%d%c",i,i==a+b-1?'\n':' ');
}




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

int main() {
  int N;
  string S;
  cin >> N;
  cin >> S;
  rep (i, S.size()) S[i] = (S[i] - 'A' + N) % 26 + 'A';
  cout << S << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define ll long long
#define ll_MAX LONG_LONG_MAX
#define ll_MIN LONG_LONG_MIN
#define pi pair<int,int>
#define endl "\n"
#define MAXN 100005
#define mod 1000000007
using namespace std;

void solve()
{
    
}
vector<ll> dp(100001, -1);
void dfs(ll s, vector< vector<ll> > &adj, vector<bool> &v)
{
    v[s] = true;
    ll child = 0;
    for(auto c: adj[s])
    {
        if(!v[c])
        {
            dfs(c, adj, v);
        }
        if(dp[c] == -1)
            continue;
        dp[s] = max(dp[s], dp[c] + 1);
        child += 1;
    }
    if(!child)
    {
        dp[s] = 0;
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	cout.tie(NULL);
    solve();
    ll n,m;
    cin>>n>>m;
    vector< vector<ll> > adj(n + 1);
    vector<bool> vis(n + 1, false);
    for (ll i = 0; i < m; i++)
    {
        /* code */
        ll v1,v2;
        cin>>v1>>v2;
        adj[v1].push_back(v2);
    }
    ll ans = 0;
    for(ll i=1; i<=n; i++)
    {
        if(!vis[i])
            dfs(i, adj, vis);
    }
    for(ll i=1; i<=n; i++)
    {
        ans = max(ans, dp[i]);
    }
    cout<<ans<<'\n';
}

Measured memory_bytes: 13308
#include<cstdio>
#include<cstring>
#define ll long long
const ll MAXN=1e5+10;
int main(){
	int a[2*MAXN];
	int n;
	scanf("%d",&n);
	if(n%2==0){
		int m,q;
		for(int y=n/2+1,z=n/2;y<=n;y++,z--){
			
			scanf("%d %d",&m,&q);
			a[y]=m,a[z]=q;
		}
	}
	else {
		int m,q;
		scanf("%d",&m);
		a[n/2+1]=m;
		for(int y=n/2+2,z=n/2;y<=n;y++,z--){
			scanf("%d %d",&m,&q);
			a[y]=m,a[z]=q;
		}
	}
	for(int i=1;i<=n;i++){
		printf("%d ",a[i]);
	}
	return 0;
}

Measured memory_bytes: 2816
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(LL &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const LL &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
int main(){
    int a,b,c;
    R(a,b,c);
    W(max({a,b,c})-min({a,b,c}));
    return 0;
}


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

class Main{
    public static void main(String[] args){
        FastScanner fsc=new FastScanner();
        int a=fsc.nextInt();
        int b=fsc.nextInt();
        int c=fsc.nextInt();
        fsc.close();
        if(a==b && b==c){
            System.out.println(1);
        } else if(a==b || b==c || c==a){
            System.out.println(2);
        } else{
            System.out.println(3);
        }
    }
    static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte(){
            if(ptr<buflen) return true;
            else{
                ptr = 0;
                try{
                    buflen = in.read(buffer);
                }
                catch(IOException e){
                    e.printStackTrace();
                }
                if(buflen<=0) return false;
            }
        return true;
        }
        private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
        private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
        public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public long nextLong() {
            if (!hasNext()) throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) throw new NumberFormatException();
            while(true){
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                }
                else if(b == -1 || !isPrintableChar(b)) return minus ? -n : n;
                else throw new NumberFormatException();
                b = readByte();
            }
        }
        public int nextInt() {
            long nl = nextLong();
            if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
            return (int) nl;
        }
        public double nextDouble() { return Double.parseDouble(next());}
        public void close(){
            try{in.close();}
            catch(IOException e){e.printStackTrace();}
        }
    }
}


Measured memory_bytes: 20564
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
int main(){
	int N, M; 
	cin >> N >> M; 
	int X[100010] = {}; 
	for(int i = 0; i < M; i++){
		cin >> X[i]; 
	}
	sort(X, X+M); 
	int D[100010] = {}; 
	for(int i = 0; i < M-1; i++){
		D[i] = X[i+1] - X[i]; 
	}
	sort(D, D+M-1, greater<int>()); 
	int ans = X[M-1] - X[0]; 
	for(int i = 0; i < N-1; i++){
		ans -= D[i]; 
	}
	cout << ans << endl; 
}

Measured memory_bytes: 1024
counter = 0


def merge(A, left, mid, right):
    m = mid - left
    n = right - mid
    L = [None] * (m+1)
    R = [None] * (n+2)

    for i in range(m):
        L[i] = A[left + i]

    for i in range(n):
        R[i] = A[mid + i]

    L[m], R[n] = float("inf"), float("inf")  # stoper
    i, j = 0, 0

    for k in range(left, right):
        if L[i] <= R[j]:
            A[k] = L[i]
            i += 1
        else:
            A[k] = R[j]
            j += 1
    global counter
    counter += right - left
    return


def merge_sort(A, left, right):
    if left + 1 < right:
        mid = (left + right) // 2
        merge_sort(A, left, mid)
        merge_sort(A, mid, right)
        merge(A, left, mid, right)
    return A


def main():
    _ = input()
    A = [int(i) for i in input().strip().split()]
    merge_sort(A, 0, len(A))
    print(" ".join([str(i) for i in A]))


if __name__ == "__main__":
    counter = 0
    main()
    print(counter)



Measured memory_bytes: 66788
#include<bits/stdc++.h>
using namespace std;
 
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define test cout<<"test"<<endl;
#define fi first
#define se second
#define rep(i,n,m) for(ll i = n; i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = n - 1; i >= (ll)(m); i--)
typedef long long ll;
typedef long double ld;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T>
void chmin(T &a,T b){if(a>b)a=b;}
template<typename T>
void chmax(T &a,T b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void pmod(ll &a,ll b,ll c){a=(b+c)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void qmod(ll &a,ll b,ll c){a=(b*c)%MOD;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
void debug(vector<vector<ll>>v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
void debug(vector<ll>v,ll n){cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
vector<vector<ll>>vec(ll x, ll y, ll w){
  vector<vector<ll>>v(x,vector<ll>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while((r=x%y)!=0){x=y;y=r;}return y;}
//m.emplace(x,0).fi->se++;
 
ll MAX_V = 3000; //頂点数
struct edge {
    ll to;
    ll cost;
};
vector<vector<struct edge>> G(MAX_V); //隣接リスト
vector<ll> d(MAX_V); //各頂点への最短距離
vector<ll> neg(MAX_V,0);
ll n;
bool bellmanford(ll s){
  fill(ALL(d), INF);
  d[s]=0;
  for(ll i=0;i<2*MAX_V;i++){
    for(ll j=0;j<G.size();j++){
      for(ll k=0;k<G[j].size();k++){
        struct edge e=G[j][k];
        if(d[j]!=INF&&d[e.to]>d[j]+e.cost){
          d[e.to]=d[j]+e.cost;
          if(i>=MAX_V-1){
            d[e.to]=-INF;
            if(e.to==n)
            return false;
          }
        }
      }
    }
  }
  return true;
}
 
 
int main(){
  cin.tie(NULL);
  ios_base::sync_with_stdio(false);
  ll res=0,res1=INF,res2=-INF,buf=0;
  bool judge = true;
  ll m,p;cin>>n>>m>>p;
  vector<ll> u(m),v(m),a(m);
  for(ll i=0;i<m;i++){
    cin>>u[i]>>v[i]>>a[i];
    struct edge e ={v[i],p-a[i]};
    G[u[i]].push_back(e);
  }
  if(bellmanford(1)){
    cout<<max(0LL,-d[n])<<endl;
  }
  else{
    cout<<-1<<endl;
  }
  return 0;
}

Measured memory_bytes: 768
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;

int main() {
    int h, w; cin >> h >> w;
    int cnt = 0;
    for (int i = 0; i < h; i++) {
        string s; cin >> s;
        for (char& ch : s) cnt += ch == '#';
    }
    if (cnt == h + w - 1) {
        cout << "Possible" << endl;
    } else {
        cout << "Impossible" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
	d = zeros(Int,4)
	for i in 1:3
		a,b = readline() |> split |> parseMap
		d[a]+=1
		d[b]+=1
	end
	println(maximum(d)==2?"YES":"NO")
end

main()

Measured memory_bytes: 110208
#include <iostream>

using namespace std;
using ll = long long;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define IN(v) int v;cin>>v;
#define OUT(v) cout<<v<<"\n"
const int MAX_N = 1e5;

int A[MAX_N];
int main() {
  cin.tie(0); ios::sync_with_stdio(false);

  IN(N);

  ll ans = 0;
  REP(i, N) {
    cin >> A[i];
  }
  REP(i, N) {
    ans += (ll)A[i] / 2;
   A[i] %= 2;
    if (i+1 < N && A[i] == 1 && A[i+1] > 0) {
      --A[i+1];
      A[i] = 0;
      ++ans;
    }
  }
  OUT(ans);

  return 0;
}


Measured memory_bytes: 640
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iostream>
#include <iostream>
#include <fstream>
#include <numeric>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <cmath>
#include <set>
#include <map>
#include <functional>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
using namespace std;
#define     loop(n,i,a)     for(int i=a;i<n;i++)
#define     loopR(n,i,a)    for(int i=n-1;i>=a;i--)
#define     all(arr,n)      arr,arr+n
#define     allv(v)         (v).begin(),(v).end()
#define     rallv(v)        (v).rbegin(),(v).rend()
#define     m_p             make_pair
#define     ll              long long
#define     pii             pair<ll,ll>
#define     vi              vector<int>
#define     vll             vector<ll>
#define     vii             vector<pair<ll,ll>>
#define     sz(x)           (int)x.size()
#define     pb              push_back
#define     endl            "\n"
#define     Endl            "\n"
#define     f               first
#define     s               second
#define     mem(dp,n)       memset(dp,n,sizeof dp)
int dx[] = { 1 , 0 ,-1 , 0 ,-1 ,-1 , 1 , 1 };
int dy[] = { 0 , 1 , 0 ,-1 ,-1 , 1 ,-1 , 1 };
void fast(){
    std::ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
}
vector<string> vec_splitter(string s) {
    s += ',';
    vector<string> res;
    while(!s.empty()) {
        res.push_back(s.substr(0, s.find(',')));
        s = s.substr(s.find(',') + 1);
    }
    return res;
}
void debug_out(
        vector<string> __attribute__ ((unused)) args,
        __attribute__ ((unused)) int idx,
        __attribute__ ((unused)) int LINE_NUM) { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
    if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
    stringstream ss; ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, LINE_NUM, T...);
}
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
const ll mxN=2e6+10,oo=0x3f3f3f3f,MOD=998244353;
const double PI = acos(-1);

void solve(){
    ll n,m,k;
    cin>>n>>m>>k;
    ll a[n+1]={},b[m+1]={};
    loop(n+1,i,1)
        cin>>a[i],a[i]+=a[i-1];
    loop(m+1,i,1)
        cin>>b[i],b[i]+=b[i-1];
    int i=0,j=m,res=0;
    while(i<=n){
        if(a[i]>k)
            break;
        while(b[j]>k-a[i])
            j--;
        res=max(res,i+j);
        i++;
    }
    cout<<res<<Endl;
}
int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    fast();
    solve();
}

Measured memory_bytes: 6740
# -*- coding: utf-8 -*-
N = int(input())
R = [list(map(int, input().split(' '))) for _ in range(N)]
B = [list(map(int, input().split(' '))) for _ in range(N)]

B.sort(key=lambda x: x)


ans = 0
used = set()
for c, d in B:
    candidates = [(a, b, i) for i, (a, b) in enumerate(R)
                    if i not in used and a < c and b < d]

    if len(candidates) > 0:
        candidates.sort(key= lambda x: -x[1])
        # print(candidates)
        used.add(candidates[0][2])

# print(used)
print(len(used))



Measured memory_bytes: 39152
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


int main(){
  int N, K;

  cin >> N >> K;

  cout << N - K + 1 << endl;

  return 0;
}


Measured memory_bytes: 256
from itertools import product

N, M = map(int, input().split())
L = [[] for _ in range(N)]

for i in range(N):
  x, y, z = map(int, input().split())
  L[i] += [x, y, z]

ans = 0

for pm in product([-1, 1], repeat=3):
  temp = []
  for l in L:
    temp.append(pm[0]*l[0] + pm[1]*l[1] + pm[2]*l[2])
  temp.sort(reverse = True)
  ans = max(ans, sum(temp[:M]))

print(ans)

Measured memory_bytes: 9236
#include <iostream>
#include <fstream>
#include <cstring>
#include <climits>
#include <algorithm>
#include <math.h>
#include <vector>
using namespace std;

#define ll long long

ll dp[1000][100000];

ll solve1(int i, int vt, ll int* w, ll int* v, int n) {

	// we define dp[i][j] as the min weight for attaining value j from the suffix i:

	if (vt <= 0)
      	return 0;

	if (i == n)
      	return INT_MAX;

	if (dp[i][vt] != -1)
		return dp[i][vt];

	dp[i][vt] = min(solve1(i+1, vt, w, v, n), w[i] + solve1(i+1, vt-v[i], w, v, n));
	return dp[i][vt];
}

int knapSack(ll int* v, ll int* w, int n, int W) {
	int V = 0;
	for (int i = 0; i < n; ++i)
		V += v[i];

	int ans = 0;
	for (int x = V; x >= 0; x--)
		if (solve1(0, x, w, v, n) <= W)
			return x;
}

int main() {

	int n, W;
	cin >> n >> W;
	ll v[n], w[n];
	for (int i = 0; i < n; ++i)
		cin >> w[i] >> v[i];
	memset(dp, -1, sizeof(dp));
	// cout << solve(0, W, w, v, n);
	// cout << solve_ite(W, w, v, n);
	
	cout << knapSack(v, w, n, W);

	return 0;
}

Measured memory_bytes: 781440
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

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

  ll n, m;
  cin >> n >> m;

  ll ans = 0;

  if (n == 1 && m == 1) {
    ans = 1;
  } else if (n == 1 || m == 1) {
    ans = n * m - 2;
  } else {
    ans = (n - 2) * (m - 2);
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
// Begin Header {{{
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i,n) for(ll i=0; i<n; i++)
#define loop(i, j, n) for(ll i=j; i<n; i++)
#define all(x) (x).begin(), (x).end()
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
const long double PI = acos(-1);
// }}} End Header
int main() {
	string s;
	cin >> s;
	if(s[0]>='a' && s[0]<='z') cout << 'a';
	else cout << 'A';
	return 0;
}

Measured memory_bytes: 3592
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>

using namespace std;

const size_t opsize = 81, bufsize = 102;
unsigned char op1[opsize], op2[opsize];
char buf[bufsize];

bool readOp(unsigned char * op){
    memset(op, 0, opsize);
    
    fgets(buf, bufsize, stdin);
    int l = strlen(buf);
    if(l > 81) return true;

    char *p = &buf[l-2];
    for (int j = 0; j < l-1; j++) {
        op[j] = *p - '0';
        p--;
    }
    return false;
}

void printOp(unsigned char * op){
    int mh = opsize - 1;
    while(op[mh] == 0 && mh > 0) mh--;
    for(; mh >= 0; mh--){
        putchar(op[mh] + '0');
    }
    putchar('\n');
}

bool plus(){
    for (int i = 0; i < opsize - 1; i++) {
        op1[i] += op2[i];
        if(op1[i] >= 10){
            op1[i] -= 10;
            op1[i+1] += 1;
        }
    }
    return op1[opsize - 1] != 0;
}

int main(int argc, char const* argv[])
{
    int n;
    scanf("%d ", &n);
    for (int i = 0; i < n; i++) {
        bool overflow = false;
        overflow |= readOp(op1);
        overflow |= readOp(op2);
        if(overflow){
            puts("overflow");
            continue;
        }
        overflow = plus();

        if(overflow){
            puts("overflow");
            continue;
        }
        printOp(op1);
    }
    
    return 0;
}

Measured memory_bytes: 2596
a = []

3.times do
  a << gets.split.map{|e| e.to_i}
end

a.flatten!

n = gets.to_i

n.times do
  x = gets.to_i
  9.times do |i|
    if a[i] == x
      a[i] = 999
    end
  end
end

b = [a[0,3], a[3,3], a[6,3]]

3.times do |y|
  sum = 0
  3.times do |x|
    sum += b[y][x]
  end
  if sum == 999*3
    puts "Yes"
    exit
  end
end

3.times do |y|
  sum = 0
  3.times do |x|
    sum += b[x][y]
  end
  if sum == 999*3
    puts "Yes"
    exit
  end
end

if b[0][0] + b[1][1] + b[2][2] == 999*3
    puts "Yes"
    exit
end

if b[2][0] + b[1][1] + b[0][2] == 999*3
    puts "Yes"
    exit
end

puts "No"


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

#define rep(i, N) for (ll i = 0; i < N; i++)
#define rep1(i, N) for (ll i = 1; i <= N; i++)
#define repr(i, N) for (ll i = N-1; i >= 0; i--)
#define repr1(i, N) for (ll i = N; i > 0; i--)

#define INF 1000000007

using ll = long long;
using namespace std;

typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<P> vpi;


int main() {
    ll N,K,ans=0;
    cin >> N >> K;

    ans = min(N, min(abs(N-K*(N/K)), abs(N-K*(N/K+1))));
    
    cout << ans;
    //printf("%.15lf", ans);
    cout << "\n";
    return 0;
}


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

int main() {
  int N;
  string S;
  cin >> N >> S;
  
  if (N % 2 != 0){
    cout << "No" << endl;
    return 0;
  }
 
  for (int i = 0; i < N/2; i++) {
    if (S.at(i) != S.at(i+N/2)){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}

  

Measured memory_bytes: 3604
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream& operator<<(ostream& os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
int main(){
    int a, b;
    cin >> a >> b;
    for(int i = 0; i <= a; i++){
        for(int j= 0; j <= b; j++){
            if(i + j == a and i * 2 + j * 4 == b){
                puts("Yes");
                return 0;
            }
        }
    }
    puts("No");
}


Measured memory_bytes: 3640
MOD=10**9+7
cnt=0; sum=0; prev=nil; ha=Hash.new(0)
def gs() gets.chomp end
def gi() gets.to_i end
def gsmi() gets.chomp.split.map(&:to_i) end

def desc(ar) ar.sort!{|x,y|y<=>x} end
def min(a,b) a<=b ? a : b end
def max(a,b) a>=b ? a : b end

def puts_yesno(can) puts(can ? 'Yes' : 'No') end
def putsend(s) puts s; exit end
def debug(k,v) puts "#{k}:#{v}" end
########### ( ˘ω˘ )ｽﾔｧ… ###########
n = gi
h = gsmi

cnt = 0
while h.sort[-1] > 0 do
  prev = -1
  0.upto(n-1) do |i|
    cnt+=1 if h[i]>0 && prev<0
    h[i]-=1
    prev=h[i]
  end
end
puts cnt


Measured memory_bytes: 1916
import java.util.*;
 
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int ans = N;
		for(int i=0;i<=N;++i){
			int six = i;
			int nine = N-six;
			int score = 0;
			while(six!=0){
				score += six%6;
				six /= 6;
			}
			while(nine!=0){
				score += nine%9;
				nine /= 9;
			}
			if(score<ans) ans = score;
		}
		
		System.out.println(ans);
		return;
	}
}

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

int main()
{
    int n;
    scanf("%d", &n);

    if (n % 10 == 3)
        printf("bon");
    else if (n % 10 == 0 || n % 10 == 1 || n % 10 == 6 || n % 10 == 8)
        printf("pon");
    else
    {
        printf("hon");
    }

    return 0;
}

Measured memory_bytes: 1732