akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>

int main()
{
    std::string s, t;
    std::cin >> s >> t;

    int minCount = 1e9;
    for (int i = 0; i <= (int)(s.size()-t.size()); ++i)
    {
        int count = 0;
        for (int j = 0; j < (int)t.size(); ++j)
            if (s[i+j] != t[j])
                ++count;
            
        minCount = std::min(minCount, count);
    }

    printf("%d", minCount);

    return 0;
}

Measured memory_bytes: 3724
import heapq

def _heappush_max(heap, item):
    heap.append(item)
    heapq._siftdown_max(heap, 0, len(heap)-1)
    
def _heappop_max(heap):
    lastelt = heap.pop()    
    if heap:
        returnitem = heap[0]
        heap[0] = lastelt
        heapq._siftup_max(heap, 0)
        return returnitem
    return lastelt

N, M = map(int, input().split())
p = list(map(int, input().split()))

heapq._heapify_max(p)

for i in range(M):
    a = _heappop_max(p)
    a //= 2
    _heappush_max(p, a)

print(sum(p))

Measured memory_bytes: 14188
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset>    // bitset
#include <deque>     // deque
#include <iomanip>   //setprecsion
#include <iostream>  // cout, endl, cin
#include <map>       // map
#include <queue>     // queue, priority_queue
#include <set>       // set
#include <stack>     // stack
#include <string>    // string, to_string, stoi
#include <tuple>     // tuple, make_tuple
#include <utility>   // pair, make_pair
#include <vector>    // vector

#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>  //sin, cos, tan

using namespace std;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define blank(ans) cout << (ans) << " ";
#define mp(p, q) make_pair(p, q)
#define mt(p, q, r) make_tuple(p, q, r)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef string str;

typedef vector<ll> vll;
typedef vector<ld> vd;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<str> vs;
typedef vector<vector<ll>> vvll;
typedef vector<vector<ld>> vvd;
typedef vector<vector<bool>> vvb;
typedef vector<vector<char>> vvc;
typedef vector<vector<str>> vvs;
typedef vector<pair<ll, ll>> vpll;
typedef vector<tuple<ll, ll, ll>> vtlll;

const ld PI = acos(-1.0);
const ll MAX = 9000000000000000000;
const ll MIN = -9000000000000000000;
const ld DMAX = 4500;
const ld DMIN = -4500;
const ll MOD = 1000000007;

template <typename T>
void fin(T a)
{
  cout << a << endl;
  exit(0);
}

//桁数
ll GetDigit(ll num)
{
  return log10(num) + 1;
}

//約数全列挙
vector<ll> enum_div(ll n)
{
  vector<ll> ret;
  for (ll i = 1; i * i <= n; ++i)
  {
    if (n % i == 0)
    {
      ret.push_back(i);
      if (i * i != n)
      {
        ret.push_back(n / i);
      }
    }
  }
  sort(begin(ret), end(ret));
  return ret;
}

//累乗(xのn乗%mod)
ll modpow(ll x, ll n, ll mod = MAX)
{
  ll res = 1;
  while (n > 0)
  {
    if (n & 1)
      res = res * x % mod;
    x = x * x % mod;
    n >>= 1;
  }
  return res;
}

//階乗
ll factorial(ll n)
{
  if (n > 0)
    return n * factorial(n - 1);
  else
    return 1;
}

ll modinv(ll a, ll mod)
{
  ll b = mod, u = 1, v = 0;
  while (b)
  {
    ll t = a / b;
    a -= t * b;
    swap(a, b);
    u -= t * v;
    swap(u, v);
  }
  u %= mod;
  if (u < 0)
    u += mod;
  return u;
}

ll gcd(ll a, ll b)
{
  return b ? gcd(b, a % b) : a;
}

ll lcm(ll a, ll b)
{
  return a * b / gcd(a, b);
}

void Main()
{
  vll x(5); rep(i,5) cin >> x[i];
  if(x[0] == 0) fin(1);
  if(x[1] == 0) fin(2);
  if(x[2] == 0) fin(3);
  if(x[3] == 0) fin(4);
  fin(5);
}

//前処理
int main()
{
  //ios::sync_with_stdio(false);
  //cin.tie(0);
  cout << fixed << setprecision(20); //高精度少数表示
  //cout << setfill('0') << internal << setw(4); 0埋め４桁
  Main();
  return 0;
}

Measured memory_bytes: 3596
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <map>
#define ll long long
ll const N = 200000;
using namespace std;
ll a[N + 10];
int main() {
	int n;
	cin >> n;
	int id = 0;
	map<ll, int> ps;
	ll ch;
	for (int i = 0; i < n; i++) {
		scanf("%lld", &ch);
		a[++id] = ch;
	}
	ll res = 0;
	for (int i = 1; i <= id; i++) {		
		res += ps[(ll)(i - a[i])];
		ps[(ll)(i + a[i])]++;
	}
	cout << res;
	












	return 0;
}

Measured memory_bytes: 27376
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<bitset>
#include<unordered_map>
#include <climits>
#include<fstream>
using namespace std;
//---------------------------------------------------
//ライブラリゾーン！！！！
typedef long long ll;
typedef long double ld;
#define rep(i,j) for(ll i=0;i<(long long)(j);i++)
#define all(a) (a).begin(),(a).end()
const ll Mod = 1000000007;
struct P {
	ll pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {//隣接リスト表現
	ll to, cost;
};
struct E {//辺の情報を入れる変数
	ll from, to, cost;
};
bool operator<(E a, E b) {
	return a.cost < b.cost;
}
struct H {
	ll x, y;
};
bool operator<(H a, H b) {
	if (a.x != b.x) return a.x < b.x;
	return a.y < b.y;
}
bool operator>(H a, H b) {
	if (a.x != b.x) return a.x > b.x;
	return a.y > b.y;
}
bool operator==(H a, H b) {
	return a.x == b.x&&a.y == b.y;
}
bool operator!=(H a, H b) {
	return a.x != b.x || a.y != b.y;
}
ll gcm(ll i, ll j) {//最大公約数
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcm(j%i, i);
}
ld rad(H a, H b) {
	return sqrt(pow(a.x - b.x, 2.0) + pow(a.y - b.y, 2.0));
}//rad＝座標上の2点間の距離
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x%p;
		x = x * x%p;
		n >>= 1;
	}
	return res;
}//x^n%p
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
//++++++++++++++++++++++++++++++++++++++++++++++++++++
int a[4][3][10];
int n;
int b, f, r, v;
signed main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> b >> f >> r >> v;
		b--; f--; r--;
		a[b][f][r] += v;
	}
	for (int i = 0; i < 4; i++) {
		for (int j = 0; j < 3; j++) {
			for (int z = 0; z < 10; z++) {
				cout << " " << a[i][j][z];
			}
			cout << endl;
		}
		if (i < 3) {
			for (int i = 0; i < 20; i++)
				cout << "#";
			cout << endl;
		}
	}
}


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
using namespace std;
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL);

