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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    int K;
    cin >> S >> K;
    for (int i = 0; i < S.length(); i++) {
        if (K == 0) break;
        if ((26 - int(S[i] - 'a')) % 26 > K) continue;
        K -= (26 - int(S[i] - 'a')) % 26;
        S[i] = 'a';
    }
    if (K > 0) {
        S[S.length() - 1] = char((S[S.length() - 1] - 'a' + K) % 26 + 'a');
    }
    cout << S << endl;
    return 0;
}

Measured memory_bytes: 592
using namespace std;
#include<bits/stdc++.h>
#define BEGIN ios_base::sync_with_stdio(0);cin.tie(0);
#define END return EXIT_SUCCESS;
#define FOR(I,A,B) for((I)=(A);(I)<(B);(I)++)
#define REP(I,N) FOR((I),0,(N))
#define UP(I,A,B) for((I)=(A);(I)<=(B);(I)++)
#define DW(I,A,B) for((I)=(A);(I)>=(B);(I)--)
#define IN(P) cin>>(P)
#define IN2(P1,P2) cin>>(P1)>>(P2)
#define IN3(P1,P2,P3) cin>>(P1)>>(P2)>>(P3)
#define INS(I,N,V) REP((I),(N)) cin>>(V[I])
#define INS2(I,N,V1,V2) REP((I),(N)) cin>>(V1[I])>>(V2[I]);
#define INS3(I,N,V1,V2,V3) REP((I),(N)) cin>>(V1[I])>>(V2[I])>>(V3[I]);
#define OUT(P) cout<<(P)<<endl
#define OUT2(P1,P2) cout<<(P1)<<" "<<(P2)<<endl
#define OUT3(P1,P2,P3) cout<<(P1)<<" "<<(P2)<<" "<<(P3)<<endl
#define OUTS(I,N,V) REP((I),(N)) cout<<(V[i])<<endl
#define ALL(C) (C).begin(),(C).end()
#define RALL(C) (C).rbegin(),(C).rend()
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
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;}

int a,b;
inline void solve(){
  IN2(a,b);
  // OUT((a-1)+(a<=b));
  OUT(a<=b?a:a-1);
}

int main(int argc,char**argv){
  BEGIN
  solve();
  END
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll> 
#define P pair<ll,ll>
#define rep(i,n) for(ll (i)=0; (i)<(n); ++(i))
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s,ans;cin>>s;
  rep(i,s.length()) ans+='x';
  print(ans);
  return 0;
}

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

const long long MOD = 1000000007;

int main(){
	int n,m;
	cin >> n >> m;
	vector<int> a(n+1,1);
	int s;

	for (int i=0; i<m; i++){
		cin >> s;
		a[s] = 0;
	}

	vector<long long> dp(n+10,0);
	dp[0] = 1;
	for (int i=0; i<n; i++){
		if (a[i+1]){
			dp[i+1] += dp[i];
			dp[i+1] %= MOD;
		}
		if (a[i+2]){
			dp[i+2] += dp[i];
			dp[i+2] %= MOD;
		}
	}

	cout << dp[n] << endl;

	return 0;
}

Measured memory_bytes: 4188
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

int a[110];

int main() {
    int n, m, sum = 0;
    scanf("%d%d", &n, &m);
    for(int i = 1; i <= n; i++) {
        scanf("%d", &a[i]);
        sum += a[i];
    }
    int x = sum / (4 * m), cnt = 0;
    for(int i = 1; i <= n; i++) {
        if(a[i] > x) cnt++;
        if(a[i] == x) {
            if(a[i] * 4 * m == sum) cnt++;
        }
    }
    if(cnt >= m) printf("Yes\n");
    else printf("No\n");

    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
const int N = 1e6+10;
typedef long long ll;
//注意有些int类型要改成long long类型 
vector<int> ve[N]; 
int main(){
//	freopen("input.txt","r",stdin); 
	int n,m;
	cin>>n>>m;
	int a,b;
//	vector<int> ve[N]; 
	priority_queue<int> q;
	ll earn=0;
	for(int i=0;i<n;i++)
	{
		scanf("%d%d",&a,&b);
		if(a>m) continue;
		ve[m-a+1].push_back(b);
	}
	for(int i=m;i>=1;i--)
	{
		for(int v:ve[i]) q.push(v);
		if(!q.empty())
		{
			earn+=q.top();
			q.pop();			
		}
	}
	cout<<earn<<endl;
	return 0;
}








Measured memory_bytes: 26752
class WeightedUnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n + 1)]
        self.rank = [0] * (n + 1)
        # 根への距離を管理
        self.weight = [0] * (n + 1)

    # 検索
    def find(self, x):  # xの親を返す
        if self.par[x] == x:
            return x
        else:
            y = self.find(self.par[x])
            # 親への重みを追加しながら根まで走査
            self.weight[x] += self.weight[self.par[x]]
            # 親の値を更新(アルゴリズムの高速化)
            self.par[x] = y
            return y #親

    # 併合
    # (xからyへの重みがw) = (y - x = W)
    def union(self, x, y, w):
        rx = self.find(x)
        ry = self.find(y)
        # 既に同集合の場合
        if rx == ry:
            if self.diff(x, y) != w:
                print("No")
                exit()
        # 木の高さで処理を変えるのは高速化(木を低くする)のため
        # xの木の高さ < yの木の高さ
        if self.rank[rx] < self.rank[ry]:
            self.par[rx] = ry
            self.weight[rx] = w - self.weight[x] + self.weight[y]
        # xの木の高さ ≧ yの木の高さ
        else:
            self.par[ry] = rx
            self.weight[ry] = -w - self.weight[y] + self.weight[x]
            # 木の高さが同じだった場合の処理
            if self.rank[rx] == self.rank[ry]:
                self.rank[rx] += 1

    # 同じ集合に属するか
    def same(self, x, y):
        return self.find(x) == self.find(y)

    # xからyへのコスト
    def diff(self, x, y):
        return self.weight[x] - self.weight[y]


