akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <sstream>
#include <algorithm>
#include <functional>
#include <iterator>
#include <bitset>
#include <string>
#include <list>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>

typedef   signed long long int slli;
typedef unsigned long long int ulli;
const slli MAX_SLLI = 0x7FFFFFFFFFFFFFFF;
const slli MIN_SLLI = 0x8000000000000000;
const ulli MAX_ULLI = 0xFFFFFFFFFFFFFFFF;
const ulli MIN_ULLI = 0x0000000000000000;

const ulli MOD = 1e+9 + 7;

#define N_TIMES(i, n)     for (ulli i = 0;     i <  n; ++i)
#define N_TIMES_REV(i, n) for (slli i = n - 1; i >= 0; --i)

#ifdef __DEBUG__
template<typename T>
std::ostream& operator<<(std::ostream &os, const std::list<T> &list)
{
  const std::string delim = ", ";
  typename std::list<T>::const_iterator itr = list.begin();
  while (itr != list.end()) {
    os << *itr;
    ++itr;
    if(itr != list.end()) os << delim;
  }
  return os;
}

template<typename T>
std::ostream& operator<<(std::ostream &os, const std::vector<T> &v)
{
  const std::string delim = ", ";
  for (unsigned n = 0; n < v.size(); ++n) {
    os << v[n];
    if((n + 1) < v.size()) os << delim;
  }
  return os;
}
#endif /* __DEBUG__ */