int main() 
{
    FAST;
    ll n,i,j,x;
    cin>>n;
    vector<ll> v;
    ll gcd=0;
    map<ll,ll> mp;
    for(i=0;i<n;i++)
    {
        cin>>x;
        mp[x]++;
        gcd=__gcd(gcd,x);
        v.push_back(x);
    }
    if(gcd>1)
    {
        cout<<"not coprime"<<endl;
    }
    else
    {
        ll vs[1000007];
        memset(vs,-1,sizeof vs);
        ll f=0;
        for(i=2;i<=1000000;i++)
        {
            if(vs[i]==-1)
            {
                ll cnt=0;
                for(j=i;j<=1000001;j+=i)
                {
                    vs[j]=1;
                    if(mp[j]>0)
                    {
                        cnt++;
                    }
                }
                if(cnt>1)
                {
                    f=1;
                    break;
                }
            }
        }
        if(f==1)
        {
            cout<<"setwise coprime";
        }
        else
        {
            cout<<"pairwise coprime";
        }
    }
    
}

Measured memory_bytes: 81424
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<list>
#include<map>
#include<numeric>
#include<iomanip>
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define ll long long
const double pi = 3.141592653589793;

using namespace std;

//最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) {
		return a;
	}
	return gcd(b, a % b);
}

//最小公倍数
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}

//階乗
ll fact(ll a) {
	int ans = 1;
	for (int i = 1; i <= a; i++) {
		ans *= i;
	}
	return ans;
}

//コンビネーション
ll combi(ll a, ll b) {
	return fact(a) / (fact(b) * fact(a - b));
}

int main() {
	int a, b;
	cin >> a >> b;
	cout << a * b << endl;
	return 0;
}


Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()
ll d1[4] = {1, -1, 0, 0};
ll d2[4] = {0, 0, 1, -1};