n, m = [int(i) for i in input().split()]
l = [0 for i in range(m)]
r = [0 for i in range(m)]
d = [0 for i in range(m)]

union = WeightedUnionFind(n)
for i in range(m):
    l[i], r[i], d[i] = [int(i) for i in input().split()]
    union.union(l[i], r[i], d[i])
print("Yes")
#for i in range(1, n+1):
    #print("{} par:{} w:{}".format(i, union.par[i], union.weight[i]))


Measured memory_bytes: 29808
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 1000000007
#define MAX 100000
void inarray(int a[], int n){
    for(int i = 0; i < n; i++) cin >> a[i];
}

int main(){
    int n,k; cin >> n >> k;
    ll s[n+1];
    s[0] = 0;
    for(int i = 1; i <= n; i++){
        s[i] = s[i-1] + i;
    }

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

Measured memory_bytes: 5088
/******************************************************************************

Welcome to GDB Online.
GDB online is an online compiler and debugger tool for C, C++, Python, PHP, Ruby, 
C#, VB, Perl, Swift, Prolog, Javascript, Pascal, HTML, CSS, JS
Code, Compile, Run and Debug online from anywhere in world.

*******************************************************************************/
#include <iostream>
using namespace std;

int main()
{
    int n,m,i,s1=1,s2=1,p;
    cin>>n>>m;
    if(n==1 && m==1)
    {
    cout<< 0;
    return 0;
    }
    if(n>2)
    {   p=n-2;
       for(i=p+1;i<=n;i++)
       s1=s1*i;
       s1=s1/2;
    }
      if(m>1)
    {   p=m-2; 
       for(i=p+1;i<=m;i++)
       s2=s2*i;
       s2=s2/2;
    }
    
    if(n<2)
    s1=0;
       if(m<2)
    s2=0;
   cout<<s1+s2;
    
   
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
int main(){
    string s1,s2; cin>>s1>>s2;
    ll n1=s1.size(), n2=s2.size();
    vector<vector<ll>> dp(n1+1, vector<ll>(n2+1, 0));
    rep(i,n1+1) dp[i][0]=i;
    rep(i,n2+1) dp[0][i]=i;
    for(ll i=1; i<=n1; i++){
        for(ll j=1; j<=n2; j++){
            ll cost=1;
            if(s1[i-1]==s2[j-1]) cost=0;
            dp[i][j]=min(dp[i-1][j-1]+cost, min(dp[i-1][j]+1, dp[i][j-1]+1));
        }
    }
    cout<<dp[n1][n2]<<endl;
    return 0;
}


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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

int N;
std::string S;

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

  std::cin >> N >> S;

  int res = 0;

  for(int i=0,j=0;i<N;i=j){
      while(j < N && S[j] == S[i]){
          j += 1;
      }

      res += 1;
  }

  std::cout << res << std::endl;
}


Measured memory_bytes: 512
//g++  7.4.0

#include <bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
    ll n, d, x, y;
    cin>>n>>d;
    int cnt = 0;
    for(int i=0; i<n; i++)
    {
        cin>>x>>y;
        if(d*d>=(x*x + y*y))
            cnt++;
    }
    cout<<cnt<<"\n";
    return 0;
}

Measured memory_bytes: 3624
A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
z = [list(map(int, input().split())) for i in range(M)]

price = min(a) + min(b)

for e in z:
    tmp_price = a[e[0]-1] + b[e[1]-1] - e[2]

    if(price > tmp_price):
        price = tmp_price

print(price)


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

int main(){
    
    long long n, l; cin >> n >> l;
    vector<long long> a(n);
    for(int i = 0; i < (int)n; i++){
        cin >> a[i];
    }


    bool flag = false;
    int idx;
    for(int i = 1; i < (int)n; i++){
        if(a[i] + a[i - 1] >= l){
            idx = i;
            flag = true;
            break;
        }
    }

    if(!flag) puts("Impossible");
    else{
        puts("Possible");

        for(int i = 1; i < idx; i++){
            cout << i << endl;
        }

        for(int i = (int)n - 1; i >= idx; i--){
            cout << i << endl;
        }

    }
    return 0;
}

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

int main() {

  string S;
  cin >> S;

  if(S.length() % 2 == 0){
    cout << "No" << endl;
    return 0;
  }
  string mae = S.substr(0, S.length() / 2);
  string ushiro = S.substr((S.length() + 1) / 2, S.length() / 2);

  string rS = S;
  reverse(rS.begin(), rS.end());

  string rmae = mae;
  reverse(rmae.begin(), rmae.end());

  string rushiro = ushiro;
  reverse(rushiro.begin(), rushiro.end());

  if(rS == S && rmae == mae && rushiro == ushiro){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }

}

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

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

  long long X, Y;
  cin >> X >> Y;

  long long ans=0;
  while(X <= Y){
    X *= 2;
    ans++;
  }
  cout << ans << endl;

  return 0;
}


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

int main(){
  int k,x;
  cin >> k >> x;
  long long pos = x-k+1;
  if(pos < -1000000) pos = -1000000;
  
  for(int i=0; i<k*2-1; i++){
    cout << pos << ' ';
    pos++;
  }
  cout << endl;
}

