akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <algorithm>
#include <iostream>
#include <set>
using namespace std;

int main(){
    string s;
    cin >> s;
    string s_after;

    for(int i=0;i<s.length();i+=2){
        s_after+=s[i];
    }

    cout << s_after << endl;

    
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int,int>;
#define rep(i,n) for(int i=0; i<n; i++)
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてから使う
#define INF 2147483647
#define LLINF 9223372036854775807LL

ll MOD = 1000000007;
ll n;

ll Pow(ll m){ //m^nを返す
  ll ret = 1;
  rep(i,n){
    ret *= m;
    ret %= MOD;
  }
  ret %= MOD;
  //cout << "m=" << m << ",ret = " << ret << endl;
  return ret;
}

int SumDig(int i){
  string s = to_string(i);
  int sum = 0;
  rep(j,s.size()){
    sum += s[j] - '0';
  }
  return sum;
}

int main(){
  int n,a,b;
  cin>>n>>a>>b;
  int sum = 0;
  for (int i=1; i<=n; i++){
    int dig = 0;
    dig += SumDig(i);
    if (dig >= a && dig <= b) sum += i;
  }
  cout << sum << endl;
}

Measured memory_bytes: 3740
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(i, n) for(int i=0; i<=n; i++)
#define repr(i, n) for(int i=n; i>0; i--)
#define REPR(i, n) for(int i=n; i>=0; i--)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
template<class T> void puts(T x) { std::cout << x << std::endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int n;
vector<pair<ll, ll>> v;

int main() {
    cin >> n;
    rep(i, n) {
        ll a, b; cin >> a >> b;
        v.emplace_back(make_pair(b, a));
    }

    sort(v.begin(), v.end());
    ll tmp = 0;
    rep(i, n) {
        tmp += v[i].second;
        if (tmp > v[i].first) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 6512
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string ch,str;
    int flag;
    while(cin>>str>>ch)
    {
        flag=0;
        if(str.size()==ch.size()-1)
        {
            for(int i=0;i<str.size();i++)
            {
                if(str[i]==ch[i])
                {
                    continue;
                }
                else
                {
                    flag=1;
                    break;
                }
            }
            if(flag==1)
            {
                cout<<"No"<<endl;
            }
            else
            {
                cout<<"Yes"<<endl;
            }
        }
        else
        {
            cout<<"No"<<endl;
        }
    }
}


Measured memory_bytes: 3560
/**
 * @Author:      G_bg
 * @DateTime:    2019-07-20 20:22:09
 * @Description: 
 */
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const double PI = 3.1415926535898;
const double E = 2.718281828459;
const int INF = 0x7fffffff;
const int mod = 1e9+7;
const int maxn=2e5+10;
int a[maxn],b[maxn];
vector<int> v;
int main(int argc, char const *argv[]) {
	ios::sync_with_stdio(0);cin.tie(0);
	int n;cin >> n;
	for(int i = 1;i <= n;i++) cin >> a[i];
	for(int i = n;i >= 1;i--){
		int num = 0;
		for(int j = i+i;j <= n;j += i){
			if(b[j] == 1) num++;
		}
		if(num%2 != a[i]) {
			b[i] = 1,v.push_back(i);
		}
	}
	int x = v.size();
	cout << x << endl;
	for(int i = 0;i < x;i++)
		cout << v[i] << endl;
	//system("pause");
	return 0;
}

Measured memory_bytes: 2936
#include <algorithm>
#include <iostream>
#include <queue>
#include <utility>
#include <vector>
using namespace std;

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> A(N), B(M), C(M);
  for (int i = 0; i < N; ++i)
    cin >> A[i];
  for (int j = 0; j < M; ++j)
    cin >> B[j] >> C[j];
  vector<pair<int, int>> bc(M);
  for (int j = 0; j < M; ++j)
    bc[j] = make_pair(C[j], B[j]);
  sort(bc.begin(), bc.end(), greater<pair<int, int>>());
  priority_queue<int, vector<int>, greater<int>> pq;
  for (int i = 0; i < N; ++i)
    pq.push(A[i]);
  for (int j = 0; j < M; ++j) {
    for (int k = 0; k < bc[j].second; ++k) {
      if (pq.top() >= bc[j].first)
        break;
      int a = bc[j].first;
      pq.pop();
      pq.push(a);
    }
  }

  long long ans = 0;
  for (int i = 0; i < N; ++i) {
    ans += pq.top();
    pq.pop();
  }

  cout << ans << endl;
}

Measured memory_bytes: 2812
from bisect import bisect_left

CHARACTERs = 'abcdefghijklmnopqrstuvwxyz'

As = input()
lenA = len(As)

posChars = dict([(ch, [lenA]) for ch in CHARACTERs])
dp = [0] * lenA + [1, 0]
for i in reversed(range(lenA)):
    posChars[As[i]].append(i)
    dp[i] = min([dp[posChars[ch][-1] + 1] for ch in CHARACTERs]) + 1

for ch in CHARACTERs:
    posChars[ch] = posChars[ch][::-1]

ans = []
i = 0
for k in reversed(range(dp[0])):
    for ch in CHARACTERs:
        pos = posChars[ch][bisect_left(posChars[ch], i)]
        if dp[pos + 1] == k:
            ans.append(ch)
            i = pos + 1
            break

print(''.join(ans))


Measured memory_bytes: 19556
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <queue>
typedef long long ll;
using namespace std;

int main(void){
  int n;
  cin>>n;
  int m=n;

  if(n>=100000){
    cout<<90909<<endl;
  }
  else if(n>=10000){
    cout<<n-9090<<endl;
  }
  else if(n>=1000){
    cout<<909<<endl;
  }
  else if(n>=100){
    cout<<n-90<<endl;
  }
  else if(n>=10){
    cout<<9<<endl;
  }
  else{
    cout<<n<<endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
 
int main(){
	double N,K,ch,ch2;
	int count=0;
	double num=0.0;
	scanf("%lf%lf",&N,&K);
	for(int i=1.0000;i<=N;i++){
		ch2=0.50000000000;
		ch=i;
		count=0;
		if(ch>=K){
			ch2=1.0000000000;
		}else{
			do{
				ch=ch*2.00000000;
				//printf("%lf\n",ch);
				count++;
			}while(ch<K);
			//printf("count=%d\n",count);
			for(int j=1;j<count;j++){
				ch2=ch2*(0.5000000000);
				//printf("ch2=%lf\n",ch2);
			}
		}
		//printf("ch2=%lf\n",ch2);
		num+=(1.00000000/N)*ch2;
	}
	printf("%.16lf\n",num);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back

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

VI a;
int N, all;

bool check(int n) {
    vector<bool> b(all);
    REP(i, all) b[i] = (a[i] >= n);
    if (b[N - 2] == b[N - 1] || b[N - 1] == b[N]) return b[N - 1];
    int right = N - 1, left = N - 1;
    while (right + 1 < all && b[right] != b[right + 1]) right++;
    while (left - 1 >= 0 && b[left] != b[left - 1]) left--;
    return ((abs(N - 1 - left) >= abs(N - 1 - right)) ? b[right] : b[left]);
}

int main(void) {
    cin >> N;
    all = 2 * N - 1;
    a.resize(all);
    REP(i, all) scanf("%d", &a[i]);
    int high = all, low = 0;
    while (high - low > 1) {
	int mid = (high + low) / 2;
	(check(mid) ? low : high) = mid;
    }
    cout << low << endl;
}


Measured memory_bytes: 1152
n,m,l = gets.split().map(&:to_i)

a = Array.new()
b = Array.new()

n.times do |i|
  a[i] = gets.split().map(&:to_i)
end

m.times do |j|
  b[j] = gets.split().map(&:to_i)
end

c = Array.new(n).map{Array.new(l,0)}
n.times do |x|
  l.times do |y|
    m.times do |z|
      c[x][y] += a[x][z] * b[z][y]
    end
  end
end

c.each do |answer|
  puts answer.join(" ")
end


Measured memory_bytes: 7396
/* *****fireice**** */

#include<bits/stdc++.h>

#define ll long long int
#define ld long double
#define vi vector<int>
#define vc vector<char>
#define vl vector<ll>
#define vii vector<pair<int,int>>
#define vll vector<pair<ll,ll>>
#define pii pair<int,int>
#define pb push_back
#define eb emplace_back
#define el '\n'
#define N 1000000007
#define re return
#define F first
#define S second
#define L length
#define deb(x) cout<<#x<<" "<<x<<el;
#define mp make_pair
#define PI 3.14159265
#define all(a) (a).begin(),(a).end()
#define forup(i,n) for(int i=0;i<n;i++)
#define forf(i,x,n) for(int i=x;i<n;i++)
#define ford(i,n) for(int (i)=(n)-1;i>=0;(i)--)
#define take(a,n) forup(i,n) cin>>a[i];
using namespace std;

int gcdExtended(int a, int b, int *x, int *y)
{
    // Base Case
    if (a == 0)
    {
        *x = 0, *y = 1;
        return b;
    }

    int x1, y1; // To store results of recursive call
    int gcd = gcdExtended(b%a, a, &x1, &y1);

    // Update x and y using results of recursive
    // call
    *x = y1 - (b/a) * x1;
    *y = x1;

    return gcd;
}

ll modInverse(int a, int m)
{
    int x, y;
    int g = gcdExtended(a, m, &x, &y);
        // m is added to handle negative x
    ll res = ((ll)x%m + (ll)m) % m;

    return res;
}

ll poww(ll x,ll n)
{
    if(n==0)
        return 1;
    else if(n==1) return x;
    else if(n%2 == 0)        //n is even
        return poww(x*x,n/2);
    else                              //n is odd
        return x*poww(x*x,(n-1)/2);
}

ll modularExponentiation(ll x,ll n,ll M)
{
    ll result=1;
    while(n>0)
    {
        if(n % 2 ==1)
            result=(result * x)%M;
        x=(x*x)%M;
        n=n/2;
    }
    return result;
}

template<typename T>
T maxx(T a,T b)
{
  if(a<b) re b;
  re b;
}
template<typename T, typename... Args>
T maxx(T a,T b, Args... args)
{
    re(maxx(maxx(a,b),args...));
}

template<typename T>
T minn(T a,T b)
{
  if(a<b) re a;
  re b;
}
template<typename T, typename... Args>
T minn(T a,T b, Args... args)
{
    re(minn(minn(a,b),args...));
}

template<typename T>
void read(T& a)
{
  cin>>a;
}
template<typename T, typename... Args>
void read(T& a,Args&... args)
{
  cin>>a; read(args...);
}

template<typename T>
void write(T a)
{
  cout<<a<<' ';
}
template<typename T, typename... Args>
void write(T a,Args... args)
{
  cout<<a<<' '; write(args...);
}

inline ll min(ll a,ll b)
{
  if(a<b) re a;
  else re b;
}
inline ll max(ll a,ll b)
{
  if(a<b) re b;
  else re a;
}

ll gcd(ll a, ll b)
{
    if (a == 0)
       return b;
    if (b == 0)
       return a;

    if (a == b)
        return a;

    if (a > b)
        return gcd(a-b, b);
    else return gcd(a, b-a);
}

ll ncr(int n,int r)
{
  ll ans=1;
  r=min(r,n-r);
  forup(i,r)
  {
    ans=((ans*((n-i)%N))%N*modInverse(i+1,N))%N;
  }
  re ans;
}

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

  int t=1;
  //cin>>t;
  while(t--)
  {
    ll n,m,k;
    read(k,n,m);
    forf(i,n,m+1)
    {
      if(i%k==0)
      {
        cout<<"OK"<<el;
        re 0;
      }
    }
    cout<<"NG";
  }


  return 0;
}


Measured memory_bytes: 3608
package main

import (
	"fmt"
	"math"
)

func abs(a int) int {
	return int(math.Abs(float64(a)))
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func main() {
	var w, h, x, y int
	fmt.Scan(&w, &h, &x, &y)
	a1 := float32(w) * float32(h) /2.0
	a2 := 0
	cnt := 0

	if x*2 == w {
		cnt += 1
	}
	if y*2 == h {
		cnt += 1
	}
	if cnt == 2 {
		a2 = 1
	}

	fmt.Println(a1, a2)
}

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

int topdigit(int n){
    int a = n;
    while(a >= 10){
        a = floor(a / 10);
    }
    return a;
}

int main() {
    long long N, cnt;
    cnt = 0;
    cin>>N;
    vector<vector<int>> P(9, vector<int>(9, 0));
    REP(i, 1, N + 1){
        int a = i%10;
        int b = topdigit(i);
        if(a != 0 && b != 0){
            P[a-1][b-1]++;
        }
    }
    REP(i, 0, 9){
        REP(j, 0, 9){
            cnt += P[i][j] * P[j][i];
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
local read = io.read
local N, K = read("*n", "*n")

local A = {}
for i = 1, N do
	A[i] = read("*n")
end

local out = {}
for i = 1, N - K do
	if A[i + K] / A[i] > 1 then
		out[i] = "Yes"
	else
		out[i] = "No"
	end
end

print(table.concat(out, "\n"))


Measured memory_bytes: 7864
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m,mx;
  int a[1001]={};
  while(cin>>n>>m,n!=0&&m!=0){
    mx=-1;
    for(int i=0;i<n;i++){
      cin>>a[i];
    }
    for(int i=0;i<n;i++){
      for(int j=i+1;j<n;j++){
        if(a[i]+a[j]<=m)
          mx=max(mx,a[i]+a[j]);
      }
    }
    if(mx == -1)
      cout<<"NONE"<<endl;
    else
      cout<<mx<<endl;
  }
}


Measured memory_bytes: 3072
// sumitrust2019_b
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) rep(i,v.size())cout<<" "<<v[i];cout<<endl<<endl;
#define show2d(v) rep(i,v.size()){rep(j,v[i].size())cout<<" "<<v[i][j];cout<<endl;}cout<<endl;
using namespace std;
typedef long long ll;
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(int argc, char *argv[])
{
  int n,x1,x2;
  cin>>n;
  x1 = n / 1.08;
  x2 = n / 1.08+0.99;

  if((int)(x1*1.08) == n) {
    cout<<x1<<endl;
  } else if((int)(x2*1.08) == n) {
    cout << x2<<endl;
  } else {
    cout<<":("<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
// D - String Equivalence
#include <bits/stdc++.h>
using namespace std;
#define rp(i,s,e) for(int i=(s);i<(e);++i)

int main(){
	int N; cin>>N;
	vector<string> s(1,"a");
	while(--N){
		vector<string>t; swap(s,t);
		rp(i, 0, t.size()){
			int n = t[i].size();
			char mx = *max_element(t[i].begin(), t[i].end()) + 1;
			rp(c, 'a', mx+1) s.push_back(t[i] + char(c));

		}
	}
	rp(i, 0, s.size()) cout<< s[i] <<endl;
}

Measured memory_bytes: 10956
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 9;

int n;
int a[N];

int main() {
    cin >> n;
    for(int i = 1; i <= n; i++)
        cin >> a[i];
    
    priority_queue<int> pq(a+1, a+n+1);

    for(int i = 1; i <= n; i++) {
        int ma1 = pq.top(); pq.pop();
        int ma2 = pq.top(); pq.pop();
        cout << (a[i] == ma1 ? ma2 : ma1) << endl;
        pq.push(ma1);
        pq.push(ma2);
    }
}

Measured memory_bytes: 3200
#include <iostream>
#include <algorithm>

using namespace std;

int main(){

    int n, k;
    cin >> n >> k;

    int nums[n];

    int res = 0;

    for (int i = 0; i < n; i++){
        int temp;
        cin >> temp;
        res += min(temp * 2, (k - temp)*2);
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int root,t[2][100000],hight[100000],n,par[100000],sib[100000],a,b,c,dep,deg;
int dfs(int p){
  if(p==-1)return -1;
  return hight[p]=max(dfs(t[0][p]),dfs(t[1][p]))+1;
}
int main(){
  cin>>n;
  memset(sib,-1,sizeof(sib));
  memset(par,-1,sizeof(par));
  for(int i=0;i<n;i++){
    cin>>a>>b>>c;
    t[0][a]=b;
    t[1][a]=c;
    if(b!=-1)sib[b]=c,par[b]=a;
    if(c!=-1)sib[c]=b,par[c]=a;
  }
  for(int i=0;i<n;i++)if(par[i]==-1)root=i;
  dfs(root);
  for(int i=0;i<n;i++){
    deg=(int)(t[0][i]!=-1)+(int)(t[1][i]!=-1);
    dep=0;
    for(int j=par[i];j!=-1;j=par[j])dep++;
    cout<<"node "<<i<<": parent = "<<par[i]<<", sibling = "<<sib[i]<<", degree = "<<deg<<", depth = "<<dep<<", height = "<<hight[i]<<", ";
    if(!dep)cout<<"root";
    else if(t[0][i]==t[1][i])cout<<"leaf";
    else cout<<"internal node";
    cout<<endl;
  }
  return 0;
}



Measured memory_bytes: 3892
h, w=map(int, input().split())
s=[input() for i in range(h)]
ans=0
for i in range(h):
    for j in range(w):
        if s[i][j]=='#':
            t=0
            try:
                if s[i+1][j]=='#':
                    t=1
            except:
                pass
            try:
                if s[i-1][j]=='#':
                    t=1
            except:
                pass
            try:
                if s[i][j+1]=='#':
                    t=1
            except:
                pass
            try:
                if s[i][j-1]=='#':
                    t=1
            except:
                pass
            if t==0:
                ans+=1
print('Yes') if ans==0 else print('No')

Measured memory_bytes: 3064
N = int(input())
A_list = [[] for _ in range(N)]
for i in range(N):
    A = int(input())
    for a in range(A):
        x, y = map(int, input().split())
        A_list[i].append([x,y])
ans = 0
for i in range(1 << N):
    for j in range(N):
        wrong = False
        if 1 << j & i:
            prf = A_list[j]
            for p in prf:
                x, y = p
                if y == 0 and not (i & 1 << (x - 1)):
                    continue
                elif (i & 1 << (x - 1)) and y == 1:
                    continue
                else:
                    wrong = True
                    break

        if wrong:
            break
    if not wrong:
        cnt = 0
        for j in range(N):
            if 1 << j & i:
                cnt += 1
        ans = max(ans, cnt)
print(ans)


Measured memory_bytes: 3064
use std::io;

/// a[st..end]について、a[st..q] < a[q] < a[q+1..end]となるように操作してqを返す関数
/// なお、分割の基準にはa[end]を用いるものとする
/// こちらは自分が教科書で見ていたやつ
fn partition2(vec: &mut Vec<u32>, st: usize, end: usize) -> usize {
    let num = vec[end];
    let mut i = st;
    let mut j = end-1;

    while i < j {
        while vec[i] <= num {
            i+=1;
        }
        while vec[j] > num && j > 0 {
            j-=1;
        }
        if i < j{
            vec.swap(i, j);
        }
    }
    vec.swap(end, i);
    i
}

/// AOJの疑似コートで指定されていたもの
fn partition(vec: &mut Vec<u32>, st: usize, end: usize) -> usize {
    let num = vec[end];
    let mut i: i32 = st as i32 - 1;

    for j in st..end {
        if vec[j] <= num {
            i += 1;
            vec.swap(i as usize, j);
        }
    }
    vec.swap(end, i as usize +1);
    i as usize + 1
}

fn main() {
    let sin = io::stdin();
    let mut buf = String::new();
    sin.read_line(&mut buf).ok();
    let _n: usize = buf.trim().parse().unwrap();

    let mut buf = String::new();
    sin.read_line(&mut buf).ok();
    let mut a: Vec<u32> = buf.split_whitespace()
        .map(|v| v.parse::<u32>().unwrap())
        .collect::<Vec<u32>>();

    let l = a.len() - 1;
    // let idx = partition2(&mut a, 0, l);
    let idx = partition(&mut a, 0, l);

    for (i,v) in a.iter().enumerate() {
        if i == idx {
            print!("[{}]", v);
        } else {
            print!("{}", v);
        }
        if i != l {
            print!(" ");
        } else {
            println!("");
        }
    }
}



Measured memory_bytes: 5040
using System;
using System.Collections.Generic;
using System.Linq;

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            int q = int.Parse(Console.ReadLine());
            string[] l = Console.ReadLine().Split();
            int[] b = new int[q];
            int an = 0;
            int d = 0;
            for (int i = 0; i < q; i++) { b[i] = int.Parse(l[i]); }
            for (int i = 0; i < q-1;i++){
                d += b[i];
                an += d * b[i + 1];
            }
            Console.Write(an);
        }
    }
}

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

int n, k;
int p[200000];

int main() {
	int i;
	
	cin >> n >> k;
	rep(i, n) cin >> p[i];
	
	rep(i, n) p[i] = p[i] + 1;
	
	int s = 0;
	rep(i, k) s += p[i];
	int ans = s;
	
	for (i = k; i < n; i++) {
		s -= p[i - k];
		s += p[i];
		ans = max(ans, s);
	}
	
	printf("%.14f\n", ans * 0.5);
	return 0;
}

Measured memory_bytes: 1024
S = gets.chomp
slopes = [0]
(0..(S.length-1)).each do |i|
    if S[i] == "/"
        slopes.push(slopes[-1]+1)
    elsif S[i] == "_"
        slopes.push(slopes[-1])
    else
        slopes.push(slopes[-1]-1)
    end
end

before_max = slopes[0]
left_s = ""
(0..S.length).each do |i|
    if slopes[i] >= before_max
        before_max = slopes[i]
        left_s = "0" + left_s
    else
        left_s = "1" + left_s
    end
end

before_max = slopes[-1]
right_s = ""
(0..S.length).to_a.reverse.each do |i|
    if slopes[i] >= before_max
        before_max = slopes[i]
        right_s = right_s + "0"
    else
        right_s = right_s + "1"
    end
end

s = (left_s.to_i(2) & right_s.to_i(2)).to_s(2).reverse + "0"

cnt = 0
surface = 0
area = 0
areas = []
(0..(s.length-1)).each do |i|
    if s[i] == "0"
        if area != 0
            areas.push(area)
            area = 0
        end
    else
        if area == 0
            cnt += 1
            surface = slopes[i-1]
            area = 1
        else
            area += (surface-slopes[i])
        end
    end
end

if areas.empty?
    puts 0
    puts 0
    exit
end

puts areas.inject(:+)
print "#{cnt} "
puts areas.join(" ")


Measured memory_bytes: 88704
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<numeric>
#include<algorithm>
#define int long long
const int inf=1145141919;
const int mod=1000000007;
using namespace std;
template<class T>void debug(T *a,int l,int r,const char *name){
	for(int i=l;i<r;i++)
		cout<<name<<"["<<i<<"]="<<a[i]<<endl;
}
int N;
signed main(){
	int i,j;
	string s;
	cin>>s;
	string t;
	for(auto x:s)
		if(x!='x')
			t.push_back(x);
	for(i=0;i<t.size();i++)
		if(t[i]!=t[t.size()-i-1]){
			cout<<-1<<endl;
			return 0;
		}
	i=0;
	j=s.size()-1;
	int ans=0;
	while(i<j){
		if(s[i]!=s[j]){
			ans++;
			if(s[i]=='x')
				i++;
			else
				j--;
		}else{
			i++;
			j--;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<map>
#include<complex>
#define INF 2147483647
#define llINF 9223372036854775807
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long

using namespace std;
int main(){
  int n;
  while(cin>>n,n){
    vector<vector<int> >vvi(n+10);
    for(int i=0;i<n;i++){
      int m;cin>>m;
      for(int j=0;j<m;j++){
	int a;cin>>a;
	vvi[i].pb(a);
      }
    }
    int k;cin>>k;
    bool flag=true;
    int l;
    vector<int>vi;
    for(int i=0;i<k;i++){
      cin>>l;
      vi.pb(l);
    }
    int cnt=0;
    int po=-1;
    for(int i=0;i<n;i++){
      int cn=0;
      for(int j=0;j<vvi[i].size();j++){
	for(int op=0;op<vi.size();op++){
	  if(vvi[i][j]==vi[op]){
	    cn++;
	    break;
	  }
	}
      }
      if(cn==k){
	cnt++;
	po=i+1;
      }
    }
    if(cnt==1)cout<<po<<endl;
    else cout<<-1<<endl;
  }
  return 0;
}



Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,x;
  cin>>n>>x;
  if(x==1||x==2*n-1){
    cout<<"No";
    return 0;
  }
  cout<<"Yes"<<endl;
  if(x>=n){
    for(int i=x-n+1;i<=2*n-1;i++) cout<<i<<endl;
    for(int i=1;i<x-n+1;i++) cout<<i<<endl;
  }else{
    for(int i=n+x-1;i>=1;i--) cout<<i<<endl;
    for(int i=2*n-1;i>n+x-1;i--) cout<<i<<endl;
  }
}

Measured memory_bytes: 1536
/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Code author: Saurabh Singhal
Code copy karne vaale tera muh kaala
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/

#include<bits/stdc++.h>
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define ppb pop_back

using namespace std;
typedef long long int ll;
typedef vector<int> vi_t;
typedef vector<ll> vll_t;
int t=1;
vll_t a,b;
int  main(){
	// #ifndef ONLINE_JUDGE
 //    // for getting input from input.txt
 //    freopen("input.txt", "r", stdin);
 //    // for writing output to output.txt
 //    freopen("output.txt", "w", stdout);
	// #endif
	int a,b;
	cin>>a>>b;
	int c=b-a;
	int sum=c*(c+1)/2;
	cout<<sum-b<<endl;
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

signed main(){
    int x,y;
    cin>>x>>y;

    int ans=1;
    while(x*2<=y)x*=2,ans++;
    cout<<ans<<endl;
    return 0;
}


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

using namespace std;

int main(int argc, char *argv[]) {
    int N;
    cin >> N;
    map<int64_t, int64_t> m;
    vector<int64_t> arr(N);
    for (int i = 0; i < N; i++) {
        int64_t cur;
        cin >> cur;
        m[cur] += 1;
        arr[i] = cur;
    }

    int64_t sum = 0;
    for (auto var: m) {
        if (var.second > 1) {
            int64_t tmp = (var.second * (var.second - 1)) / 2;
            sum += tmp;
        }
    }

    for (int j = 0; j < N; j++) {
        int64_t cur = m[arr[j]];
        int64_t curm1 = cur - 1;
        int64_t sub = ((cur * max(cur - 1, 0L)) / 2) - ((curm1 * max(curm1 - 1, 0L)) / 2);
        cout << sum - sub << endl;
    }

    return 0;
}


Measured memory_bytes: 11008
import math
n,d  = map(int,input().split())

x =[]
y = []
for i in range(n):
    x1,y1  = map(int,input().split())
    x.append(x1)
    y.append(y1)

n = 0
 
for i ,index in enumerate(x):
  m = math.sqrt(x[i]**2 + y[i]**2)
  if m <= d:
    n += 1
 
print(n)

Measured memory_bytes: 24912
#include<bits/stdc++.h>
using namespace std;
using ll=long long int;
int main()
{
  ll mod,val,c=0;
  cin>>mod;
  val=7%mod;
  for(int i=1;i<1e7;i++)
  {
    
    if(val==0)
    {
      cout<<i<<endl;
      c=1;
      break;
    }
    val=(val*10+7)%mod;
  }
  if(c==0)
  cout<<"-1"<<endl;
}


Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    while(cin>>n,n){
        int man[2];
        double bmi[2],h,w;
        cin>>man[0]>>h>>w;
        h/=100;
        bmi[0]=w/(h*h)-22;
        if(bmi[0]<0)bmi[0]*=-1;
        for(int i=1;i<n;i++){
            cin>>man[1]>>h>>w;
            h/=100;
            bmi[1]=w/(h*h)-22;
            if(bmi[1]<0)bmi[1]*=-1;
            if(bmi[1]<bmi[0]||bmi[0]==bmi[1]&&man[1]<man[0]){
                bmi[0]=bmi[1];
                man[0]=man[1];
            }
        }
        cout<<man[0]<<endl;
    }
}

Measured memory_bytes: 1228
#include<bits/stdc++.h>
#define reg register
#define mod 924844033
#define G 5
#define Gi 554906420
#define maxn 2000001
using namespace std;
inline int  read() {
    reg int s = 0, t = 0; reg char ch = getchar();
    while(ch > '9' || ch < '0') t |= ch == '-', ch = getchar();
    while(ch >= '0' && ch <= '9') s = (s << 1) + (s << 3) + (ch ^ 48), ch = getchar();
    return t ? -s : s;
}
int inv[maxn], fac[maxn], ifac[maxn], nt[maxn], fi[maxn], go[maxn];
int lim, rev[maxn], cnt, siz[maxn], n, f[maxn], g[maxn];
int ksm(int u, int v){
    int s = 1;
    for(int i = v; i; i >>= 1){
        if(i & 1) s = 1ll * s * u % mod;
        u = 1ll * u * u % mod;
    }
    return s;
}
void add(int u, int v){
    nt[++cnt] = fi[u]; fi[u] = cnt; go[cnt] = v;
}
int C(int x, int y) {
  if (x < 0 || y < 0 || x < y)
    return 0;
  else
    return 1ll * fac[x] * ifac[y] % mod * ifac[x - y] % mod;
}
void dfs(int u, int fa){
    siz[u] = 1;
    for(int i = fi[u]; i; i = nt[i]){
        int v = go[i]; if(v == fa) continue;
        dfs(v, u); siz[u] += siz[v];
    }
    f[siz[u]]++;  f[n - siz[u]]++;
}
void ntt(int *a, int type){
    for(int i = 1; i < lim; i++)
        if(i < rev[i]) swap(a[i], a[rev[i]]);
    for(int i = 1; i < lim; i <<= 1){
        int x = ksm(type == 1 ? G : Gi, (mod - 1) / (i << 1));
        for(int j = 0; j < lim; j += (i << 1)){
            int y = 1;
            for(int k = 0; k < i; k++, y = 1ll * y * x % mod){
                int p = a[j + k], q = 1ll * y * a[j + k + i] % mod;
                a[j + k] = (p + q) % mod, a[j + k + i] = (p - q + mod) % mod;
            }
        }
    } 
}
int main()
{
    n = read();
    for(int i = 1; i < n; i++) {
        int x = read(), y =  read();
        add(x, y); add(y, x);
    }
    dfs(1, 0);
     fac[0] = 1; ifac[0] = 1; inv[0] = 1;
    for(int i = 1; i < maxn; i++){
        inv[i] = (i == 1) ? 1 : 1ll * inv[mod % i] * (mod - mod / i) % mod;
        fac[i] = 1ll *  fac[i - 1] * i % mod;
        ifac[i] = 1ll * ifac[i - 1] * inv[i] % mod;
    }
    int ans = 0;
    for(int i = 1; i <= n; i++)
        f[i] = 1ll * f[i] *fac[i] % mod; 
    for(int i = 0; i <= n; i++) g[i] = ifac[i];
    reverse(f, f + n + 1);
    int len = 0; 
    for(lim = 1; lim <= (n << 1); lim <<= 1, len++);
    for(int i = 1; i < lim; i++)
    rev[i] = (rev[i >> 1] >> 1) | ((i & 1) << (len  - 1));
    ntt(g, 1); ntt(f, 1);
    for(int i = 0; i < lim; i++) g[i] = 1ll * g[i] * f[i] % mod;
    ntt(g, -1); 
    for(int i = 0; i < lim; i++) g[i] = 1ll * g[i] * ksm(lim, mod - 2) % mod;
    reverse(g, g + n + 1);
    for(int i = 1; i <= n; i++){
        ans = 1ll * (n + 1) * C(n, i) % mod;
        ans = (ans - 1ll * g[i] * ifac[i] % mod + mod) % mod;
        printf("%d\n", ans);
    } 
}

Measured memory_bytes: 61568
#pragma GCC optimize ("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse4")
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
#define int ll
#define all(x) x.begin(), x.end()
#define trav(i,a) for(auto &i:a) 
inline int in(){int x;scanf("%lld",&x);return x;}
vector<pair<int,int>> g[51];
int val[25],mak=0;
#define f first
#define s second
bool dfs(int u,int par, int v)
{
	if(v==u)return 1;
	for(auto x:g[u])
	{
		if(x.f==par)continue;
		if(dfs(x.f,u,v))
		{
			mak|=(1LL<<x.s);
			return 1;
		}
	}
	return 0;
	
}
int32_t main()
{
	int n=in();
	int u,v;
	for(int i=0;i<n-1;i++)
	{
		u=in();v=in();
		g[u].push_back({v,i});
		g[v].push_back({u,i});
	}
	int m=in();
	for(int i=0;i<m;i++)
	{
		u=in();v=in();
		bool b=dfs(u,0,v);	
		val[i]=mak;
		mak=0;
	}
	
	int ans=0;
	
	for(int mask=0;mask<(1<<m);mask++)
	{
		//contains union of all edges in constraints in mask
		int submask=0;
		for(int j=0;j<m;j++)
		{
			if(mask&(1LL<<j))submask|=(val[j]);	
		}
		int num=__builtin_popcountll(submask);
		int rem=n-1-num;
		
		if(__builtin_popcountll(mask)&1)ans-=(1LL<<rem);
		else ans+=(1LL<<rem);
	}
	cout<<ans;
}

Measured memory_bytes: 3760
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <sstream>

using namespace std;

// ?????????????????????????????§????????£???????????????
vector<string> split(const string &str, char sep)
{
    vector<string> v;
    stringstream ss(str);
    string buffer;
	
    while(getline(ss, buffer, sep)){
        v.push_back(buffer);
    }
	
    return v;
}

int int_str(string str){
	int num = 0;
	bool minus = false;
	if(str[0] == '-'){
		str = str.substr(1);
		minus = true;
	}
	for(int i = 0; i < str.size(); i++){
		num *= 10;
		num += (str[i] - '0');
	}
	if(minus){
		num = -num;
	}
	return num;
}

vector<int> str_to_int_vector(vector<string> v_str){
	vector<int> v_int;
	for(int i = 0; i < v_str.size(); i++){
		v_int.push_back(int_str(v_str.at(i)));
	}
	return v_int;
}

int main(){
	
	while(true){
		
		string str;
		
		getline(cin, str);
		
		if(cin.eof()){
			break;
		}
		
		vector<string> v_str = split(str, ' ');
		vector<int> v_int = str_to_int_vector(v_str);
		
		if(v_int.at(0) == 0){
			return 0;
		}
		
		int ans = 0;
		int count_1 = 0;
		
		for(int i = 0; i < v_int.size(); i++){
			if(v_int.at(i) == 1){
				count_1++;
				ans += v_int.at(i);
			}else if(v_int.at(i) <= 10){
				ans += v_int.at(i);
			}else{
				ans += 10;
			}
		}
		
		if(count_1 > 0){
			if(ans <= 11){
				ans += 10;
				count_1--;
			}
		}
		
		if(ans > 21){
			ans = 0;
		}
		
		cout << ans << endl;
		
	}
	
	return 0;
}

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

#define ll long long

int main()
{
    int n;

    cin >> n;

    int hund = n / 500;

    int five = (n - hund * 500) / 5;

    cout << (ll)(hund * 1000 + five * 5);

    return 0;
}


Measured memory_bytes: 3144
#include<cstdio>
#include<cstring>
#include<algorithm>
#define N 200010
#define ll long long
#define mod 1000000007
using namespace std;

struct edge{int x, y, next;}a[N];
int n, p[N], x, l, flag[N], sum, s[N], cl, d[N], fa[N], ans, def[N], f[N], ff, last, g[N];

inline void add(int x, int y){a[++l].x=x; a[l].y=y; a[l].next=p[x]; p[x]=l;}

inline void dfs(int x, int FA){
	flag[x]=1; sum++;
	for(int i=p[x]; i; i=a[i].next)if(i!=(FA^1)){
		if(flag[a[i].y]){cl=1; d[0]=x; d[1]=a[i].y;}
		else{fa[a[i].y]=x; dfs(a[i].y, i);}
	}
}

inline void dfs1(int x, int fa){
	def[x]=0;
	int sum=0;
	for(int i=p[x]; i; i=a[i].next)if(fa!=a[i].y&&!f[a[i].y]){
		sum++; dfs1(a[i].y, x); def[x]=def[a[i].y]+1;
	}
	if(sum>=2)ff=0;
}

int main(){
	scanf("%d", &n);
	l=1; memset(p, 0, sizeof(p));
	for(int i=1; i<=n; i++){scanf("%d", &x); add(x, i); add(i, x);}
	ans=1; memset(flag, 0, sizeof(flag)); memset(s, 0, sizeof(s)); memset(f, 0, sizeof(f));
	for(int i=1; i<=n; i++)if(!flag[i]){
		sum=0; dfs(i, 0);
		x=d[1]; while(x!=d[0]){x=fa[x]; d[++cl]=x;}
		if(sum==cl){s[sum]++; continue;}
		for(int j=p[d[1]]; j; j=a[j].next)if(a[j].y==d[0])
			if(j&1){for(int k=1; k<=cl/2; k++)swap(d[k], d[cl-k+1]); d[0]=d[cl];}
		for(int j=1; j<=cl; j++)f[d[j]]=1;
		ff=1;
		for(int j=1; j<=cl&&ff; j++)dfs1(d[j], 0);
		if(!ff){printf("0"); return 0;}
		last=cl; while(!def[d[last]])last--;
		for(int j=1; j<=cl; j++)if(def[d[j]]){
			x=(j-last-1+cl)%cl;
			if(def[d[j]]<=x)ans=ans*2%mod;
			if(def[d[j]]>=x+2){printf("0"); return 0;}
			last=j;
		}
	}
	for(int i=1; i<=n; i++)if(s[i]){
		x=1; if((i&1)&&i>=3)x++;
		g[0]=1; g[1]=x;
		for(int j=2; j<=s[i]; j++)g[j]=((ll)x*g[j-1]%mod+(ll)(j-1)*i%mod*g[j-2]%mod)%mod;
		ans=(ll)ans*g[s[i]]%mod;
	}
	printf("%d", ans);
	return 0;
}

Measured memory_bytes: 9856
from collections import deque

N = int(input())

adj = [[] for _ in range(N)]
for i in range(N):
    S = input()
    for j, s in enumerate(S):
        if s == '1':
            adj[i].append(j)

ans = 0
for i in range(N):
    que = deque()
    que.append(i)
    seen = [0] * N
    seen[i] = 1
    while que:
        v = que.pop()
        for u in adj[v]:
            if seen[u] == 0:
                que.appendleft(u)
                seen[u] = -seen[v] - 1 if seen[v] > 0 else -seen[v] + 1
            else:
                if seen[v] * seen[u] > 0:
                    print(-1)
                    exit()
    ans_i = max(max(seen), -min(seen))
    ans = max(ans, ans_i)
print(ans)


Measured memory_bytes: 42352
bingo = Array.new(3) { Array.new(3) }
ans = Array.new(3) { Array.new(3) }

(0..bingo.length - 1).each do |y|
  n0, n1, n2 = gets.split(" ").map!{|i| i.to_i}
  (0..bingo.length - 1).each do |x|
    case x
    when 0
      bingo[y][0] = n0
    when 1
      bingo[y][1] = n1
    when 2
      bingo[y][2] = n2
    end
  end
end

N = gets.to_i

(1..N).each do |cknum|
  cknum = gets.to_i
  (0..bingo.length - 1).each do |y|
    (0..bingo.length - 1).each do |x|
      if bingo[y][x] == cknum
        ans[y][x] = "OK"
      end
    end
  end
end

if (ans[0][0] == "OK" && ans[0][1] == "OK" && ans[0][2] == "OK") ||
   (ans[1][0] == "OK" && ans[1][1] == "OK" && ans[1][2] == "OK") ||
   (ans[2][0] == "OK" && ans[2][1] == "OK" && ans[2][2] == "OK") ||
   (ans[0][0] == "OK" && ans[1][0] == "OK" && ans[2][0] == "OK") ||
   (ans[0][1] == "OK" && ans[1][1] == "OK" && ans[2][1] == "OK") ||
   (ans[0][2] == "OK" && ans[1][2] == "OK" && ans[2][2] == "OK") ||
   (ans[0][0] == "OK" && ans[1][1] == "OK" && ans[2][2] == "OK") ||
   (ans[0][2] == "OK" && ans[1][1] == "OK" && ans[2][0] == "OK")
  puts "Yes"
else
  puts "No"
end


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



int main(){
  int n, s= 0;
  cin >> n;
  vector<int>l(n);
  for(int i=0;i<n;i++)cin >> l[i];
  sort(l.begin(),l.end());
  for(int i=0;i<n;i++){
    int k=i;
    for(int j=i+1;j<n;j++){
      while(k<n && l[k]<l[i]+l[j]) k++;
      s += max(0,k-(j+1));
    }
  }
  cout<<s<<endl;
  
}

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

int main() {
  int A,B;
  cin >>A>>B;
 if(A >= 13){
   cout << B << endl;
 }
  else if (A >= 6 && A <= 12){
    cout << B/2 << endl;
  }
else {
cout << 0 << endl;
}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long t,j,p,r,i,n;
    cin>>n;
    if(n<=9)
    cout<<n;
    else if(n>=10&&n<100)
    cout<<9<<endl;
    else if(n>=100&&n<1000)
    cout<<n-100+10;
    else if(n>=1000&&n<10000)
    cout<<909;
    else if(n>=10000&&n<100000)
    cout<<n-10000+910;
    else if(n==100000)
    cout<<90909;
    return 0;
}


Measured memory_bytes: 256
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>
#include <cstring>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
#include <stack>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
#define P pair<ll, ll>

/* ---------- Constants  */
const double PI = 3.141592653589793238462643383279;
const ll MOD = 1e9 + 7;
const int INF = 1LL << 55;

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define m1(x) memset(x,-1,sizeof(x))
const ll INF = 1e18 + 1;
const ll MOD = 1e9 + 7;
const double PI = 3.141592653589793;

int main(){
  string s;
  cin >> s;
  ll dp[110000][13];
  for(int i = 0; i < 110000; i++){
    fill(dp[i], dp[i] + 13, 0);
  }
  if(s.at(0) == '?') fill(dp[0], dp[0] + 10, 1);
  else dp[0][s.at(0) - '0'] = 1;
  
  for(ll i = 1; i < s.size(); i++){
    if(s.at(i) != '?'){
      ll k = s.at(i) - '0';
      for(ll j = 0; j < 13; j++){
        dp[i][(10*j + k)%13] = dp[i-1][j];
      }
    }else{
      for(ll j = 0; j < 13; j++){
        for(ll k = 0; k <= 9; k++){
          dp[i][(10*j+k)%13] += dp[i-1][j];
          dp[i][(10*j+k)%13] %= MOD;
        }
      }
    }
  }
  cout <<dp[s.size() - 1][5] % MOD<<endl;
}

Measured memory_bytes: 14908
#include <iostream>
#include <iomanip>
#include <cstring>
#include <algorithm> 
#include <math.h>
#include <queue>
#include <functional>
#include <map>
#include <vector>
#include <string>
using namespace std;
typedef long long ll;


int main(void){
    string s;
    cin >> s;

    if (s == "AKIHABARA" || s == "AKIHABAR" || s == "AKIHABRA" || s == "AKIHABR" || s == "AKIHBARA" || s == "AKIHBAR" || s == "AKIHBRA" || s == "AKIHBR" ||
        s == "AKIHABARA" || s == "KIHABAR" || s == "KIHABR" || s == "KIHABR" || s == "KIHBARA" || s == "KIHBAR" || s == "KIHBRA" || s == "KIHBR")
    {
        cout << "YES" << endl;
        return 0;
    }

    cout << "NO" << endl;
    
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define ll long long
using namespace std;
template<typename tn> void read(tn &a){
	tn x=0,f=1; char c=' ';
	for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
	for(;isdigit(c);c=getchar()) x=x*10+c-'0';
	a=x*f;
}
int n,a[101000];
int f[110000];
vector<int> e[101000];
void dfs(int x,int dad){
	if(e[x].size()==1){f[x]=a[x];return;}
	ll s=0;int mx=0;
	for(int v:e[x]) if(v!=dad){
		dfs(v,x);
		mx=max(mx,f[v]);
		s+=f[v];
	}
	if(s<a[x]||s>2ll*a[x]){puts("NO");exit(0);}
	f[x]=2*a[x]-s;
	if(2*mx-s>f[x]){puts("NO");exit(0);}
}
int main(){
	read(n);
	for(int i=1;i<=n;i++) read(a[i]);
	if(n==2){puts(a[1]==a[2]?"YES":"NO");return 0;}
	for(int i=1;i<n;i++){
		int x,y;read(x);read(y);
		e[x].push_back(y);
		e[y].push_back(x);
	}
	for(int i=1;i<=n;i++)
		if(e[i].size()>1){
			dfs(i,0);
			if(!f[i])puts("YES");
			else puts("NO");
			return 0;
		}
	return 0;
}


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

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

using namespace std;
typedef long long int ll;
const int INF = 1000000000;
const double PI = 3.1415926535;

int n, m, q;
int a[50], b[50], c[50], d[50];
int ans = 0;

void dfs(vector<int> A) {
	if (A.size() == n + 1) {
		int score = 0;
		rep(i, q) {
			if (A[b[i]] - A[a[i]] == c[i]) score += d[i];
		}
		ans = max(ans, score);
		return;
	}
	A.push_back(A.back());
	while (A.back() <= m) {
		dfs(A);
		A.back() += 1;
	}
}

int main()
{
	cin >> n >> m >> q;
	rep(i, q) {
		cin >> a[i] >> b[i] >> c[i] >> d[i];
	}
	dfs(vector<int>(1, 1));
	cout << ans << endl;
}

Measured memory_bytes: 3592
using System;
using System.Collections.Generic;
using System.Linq;

namespace CSharpSample01
{
    
    class Program
    {
        
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            long N = long.Parse(input[0]);
            long M = long.Parse(input[1]);

            long max_D = M / N;

            long ans = 1;

            List<long> fact_list = new List<long>();

            for(long i = 1; i <= Math.Sqrt(M) + 1; i++)
            {
                if(M % i == 0)
                {
                    fact_list.Add(i);
                    fact_list.Add(M / i);
                }
            }

            fact_list.Sort();
            fact_list.Reverse();

            
            foreach(var s in fact_list)
            {
                if(s <= max_D)
                {
                    ans = s;
                    break;
                }
            }
                        
            Console.WriteLine(ans);

        }
    }
}


Measured memory_bytes: 13268
//競技プログラミング　テンプレ
//
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

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

const int max_v = 300;
const int INF = 1000000;



int main() {
	 long long int n, ans=0;
     int i=0,n1;
	cin >> n;
     n1 = n;
	vector <long long  int> a(10);

    while(1){
        a[i] = n - (n /10)*10;
        i++;
        n = n/10;
        if(n==0){break;}
    }

    for (int k; k<=i; k++) {ans +=a[k];}
    if(n1 % ans ==0) cout << "Yes" << endl;
    else cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 256
import Data.List
import Data.Ord
import Data.Char
import Data.Ratio
import Data.Maybe

main = do
  [a,b,k] <- map (read::String->Int) . words <$> getLine
  print $ (cdList a b)!!(k-1)

cdList a b = [x|let c = min a b, x<-[c,c-1..1], mod a x　==　0 && mod b x　==　0]

Measured memory_bytes: 3924
#pragma GCC optimize("O3")
#pragma GCC target("sse4")

#include <bits/stdc++.h>

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <typeinfo>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ld, ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

template <class T>
using Tree =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i = a; i < (b); i++)
#define F0R(i, a) for (int i = 0; i < (a); i++)
#define FORd(i, a, b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i, a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001;  // check the limits, dummy

typedef long long ll;
const int inf = INT_MAX / 2;
const ll infl = 1LL << 60;
template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}

template <class T>
void print(const vector<T> v) {
  cout << "[ ";
  F0R(i, v.size()) { cout << v[i] << ' '; }
  cout << "]" << '\n';
}

int mod(int i, int j) {
  return (i % j) < 0 ? (i % j) + 0 + (j < 0 ? -j : j) : (i % j + 0);
}

// --------------------------------------------------------
// This is tool
// --------------------------------------------------------
void Main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int n, k;
  vi A(150, 0);
  cin >> n >> k;
  // cout << n << k << endl;
  FOR(i, 0, k) {
    int d;
    cin >> d;
    // cout << d << endl;

    FOR(j, 0, d) {
      int x;
      cin >> x;
      A[x - 1] = 1;
      // cout << A[x - 1] << endl;
      // cout << x - 1 << endl;
    }
  }
  int ans = 0;
  FOR(i, 0, n) {
    if (A[i] == 0) {
      ans++;
    }
  }
  cout << ans << endl;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
}

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

#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>


using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef queue<int> qi;

int main()
{
    int n ,m;
    cin >> n>>m;

    vvi adjLst(n);
    vi hi(n) , dp(n);

    int x ,y;

    for(int i=0; i<m; i++)
    {
        cin >> x >> y;
        adjLst[x-1].push_back(y-1);
        ++hi[y-1];
    }

    qi que;

    for(int i=0; i<n; i++)
    {
        // cout << hi[i]<< " ";

        if(hi[i]==0) que.push(i);

    }

    cout << endl;
    while(!que.empty())
    {
        int node = que.front();
        // cout <<node << endl;

        que.pop();


        for(int& parent : adjLst[node])
        {   
            // cout << parent<< endl;
            if(--hi[parent]==0){
                // cout << parent << " "<<hi[parent]<< endl;
                dp[parent] = dp[node] + 1;
                que.push(parent);
            }
        }
    }

    int mxlength = 0;

    for(int& i : dp)
    {
        mxlength = max(mxlength , i);
        // cout << mxlength<<" ";
    }
    cout << mxlength<< endl;


    return 0;
}

Measured memory_bytes: 6528