int main(){
    ll N;
    cin >> N;
    VL t(N+1), x(N+1), y(N+1);
    x[0] = 0; y[0] = 0; t[0] = 0;
    rep(i, 1, N+1) cin >> t[i] >> x[i] >> y[i];
    rep(i, 0, N){ // ?
        ll diff = abs(x[i+1] - x[i]) + abs(y[i+1] - y[i]);
        if(diff > t[i+1] - t[i] || diff % 2 != (t[i+1] - t[i]) % 2){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 2560
#include "bits/stdc++.h"
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
typedef pair<P, int> E;
typedef pair<int, P> S;
map<P, vector<E>> G;
map<P, int> dist;
int main() {
	int N, M;
	cin >> N >> M;
	for (int i = 0; i < M; i++) {
		int p, q, c;
		cin >> p >> q >> c;
		p--; q--;
		G[P(p, c)].emplace_back(P(q, c), 0);
		G[P(q, c)].emplace_back(P(p, c), 0);
		G[P(p, -1)].emplace_back(P(p, c), 1);
		G[P(p, c)].emplace_back(P(p, -1), 0);
		G[P(q, -1)].emplace_back(P(q, c), 1);
		G[P(q, c)].emplace_back(P(q, -1), 0);
	}
	priority_queue<S, vector<S>, greater<S>> Q;
	Q.push(S(0, P(0, -1)));
	dist[P(0, -1)] = 0;
	int ans = 1 << 30;
	while (!Q.empty()) {
		S s = Q.top(); Q.pop();
		if (s.first > dist[s.second]) continue;
		if (s.second.first == N - 1) ans = min(ans, s.first);
		for (auto e : G[s.second]) {
			int cost = s.first + e.second;
			if (dist.find(e.first) == dist.end() || dist[e.first] > cost) {
				dist[e.first] = cost;
				Q.push(S(cost, e.first));
			}
		}
	}
	if (ans == 1 << 30) {
		cout << -1 << endl;
		return 0;
	}
	cout << ans << endl;
}

Measured memory_bytes: 91700
import sys
from io import StringIO
import unittest

import random
import numpy as np
random.seed(42)
TYPE_NUM = 26
WEIGHT1 = 16
WEIGHT2 = 8
WEIGHT3 = 1

def resolve():

    inp = sys.stdin.readlines()
    D = int(inp[0])
    c = np.array(list(map(int, inp[1].split(' '))))
    s = []
    last = np.zeros(TYPE_NUM, dtype=int)
    types = []

    for i in range(2, len(inp)):
        s.append(list(map(int, inp[i].split(' '))))
    s = np.array(s, dtype=int)

    for d in range(D):
        temp_delta_satis = np.zeros([TYPE_NUM, TYPE_NUM, TYPE_NUM], dtype=int)
        for idx in range(TYPE_NUM):
            val = s[d, idx]
            org = last[idx]
            last[idx] = d+1
            temp_delta_satis[:, :, idx] = (np.sum(-c*(d+1-last)) + val)*WEIGHT1
            if D > d+1:
                for idx2 in range(TYPE_NUM):
                    rand = random.random()
                    if rand > 0.9:
                        val2 = s[d+1, idx2]
                        org2 = last[idx2]
                        last[idx2] = d+2
                        temp_delta_satis[idx2, idx] += (np.sum(-c*(d+2-last)) + val2)*WEIGHT2
                        last[idx2] = org2
                    else:
                        temp_delta_satis[idx2, idx] = -10 ** 16
                        continue
                if D > d+2:
                    for idx3 in range(TYPE_NUM):
                        rand = random.random()
                        if rand > 0.5:
                            val3 = s[d+2, idx3]
                            org3 = last[idx3]
                            last[idx3] = d+3
                            temp_delta_satis[idx3, idx2, idx] += (np.sum(-c*(d+3-last)) + val3)*WEIGHT3
                            last[idx3] = org3
                        else:
                            temp_delta_satis[idx3, idx2, idx] = -10 ** 16
            last[idx] = org
        opt_idx = np.unravel_index(np.argmax(temp_delta_satis), temp_delta_satis.shape)[2]
        last[opt_idx] = d+1
        types.append(opt_idx+1)
    print(*types, sep='\n')
    
resolve()

Measured memory_bytes: 32724
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define i_inf int(1e9)
#define i_half_inf int(1e5)
#define ll_inf ll(1e9)*ll(1e9)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const int mod = 1000000007;

ll a, b, c;

void solve() {
    if (a % 2 != 0 || b % 2 != 0 || c % 2 != 0) {
        cout << 0 << endl;
        return;
    }
    if (a == b && b == c) {
        cout << -1 << endl;
        return;
    }

    ll ab = a + b, bc = b + c, ca = c + a;
    ll t_ab = 0, t_bc = 0, t_ca = 0;
    while (ab % 2 == 0) ab /= 2, t_ab++;
    while (bc % 2 == 0) bc /= 2, t_bc++;
    while (ca % 2 == 0) ca /= 2, t_ca++;
    cout << min(min(t_ab, t_bc), t_ca) << endl;
}

int main() {
    cin >> a >> b >> c;
    solve();
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
#include <string>
int main()
{
    // 整数の入力
    int a;
    cin >> a;
  if(a<30)
  {
      
    // 出力
    cout <<  "No" << endl;
  }
  else
  {
      
    // 出力
    cout << "Yes" << endl;
  }
 
    return 0;
}

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

using namespace std;
using ll = long long;
// #define int ll
using PII = pair<ll, ll>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()

template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type
fill_v(T &t, const V &v) { t=v; }
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t, const V &v ) { for(auto &e:t) fill_v(e,v); }

template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a) {
    out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
    out<<'[';
    for(const T &i: a) out<<i<<',';
    out<<']';
    return out;
}
template<class T>
ostream &operator <<(ostream& out, const set<T>& a) {
    out<<'{';
    for(const T &i: a) out<<i<<',';
    out<<'}';
    return out;
}
template<class T, class S>
ostream &operator <<(ostream& out, const map<T,S>& a) {
    out<<'{';
    for(auto &i: a) out<<i<<',';
    out<<'}';
    return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;

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

    string s;
    cin >> s;
    ll n = s.size();

    vector<ll> ret(n);
    bool turn = true;
    ll cnt1 = 0, cnt2 = 0, idx = -1;
    REP(i, n) {
        if(turn) {
            if(s[i]=='R') {
                cnt1++;
            } else {
                cnt2++;
                idx = i;
                turn = false;
            }
        } else {
            if(s[i]=='R') {
                ret[idx-1] += (cnt1+1)/2;
                ret[idx] += cnt1/2;
                ret[idx-1] += cnt2/2;
                ret[idx] += (cnt2+1)/2;
                turn = true;
                cnt1 = 1, cnt2 = 0;
            } else {
                cnt2++;
            }
        }
    }
    ret[idx-1] += (cnt1+1)/2;
    ret[idx] += cnt1/2;
    ret[idx-1] += cnt2/2;
    ret[idx] += (cnt2+1)/2;

    REP(i, n) {
        cout << ret[i] << (i==n-1?'\n':' ');
    }

    return 0;
}


Measured memory_bytes: 1488
#include <bits/stdc++.h>
using namespace std;
	 
#define fast_io ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define cout_precision cout.setf(ios::fixed); cout.precision(32);
#define clr(a) memset(a,0,sizeof(a))
#define umap unordered_map
#define uset unordered_set
#define fr first
#define sc second
#define pb push_back
#define M int(1e9+7)
#define endl '\n'
	
using ll = int64_t; using vll = vector<ll>; using vvll = vector<vll>;
using pll = pair<ll, ll>; using vpll = vector<pll>; using vvpll = vector<vpll>;
	
	
int main(){
	fast_io; cout_precision;
	int n,m;	cin >>n >> m;
	if(n == m)	cout <<"Yes"<<endl;
	else	cout <<"No"<<endl;
	
	return 0;
}

Measured memory_bytes: 256
import sys
#from me.io import dup_file_stdin

N=1000000
primes = [1]*N
primes[0:2]=[0,0,1]

for i in range(2,N):
    if primes[i]==1:
        j=i+i
        while j<=N:
            primes[j]=0
            j+=i

#@dup_file_stdin
def solve():
    for query in map(int,sys.stdin):
        print(sum(primes[2:query+1]))
solve()

Measured memory_bytes: 24328
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let n: usize = iterator.next().unwrap().parse().unwrap();

    let divisors = enumerate_divisors(n);
    let mut ans: usize = 0;
    for d in divisors {
        if d == 1 {
            continue;
        }
        let d = d - 1;
        if n / d == n % d {
            ans += d;
        }
    }
    ans.to_string()
}

fn enumerate_divisors(n: usize) -> Vec<usize> {
    let mut divisors = Vec::new();

    let mut i = 1;
    while i * i <= n {
        if n % i == 0 {
            divisors.push(i);
            if n / i != i {
                divisors.push(n / i);
            }
        }
        i += 1;
    }
    divisors.sort();
    return divisors;
}


Measured memory_bytes: 2156
I=lambda:list(map(int,input().split()))
n,m,q=I()
k=n+2
l=[0]*k**2
for _ in range(m):
  s,g=I()
  l[s*k+g]+=1
for i in range(1,n+1):
  for j in range(1,n+1):
    l[i*k+j]+=l[i*k+j-1]
for i in range(1,n+1):
  for j in range(1,n+1):
    l[i*k+j]+=l[~-i*k+j]
for _ in range(q):
  s,g=I()
  print(l[g*k+g]-l[~-s*k+g]-l[g*k+s-1]+l[~-s*k+s-1])

Measured memory_bytes: 13388
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
ll GetDigit(ll num){ return log10(num)+1; } //numの桁数を求める

int main()
{
    int n,a,b;
    cin >> n >> a >> b;
    if(n*a < b) cout << n*a << endl;
    else cout << b << endl;
    return 0;
}

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

const int MAXN = 200000 + 10;
int n, a[MAXN], b[MAXN];

int main()
{
	cin >> n;
	for(int i = 1; i <= n; i++)	cin >> a[i];
	
	for(int i = n; i >= n / 2 + 1; i--) b[i] = a[i];
	
	for(int i = n / 2; i >= 1; i--)
	{
		int cnt = 0;
		for(int j = 2; i * j <= n; j++)
			cnt += b[i * j];
		if(cnt % 2 == a[i] % 2) b[i] = 0;
		else b[i] = 1;
	} 
	
	int cnt = 0;
	for(int i = 1; i <= n; i++) cnt += b[i];
	if(cnt)
	{
		cout << cnt << endl;
		for(int i = 1; i <= n; i++) if(b[i]) cout << i << endl;
	}
	else 
	{
		cout << 0 << endl;
	}
	
	return 0;
}


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

using namespace std;

#define SZ(v) ((int)(v).size())
#define ALL(v) (v).begin(),(v).end()
#define one first
#define two second
typedef long long ll;
typedef pair<int, int> pi;
const int INF = 0x3f2f1f0f;
const ll LINF = 1ll * INF * INF;

const int MAX_N = 1e3 + 100, MAX_NR = 5e3 + 100;;

int N, Nr[MAX_N], Dy[MAX_N];
vector<int> Ed[MAX_N];
int minV[2][MAX_NR];
bool getDy(int v, int p) {
	for(int w : Ed[v]) if(w != p) if(getDy(w, v) == false) return false;
	int n = 0, o = 1; 
	for(int i=0; i<=Nr[v]; i++) minV[0][i] = INF; 
	minV[0][0] = 0;

	for(int w : Ed[v]) if(w != p) {
		swap(n, o);
		for(int i=0; i<=Nr[v]; i++) minV[n][i] = INF;
		int val[2] = {Nr[w], Dy[w]};
		for(int k=0; k<2; k++) for(int i=0; i<=Nr[v]-val[k]; i++) minV[n][i+val[k]] = min(minV[n][i+val[k]], minV[o][i] + val[1-k]);
	}
	Dy[v] = INF;
	for(int i=0; i<=Nr[v]; i++) Dy[v] = min(Dy[v], minV[n][i]);
	return Dy[v] != INF;
}
int main() {
	cin >> N;
	for(int i=2; i<=N; i++) {
		int x; scanf("%d", &x);
		Ed[x].push_back(i); Ed[i].push_back(x);
	}
	for(int i=1; i<=N; i++) scanf("%d", &Nr[i]);
	bool isCan = getDy(1, 0);
	puts(isCan ? "POSSIBLE" : "IMPOSSIBLE");
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef vector<int> VI;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)
int N;
LL D,A;
pair<LL,LL> P[200011];
LL F[200011];
void MAIN(){
    scanf("%d%lld%lld",&N,&D,&A);
    REP (i,N) scanf("%lld%lld",&P[i].first,&P[i].second);
    sort(P,P+N);
    LL ans=0;
    REP (i,N){
		if (F[i]<P[i].second){
	    LL rest=P[i].second-F[i];
	    LL t=(rest+A-1)/A;
	    F[i]+=A*t;
	    ans+=t;
	    LL right=P[i].first+D+D;
	    int k=upper_bound(P,P+N,make_pair(right,1LL<<60))-P;
	    F[k]-=A*t;
		}
		F[i+1]+=F[i];
    }
	printf("%lld\n",ans);
}
int main() {
    int TC=1;
    REP (tc,TC) MAIN();
    return 0;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()
ll d1[4] = {1, -1, 0, 0};
ll d2[4] = {0, 0, 1, -1};

// ll dp[3010][3010][5];
vector<VVL> dp(3010, VVL(3010, VL(5, 0)));
ll tbl[3010][3010];

void init() {
    rep(i, 0, 3010) rep(j, 0, 3010) {
        // rep(k, 0, 5) dp[i][j][k] = 0;
        tbl[i][j] = 0;
    }
}


int main(){

    init();

    // input
    ll R, C, K;
    cin >> R >> C >> K;
    VL r(K), c(K), v(K);
    rep(i, 0, K){
        cin >> r[i] >> c[i] >> v[i];
        tbl[r[i]-1][c[i]-1] = v[i];
    }

   
    rep(i, 0, R+1){
        rep(j, 0, C+1) {
            // (i, j) -> (i+1, j)
            if(i < R){
                // i, j で取らない
                rep(k, 0, 4) dp[i+1][j][0] = max(dp[i+1][j][0], dp[i][j][k]);
                // i, j で取る
                rep(k, 0, 3) dp[i+1][j][0] = max(dp[i+1][j][0], dp[i][j][k] + tbl[i][j]);
            }
            // (i, j) -> (i, j+1)
            if(j < C){
                // i, jで取らない
                rep(k, 0, 4) dp[i][j+1][k] = max(dp[i][j+1][k], dp[i][j][k]);
                // i, jで取る 
                rep(k, 0, 3) dp[i][j+1][k+1] = max(dp[i][j+1][k+1], dp[i][j][k] + tbl[i][j]);
            }
        }
    }
    
    ll ans = 0;
    rep(i, 0, 4) ans = max(dp[R][C][i], ans);
    cout << ans << endl;
    return 0;
}

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

namespace easy_Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            double N = double.Parse(Console.ReadLine());
            Console.WriteLine((N-(int)((N/2)))/N);
        }
            // long[] NK = Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
            // long N = NK[0];
            // long K = NK[1];
            // long K = long.Parse(Console.ReadLine());
            // int[] abc = Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
            // string S = Console.ReadLine();
            // int x = int.Parse(Console.ReadLine());
            // int b = int.Parse(Console.ReadLine());
            // int N = int.Parse(Console.ReadLine());
            // float N = float.Parse(Console.ReadLine());
            // string c = Console.ReadLine();
            // string B = Console.ReadLine();
            // string[] s = Console.ReadLine().Split();
            // var s = (new string[] { Console.ReadLine(), Console.ReadLine(), Console.ReadLine() }).Select(float.Parse);
            // float[] a = Array.ConvertAll(Console.ReadLine().Split(),float.Parse);
            // var X = Console.ReadLine();
            // int[,] abcd = new int[NMQ[2],4];
            // int[] A = new int[NMQ[0]];
            // int[] A_num = new int[NMQ[0]];
            // long[] s=Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
            // var hs=new Dictionary<long,long>();
            // for(int i=0;i<s[0];i++){
            //     long[] q=Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
            //     if(hs.ContainsKey(q[0])){hs[q[0]]+=q[1];}
            //     else{hs.Add(q[0],q[1]);}
            // }
        
        // //最小公倍数
        // static long Lcm(long a, long b)
        // {
        //     return a/Gcd(a,b)*b;
        // }

        // //最大公約数
        // static long Gcd(long m, long n)
        // {
        //     if(n==0)return m;
        //     return Gcd(n,m%n);
        // }
    }
}


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