Measured memory_bytes: 256
H, W = 5, 4
D = [
  [-1,-1], [0,-1], [1,-1],
  [-1,0],          [1,0],
  [-1,1],  [0,1],  [1,1],
]
Y, X = 0, 1
def dfs(card)
  return @memo[card] if @memo[card]
  result = card.flatten.size
  card.size.times do |i|
    card[i].size.times do |j|
      D.each do |d|
        y = i+d[Y]
        x = j+d[X]
        next if y<0 || card.size<=y
        next if x<0 || card[i].size<=x
        next if card[i][j] != card[y][x]
        c = card.map(&:dup)
        c[i][j] = c[y][x] = -1
        c[i].delete(-1)
        c[y].delete(-1)
        rearrange(c)
        result = [result, dfs(c)].min
      end
    end
  end
  @memo[card] = result
end

def rearrange(card)
  (card.size-1).times do |i|
    case card[i].size
      when W-1
        card[i].push(card[i+1].shift)
      when W-2
        card[i].push(*card[i+1].shift(2))
    end
  end
  card.delete([])
end

gets.to_i.times do
  c = Array.new
  H.times do
    c.push(gets.split.map(&:to_i))
  end
  @memo = Hash.new
  p dfs(c)
end

Measured memory_bytes: 6144
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<iostream>
#include <iomanip>
#include<queue>
#include<algorithm>
#include <functional>
#include<vector>
#include <math.h>
#include <numeric>
using namespace std;

const int N_MAX = 100001;
int N, Q;
string S;
int d[N_MAX] = {};
int l[N_MAX], r[N_MAX];

int main() {
	cin >> N >> Q;
	cin >> S;
	for (int i = 0; i < Q; i++) cin >> l[i] >> r[i];
	for (int i = 1; i < N; i++) {
		if (S[i-1] == 'A'&&S[i] == 'C') d[i] = d[i-1]+1;
		else d[i] = d[i - 1];
	}
	for (int i = 0; i < Q; i++) {
		l[i] -= 1;
		r[i] -= 1;
		cout << d[r[i]]-d[l[i]] << endl;
	}
}

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