int main()
{
  unsigned N;
  std::cin >> N;
  
  std::string S1, S2;
  std::cin >> S1 >> S2;
  
  unsigned x = (S1[0] == S2[0]) ? 1 : 2;
  ulli count = x * 3;
  while(x < N) {
    if (S1[x] == S2[x]) { // 縦ブロック
      if (S1[x - 1] == S2[x - 1]) { // 縦ブロック
        count = (count * 2) % MOD;
      } else { // 横ブロックx2
        count = (count * 1) % MOD;
      }
      
      x += 1;
    } else { // 横ブロックx2
      if (S1[x - 1] == S2[x - 1]) { // 縦ブロック
        count = (count * 2) % MOD;
      } else { // 横ブロックx2
        count = (count * 3) % MOD;
      }
      
      x += 2;
    }
  }
  
  std::cout << count << std::endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll sum = 0;
ll a[3 * 123456];
bool cmd(ll x, ll y)
{
	return x > y;
}
int n;
inline void _read(int &x)
{
	x = 0;
	char t = getchar();
	while (!isdigit(t)) t = getchar();
	while (isdigit(t))
	{
		x = x * 10 + t - '0';
		t = getchar();
	}
}
inline void _read(ll &x)
{
	x = 0;
	char t = getchar();
	while (!isdigit(t)) t = getchar();
	while (isdigit(t))
	{
		x = x * 10 + t - '0';
		t = getchar();
	}
}
int main()
{
	_read(n);
	for (int i = 1; i <= 3 * n; i++) _read(a[i]);
	int i = 2;
	sort(a + 1, a + 1 + 3 * n, cmd);
	while (n--)
	{
		sum += a[i];
		i += 2;
	}
	printf("%lld", sum);
	return 0;
}

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

typedef long long ll;

int main() {
    int N;
    cin >> N;
    vector<int> P(N);
    for (int i=0;i<N;i++) cin >> P[i];
    for (int i=0;i<N;i++) P[i]--;
    vector<int> idx(N);
    for (int i=0;i<N;i++) idx[P[i]] = i;
    set<int> s;
    ll ans = 0;
    for (int x = N-1;x>=0;x--){
        // 大きい数から順に処理していく
        int i = idx[x];
        // cはある値が２番目に大きくなる区間の個数
        ll c = 0;
        //現在見ている数をsetに入れる
        s.insert(i);
        // lは現在見ている数より大きい左にある数の位置
        // rは現在見ている数より大きい右にある数の位置
        vector<int> l(2,-1);
        vector<int> r(2,N);
        auto it = s.find(i);
        for (int j=0;j<2;j++){
            if (it == s.begin()) break;
            it--;
            l[j] = *it;
        }
        it = s.find(i);
        for (int j=0;j<2;j++){
            it++;
            if (it == s.end()) break;
            r[j] = *it;
        }
        // lsは見ている数から左にある大きな数への区間数
        vector<int> ls(2);
        ls[0] = i - l[0]; ls[1] = l[0] - l[1];
        vector<int> rs(2);
        rs[0] = r[0] - i; rs[1] = r[1] -r[0];
        //自分より大きい数を１個だけ含む区間数
        c = (ll)ls[0]*rs[1] + (ll)ls[1]*rs[0];

        ans += c*(x+1);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
#define FOR(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define FORUL(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#define FORULE(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define FOREACH(it, X) for(__typeof((X).begin()) it = (X).begin(); it != (X).end(); it++)
#if defined(_MSC_VER) || __cplusplus > 199711L
#define AUTOVAR(newvar,v) auto newvar = (v)
#else
#define AUTOVAR(newvar,v) __typeof(newvar) r = (v)
#endif
#define PB(x) push_back(x)
#define MP(x,y) make_pair((x),(y))
#define MEMSET(m,v) memset(m,v,sizeof(m))

typedef long long				 ll;
typedef unsigned long long		ull;

#define DEBUG 1

#if DEBUG
#define DOUT cout<<"["<<__LINE__<<"]:"
#else
#define DOUT 0 && cout
#endif

using namespace std;

int N, M;
vector<vector<int> > jobs;

int main(int argc, char *argv[])
{
	ios::sync_with_stdio(false);

	cin >> N >> M;
	jobs.resize(M);
	for(int n=0; n<N; n++) {
		int a,b;
		cin >> a >> b;
		if (M-a<0) {
			continue;
		}
		jobs[M-a].push_back(b);
	}

	int ans = 0;
	priority_queue<int> q;
	for(int m=M-1; m>=0; m--) {
		for(vector<int>::iterator it=jobs[m].begin();
				it!=jobs[m].end(); it++) {
			q.push(*it);
		}
		if (!q.empty()) {
			ans += q.top();
			q.pop();
		}
	}
	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 5632
//CODE FESTIVAL 2016 qual C A
#include <bits/stdc++.h>
using namespace std;

int main(){
	char s[123];
	int a = 0;
	for(int i=0; i<123; i++){
		s[i] = 0;
	}
	scanf("%s", s);
	for(int i=0; i<123; i++){
		if(s[i] == 'C' && a == 0){
			for(int j=i; j<123; j++){
				if(s[j] == 'F'){
					printf("Yes");
					a = 1;
					break;
				}
			}
		}
	}
	if(a == 0) printf("No");
}

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

#define int long long

const int MOD = 1e9 + 7;

signed main()
{
  int n;
  int kanade = 1;

  cin >> n;
  for (int i = 1; i <= n; i++) {
    kanade = i * kanade % MOD;
  }

  cout << kanade << endl;

  return (0);
}

Measured memory_bytes: 256
function PriorityQueue(){
    this.heap = [];
}
PriorityQueue.prototype = {
    push : function(x){
        var h = this.heap, i = h.length++, j;
        while(i){
            j = i-1 >> 1;
            if(h[j] <= x)break;
            h[i] = h[j];
            i = j;
        }
        h[i] = x;
    },
    pop : function(){
        var h = this.heap, r = h[0], x = h.pop();
        var i = 0, k = h.length >> 1, j;
        while (i < k) {
            j = (i << 1) + 1;
            if(h[j+1] < h[j])++j;
            if(x <= h[j])break;
            h[i] = h[j];
            i = j;
        }
        if(h.length)h[i] = x;
        return r;
    },
    size : function(){return this.heap.length;},
    top : function(){return this.heap[0];},
};

function main(input) {
    var args = input.trim().split("\n");
    var info = args[0].split(" ").map((v) => parseInt(v));
    var N = info[0]; // 個数
    var M = info[1]; // 割引券
    var As = args[1].split(" ").map((v) => parseInt(v)); // 値段

    if (N === 1) {
        console.log(Math.floor(As[0] / Math.pow(2, M)));
        return;
    }

    var pq = new PriorityQueue();

    for (var i = 0; As.length > i; i++) {
        pq.push(-As[i]);
    }

    for(var j = 0; M > j; j++) {
        var max = -pq.pop();
        pq.push(-(Math.floor(max / 2)));
    }

    var result = 0;
    while(pq.size() > 0) {
        result += -pq.pop();
    }

    console.log(result);
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

template<typename T>
struct edge {
    int to;
    T cost;
    bool operator > (const edge &r) const { return cost > r.cost; }
};

template<typename T>
vector<T> Dijkstra(int s, const vector<vector<edge<T>>> &g) {
    int n = g.size();
    const T INF = numeric_limits<T>::max();
    using E = edge<T>;
    vector<T> dist(n,INF);
    priority_queue<E, vector<E>, greater<E>> que;
    dist[s] = 0;
    que.push({s,0});
    while(!que.empty()) {
        E now = que.top(); que.pop();
        if(dist[now.to] < now.cost) continue;
        for(auto next : g[now.to]) {
            if(dist[next.to] > dist[now.to] + next.cost) {
                dist[next.to] = dist[now.to] + next.cost;
                que.push({next.to, dist[next.to]});
            }
        }
    }
    return dist;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int v,e,r; cin >> v >> e >> r;
    vector<vector<edge<ll>>> g(v);
    for(int i = 0; i < e; ++i) {
        ll s,t, d; cin >> s >> t >> d;
        g[s].push_back({(int)t,d});
    }
    vector<ll> dist = Dijkstra(r,g);
    for(int i = 0; i < v; ++i) {
        ll ans = dist[i];
        if(ans>=numeric_limits<ll>::max()) cout << "INF" <<'\n';
        else cout << ans << '\n';
    }
    return 0;
}


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

#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

#define MAXX 100005

#define PI 3.14159265358979323846264338327950

#define ll signed long long int

ll c[MAXX], o;
multiset<ll> ms;
multiset<ll>::iterator it;
signed main()
{
    FAST;
    string s;
    ll t;
    ll n;
    cin >> n >> t;
    cin >> s;
    ll ans, h = 0;
    for(int i = 1; i < n; i++){
        c[i + 1] = c[i];
        if(s[i - 1] == 'A' && s[i] == 'C')
            c[i + 1]++;
    }
    while(t--){
    	ll a, b;
        cin >> a >> b;
        cout << (c[b] - c[a]) << endl;
    }
}

Measured memory_bytes: 1872
#include<iostream>
#include<cstdio>
#include<algorithm>
#define ll long long
#define N 123456
using namespace std;
ll n,a,b,A[N],ans;
int main()
{
	scanf("%lld%lld%lld",&n,&a,&b);
	for(int i=1;i<=n;i++) scanf("%lld",&A[i]);
	for(int i=1;i<n;i++)
		ans += min(a*(A[i+1]-A[i]),b);
	printf("%lld\n",ans);
	return 0; 
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
typedef long long ll;

int main(){
    int a,b,c;
    cin >> a >> b;
    c=a*b;
    int ans;
    if(c==6){
        ans=1;
    }else if(c==3){
        ans=2;
    }else {
        ans=3;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
bool cmp(int x,int y){
	return x>y;	
}
int main(){
	int a,b,c,A[3];
	cin>>a>>b>>c;
	A[0]=abs(a-b),A[1]=abs(a-c),A[2]=abs(b-c);
	sort(A,A+3);//5 2 3
	cout<<A[0]+A[1]<<endl;
	return 0;	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
long long m[1005][1005];
int main()
{
    int r, s;
    cin >> r >> s;
    char n[r][s];
    for(int i = 0; i < r; i++)
    {
    	for(int j = 0; j < s; j++)
    	{
    		cin >> n[i][j];
		}
	}
	m[0][0] = 1;
    for(int i = 0; i < r; i++)
    {
    	for(int j = 0; j < s; j++)
    	{
		    if(n[i][j] == '.')
			{
				if(i > 0)
				{
					m[i][j] += m[i-1][j];
				}
				if(j > 0)
				{
					m[i][j] += m[i][j-1];
				}
				if(m[i][j] > MOD)
				{
					m[i][j] -= MOD;
				}
			}
		}
	}
	cout << m[r-1][s-1] << endl;
}



Measured memory_bytes: 9088
#include <stdio.h>
int A[2000];
int n;

int main(){
  int i,q,mi,judge;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&mi);
    judge=solve(0,mi);
    if(judge==1){
      printf("yes\n");
    }
    else if(judge==0){
      printf("no\n");
    }
  }
  return 0;
}

int solve(int i, int m){
  int res;
  if(m==0){
    return 1;
  }
  if(i>=n){
    return 0;
  }
  if(solve(i+1,m) || solve(i+1,m-A[i]))
    return 1;
  else
    return 0;
  
}

Measured memory_bytes: 580
<?php
$n = trim(fgets(STDIN));
$ans = array_fill(1, $n, 0);
$x = 1;
while ($x < 100) {
    $y = 1;
    while ($y < 100) {
        $z = 1;
        while ($z < 100) {
            $p = $x * $x + $y * $y + $z * $z + $x * $y + $y * $z + $z * $x;
            if ($p <= $n) {
                ++$ans[$p];
            } else {
                $z = 100;
            }
            ++$z;
        }
        ++$y;
    }
    ++$x;
}
echo join("\n", $ans);


Measured memory_bytes: 16588
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>
#include <numeric>

using namespace std;

#define mod 1000000007

// seiyaku[i][0] : 値iは行seiyaku[i][0]で最大値でないといけない
// seiyaku[i][1] : 値iは列seiyaku[i][0]で最大値でないといけない
int seiyaku[1000001][2] = {};

int main()
{
	int n, m;
	cin >> n >> m;
	long long int ans = 1;
	for(int i = 1; i <= n; i++){
		int a;
		cin >> a;
		if(seiyaku[a][0] > 0) ans = 0;
		else seiyaku[a][0] = i;
	}
	for(int i = 1; i <= m; i++){
		int b;
		cin >> b;
		if(seiyaku[b][1] > 0) ans = 0;
		else seiyaku[b][1] = i;
	}
	// i行目にはすでに最大値が埋められている
	bool alreadymax_g[1001];
	// i列目にはすでに最大値が埋められている
	bool alreadymax_r[1001];
	for(int i = 1; i <= n; i++){
		alreadymax_g[i] = false;
	}
	for(int i = 1; i <= m; i++){
		alreadymax_r[i] = false;
	}

	for(int i = n * m; i>= 1; i--){
		int g = seiyaku[i][0];
		int r = seiyaku[i][1];
		if(g > 0 && r > 0){
			// 行と列どちらにも制約がある(最大値となる)場合
			// g行目r列目にiを埋めないといけない
			if(alreadymax_g[g] || alreadymax_r[r]){
				ans = 0;
			} else {
				alreadymax_g[g] = true;
				alreadymax_r[r] = true;
			}
		} else if(g > 0 && r == 0){
			// 行にのみ制約がある場合
			// g行目に埋めることは確定しているが、列は確定していない
			if(alreadymax_g[g]){
				// g行目にすでに最大値が埋まっていたらアウト
				ans = 0;
			} else {
				alreadymax_g[g] = true;
				// g行目で制約を気にせず入れられるマスの数を求める
				int tmp = 0;
				for(int j = 1; j <= m; j++){
					if(alreadymax_r[j]) tmp++;
				}
				ans = (ans * tmp) % mod;
			}
		} else if(g == 0 && r > 0){
			// 列のみに制約がある場合
			// 上と同様
			if(alreadymax_r[r]){
				ans = 0;
			} else {
				alreadymax_r[r] = true;
				int tmp = 0;
				for(int j = 1; j <= n; j++){
					if(alreadymax_g[j]) tmp++;
				}
				ans = (ans * tmp) % mod;
			}
		} else {
			// 行にも列にも制約がない場合
			int tmp_g = 0;
			int tmp_r = 0;
			for(int j = 1; j <= n; j++){
				if(alreadymax_g[j]) tmp_g++;
			}
			for(int j = 1; j <= m; j++){
				if(alreadymax_r[j]) tmp_r++;
			}
			ans =(ans * (tmp_r * tmp_g - (n * m - i))) % mod;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 384
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>

int main() {
	int H[300];
	int W[300];
	int count;
	int i = 0;

	while (1) {
		std::cin >> H[i] >> W[i];
		if (H[i] == 0 && W[i] == 0) {
			count = i;
			break;
		}
		i++;
	}

	for (i = 0; i < count; i++) {
		for (int j = 0; j < H[i]; j++) {
			for (int k = 0; k < W[i]; k++) {
				if (j != 0 && j != H[i] - 1) {
					if (k != 0 && k != W[i] - 1) {
						std::cout << '.';
						continue;
					}
				}
				std::cout << '#';
			}
			std::cout << '\n';
		}
		std::cout << '\n';
	}

	return 0;
}

Measured memory_bytes: 3040
fun main(args: Array<String>) {
    Program().solve()
}

class Program {
    fun solve() {
        val sc = MyScanner()
        val n = sc.nextInt()
        val a = Array(n) { 0 }
        val b = Array(n) { 0 }
        for (i in 0 until n) {
            a[i] = sc.nextInt()
            b[i] = sc.nextInt()
        }

        val sorted = Array(n) { it }.sortedBy { b[it] }
        var time = 0
        for (t in 0 until n) {
            val i = sorted[t]
            if (time + a[i] > b[i]) {
                println("No")
                return
            }
            time += a[i]
        }
        println("Yes")
    }
}


class MyScanner() {
    private var index = 0
    private var line = listOf<String>()

    fun next(): String {
        while (line.size <= index) {
            line = readLine()!!.split(' ')
            index = 0
        }
        return line[index++]
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextDouble() = next().toDouble()
    fun nextCharArray() = next().toCharArray()
    fun nextChar() = next()[0]

    fun strList(): List<String> {
        index = line.size
        return readLine()!!.split(' ')
    }

    fun intList() = strList().map { it.toInt() }
    fun longList() = strList().map { it.toLong() }
    fun doubleList() = strList().map { it.toDouble() }
}

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

int main()
{
    int N, A, B;
    cin >> N >> A >> B;
    std::string S;
    cin >> S;

    int a = 0, b = 0;
    for (int i = 0; i < N; ++i)
    {
        switch (S[i])
        {
        case 'a':
            if (a + b < A + B)
            {
                a++;
                cout << "Yes" << endl;
            }
            else
            {
                cout << "No" << endl;
            }
            break;
        case 'b':
            if (a + b < A + B && b < B)
            {
                b++;
                cout << "Yes" << endl;
            }
            else
            {
                cout << "No" << endl;
            }
            break;
        case 'c':
            cout << "No" << endl;
            break;
        default:
            break;
        }
    }

    return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstring>
#include <chrono>
#include <complex>
#define endl "\n"
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 1000000000000000001;
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define f first
#define s second

using namespace std;
int main()
{
	string str, qtr;
	cin >> str >> qtr;
	if (str == qtr) {
		cout << "0" << endl;
	}
	else {
		int ans = 0;
		for (int i = 0; i < str.size(); i++) {
			if (str[i] != qtr[i]) ans++;
		}
		cout << ans << endl;
	}
}


Measured memory_bytes: 3920
//------------------------------------------
// C++ templete 
//------------------------------------------
#include <bits/stdc++.h>
using namespace std;

#define endl "\n"

//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

//REPEAT
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//container util
//------------------------------------------
#define pb push_back
#define paired make_pair
#define ALL(a) (a).begin(),(a).end()
#define PRINT(V) for (auto v : (V)) cout << v << " "
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())

//constant
//------------------------------------------
const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

//math
//------------------------------------------
int QP(int a,int b){int ans=1;do{if(b&1)ans=1ll*ans*a%MOD;a=1ll*a*a%MOD;}while(b>>=1);return ans;}
int QP(int a,int b,int MOD){int ans=1;do{if(b&1)ans=1ll*ans*a%MOD;a=1ll*a*a%MOD;}while(b>>=1);return ans;}
int GCD(int a,int b){return b?GCD(b,a%b):a;}

//debug
//------------------------------------------
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//grobal variable
//------------------------------------------
int N,M;
VI Vec;

//動的計画法で役に立つ関数
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() 
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    int N; cin >> N;

    int n_a=0, n_b=0, n_ab=0, n_a_b=0;;

    REP(i, N)
    {
        string s;cin >> s;
        if (s.front() == 'B' && s.back() != 'A') n_b++;
        if (s.back() == 'A' ) 
        {
            if (s.front() == 'B') n_a_b++;
            else n_a++;
        }
        bool was_A = false;
        for (auto c : s)
        {
            if (was_A && c=='B') n_ab++;
            if (c=='A') was_A=true;
            else was_A=false;
        }
    }
    if (n_a!=0 || n_b!=0) cout << n_ab+min(n_a+n_a_b, n_b+n_a_b) << endl;
    else if (n_a_b != 0) cout << n_ab+n_a_b-1<<endl;
    else cout << n_ab << endl;
    return 0;
}



Measured memory_bytes: 256
def solve(string):
    n, m, q, *lrpq = map(int, string.split())
    lr, pq = lrpq[:2 * m], lrpq[2 * m:]
    t = [[0] * (n + 1) for _ in range(n + 1)]
    for l, r in zip(lr[::2], lr[1::2]):
        t[l][r] += 1
    for i in range(n + 1):
        for j in range(n + 1):
            if j > 0:
                t[i][j] += t[i][j - 1]

    ans = [
        str(sum([t[i][q] - t[i][p - 1]
                 for i in range(p, q + 1)]))
        for p, q in zip(pq[::2], pq[1::2])
    ]
    return "\n".join(ans)


if __name__ == '__main__':
    n, m, q = map(int, input().split())
    print(solve('{} {} {}\n'.format(n, m, q) + '\n'.join([input() for _ in range(m + q)])))


Measured memory_bytes: 138104
#include <bits/stdc++.h>
#define fo(i,a,b) for(int i=a;i<=b;++i)
#define fod(i,a,b) for(int i=a;i>=b;--i)
const int N=2115;
const int INF=1e7;
typedef long long LL;
using namespace std;
vector <int> ap[N];
int n,n1,st,ed,f[N][N];
LL ans,pr[N][N];
void link(int x,int y,int w,LL c)
{
	ap[x].push_back(y);
	f[x][y]=w,pr[x][y]=c;
	ap[y].push_back(x);
	f[y][x]=0,pr[y][x]=-c;
}
typedef vector<int>::iterator IT;
namespace Flow
{
	LL dis[N];
	bool bz[N];
	IT cur[N];
	int d[200*N];
	bool spfa()
	{
		memset(dis,107,sizeof(dis));
		memset(bz,0,sizeof(bz));
		dis[st]=0,bz[st]=1,d[1]=st;
		fo(i,1,n1) cur[i]=ap[i].begin();
		int l=0,r=1;
		while(l<r)
		{
			int k=d[++l];
			for(IT i=ap[k].begin();i!=ap[k].end();i++)	
			{
				int p=*i;
				if(f[k][p]&&dis[k]+pr[k][p]<dis[p]) 
				{
					dis[p]=dis[k]+pr[k][p];
					if(!bz[p]) bz[p]=1,d[++r]=p;
				}
			}
			bz[k]=0;
		}
		return (dis[ed]<=1e17);
	}
	int flow(int k,int s)
	{
		if(k==ed) return s;
		int sl=0,v;
		bz[k]=1;
		for(;cur[k]!=ap[k].end();cur[k]++)
		{
			int p=*cur[k];
			if(!bz[p]&&f[k][p]&&dis[p]==dis[k]+pr[k][p]) 
			{
				if(v=flow(p,min(s,f[k][p]))) 
				{
					sl+=v,s-=v;
					f[k][p]-=v,f[p][k]+=v;
					ans+=(LL)v*pr[k][p];
					if(!s) break;
				}
			}
		}
		bz[k]=0;
		return sl;
	}
}
using Flow::flow;
using Flow::spfa;
int main()
{	
	cin>>n;
	n1=2*n+6,st=2*n+5,ed=n1;
	fo(i,1,n) 
	{
		int x,y,z;
		scanf("%d%d%d",&x,&y,&z);
		link(st,i,z,0);
		link(i,2*n+1,z,x+y);
		link(i,2*n+2,z,x-y);
		link(i,2*n+3,z,-x+y);
		link(i,2*n+4,z,-x-y);
	}  
	fo(i,1,n) 
	{
		int x,y,z;
		scanf("%d%d%d",&x,&y,&z);
		link(i+n,ed,z,0);
		link(2*n+1,i+n,z,-x-y);
		link(2*n+2,i+n,z,-x+y);
		link(2*n+3,i+n,z,x-y);
		link(2*n+4,i+n,z,x+y);
	}
	ans=0;
	while(spfa()) 
		flow(st,INF);
	printf("%lld\n",-ans);
}

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

#define int long long
#define double long double
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define all(x) (x).begin(), (x).end()
#define uniq(x) (x).erase(unique(all(x)), (x).end())
#define bit(n) (1LL << (n))
#define dump(x) cerr << #x " = " << (x) << endl
using vint=vector<int>;
using vvint=vector<vint>;
using pint=pair<int, int>;
using vpint=vector<pint>;
template<typename T> using priority_queue_rev=priority_queue<T, vector<T>, greater<T>>;
constexpr double pi = 3.1415926535897932384626433832795028;
constexpr int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T1, typename T2> bool chmax(T1 &a, const T2 &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T1, typename T2> bool chmin(T1 &a, const T2 &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

int N, K;
int H[330];
int dp[330][330][330];
signed main() {
    cin >> N >> K;
    reps(i, N) { cin >> H[i]; }
    rep(i, 330)rep(j, 330)rep(k, 330) { dp[i][j][k] = LLONG_MAX; }
    dp[0][0][0] = 0;
    rep(i, N) {
        rep(j, N) {
            rep(k, N) {
                if (dp[i][j][k] == LLONG_MAX) { continue; }
                chmin(dp[i + 1][j + 1][k], dp[i][j][k]);
                int x = 0;
                if (H[k] <= H[i + 1]) { x = H[i + 1] - H[k]; }
                chmin(dp[i + 1][j][i + 1], dp[i][j][k] + x);
            }
        }
    }
    int ans = LLONG_MAX;
    for (int i = 0; i <= N; i++) { chmin(ans, dp[N][K][i]); }
    cout << ans << endl;
}


Measured memory_bytes: 281088
#include "bits/stdc++.h"
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define put(a) cout<<a<<"\n"
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }


int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	REP(i, n) {
		cin >> a[i];
	}
	vector<int> res;
	vector<int> p(n+1, 0);
	RREP(i, n) {
		int cnt = 0;
		for (int j = i+1; j <= n; j+=i+1) {
			if (p[j] == 1)cnt++;
		}
		if (cnt % 2 != a[i]) {
			p[i+1] = 1;
		}
	}
	REP(i, n) {
		if (p[i + 1] == 1) {
			res.push_back(i+1);
		}
	}
	int m = res.size();
	put(res.size());
	REP(i, m) {
		put(res[i]);
	}
	return 0;
}


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

#define REP(i,m,n) for(int i=(m); i<(int)(n); i++)
#define RREP(i,m,n) for(int i=(int)(n-1); i>=m; i--)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) RREP(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define fi first
#define se second
#define debug(...) {cerr<<"[L"<<__LINE__<<"] "; _debug(__VA_ARGS__);}

template<typename T>
string join(const vector<T>&v, string del=", "){ stringstream s;
    for(auto x : v) s << del << x; return s.str().substr(del.size());
}
template<typename T>
ostream& operator<<(ostream& o, const vector<T>&v){
    if(v.size()) o << "[" << join(v) << "]"; return o;
}
template<typename T>
ostream& operator<<(ostream& o, const vector<vector<T> >&vv){
    int l = vv.size();
    if(l){ o<<endl; rep(i,l) o << (i==0 ? "[ " : ",\n  " ) << vv[i] << (i==l-1 ? " ]" : ""); }
    return o;
}
inline void _debug(){cerr<<endl;}
template<class First, class... Rest>
void _debug(const First& first, const Rest&... rest){cerr<<first<<" ";_debug(rest...);}

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;

const double PI = (1*acos(0.0));
const double EPS = 1e-9;
const int INF = 0x3f3f3f3f;
const ll INFL = 0x3f3f3f3f3f3f3f3fLL;
const ll mod = 1e9 + 7;

inline void finput(string filename) {
    freopen(filename.c_str(), "r", stdin);
}

int n,m,s;
vector<tuple<ll,ll,ll>> g[50];
pll ts[50];
int main(){
    ios_base::sync_with_stdio(0);
    // finput("./input");
    cin >> n >> m >> s;
    rep(i,m){
        int u,v,a,b;
        cin >> u >> v >> a >> b;
        u--; v--;
        g[u].emplace_back(v,a,b);
        g[v].emplace_back(u,a,b);
    }
    rep(i,n){
        int c,d;
        cin >> c >> d;
        ts[i] = pll(c, d);
    }

    vvl dp(n, vl(n*50, INFL));
    dp[0][min(n*50-1, s)] = 0;
    queue<ll> Q;
    Q.push(0);
    while(!Q.empty()){
        int v = Q.front(); Q.pop();
        rep(i,n*50){
            int c = ts[v].fi, d = ts[v].se;
            if(i-c >= 0) dp[v][i] = min(dp[v][i], dp[v][i-c] + d);
        }
        for(auto tup : g[v]){
            int u = get<0>(tup);
            ll a = get<1>(tup);
            ll b = get<2>(tup);
            bool update = false;
            rep(i,n*50){
                if(i+a < n*50 && dp[u][i] > dp[v][i+a] + b){
                    dp[u][i] = dp[v][i+a] + b;
                    update = true;
                }
            }
            if(update) Q.push(u);
        }
    }
    REP(i,1,n){
        cout << *min_element(all(dp[i])) << endl;
    }
    return 0;
}

Measured memory_bytes: 4308
#include <stdio.h>
#define NXMAX 50
int main(void)
{
  int i, j, n, a, x;
  long long dp[2][NXMAX*NXMAX*2+1] = {0};
  scanf("%d %d", &n, &a);
  dp[0][NXMAX*NXMAX] = 1;
  for (i = 0; i < n; i++) {
    scanf("%d", &x);
    x -= a;
    for (j = NXMAX; j + NXMAX <= NXMAX * NXMAX * 2; j++) {
      dp[(i+1)&1][j] = dp[i&1][j] + dp[i&1][j-x];
    }
  }
  printf("%lld\n", dp[i&1][NXMAX*NXMAX] - 1);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
//int  t,nr,ng,nb;
ll sq(int x){return 1ll*x*x;}
#define mod 1000000007
/*void solve(vector<int>a,vector<int>b,vector<int>c)
{
  for(auto x:a)
  {
   auto y=lower_bound(b.begin(),b.end(),x);
   auto z=upper_bound(c.begin(),c.end(),x);
   if(y==b.end()||z==c.begin())
        continue;
   z--;
   ans=min(ans,sq(x-*y)+sq(*y-*z)+sq(x-*z));
  }

}*/
int main()
{ios_base::sync_with_stdio(false);
ll n;
cin>>n;
ll ans[n+1]={0};
ll temp;
for(ll i=0;i<n-1;i++)
{
    cin>>temp;ans[temp]++;
}
for(ll i=1;i<n+1;i++)
    cout<<ans[i]<<endl;
}


Measured memory_bytes: 5176
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef tuple<int,int,int> tii;
#define rep(i,s,n) for(int i=(int)(s);i<(int)(n);i++)

int main(){
  ll N,M; cin >> N >> M;
  priority_queue<ll> pque;
  for(int i=0;i<N;i++){
    ll x; cin >> x;
    pque.push(x);
  }
  for(int i=0;i<M;i++){
    ll y = pque.top();
    pque.pop();
    pque.push(y/2);
  }
  ll ans = 0;
  for(int i=0;i<N;i++){
    ll z = pque.top();
    pque.pop();
    ans += z;
  }
  cout << ans << endl;
}


Measured memory_bytes: 4252
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include<iomanip>
#include<sstream>
#include <fstream>
#define ll long long
#define pb push_back
#define clr(a, b) memset((a), (b), sizeof(a))
#define debugs(x) cout << "Line" << __LINE__ << "	" << #x << "=" << x << endl
#define break break
#define continue continue
#define itn int
#define endl '\n'
#define Endl endl
#define vint vector<int>
#define pii pair<int, int> 
using namespace std;

int n, k, m;
void solve(int T)
{
	cin >> n;
	cout << (int)ceil(1.0*n / 1000) * 1000 - n << endl;
}
int main()
{
	std::ios::sync_with_stdio(false);
	cin.tie(NULL);
	int numoftest = 1;

	//cin >> numoftest;


	for (int siven = 1; siven <= numoftest; ++siven)
		solve(siven);
	return 0;
}

/*


*/

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

int main(){
  string a,b;
  cin >> a >> b;
  if(a.size()<b.size()) cout << "LESS" << endl;
  else if(a.size()>b.size()) cout << "GREATER" << endl;
  else{
      for(int i=0;i<a.size();i++){
          if(a[i]<b[i]){
              cout << "LESS" << endl;
              return 0;
          }
          else if(a[i]>b[i]){
              cout << "GREATER" << endl;
              return 0;
          }
          else continue;
      }
      cout << "EQUAL" << endl;
      return 0;
  }
}


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

int n,a[205];

int main() {
    cin>>n;
    for(int i=1;i<=2*n;i++) cin>>a[i];
    sort(a+1,a+2*n+1);
    int ans =0 ;
    for(int i=1;i<=n;i++) ans+=min(a[i*2-1],a[i*2]);
    cout<<ans<<endl;
}


Measured memory_bytes: 256
a = int(input())

if (a % 10 == 3):
    print('bon')
elif (a % 10 == 0):
    print('pon')
elif (a % 10 == 1):
    print('pon')
elif (a % 10 == 6):
    print('pon')
elif (a % 10 == 8):
    print('pon')
else:
    print('hon')

Measured memory_bytes: 9124
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
#include <stdio.h>
#include <stack>
#include <queue>
#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
#include <fstream>
#include <list>
#include <cctype>

using namespace std;

#define Int int64_t

void printVec(std::vector<int>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec1(std::vector<string>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
	vector.erase(vector.begin() + index);
}

int vector_finder(std::vector<string> vec, string number) {
	auto itr = std::find(vec.begin(), vec.end(), number);
	size_t index = std::distance(vec.begin(), itr);
	if (index != vec.size()) { // 発見できたとき
		return 1;
	}
	else { // 発見できなかったとき
		return 0;
	}
}

#include <sstream> 
std::vector<std::string> StringSplit(const std::string& str, char sep)
{
	std::vector<std::string> v;
	std::stringstream ss(str);
	std::string buffer;
	while (std::getline(ss, buffer, sep)) {
		v.push_back(buffer);
	}
	return v;
}

Int gcd(Int a, Int b) {
	return b != 0 ? gcd(b, a % b) : a;
}
Int lcm(Int a, Int b) {
	return a * b / gcd(a, b);
}

int main() {
	string s; cin >> s;
	for (int i = 1; i <= s.size(); i++) {
		if (i % 2 == 1) cout << s[i-1];
	}




	


	cout << endl;
	return 0;
}

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

using namespace std;

#define REP(i, N) for (int (i) = 0; (i) < (N); ++(i))
#define READALL(c) for (auto &e : c) { cin >> e; }
#define PRINTALL(c) for (const auto &e : c) { cout << e << "\t"; } cout << "\n";

template <typename T>
using V = vector<T>;

typedef long double ld;

int64_t N, M, K;



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

	cin >> N >> M >> K;

	set<int64_t> yee;


	REP(i, N) {
		int64_t cnt = i*M+M;
		yee.insert(cnt);
		REP(j, M) {
			cnt -= i+1;
			cnt += N-(i+1);
			yee.insert(cnt);
		}
	}

	REP(i, M) {
		int64_t cnt = i*N+N;
		yee.insert(cnt);
		REP(j, N) {
			cnt -= i+1;
			cnt += M-(i+1);
			yee.insert(cnt);
		}
	}

	cout << (yee.count(K) ? "Yes" : "No") << endl;

	// for (int N = 1; N < 12; ++N) {
	// 	for (int M = 1; M < 12; ++M) {
	// 		set<int> yee;


	// 		REP(i, N) {
	// 			int cnt = i*M+M;
	// 			yee.insert(cnt);
	// 			REP(j, M) {
	// 				cnt -= i+1;
	// 				cnt += N-(i+1);
	// 				yee.insert(cnt);
	// 			}
	// 		}

	// 		REP(i, M) {
	// 			int cnt = i*N+N;
	// 			yee.insert(cnt);
	// 			REP(j, N) {
	// 				cnt -= i+1;
	// 				cnt += M-(i+1);
	// 				yee.insert(cnt);
	// 			}
	// 		}

	// 		// for (int c : yee) {
	// 		// 	cout << c << endl;
	// 		// }


	// 		V<V<int>> init(N, V<int>(M));
	// 		set<V<V<int>>> vis = {init};
	// 		queue<V<V<int>>> Q;
	// 		Q.push(init);
	// 		set<int> memes;
	// 		while (Q.size()) {
	// 			auto gr = Q.front();
	// 			Q.pop();
	// 			int cnt = 0;
	// 			REP(i, N) REP(j, M) cnt += gr[i][j];
	// 			memes.insert(cnt);
	// 			REP(i, N) {
	// 				auto tmp = gr;
	// 				REP(j, M) {
	// 					tmp[i][j] = !gr[i][j];
	// 				}
	// 				if (!vis.count(tmp)) {
	// 					vis.insert(tmp);
	// 					Q.push(tmp);
	// 				}
	// 			}

	// 			REP(j, M) {
	// 				auto tmp = gr;
	// 				REP(i, N) {
	// 					tmp[i][j] = !gr[i][j];
	// 				}
	// 				if (!vis.count(tmp)) {
	// 					vis.insert(tmp);
	// 					Q.push(tmp);
	// 				}
	// 			}
	// 		}

	// 		// for (int c : memes) {
	// 		// 	cout << c << endl;
	// 		// }

	// 		cout << N << " " << M << " " << yee.size() << endl;

	// 		assert(yee == memes);
	// 	}
	// }


	
}

Measured memory_bytes: 13056
import sys
sys.setrecursionlimit(10**9)
INF=10**18
def input():
    return sys.stdin.readline().rstrip()

def main():
    N=int(input())
    for i in range(1,50001):
        if (i*1.08)//1 == N:
            print(i)
            exit()
    print(':(')

if __name__ == '__main__':
    main()


Measured memory_bytes: 39536
#include <bits/stdc++.h>
using namespace std;
int main() {
  
  int N;
  cin >> N;
  vector<int> vec(N);
  int sum = 1;
  
  for(int i = 0 ; i < N ; i++){
    cin >> vec.at(i);
  }
  
  sort(vec.begin(), vec.end());
  reverse(vec.begin(),vec.end());
  
  for(int i = 0 ; i < N-1 ; i++){
    if(vec.at(i) != vec.at(i+1)){
      sum ++;
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
while (n, x = gets.chomp.split.map(&:to_i)) != [0, 0]
  comb = []
  1.upto(n) do |first|
    1.upto(n) do |second|
      next if second <= first
      1.upto(n) do |third|
        next if third <= second
        comb << [first, second, third] if first + second + third == x
      end
    end
  end
  puts comb.size
end



Measured memory_bytes: 6960
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
/////////

typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;

////定数
const int INF = (int)1e9 + 10;
const LL MOD = (LL)1e9 + 7;
const LL LINF = (LL)4e18 + 20;
const LD PI = acos(-1.0);
const double EPS = 1e-9; 
/////////
using namespace::std;
template<typename T>
void chmax(T& a, T b) {
	a = max(a, b);
}

template<typename T>
void chmin(T& a, T b) {
	a = min(a, b);
}

template<typename T>
void IN(vector<T> &A,int N=-1) {
	if (N == -1) {
		N = A.size();
	}
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
	}
}

template<typename T>
void SO(vector<T> &A,bool F=false) {
	sort(A.begin(), A.end());
	if (F) {
		reverse(A.begin(), A.end());
	}
}
//////////////

void solve() {
	int N;
	cin >> N;
	if (N % 2 == 0) {
		LD a = N;
		cout << (LD)1 / 2;
	}
	else {//
		LD ans = (LD)(N/2 + 1) / N;
		cout << ans << endl;
	}
}

signed main(void) {
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
typedef long long int ll;
const int N = 1e5 + 5;
//const int INF = 1e9 + 5;
//int a[N];
void solve_test_case(){
	ll n;
	cin>>n;
	cout<<(!(n%1000)? 0 : (1000 - (n%1000)))<<"\n";
}
 
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int t = 1;
	// cin>>t;
	for(int i = 0;i < t;++i){
		solve_test_case();
	}
}


Measured memory_bytes: 3640
n = int(input())
 
if n%2 == 0:
    print(0.5)    #整数Nが偶数のとき
else:
    s = (n-1)/2    #偶数の数を確認
    s /= n    #nで割って偶数の確率を求める
    print(1-s)    #全体から偶数の確率を引いて奇数の確率を求める

Measured memory_bytes: 2940
import math
n,k = map(int,input().split())
twos = [1]
i = 0
while 2*twos[i] <= 10**5:
    twos.append(twos[i]*2)
    i += 1
twos.append(twos[-1]*2)

ans = 0
for i in range(1,n+1):
    temp = 0
    while twos[temp] * i <= k-1:
        temp += 1
    ans += 1/n * 1/twos[temp]
print(ans)

Measured memory_bytes: 3064
import fractions
n = int(input())
a = list(map(int, input().split()))
gcd = 0
for i in a:
    gcd = fractions.gcd(gcd, i)
cnt = 0
while True:
    if gcd % 2 == 0:
        gcd //= 2
        cnt += 1
    else:
        print(cnt)
        exit()


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

using namespace std;

using ll = long long;
const int N = 13;
const int M = 1001;
bool visited[N];
ll dp[M][1 << N];
int n, m, c[M], b[M][N];

ll solve(int kkey, int mask) {
    if (kkey == m) {
        if (mask == (1LL << n) - 1) {
            return 0;
        } else {
            return 1e15;
        }
    }
    ll& ans = dp[kkey][mask];
    if (ans != -1) {
        return ans;
    }
    ans = 1e18;
    int newMask = mask;
    for (int i = 0; i < n; i++) {
        if (b[kkey][i]) {
            newMask |= (1 << i);
        }
    }
    ans = min(ans, min(solve(kkey + 1, mask), solve(kkey + 1, newMask) + c[kkey]));
    return ans;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> n >> m;
    for (int i = 0; i < m; i++) {
        cin >> c[i];
        int k;
        cin >> k;
        for (int j = 0; j < k; j++) {
            int x;
            cin >> x;
            b[i][x - 1] = true;
            visited[x - 1] = true;
        }
    }
    bool flag = true;
    for (int i = 0; i < n; i++) {
        if (!visited[i]) {
            flag = false;
        }
    }
    if (!flag) {
        cout << -1;
        return 0;
    }
    memset(dp, -1, sizeof dp);
    cout << solve(0, 0);
    return 0;
}


Measured memory_bytes: 64384
#include <iostream>
#include <cmath>

#include <set>
#include <string>
#include <bits/stdc++.h>
#include <string>
#define FIXED_FLOAT(x)  std::fixed <<std::setprecision(2)<<(x)
#define MAX 100
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define INF INT_MAX
#define ll long long
#define vi vector<int>
#define all(a) a.begin(), a.end()
#define pb push_back
#define ull unsigned long long;


using namespace  std;

void sol() {
    long double a,b;
    cin>>a>>b;
    cout<<(long long)(a*b+1e-3)<<endl;
}
int main() {
    fast;
    sol();


}




Measured memory_bytes: 3760
using System;
using System.Linq;

class name
{
    static void Main()
    {

        int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int d = a[0];
        int[] ans = new int[a[0] + 5];
        for (int i = 1; i * i <= d; i++)
        {
            for (int s = 1; s * s <= d; s++)
            {
                for (int t = 1; t * t <= d; t++)
                {
                    int dem = i * i + s * s + t * t + i * s + s * t + t * i;
                    if (dem <= d)
                    {
                        ans[dem]++;
                       
                    }


                }




            }




        }
        for (int f = 1; f < d + 1; f++)
        {
            Console.WriteLine(ans[f]);

        }



    }



}

Measured memory_bytes: 28176
#include <float.h>
#include <inttypes.h>
#include <limits.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <math.h>
#ifdef __cplusplus
#include <bits/stdc++.h>
#endif

int comp(const void *a, const void *b){return (*(int*)a>*(int*)b)-(*(int*)a<*(int*)b);}
int compr(const void *a, const void *b){return (*(int*)a<*(int*)b)-(*(int*)a>*(int*)b);}

uint32_t nextpint(void){ char c=getchar(); while(c<'0'||'9'<c) c=getchar(); uint32_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar(); } return x; }
uint64_t nextplong(void){ char c=getchar(); while(c<'0'||'9'<c) c=getchar(); uint64_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar(); } return x; }
uint32_t nextstr(char *s){ char c=getchar(); while(c==' '||c=='\n') c=getchar(); uint32_t len=0; while(c!=' '&&c!='\n'){ *s++=c; len++; c=getchar(); } *s='\0'; return len; }

inline int max2(const int a, const int b){return a>b?a:b;}
inline int min2(const int a, const int b){return a>b?b:a;}
inline int dif2(const int a, const int b){return a>b?a-b:b-a;}
inline int abs2(const int a){return a>=0?a:-a;}

int main(void){
	int n=nextpint();
	int k=nextpint();
	int s=nextpint();
	if(s==1000000000){
		for(int i=0; i<k; i++){
			printf("%d ", 1000000000);
		}
		for(int i=k; i<n; i++){
			printf("%d ", 1);
		}
		putchar(10);
	}else{
		for(int i=0; i<k; i++){
			printf("%d ", s);
		}
		for(int i=k; i<n; i++){
			printf("%d ", 1000000000);
		}
		putchar(10);
	}
}


Measured memory_bytes: 1280
from collections import deque
n,m = map(int,input().split())

net = [[] for _ in range(n+1)]
for _ in range(m):
    a,b = map(int,input().split())

    net[a].append(b)
    net[b].append(a)

a = [-1] * (n+1)
d = deque()
d.append(1)
while d:
    u = d.popleft()
    for child in net[u]:
        if a[child] != -1:continue
        a[child] = u
        d.append(child)
print("Yes")
print(*a[2:], sep = " ")


Measured memory_bytes: 96344
#include <bits/stdc++.h>
using namespace std;
using lint     = long long;
const lint inf = 1LL << 60;
const lint mod = 1000000007;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    lint x;
    cin >> x;
    lint c = 100;
    for (int i = 0; i < 1000000000; ++i) {
        if (c >= x) {
            cout << i << "\n";
            return 0;
        }
        c = c + lint(c / 100.0);
    }
    return 0;
}

Measured memory_bytes: 3640
#include<iostream>
#include<cmath>
#include<cstdio>
#include<vector>
#include<queue>
#include<string>
#include<algorithm>
#include<set>
using namespace std;
using ll = long long;
int main(){
  ll n;
  set<string> st;
  cin >> n;
  for(ll i=0;i<n;i++){
    string str;
    cin >> str;
    st.insert(str);
  }
  cout << st.size();
  return 0;
}

Measured memory_bytes: 19224
n,m=map(int,input().split())
ab=[[int(i) for i in input().split()] for _ in range(m)]
# print(ab)
ab.sort(key=lambda x:x[1])

ans=0
r=-1
for a,b in ab:
    if a>=r:
        ans+=1
        r=b
print(ans)


Measured memory_bytes: 24440
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <iomanip>
#include <map>
#include <bitset>
#include <cstdio>
#include <set>
#include <stack>
#include <queue>
//#include <bits/stdc++.h>
#define rep(i,n) Rep(i,0,n)
#define Rep(i,k,n) for(int i=k ; i<n ; i++)
#define rep1(i,n) for(int i=1 ; i<=n ; i++)
#define vi vector<int>
#define vii vector<int,int>
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())

typedef long long ll;

//const int MOD = 1000000007;
//const int INF = 1<<30;
using namespace std;

string yn(bool x){
    return x ? "Yes" : "No";
}



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

    if(k%2 != 0){
        ll c = 0;
        
        for(ll i=1 ; i<=n ; i++) if(i%k == 0) c++;
        cout << c*c*c << endl;
    }else{
        ll c = 0; ll t = 0;
        for(ll i=1 ; i<=n ; i++) {
            if(i%k == 0) c++;
            if(i%k == k/2) t++;
        }
        cout << c*c*c + t*t*t << endl;
    }
    
}
/*int main(void) {
    ll N, K; cin >> N >> K;
    if(K%2!=0){
        ll cnt=0;
        for(ll i=1; i<=N; ++i){
            if(i%K==0) cnt++;
        }
        cout << cnt*cnt*cnt << endl;
    }else{
        ll mid = K/2;
        ll c=0, t=0;
        for(ll i=1; i<=N; ++i){
            if(i%K==0) c++;
            if(i%K==mid) t++;
        }
        cout << c*c*c+t*t*t << endl;
    }
    return 0;
}*/



Measured memory_bytes: 256