using namespace std;

typedef long long ll;

enum player { R, P, S };

int main(){

    int n, k;
    cin >> n >> k;
    int r, s, p;
    cin >> r >> s >> p;
    string t;
    cin >> t;
    vector<char> mv(n);
    player pl;
    ll mx = 0;
    for(int i = 1; i <= k; i++)
        if( t[i-1] == 'r' )
            mx += p, mv[i-1] = 'p';
        else if( t[i-1] == 's' )
            mx += r, mv[i-1] = 'r';
        else
            mx += s, mv[i-1] = 's';

    for(int i = k+1; i <= n; i++)
        if( t[i-1] != t[i-1-k] || mv[i-1-k] == '.' ){
            if( t[i-1] == 'r' )
                mx += p, mv[i-1] = 'p';
            else if( t[i-1] == 's' )
                mx += r, mv[i-1] = 'r';
            else
                mx += s, mv[i-1] = 's';
        }else{
            mv[i-1] = '.';
        }

    cout << mx << endl;

    return 0;
}

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

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}
 
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int > vi;
typedef vector<ll> vll;
typedef vector<pll> vpll;
typedef vector<pii> vpii;
 
#define ALL(x) (x).begin(), (x).end()
#define RESET(x) memset((x), 0, sizeof (x))
#define FOR(i, b, e) for ( int i = (b); i < (e); ++i)
#define RE(i, n) FOR(i, 0, (n))
#define FOREACH(i, x, y) for ( int i = (x); i <= (y); ++i)
#define two(X) (1<<(X))//NOTES:two(
#define contain(S,X) (((S)&two(X))!=0)//NOTES:contain(
#define chkmin(X, Y) (X) = min((X), (Y))
#define chkmax(X, Y) (X) = max((X), (Y))
#define sqr(X) ((X) * (X))
#define MP(x, y) make_pair((x), (y))
 