int main(){
  string S;
  
  cin >> S;
  
  if (S[0] == S[1] || S[1] == S[2] || S[2] == S[3]) {
    cout << "Bad" << endl;
  }
  
  else {
    cout << "Good" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int N,A,B;
  scanf("%d %d",&N,&A);
  
  A=0;
  while(N>=500){
  N=N-500;
  A=A+1000;
  }
  while(N>=5){
  N=N-5;
  A=A+5;
  }
  printf("%d\n",A);
  return 0;
}

Measured memory_bytes: 1708
#include "bits/stdc++.h"
using namespace std;
int main() {
	int N, K;
	cin >> N >> K;
	vector<int>A(N);
	int ans = 0;
	for (int i = 0; i < N; i++) {
		cin >> A.at(i);
		ans += min(A.at(i), abs(K - A.at(i))) * 2;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
n = int(input())
s = tuple(map(int, input()))
f = [
    [] for i in range(10)
]
ans = 0

for i in range(n-2):
    if len(f[s[i]]) != 0:
        continue
    else:
        for j in range(i+1, n-1):
            if s[j] in f[s[i]]:
                continue
            else:
                f[s[i]].append(s[j])
                a = tuple(set(s[j+1:]))
                ans += len(a)

print(ans)




Measured memory_bytes: 3644
#include <bits/stdc++.h>
#include <cassert>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using Graph = vector<vector<int>>;

const long long MOD = 1000000007;
const long long INF = 1LL << 60;
const int INT_INF = 1000000000;

// int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int dx[8] = {-1, -1, -1, 0, 0, 1, 1, 1}, dy[8] = {-1, 0, 1, 1, -1, 1, 0, -1};

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N;
  cin >> N;
  if (N == 1)
    cout << "Hello World" << endl;
  else
  {
    int A, B;
    cin >> A >> B;
    cout << A + B << endl;
  }
  return 0;
}


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;
typedef pair<int,int> P;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
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 main(){
    int N,Y; cin >> N >> Y;
    for (int i=0; i<=Y/10000; i++){
        for (int j=0; j<=Y/5000; j++){
            if ( (Y-(10000*i+5000*j))/1000==(N-i-j) && (N-i-j)>=0 ){
                cout << i << " " << j << " " << (Y-(10000*i+5000*j))/1000 << endl; 
                return 0;
            }
        }
    }
    cout << -1 << " " << -1 << " " << -1 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
	char data[2][3];
	scanf("%s", data[0]);
	scanf("%s", data[1]);
	if(data[0][0] == data[1][2] && data[0][1] == data[1][1] && data [0][2] == data[1][0])
		printf("YES\n");
	else
		printf("NO\n");
	
}


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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end())
#define vdelete(v) (v).erase(unique(all(v)), (v).end())
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1000000007
#define INF LONG_LONG_MAX

int n;
bool f = false;

signed main() {
    cin >> n;
    rep1(i,9) rep1(j,9) if (i*j == n) f = true;
    if (f) cout << "Yes" << endl;
    else cout << "No" << endl;
}





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

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifndef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
	*this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

int main() {
	long long x, k, d;
	cin >> x >> k >> d;
	x = abs(x);
	long long div = ceil(x * 1.0 / d);
	if (div >= k) {
		cout << abs(x - (k * d)) << "\n";
		return 0;
	}
	x -= (d * div);
	k -= div;
	debug() << imie(div) imie(x) imie(k);
	if (k & 1ll) {
		cout << abs(x + d) << "\n";
	}
	else {
		cout << abs(x) << "\n";
	}
}



Measured memory_bytes: 3788
// tested by Hightail: https://github.com/dj3500/hightail
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <cmath>
#include <algorithm>
#include <sstream>
#include <stack>
#include <cstring>
#include <iomanip>
#include <ctime>
#include <cassert>
using namespace std;
#define pb push_back
#define INF 1001001001
#define FOR(i,n) for(int (i)=0;(i)<(n);++(i))
#define FORI(i,n) for(int (i)=1;(i)<=(n);++(i))
#define mp make_pair
#define pii pair<int,int>
#define ll long long
#define vi vector<int>
#define SZ(x) ((int)((x).size()))
#define fi first
#define se second
#define wez(n) int (n); scanf("%d",&(n));
#define wez2(n,m) int (n),(m); scanf("%d %d",&(n),&(m));
#define wez3(n,m,k) int (n),(m),(k); scanf("%d %d %d",&(n),&(m),&(k));
inline void pisz(int n) { printf("%d\n",n); }
template<typename T,typename TT> ostream& operator<<(ostream &s,pair<T,TT> t) {return s<<"("<<t.first<<","<<t.second<<")";}
template<typename T> ostream& operator<<(ostream &s,vector<T> t){FOR(i,SZ(t))s<<t[i]<<" ";return s; }
#define DBG(vari) cout<<"["<<__LINE__<<"] "<<#vari<<" = "<<(vari)<<endl;
#define ALL(t) t.begin(),t.end()
#define FOREACH(i,t) for (__typeof(t.begin()) i=t.begin(); i!=t.end(); i++)
#define TESTS wez(testow)while(testow--)
#define REP(i,a,b) for(int (i)=(a);(i)<=(b);++i)
#define REPD(i,a,b) for(int (i)=(a); (i)>=(b);--i)
#define REMAX(a,b) (a)=max((a),(b));
#define REMIN(a,b) (a)=min((a),(b));
#define IOS ios_base::sync_with_stdio(0);

int main () {
   ll n, x;
   cin >> n >> x;
   ll g = __gcd(n,x);
   n /= g;
   x /= g;
   cout << (3 * g * (n-1));
}

Measured memory_bytes: 256
n = gets.chomp.to_i
s = []
n.times do
  s.push(gets.chomp.split(''))
end

ans = []
ss = s.shift
ss.each do |e|
  if s.all?{|arr| arr.include?(e)}
    ans.push(e)
    (n-1).times do |i|
      s[i].delete_at(s[i].find_index(e))
    end
  end
end
puts ans.sort.join('')


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

#define BR "\n"
#define SP " "
#define SHOW(x) for(int i = 0; i < x.size(); i++) { cout << x[i] << SP; } cout << BR;
#define SHOW2(x) for(int j = 0; j < x.size(); j++) { SHOW(x[j]); } cout << BR;

ll MOD = 1e9 + 7;

ll p(ll x, ll m) {
  if (m == 0) return 1;
  if (m == 1) return x;

  ll temp = p(x, m / 2) % MOD;
  ll temp2 = (temp * temp) % MOD;
  if (m % 2) {
    return (temp2 * x) % MOD;
  } else {
    return temp2;
  }
}

ll inv(ll x) { return p(x, MOD - 2); }

int main() {
  ll N, M;
  cin >> N >> M;

  ll temp = M;
  ll index = 0;
  vector<ll> factors(1000, 0);

  for (int i = 2; i <= sqrt(M); i++) {
    if (temp % i == 0) {
      while (temp % i == 0) {
        factors[index]++;
        temp /= i;
      }
      index++;
    }
  }
  if (temp > 1) {
    factors[index]++;
    index++;
  }
  // SHOW(primes);
  // SHOW(factors);

  vector<ll> modr(35, 0);
  modr[0] = 1;
  modr[1] = 1;
  for (int r = 2; r < 32; r++) {
    modr[r] = inv(r);
  }

  ll ans = 1;
  for (int i = 0; i < index; i++) {
    ll temp = 1;
    for (int r = 1; r <= factors[i]; r++) {
      temp = (temp * (N + r - 1)) % MOD;
      temp = (temp * modr[r]) % MOD;
    }
    ans = (ans * temp) % MOD;
  }
  cout << ans << BR;

  return 0;
}

Measured memory_bytes: 256
import java.util.HashMap;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		String[] s = new String[n];

		for (int i = 0; i < n; i++) {
			s[i] = sc.next();
		}

		HashMap<String, Integer> map = new HashMap<String, Integer>();
		map.put(s[0], 1);
		int ans = 1;

		for (int i = 1; i < n; i++) {
			if (!map.containsKey(s[i])) {
				ans++;
				map.put(s[i], 1);
			}
		}

		System.out.println(ans);
	}

}


Measured memory_bytes: 69892
#include <iostream>
#include <map>

using namespace std;

#define N 21

int main(int argc, char const *argv[])
{
	int f[N][N];
	int n,xj,yj;
	int m,d;
	char c;

	int xr,yr;
	int cnt;

	map <char,pair<int,int> > mp;
	mp['N']=make_pair(0,1);
	mp['E']=make_pair(1,0);
	mp['S']=make_pair(0,-1);
	mp['W']=make_pair(-1,0);

	while(1){
		cin>>n;
		if (n==0) break;

		for(int i1=0;i1<N;i1++){
			for(int i2=0;i2<N;i2++){
				f[i1][i2]=0;
			}
		}
		xr=10;
		yr=10;
		cnt=0;

		for(int i1=0;i1<n;i1++){
			cin>>xj>>yj;
			f[yj][xj]=1;
		}
		
		if(f[yr][xr]==1){
			cnt++;
			f[yr][xr]=0;
		}


		cin>>m;
		for(int i1=0;i1<m;i1++){
			cin>>c>>d;
			
			for(int i2=0;i2<d;i2++){
				xr=mp[c].first+xr;
				yr=mp[c].second+yr;
				if(f[yr][xr]==1) {
					cnt++;
					f[yr][xr]=0;
				}
				
			}

		}

		if(cnt==n) cout<<"Yes"<<endl;
		else cout<<"No"<<endl;

	}
	return 0;
}

Measured memory_bytes: 1188
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cassert>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <complex>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <iterator>

using namespace std;

#define dump(n) cout<<"# "<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define iter(c) __typeof__((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();++i)
#define all(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;
typedef pair<int,int> pii;

const int INFTY=INT_MAX;
const double EPS=1e-9;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& a){
	os<<'[';
	rep(i,a.size()) os<<(i?" ":"")<<a[i];
	return os<<']';
}

struct SegTree{
	int size;
	vi data;
	SegTree(int s):size(Need(s)),data(size*2,INFTY){}
	void Update(int i,int x){
		for(i+=size;i;i>>=1)
			data[i]=min(data[i],x);
	}
	int Query(int a,int b,int i,int l,int r){
		if(b<=l || r<=a) return INFTY;
		if(a<=l && r<=b) return data[i];
		int res=INFTY,m=(l+r)/2;
		if(a<m) res=min(res,Query(a,b,i*2+0,l,m));
		if(m<b) res=min(res,Query(a,b,i*2+1,m,r));
		return res;
	}
	int Query(int a,int b){
		return Query(a,b,1,0,size);
	}
	int Need(int size){
		size--;
		rep(i,5) size|=size>>(1<<i);
		return size+1;
	}
};

int main()
{
	for(int r,c,q;scanf("%d%d%d",&r,&c,&q),r|c|q;){
		vvi grid;
		if(r<=c){
			grid.assign(r,vi(c));
			rep(i,r) rep(j,c) scanf("%d",&grid[i][j]);
		}
		else{
			grid.assign(c,vi(r));
			rep(i,r) rep(j,c) scanf("%d",&grid[j][i]);
		}
		
		vector<SegTree> sts;
		if(r<=c){
			sts.assign(r,SegTree(c));
			rep(i,r) rep(j,c) sts[i].Update(j,grid[i][j]);
		}
		else{
			sts.assign(c,SegTree(r));
			rep(i,c) rep(j,r) sts[i].Update(j,grid[i][j]);
		}
		
		while(q--){
			int r1,c1,r2,c2; scanf("%d%d%d%d",&r1,&c1,&r2,&c2);
			int res=INFTY;
			if(r<=c)
				repi(i,r1,r2+1) res=min(res,sts[i].Query(c1,c2+1));
			else
				repi(i,c1,c2+1) res=min(res,sts[i].Query(r1,r2+1));
			printf("%d\n",res);
		}
	}
	
	return 0;
}

Measured memory_bytes: 21280
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std ;
#define int long long
#define fi first
#define se second
#define pb push_back
#define pii pair<int, int>
#define mod 1000000007

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

int n,m ;
int arr[500005] ;
string str ;

void solve()
{
    cin >> n >> m ;
    int sum = 0 ;
    for(int i=1 ; i<=m ; i++)
    {
        cin >> arr[i] ;
        sum += arr[i] ;
    }
    if(sum > n)
    {
        cout << -1 ;
    }
    else
    {
        cout << n-sum << "\n" ;
    }
}
int32_t main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	int tt = 1;
	//cin >> tt ;
	while(tt--)
	{
	     solve() ;
	}
}


Measured memory_bytes: 3700
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<iomanip>

using namespace std;

int main() {

	double t, x; cin >> t >> x;
	double ans;
	ans = t / x;
	cout << setprecision(20) << ans << endl;

	system("pause");
	return 0;

}