const int LOGN = 22;
const ll INF = (1 << 30) + 10;
const ll MOD = 1e9 + 7;
const double PI = acos(-1.0);
const double EPS = 1e-12;

const long long maxn = 1e5 + 100;
const ll maxm = (ll) 1e6;

int main() {
#ifndef ONLINE_JUDGE
    //freopen("in.txt", "r", stdin);
#endif

    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    
    ll a, b, c, k;
    while (cin >> a >> b >> c >> k) {
        if (k & 1) {
            cout << b - a << endl;
        } else {
            cout << a - b << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#include <numeric>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

int main(void)
{
    ll n, k;

    cin >> n >> k;

    vector<ll> sum(n + 2, 0);

    ll ans = 0;

    for (int i = 1; i <= n; i++)
    {
        sum[i + 1] = i + sum[i];
    }

    for (int i = k; i <= n + 1; i++)
    {
        ans += (sum[n + 1] - sum[n + 1 - i]) - (sum[i] - sum[0]) + 1;

        ans %= MOD;
    }

    cout << ans << endl;
}


Measured memory_bytes: 4800
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b =sc.nextInt();
		int c = sc.nextInt();
		int ans = 0;
		if(a == b) {
			if(b == c) ans = 1;
			else ans = 2;
		}else if(b == c) {
			ans = 2;
		}else if(a == c){
			ans = 2;
		}else {
			ans = 3;
		}
		System.out.println(ans);
		sc.close();
	}
}

Measured memory_bytes: 22608
#pragma region header
#include <bits/stdc++.h>
using namespace std;

#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_CAT_I(x,y) x ## y

using i64 = int64_t;
using f64 = double;
constexpr f64 PI = 3.14159265358979323846;
constexpr char EL[] = "\n";

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());

template<typename T = i64>
T IN() { T x; cin >> x; return (x); }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T(&)[N]) { return static_cast<i64>(N); }

template<typename T, typename U, typename Comp = less<>>
bool chmax(T& xmax, const U& x, Comp comp = {}) {
if (comp(xmax, x)) {
xmax = x;
return true;
}
return false;
}
template<typename T, typename U, typename Comp = less<>>
bool chmin(T& xmin, const U& x, Comp comp = {}) {
if (comp(x, xmin)) {
xmin = x;
return true;
}
return false;
}

void print() {
  cout << EL;
}
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  cout << head;
  if (sizeof...(tail) != 0) cout << " ";
  print(forward<Tail>(tail)...);
}
template <class T>
void print(vector<T> &vec) {
  for (auto& a : vec) {
cout << a;
if (&a != &vec.back()) cout << " ";
  }
  cout << EL;
}
template <class T>
void print(vector<vector<T>> &df) {
  for (auto& vec : df) {
print(vec);
  }
}

struct ProconInit {
static constexpr int IOS_PREC = 15;
static constexpr bool AUTOFLUSH = false;

ProconInit() {
cin.tie(nullptr);
ios::sync_with_stdio(false);
cout << fixed << setprecision(IOS_PREC);
if (AUTOFLUSH)
cout << unitbuf;
}
} PROCON_INIT;
#pragma endregion

signed main()
{
	int n;
	cin >> n;
	int mod=99999, ans=0;
	REP(i, n){
		int a;
		cin >> a;
		ans += a;
		if (a % 10 > 0){
			mod = min(mod, a);
		}
	}
	if (ans % 10 > 0){
		print(ans);
	}else{
		if(mod==99999){
			print(0);
		}else{
			print(ans-mod);
		}
	}
	return 0;
}


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

n, q = map(int, input().split())

Len = (n-1).bit_length()
size = 2**Len
tree = [0]*(2*size)
lazy = [None]*(2*size)
h = [None]
for i in range(Len+1):
    v = 2**(Len-i)
    h += [v]*(2**i)

def gindex(l,r):
    L = (l+size)>>1;R=(r+size)>>1
    lc = 0 if l & 1 else (L&-L).bit_length()
    rc = 0 if r & 1 else (R&-R).bit_length()
    for i in range(Len):
        if rc <= i:
            yield R
        if L < R and lc <= i:
            yield L
        L >>= 1; R >>= 1
        
def propagates(ids):
    for i in reversed(ids):
        v = lazy[i]
        if v is None:
            continue
        lazy[2*i] = tree[2*i] = lazy[2*i+1] = tree[2*i+1] = v//2
        lazy[i]=None

def update(l,r,x):
    *ids, = gindex(l, r)
    propagates(ids)
    L = size+l
    R = size+r
    while L<R:
        if R&1:
            R -= 1
            lazy[R] = tree[R] = x*h[R]
        if L&1:
            lazy[L] = tree[L] = x*h[L]
            L+=1
        L>>=1;R>>=1
    for i in ids:
        if 2*i+1<size*2:
            tree[i]= tree[i*2]+tree[i*2+1]
        
def query(l, r):
    *ids, = gindex(l, r)
    propagates(ids)
    L = size + l
    R = size + r
    s = 0
    while L<R:
        if R&1:
            R-=1
            s +=tree[R]
        if L&1:
            s +=tree[L]
            L+=1
        L>>=1;R>>=1
    return s

ans = []
for i in range(q):
    a, *b = map(int, input().split())
    if a:
        ans.append(query(b[0],b[1]+1))
    else:
        update(b[0],b[1]+1,b[2])
print('\n'.join(map(str,ans)))


Measured memory_bytes: 23548
n=int(input())
 
L=[]
for i in range(n):
    x,l=map(int,input().split())
    L.append([x-l,x+l])
L.sort(key=lambda x:x[1])
 
ans=1
bef=L[0][1]
for i in range(1,n):
    if bef<=L[i][0]:
        bef=L[i][1]
        ans+=1
print(ans)

Measured memory_bytes: 21336
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner cin=new Scanner(System.in);
		
		int n=cin.nextInt();
		boolean cards[][]=new boolean[4][13];
		char simbols[]= {'S','H','C','D'};
		for(int i=0;i<4;i++) {
			for(int j=0;j<13;j++)cards[i][j]=false;
		}
		
		for(int i=0;i<n;i++) {
			String ssimbol=cin.next();int num=cin.nextInt();
			char simbol=ssimbol.charAt(0);
			if(simbol=='S')cards[0][num-1]=true;
			if(simbol=='H')cards[1][num-1]=true;
			if(simbol=='C')cards[2][num-1]=true;
			if(simbol=='D')cards[3][num-1]=true;
		}
		
		for(int i=0;i<4;i++) {
			for(int j=0;j<13;j++) {
				if(!cards[i][j])System.out.println(simbols[i]+" "+(j+1));
			}
		}
	}
}


Measured memory_bytes: 26160
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <utility>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cassert>
#include <queue>
#include <cstdlib>
using namespace std;
#define pii pair<int,int>
#define ft first
#define sc second
#define INF 1000000006
#define INFLL 4000000000000000006ll
#define vi vector<int>
#define pb push_back
#define eb emplace_back
#define gc getchar_unlocked
#define GI(x) while((_c=gc())<'0'); x=_c-'0'; while((_c=gc())>='0') x=x*10+_c-'0';
#define LL long long
#define DB double
#define PARAM int id, int l, int r
#define _L id*2,l,mid
#define _R id*2+1,mid+1,r
#define PREP int mid = (l+r)/2
#define MEMSET(x,y) memset(x,y,sizeof(x));

int r, c, n;
vector<pii> qq;
vector<int> vals;
vector<int> arr;
pii seg[600005];

bool border(int x, int y){
	return x==0 || x==r || y==0 || y==c;
}

int getId(int x, int y){
	if(y==0) return x;
	if(x==r) return r+y;
	if(y==c) return r+c+(r-x);
	return r+c+r+(c-y);
}

int comb1(int l, int r){
	if(l==-1) return r;
	if(r==-1) return l;
	return min(l,r);
}
int comb2(int l, int r){
	if(l==-1) return r;
	if(r==-1) return l;
	return max(l,r);
}