Measured memory_bytes: 504
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define ALLR(v) v.rbegin(),v.rend()
typedef long long ll;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//isPrime
//modpow modinv
//getDigit
int main() {
  cout << fixed << setprecision(10);
  int n;
  cin >> n;
  int ans = 1;
  for(int i =1; i*i<=n; i++){
    ans = max(ans,i*i);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
s=gets.chomp
gets
rev=false
pre=""
post=""
$<.each{|l|
  t,f,c=l.split
  if t==?1
    rev=!rev
    pre,post=post,pre
  else
    if f==?1
      pre<<c
    else
      post<<c
    end
  end
}
puts pre.reverse+(rev ? s.reverse : s )+post

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

int NN[100002];

const int MOD = 1000000007;

long long int kaizyodp[100002];

int n_1comdp[100002];
int lcomdp[100002];


long long int kaizyo(long long int n) {  // n!
	if (kaizyodp[n] != -1) return kaizyodp[n];
	else if (n == 1 || n == 0) return (long long int)1;
	else return kaizyodp[n] = (long long int)((n * kaizyo(n - 1)) % MOD);
}

long long int ruizyo(long long int n, long long int m) {  // n^m
	if (m == 1) return (long long int)n % MOD;
	else if (m % 2 == 0) {
		return (long long int)(ruizyo(((n * n) % MOD), m / 2) % MOD);
	}
	else {
		return (long long int)((n * ruizyo(n, m - 1)) % MOD);
	}
}


int combination(long long int n, long long int m) {
	if (n < m || m < 0) return 0;
	return (((kaizyo(n) * ruizyo(kaizyo(m), MOD - 2)) % MOD) * ruizyo(kaizyo(n - m), MOD - 2)) % MOD;
}


int main()
{
	long long int n = 0;
	cin >> n;
	vector<int> a(n + 2);
	a[0] = -1;
	for (int i = 1; i <= n + 1; i++) {
		cin >> a[i];
	}

	memset(NN, 0, sizeof(NN));
	memset(kaizyodp, -1, sizeof(kaizyodp));
	memset(n_1comdp, 0, sizeof(n_1comdp));
	memset(lcomdp, 0, sizeof(lcomdp));

	int snum = 0;
	int endnum = 0;

	for (int i = 1; i <= n + 1; i++) {
		if (NN[a[i]] == 0) NN[a[i]] = i;
		else {
			snum = NN[a[i]];
			endnum = i;
			break;
		}
	}

	long long int l = snum - 1 + (n + 1 - endnum);


	for (long long int i = 1; i < 100002; i++) {
		n_1comdp[i] = combination(n + 1, i);
		lcomdp[i] = combination(l, i);
	}

	cout << n << endl;

	for (int i = 2; i <= n + 1; i++) {
		//cout << combination(n + 1, i) - combination(l, i - 1) << endl;
		cout << (n_1comdp[i] - lcomdp[i - 1] + MOD) % MOD << endl;
	}
	return 0;
}



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

// const double PI = acos(-1.0); 

void solve();

void fastio()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
}

int main()
{
    fastio(); 

    // int t; 
    // cin >> t;

    // while (t--) 
    solve(); 

    return 0;
}

void solve()
{
    int N;
    cin >> N;

    int lastDigit = N % 10;
    string ans;
    switch (lastDigit)    
    {
        case 3:
        ans = "bon";
        break;

        case 0:
        case 1: 
        case 6:
        case 8:
        ans = "pon";
        break;

        default:
        ans = "hon";
    }

    cout << ans << "\n";
}

Measured memory_bytes: 3628
#include "bits/stdc++.h"

#define rep(i, a) for (int i = 0; i < (a); ++i)
#define REP(i, a, b) for (int i = (a); i < (b); ++i)

using namespace std;
using ll = long long;
using P = pair<int, int>;

#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0, a1, a2, a3, a4, x, ...) x
#define debug_1(x1) cerr << #x1 << ": " << x1 << endl
#define debug_2(x1, x2) cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << endl
#define debug_3(x1, x2, x3) cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << endl
#define debug_4(x1, x2, x3, x4) cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << endl
#define debug_5(x1, x2, x3, x4, x5) cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << ", " #x5 << ": " << x5 << endl
#define debug(...) CHOOSE((__VA_ARGS__, debug_5, debug_4, debug_3, debug_2, debug_1, ~)) (__VA_ARGS__)


void Main() {
  int k;
  cin >> k;
  queue<ll> A;
  rep(i, 9) A.push(i+1);
  ll a;
  rep(i, k) {
    a = A.front(); A.pop();
    int b = a % 10;
    if (b != 0) A.push(a*10+b-1);
    A.push(a*10+b);
    if (b != 9) A.push(a*10+b+1);
  }
  cout << a << endl;
}

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


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef pair<P,int> T;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
int N,L;
int main(){
	cin >> N >> L;
	int base = 0;
	for(int i=0;i<N;i++){
		base += L+i;
	}
	int m = INF;
	int ans = -1;

	for(int i=0;i<N;i++){
		int sum = 0;
		for(int j=0;j<N;j++){
			if(i==j)continue;
			sum += L+j;
		}
		if(abs(sum-base)<m){
			m = abs(sum-base);
			ans = sum;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
from collections import Counter
N = int(input())
S = input()
C = Counter(S)

ans = 0
left = set()
right = set(S)
for s in S:
    left.add(s)
    C[s] -= 1
    if not C[s]:
        right -= {s}
    ans = max(ans, len(left & right))

print(ans)

Measured memory_bytes: 3316
/*
 Author: nilesh8757
 */
#include<bits/stdc++.h>
 using namespace std;

#define FIO                     ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mod                     1000000007
#define eps                     1e-9
#define setbits                 __builtin_popcount
#define gcd                     __gcd
#define rep(i,a,b)              for(int i=a;i<=b;i++)
#define repr(i,b,a)             for(int i=b;i>=a;i--)
#define forn(i,n)               for(int i=0;i<n;i++)
#define all(a)                  a.begin(), a.end()
#define in(a,b)                 ( (b).find(a) != (b).end())
#define pb                      push_back
#define fill(a,v)               memset(a, v, sizeof a)
#define endl                    "\n"
#define ff                      first
#define ss                      second
#define mp                      make_pair
#define minin(a)                *min_element (all(a))
#define maxin(a)                *max_element(all(a))
#define asort(c)                sort(all(c))
#define dsort(c)                sort(all(c), greater<int>()) 
#define PI                      3.14159265358979323846
#define int                     long long
typedef  vector<int>                 vi;
typedef  pair<int, int>              ii;
typedef  vector<ii>                 vii;
typedef  set<int>                    si;
typedef  map<int, int>              mii;
typedef  long double                 ld;

//24% faster self-written upper bound than c++ stl's upper_bound()
template <class T> inline size_t fast_upper_bound(const vector<T>& vec, T value)
{
    size_t m_len = vec.size();
    size_t low = -1;
    size_t high = m_len;
    assert(m_len < std::numeric_limits<size_t>::max() / 2);
    while (high - low > 1) 
    {
        size_t probe = (low + high) / 2;
        T v = vec[probe];
        if (v > value)
            high = probe;
        else
            low = probe;
    }
 
    if (high == m_len)
        return m_len;
    else
        return high;
}
 

clock_t time_p=clock();
void timer()
{
    time_p=clock()-time_p;
    cerr<<"Execution Time: "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}

int32_t main()
{
  FIO
  
  
  int n,x,cnt=0;
  cin>>n>>x;

  int a[n];
  forn(i,n)
   cin>>a[i];

  sort(a,a+n);

  forn(i,n)
  {
    if(x>=a[i])
    {
        cnt++;
        x-=a[i];
    }
    else
    {
        cout<<cnt;
        exit(0);
    }
  }

  if(x>0)
    cnt--;
  cout<<cnt;
  timer();
  return 0;
}  

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

#define rep(i,n) for(ll i = 0; i < n; i++)
#define REP(i,n) for(int i = 1; i < n; i++)
#define per(i,n) for(int i = n-1; i >= 0; i--)
#define PER(i,n) for(int i = n; i >= 1; i--)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
using vb = vector<bool>;
using vc = vector<char>;
using vcc = vector<vc>;
using vP = vector<P>;
using vPl = vector<Pl>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }


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

  int n, max_w;
  cin >> n >> max_w;
  vii v(4);
  ll w_s, a;
  cin >> w_s >> a;
  v[0].push_back(a);
  REP(i,n) {
    int w, b;
    cin >> w >> b;
    v[w-w_s].push_back(b);
  }
  rep(i,4) sort(rall(v[i]));
  int ans = 0;
  rep(i,sz(v[0])+1) {
    rep(j,sz(v[1])+1) {
      rep(k,sz(v[2])+1) {
        rep(l,sz(v[3])+1) {
          int tmp = 0;
          ll weight = i*(w_s) + j*(w_s+1) + k*(w_s+2) + l*(w_s+3);
          if(weight > max_w) continue;
          rep(cnt,i) tmp += v[0][cnt];
          rep(cnt,j) tmp += v[1][cnt];
          rep(cnt,k) tmp += v[2][cnt];
          rep(cnt,l) tmp += v[3][cnt];
          chmax(ans, tmp);
        }
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int N;
    cin >> N;
    int64_t lucas = 1;
	int64_t lucas_0 = 2;
	int64_t lucas_1 = 1;
  if (N != 1){
    for(int i=0; i<N-1; i++){
    lucas = lucas_0 + lucas_1;
    lucas_0 = lucas_1;
    lucas_1 = lucas;
   }
  }
  cout << lucas << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
using namespace std;

vector<string> split(string s){
    vector<string> res;
    int right = 0, left = 0;
    while(s[right] != ':') right++;
    right = left = right + 1;

    while(right < s.size()){
        while(s[right] != ',' && s[right] != '.') right++;
        //show(s.substr(left,(right - left)));
        res.emplace_back(s.substr(left, (right - left) ));
        right = left = right + 1;
    }
    return res;
}

string requestParent(string s){
    rep(i,s.size()){
        if(s[i] == ':'){
            return s.substr(0,i);
        }
    }
}

void dfs(map<string, vector<string>> m, string cur, set<string> &s, int &cnt){
    if(s.find(cur) != s.end()) return;
    s.insert(cur);

    if(m[cur].size() == 0) cnt++;
    else{
        rep(i,m[cur].size()){
            dfs(m,m[cur][i],s,cnt);
        }
    }
}

int main(){
    int n;
    while(cin >> n,n){
        cin.ignore();

        string first;
        map<string, vector<string> > m;
        rep(i,n){
            string tmp;
            getline(cin, tmp);

            string par = requestParent(tmp);
            if(i == 0) first = par;
            vector<string> s = split(tmp);
            rep(j,s.size()){
                m[ par ].emplace_back(s[j]);
            }
        }

        int cnt = 0;
        set<string> s;
        for(auto it:m[first]){
            dfs(m,it,s,cnt);
        }
        cout << cnt << endl;
    }
}

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

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

    int a, b, c, cnt = 0;
    //vector<int> v;

    cin >> a >> b >> c;
    
    for(int i = a; i <= b; i++){
        if(c % i == 0){
            cnt++;
        }
    }

    /*
    for(int i = 0; i < v.size(); i++){
        auto result = find(v.begin(), v.end(), v[i]);
        if(result != v.end()){
            cnt++;
                cout << v[i] << endl;
        }
    }
    */

    cout << cnt << endl;

    return 0;
}

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

typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vz;
typedef vector<vz> vvz;
typedef pair<ll, ll> pll;
#define sz(x) int((x).size())
#define fo(i,n) for(ll i=0; i<(n); i++)
#define FO(i,a,b) for(ll i=(a); i!=(b); i+=(b)>(a)?1:-1)
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(c) c.begin(), c.end()
#define F first
#define S second
#define os(x) cout<<x<<' '
#define on(x) cout<<x<<"\n"
#define nl cout<<"\n"
#define maxe(x) max_element(all(x))-(x).begin()
#define mine(x) min_element(all(x))-(x).begin()

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("C:\\Users\\ASISH\\Desktop\\coding\\input1.txt", "r", stdin);
	freopen("C:\\Users\\ASISH\\Desktop\\coding\\output1.txt", "w", stdout);
#endif

	int tc=1;
	// cin>>tc;
	fo(r, tc)
	{
		ll n, d, cnt=0;
      	cin>>n>>d;
      	vll p(n), q(n);
      	fo(i, n) cin>>p[i]>>q[i];
      	fo(i, n){
          if(p[i]*p[i] + q[i]*q[i] <= d*d) cnt++;
        }
      	on(cnt);
	}
	cerr << "Time : " << ((double)clock()) / (double)CLOCKS_PER_SEC << "s\n";
	return 0;
}


Measured memory_bytes: 6348
class FUnionFind
  attr_reader :nodes, :parents, :ranks

  def initialize(n)
    @parents = (0...n).to_a
    @nodes = @parents.map{ |x| [x] }
  end

  def find(i)
    @parents[i]
  end

  def union(i,j)
    i = @parents[i]; j = @parents[j]
    return if i == j
    j,i = i,j if @nodes[i].size < @nodes[j].size
    @nodes[j].each{ |k| @parents[k] = i }
    @nodes[i].concat(@nodes[j])
    @nodes[j].clear
  end
end


N,M = gets.split.map(&:to_i)
edges = (0...M).map{ gets.split.map{ |a| a.to_i-1 } }
p (0...M).count{ |i|
  fs = FUnionFind.new(N)
  (0...M).each{ |j|
    next if i == j
    a,b = edges[j]
    fs.union(a,b)
  }
  a,b = edges[i]
  fs.find(a) != fs.find(b)
}


Measured memory_bytes: 1916
#include <limits>
#include <initializer_list>
#include <utility>
#include <bitset>
#include <tuple>
#include <type_traits>
#include <functional>
#include <string>
#include <array>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iterator>
#include <algorithm>
#include <complex>
#include <random>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <regex>
#include <cassert>
#include <cstddef>
#include <variant>
#define endl codeforces
#define ALL(v) std::begin(v), std::end(v)
#define ALLR(v) std::rbegin(v), std::rend(v)
using ll = std::int64_t;
using ull = std::uint64_t;
using pii = std::pair<int, int>;
using tii = std::tuple<int, int, int>;
using pll = std::pair<ll, ll>;
using tll = std::tuple<ll, ll, ll>;
template <typename T> using vec = std::vector<T>;
template <typename T> using vvec = vec<vec<T>>;
template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return std::min(t, var_min(tail...)); }
template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return std::max(t, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
template <typename T> T make_v(T init) { return init; }
template <typename T, typename... Tail> auto make_v(T init, std::size_t s, Tail... tail) { auto v = std::move(make_v(init, tail...)); return vec<decltype(v)>(s, v); }
template <typename T, std::size_t Head, std::size_t... Tail> struct multi_dem_array { using type = std::array<typename multi_dem_array<T, Tail...>::type, Head>; };
template <typename T, std::size_t Head> struct multi_dem_array<T, Head> { using type = std::array<T, Head>; };
template <typename T, std::size_t... Args> using mdarray = typename multi_dem_array<T, Args...>::type;
namespace init__ { struct InitIO { InitIO() { std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); std::cout << std::fixed << std::setprecision(30); } } init_io; }

const std::size_t SIZE = 2e5 + 10;
mdarray<ll, SIZE, 64> dp;

int main() {
    ll n, k;
    std::cin >> n >> k;
    for (ll i = 0; i < n; i++) {
        ll a;
        std::cin >> a;
        dp[i][0] = a - 1;
    }
    
    for (ll j = 0; j < 63; j++) for (ll i = 0; i < n; i++) {
        ll a = dp[i][j];
        dp[i][j + 1] = dp[a][j];
    }

    ll ans = 0;
    for (ll i = 0; k; i++, k /= 2) {
        if (!(k & 1)) continue;
        ans = dp[ans][i];
    }
    std::cout << ans + 1 << "\n";
    return 0;
}


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

using namespace std;

int main()
{
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	vector<long long> ans(n);
	for (int i = 0; i < n - 1; i++) {
		ans[n - 1] += i % 2 == 0 ? -a[i] : a[i];
	}
	ans[n - 1] += a[n - 1];
	ans[n - 1] /= 2;

	for (int i = n - 2; i >= 0; i--) {
		ans[i] = a[i] - ans[i + 1];
	}

	for (int i = 0; i < n; i++) {
		cout << ans[i] * 2 << (i == n - 1 ? "" : " ");
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 2432
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int n = N;
		int sum = 0;
		while(n > 0) {
			sum = sum + n%10;
			n /= 10 ;
		}
		if(N % sum == 0) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
		sc.close();
	}
}

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

int main() {
  int n, x, t;
  cin >> n >> x >> t;

  int sum = n / x;
  if (n % x > 0) sum++;

  cout << sum * t << endl;
  return 0;
}

Measured memory_bytes: 3564
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <math.h>
#include <string.h>
#include <iomanip>
#include <numeric>
#include <cstdlib>
#include <cstdint>
#include <cmath>

using namespace std;

using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vll = vector<vl>;
using vpll = vector<pll>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define Rep(i, n) for (long long i = 0; i< (long long)(n); i++)
#define RRep(i,n) for (long long i = ((long long)(n)-1); i>=0; i--)

struct Edge{
    int to;
    int weight;
    Edge(int t, int w) : to(t), weight(w){ }
};

using Graph = vector<vector<Edge>>;
using graph = vector<vector<int>>;

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

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

template <class T>
T gcd(T a, T b){
    if( b==0 ) return a;
    else return gcd(b, a%b);
}

template <class T>
T lcm(T a, T b){
    return (a*b)/gcd(a,b);
}

int INF = 1e9+7;

vector<int> dx = {-1,0,1,0};
vector<int> dy = {0,-1,0,1};

int main(){
    int n;
    cin >> n;
    vector<int> x(n);
    rep(i,n) cin >> x[i];
    int ans = INF;
    rep(i,101){
        int m = 0;
        rep(j,n){
            m += (x[j]-i)*(x[j]-i);
        }
        ans = min(ans,m);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
#define fore(i,a,b) for(ll i=(a);i<=(b);++i)
#define rep(i,n) fore(i,0,(n)-1)
#define rfore(i,a,b) for(ll i=(b);i>=(a);--i)
#define rrep(i,n) rfore(i,0,(n)-1)
#define all(x) (x).begin(),(x).end()
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
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>
ll sum(const T& a){return accumulate(all(a),0LL);}

void solve(){
    string w;cin>>w;
    ll ans=0;
    while(1){
        string x;cin>>x;
        if(x=="END_OF_TEXT")break;
        transform(x.begin(),x.end(),x.begin(),::tolower);
        if(x==w)ans++;
    }
    cout<<ans<<endl;
}

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



Measured memory_bytes: 3200