pii comb(pii l, pii r){
	return {comb1(l.ft,r.ft),comb2(l.sc,r.sc)};
}
int ql, qr;
void build(PARAM){
	if(l==r){
		seg[id] = {arr[l],arr[l]};
		return;
	}
	PREP;
	build(_L);
	build(_R);
	seg[id] = comb(seg[id*2],seg[id*2+1]);
}

pii query(PARAM){
	if(ql<=l&&r<=qr) return seg[id];
	PREP;
	pii res = {-1,-1};
	if(ql<=mid) res = comb(res,query(_L));
	if(qr>mid) res = comb(res,query(_R));
	return res;
}

int main(){
	char _c; GI(r) GI(c) GI(n)
	for(int i = 0; i < n; i++ ){
		int a, b, c, d; GI(a) GI(b) GI(c) GI(d)
		if(!border(a,b)||!border(c,d)) continue;
		int e = getId(a,b), f = getId(c,d);
		if(e>f) swap(e,f);
		qq.eb(e,f);
		vals.pb(e); vals.pb(f);
	}
	sort(vals.begin(),vals.end());
	vals.erase(unique(vals.begin(),vals.end()),vals.end());
	arr.resize(vals.size(),-1);
	for(auto &i : qq){
		i.ft = lower_bound(vals.begin(),vals.end(),i.ft)-vals.begin();
		i.sc = lower_bound(vals.begin(),vals.end(),i.sc)-vals.begin();
		arr[i.ft] = i.sc;
	}
	build(1,0,arr.size()-1);
	for(auto i : qq){
		ql = i.ft, qr = i.sc;
		pii res = query(1,0,arr.size()-1);
		if(res.ft!=-1 && res.ft < i.ft){
			printf("NO\n"); return 0;
		}
		if(res.sc!=-1 && res.sc > i.sc){
			printf("NO\n"); return 0;
		}
	}
	printf("YES\n");
	return 0;
}


Measured memory_bytes: 6892
N=int(input())
S=[]
for _ in range(N):
    S.append(input())
ans=[0,0,0,0]
for i in S:
    if i=="AC":
        ans[0]+=1
    elif i=="WA":
        ans[1]+=1
    elif i=="TLE":
        ans[2]+=1
    else:
        ans[3]+=1
print("AC x",ans[0])
print("WA x",ans[1])
print("TLE x",ans[2])
print("RE x",ans[3])

Measured memory_bytes: 16224
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(false)
using namespace std;
#define inf (0x3f3f3f3f)
typedef long long int LL;
const int maxn = 3e5 + 20;
int first[maxn], num;
struct Edge {
    int u, v, tonext;
}e[maxn];
void addEdge(int u, int v) {
    e[num].u = u, e[num].v = v, e[num].tonext = first[u];
    first[u] = num++;
}
int n;
int ans1, ans2;
int dis[maxn];
void dfs1(int cur, int fa, int to) {
    dis[cur] = to;
    for (int i = first[cur]; ~i; i = e[i].tonext) {
        int v = e[i].v;
        if (v == fa || v == n) continue;
        ans1++;
        dfs1(v, cur, to + 1);
    }
}
void dfs2(int cur, int fa, int to) {
    for (int i = first[cur]; ~i; i = e[i].tonext) {
        int v = e[i].v;
        if (v == fa || v == 1 || (to + 1 >= dis[v] && dis[v])) continue;
        if (dis[v]) ans1--;
        ans2++;
        dfs2(v, cur, to + 1);
    }
}
void work() {
    memset(first, -1, sizeof first);
    cin >> n;
    for (int i = 1; i <= n - 1; ++i) {
        int u, v;
        cin >> u >> v;
        addEdge(u, v);
        addEdge(v, u);
    }
    dfs1(1, -1, 0);
    dfs2(n, -1, 0);
    if (ans1 > ans2) {
        printf("Fennec\n");
    } else printf("Snuke\n");
}

int main() {
#ifdef local
    freopen("data.txt", "r", stdin);
//    freopen("data.txt", "w", stdout);
#endif
    work();
    return 0;
}


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

int main(){
  string s,t;
  int ans = 0;
  cin >> s >> t;
  
  for(int i=0;i<3;i++){
    if(s.at(i) == t.at(i)) ans++;
  }
  cout << ans << endl;

}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<set>
#include<queue>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include<cassert>
#include<cmath>
#include<climits>
#include<iomanip>
#include<stack>
#include<unordered_map>
#include<bitset>
#include<limits>
using namespace std;
#define MOD 1000000007
#define rep(i,m,n) for(int (i)=(int)(m);i<(int)(n);i++)
#define REP(i,n) rep(i,0,n)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
#define M_PI 3.1415926535897932LL;

int main(){
  int a, b;
  cin >> a >> b;
  cout << ceil((double)a/b) << endl;
}

Measured memory_bytes: 256
// Author -> Preeyadarshee Dev
//
// train hard win easy :D
// nik is love
// nik is motivation
//
// do modulo operations very carefully
// try to avoid binary search, use linear search preferrably to make calculations easier
// always make your custom binary search and watch out for overflows
// read the problems carefully
// never rely on floating point calculation
#include<bits/stdc++.h>
#define mp                    make_pair
#define pb                    push_back
#define ll                    long long
#define ss                       second
#define ff                        first
#define fr(i,a,b)   for(ll i=a;i<b;i++)
#define f(i,n)                fr(i,0,n)
#define rf(i,b,a) for(ll i=b-1;i>=a;i--)
#define r(i,n)                rf(i,n,0)
#define inf                   1000000007
#define eps                   0.000000000000001
#define sz(a)                int((a).size())
#define all(c)               (c).begin(),(c).end()
#define tr(c,i)              for(typeof(c).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x)         ((c).find(x) != (c).end())
#define cpresent(c,x)        (find(all(c),x) != (c).end())
#define pi                   pair<int,int>
#define pll                  pair < ll , ll >
#define endl                 '\n'
#define PI                   3.141592653589793238462643383279502884197169399375105820974944592307816406286
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef vector< int > vi;
typedef vector< vi > vvi;
int dx[8]={1,-1,0,0,-1,-1,1,1};
int dy[8]={0,0,-1,1,-1,1,-1,1};
vector<int> adj[200010],vis(200010,0),dis(200010,inf),fin(200010,0),col(200010,0),par(200010,0);
int myrandom (int i) { return std::rand()%i;}
bool cmp(pair<int,int> p1,pair<int,int> p2)
{
    return abs(p1.ff)>abs(p2.ff);
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //ifstream fin;
    //ofstream fout;
    //fin.open("input.txt");
    //fout.open("output.txt");
    int n,k;
    cin>>n>>k;
    string s;
    cin>>s;
    int i=1;
    int cnt=0;
    while(i<(int)s.length())
    {
        if(s[i]==s[i-1])
        {
            cnt++;
        }
        i++;
    }
    int l=(int)s.length();
    cout<<min(cnt+2*k,l-1)<<endl;
}


Measured memory_bytes: 9088
from collections import Counter
N = int(input())
n = N
fac = Counter()
while n % 2 == 0:
    n >>= 1
    fac[2] += 1
p = 3
while p*p <= n:
    while n % p == 0:
        n /= p
        fac[p] += 1
    if n == 1:
        break
    p += 2

fac_list = list(fac.items())

def ndigit(x):
    n = 0
    while x > 0:
        n += 1
        x //= 10
    return n

ND = ndigit(N)

def solve(fi, acc):
    if fi == len(fac_list):
        #import pdb; pdb.set_trace()
        assert N % acc == 0
        other = N // acc
        return max(ndigit(acc), ndigit(other))

    p, max_cnt = fac_list[fi]
    minval = ND
    m = 1
    for i in range(max_cnt+1):
        minval = min(minval, solve(fi+1, acc*m))
        m *= p
    return minval

print(solve(0, 1))


Measured memory_bytes: 41584
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

public class Main {

    public static void main(String[] args) throws Exception {
        InputStreamReader is = new InputStreamReader(System.in);
        BufferedReader reader = new BufferedReader(is);

        List<String> mylist = new ArrayList<>();

        // 標準入力からの値を変数strinputに代入
        String strinput = reader.readLine();

        while (strinput != null) {

            mylist.add(strinput);
            strinput = reader.readLine();

        }

        int x = Integer.valueOf(mylist.get(0));

        if (x == 2) {
            System.out.println(x);
        } else if (x == 3) {
            System.out.println(x);

        } else {

            Boolean chkflg = true;

            while (chkflg) {

                //                System.out.println(x);

                if (x % 2 == 0) {
                    x += 1;
                } else {

                    Boolean isPrime = true;
                    for (int i = 3; i < x; i++) {
                        if (x % i == 0) {
                            x += 1;
                            isPrime = false;
                            break;
                        }
                    }

                    if (isPrime) {
                        chkflg = false;
                    }

                }

            }

            System.out.println(x);

        }

    }

}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define int long long

int N, X, Y;

inline int min_distance(int a, int b){
    if(a > b) return min_distance(b, a);
    return min(b - a, abs(X-a)+abs(Y-b)+1);
}

signed main(){
    cin >> N >> X >> Y;
    vector<int> dist(N,0);
    
    reps(i,1,N-1)reps(j,i+1,N){
        dist[min_distance(i, j)]++;
    }
    
    reps(i,1,N-1) cout << dist[i] << endl;
}

Measured memory_bytes: 256
using System;

namespace AizuOnlineJudge {
    class Program {
        static void Main() {
            Console.ReadLine();
            var line = Console.ReadLine().Split();
            Console.ReadLine();
            var count = 0;

            foreach (var t in Console.ReadLine().Split()) {
                foreach (var s in line) {
                    if (t == s) {
                        ++count;
                        break;
                    }
                }
            }

            Console.WriteLine(count);
        }
    }
}



Measured memory_bytes: 17836
#include <bits/stdc++.h>
#define FIN         ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ii          pair<int,int>
#define F           first
#define S           second
#define pb          push_back
#define all(x)      (x).begin(),(x).end()
#define rall(x)     (x).rbegin(),(x).rend()
#define fore(i,a,b) for(int i = a;i < b; i+= 1)
#define forr(i,a)   for(int i = a; i >= 0; i--)
#define fori(i,m)   for(auto i = m.begin(); i != m.end(); i++) 
#define w(t)        while(t--)
#define sz(s)       int(s.size())
#define cls(a,car)  memset(a,car,sizeof (a))
#define db(x)       cerr << #x << " is " << x << '\n'
#define FI          freopen("input.txt", "r", stdin)
#define FO          freopen("output.txt", "w", stdout)
#define EjecuteTime cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n"
#define angle(x)    double(x * acos(-1) / 180.0)
using namespace std;
typedef long long   ll;
typedef vector<int> vi;
typedef vector<ii>  vii;
const int N = 5e5 + 5;
const ll mod = 1e9 + 7;
const double E = 1e-9;
//int dx[] = {0, -1}, dy[] = {-1, 0};
//int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
//int dx[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy[] = {0, 1, 1, 1, 0, -1, -1, -1};
//int dx[] = {2, 1, -1, -2, -2, -1, 1, 2}, dy[] = {1, 2, 2, 1, -1, -2, -2, -1};
// fflush(stdout)
// cout << flush
// a + b = a ^ b + 2 * (a & b)
int main(){
    FIN;
    int n;
    cin >> n;
    int v[n + 1];
    for(int i = 0; i < n; i++){
        cin >> v[i];
    }
    int ans = 0;
    sort(v, v + n);
    for(int  i = 0; i < n; i++)
        for(int j = i + 1; j < n; j++)
            for(int k = j + 1; k < n; k++)
                if(v[i] + v[j] > v[k] && v[i] != v[j] && v[j] != v[k] && v[i] != v[k])
                    ans++;
    cout << ans << '\n';
    //EjecuteTime;
    return 0;
}       


Measured memory_bytes: 3664