akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define all(x) (x).begin(),(x).end()
#define init() \
  ios::sync_with_stdio(false); \
  cin.tie(0)

#define MOD 1000000007

using namespace std;

using ll = long long;
using ull = unsigned long long;

template<typename M, typename N>
constexpr common_type_t<M, N> gcd(M a, N b) {
  return a == 0 ? b
    : b == 0 ? a
    : gcd(b, a % b);
}

template <typename M, typename N>
constexpr common_type_t<M, N> lcm(M a, N b) {
  return a * b / gcd(a, b);
}

template <long long MAX>
class CombinationCalculator {
  long long mod_;
  long long fac[MAX];
  long long finv[MAX];
  long long inv[MAX];

public:
  CombinationCalculator(long long mi = MOD): fac(), finv(), inv() {
    mod_ = mi;
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
      fac[i] = fac[i - 1] * i % mod_;
      inv[i] = mod_ - inv[mod_ % i] * (mod_ / i) % mod_;
      finv[i] = finv[i - 1] * inv[i] % mod_;
    }
  }

  long long c(long long n, long long k) const {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod_) % mod_;
  }
};

template <long long MAX = 210000>
using CC = CombinationCalculator<MAX>;

template<typename T>
T modpow(T a, T n, T mod = MOD) {
    T res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

template<typename T>
T modinv(T a, T m = MOD) {
    T b = m, u = 1, v = 0;
    while (b) {
        T t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}

int main() {
  init();

  int h, a;

  cin >> h >> a;
  int r = 0;
  while(h > 0) {
    h -= a;
    r++;
  }
  cout << r << '\n';

  return 0;
}


Measured memory_bytes: 256
P = str(input()).upper()
line = []

while True:
    tmp_line = str(input())
    if tmp_line == 'END_OF_TEXT':
        break
    line += tmp_line.upper().split()

ans = 0

for tmp_word in line:
    if tmp_word == P:
        ans += 1

print("%d"%(ans))


Measured memory_bytes: 5560
#include <bits/stdc++.h>
#define mod 1000000007
#define ll long long
#define mx 200010
using namespace std;
ll i,j,k,n,m,c,ans,x,z,vis[mx],dp[mx];
vector<ll>adj[mx];
void dfs(ll u)
{
    vis[u]=1;
    ll sz=adj[u].size(),MX=0;
    for(ll i=0;i<sz;i++)
    {
        if(vis[adj[u][i]]==0) dfs(adj[u][i]);
        MX = max(MX,dp[adj[u][i]]);
    }
    dp[u] = MX + 1;
}
int main()
{
    cin>>n>>m;
    for(i=0;i<m;i++)
    {
        cin>>x>>z;
        adj[x].push_back(z);
    }
    for(i=1;i<=n;i++)
    {
        if(vis[i]==0)
        {
            vis[i]=1;
            dfs(i);
        }
    }
    for(i=1;i<=n;i++)
        ans = max(ans,dp[i]);
    cout<<ans-1<<endl;
    return 0;
}


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

int main(){
  char mojiA,mojiB,mojiC,mojiD;
  cin>>mojiA>>mojiB>>mojiC>>mojiD;
  int A,B,C,D;
  A=mojiA-48; 
  B=mojiB-48; 
  C=mojiC-48; 
  D=mojiD-48; 
 
  if(A-B-C-D==7){
    cout<<A<<"-"<<B<<"-"<<C<<"-"<<D<<"=7"<<endl;
    return 0;
  }
  if(A+B-C-D==7){
    cout<<A<<"+"<<B<<"-"<<C<<"-"<<D<<"=7"<<endl;
    return 0;
  }
  if(A-B+C-D==7){
    cout<<A<<"-"<<B<<"+"<<C<<"-"<<D<<"=7"<<endl;
    return 0;
  }
  if(A-B-C+D==7){
    cout<<A<<"-"<<B<<"-"<<C<<"+"<<D<<"=7"<<endl;
    return 0;
  }
  if(A+B+C-D==7){
    cout<<A<<"+"<<B<<"+"<<C<<"-"<<D<<"=7"<<endl;
    return 0;
  }
  if(A-B+C+D==7){
    cout<<A<<"-"<<B<<"+"<<C<<"+"<<D<<"=7"<<endl;
    return 0;
  }
  if(A+B-C+D==7){
    cout<<A<<"+"<<B<<"-"<<C<<"+"<<D<<"=7"<<endl;
    return 0;
  }
  if(A+B+C+D==7){
    cout<<A<<"+"<<B<<"+"<<C<<"+"<<D<<"=7"<<endl;
    return 0;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <math.h>
#include <map>
#include <set>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define INF 1145141919
typedef long long int ll;
using namespace std;

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

    int ans=0;

    FOR(i,1,n+1){
        int cnt=0;
        FOR(j,1,i+1){
            if(i%j==0){
                cnt++;
            }
        }

        if(cnt==8 and i%2!=0){
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i < n; ++i)
#define repe(i, n) for(int i=0; i <= n; ++i)
#define repr(i, n) for(int i=n-1; i > 0; --i)
#define all(x) (x).begin(), (x).end()
#define pb(x) push_back(x)
using namespace std;
template <class T> bool chmax(T &a, const T &b) {if (a<b) {a = b; return 1;} return 0;}
template <class T> bool chmin(T &a, const T &b) {if (b<a) {a = b; return 1;} return 0;}
template <class T> using V=vector<T>;
typedef long long ll;
const int INF = 1e9;
const ll MOD = 1000000007;
const ll MAX = 510000;
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }
long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

double temp(int t, int h) {
    double s = t-h*0.006;
    return s;
}

int main() {
    string s,t;
    cin >> s >> t;
    int cnt =0;
    while(cnt < s.size()) {
        string ss = s;
        char v = s[s.size()-1];
        rep(i, s.size()) {
            ss[i+1] = s[i];
        }
        ss[0] = v;
        if (s==t) {
            cout << "Yes" << "\n";
            return 0;
        }
        s = ss;
        cnt++;
    }
    cout << "No" << "\n";
}


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

int main() {
    long long H, W, N;
    cin >> H >> W >> N;
    struct Square {
        long long a, b;
    };
    vector<Square> sq(N);
    for (int i = 0; i < N; i++) {
        cin >> sq[i].a >> sq[i].b;
        sq[i].a--;
        sq[i].b--;
    }

    vector<long long> ans(10, 0);
    ans[0] = (H - 2) * (W - 2);

    map<int, map<int, int>> mp;

    auto isOK = [&](int a, int b) {
        return 0 <= a && 0 <= b && a + 3 <= H && b + 3 <= W;
    };

    for (int i = 0; i < N; i++) {
        for (int k = 0; k < 3; k++) {
            for (int l = 0; l < 3; l++) {
                if (isOK(sq[i].a - k, sq[i].b - l)) {
                    mp[sq[i].a - k][sq[i].b - l]++;
                }
            }
        }
    }

    for (auto itr = mp.begin(); itr != mp.end(); itr++) {
        for (auto itr2 = itr->second.begin(); itr2 != itr->second.end(); itr2++) {
            ans[itr2->second]++;
            ans[0]--;
        }
    }

    for (int i = 0; i < 10; i++) {
        cout << ans[i] << endl;
    }
}

Measured memory_bytes: 72064
#include<stdio.h>

int main(void)
{
  int a,b,c,d;
  
  scanf("%d %d %d %d",&a, &b, &c, &d);
  
  while(1){
    c=c-b;
    
    if(c<=0)
      break;
    
    a=a-d;
    
    if(a<=0)
      break;
  }
  
  if(c<=0)
    printf("Yes");
  else if(a<=0)
    printf("No");
  
  return 0;
}


Measured memory_bytes: 1712
#include<iostream>
using namespace std;
int main()
{
	int n;
	int i, j, k, t;
	int cnt=0;
	//cin >> n;
	while (cin >> n)
	{
		cnt = 0;
		for (i = 0; i <= 9; i++)
		{
			for (j = 0; j <= 9; j++)
			{
				for (k = 0; k <= 9; k++)
				{
					for (t = 0; t <= 9; t++)
					{
						if (i + j + k + t == n)
						{
							cnt++;
						}
					}
				}
			}
		}
		cout << cnt << endl;
		//cin >> n;
	}
	return 0;
}

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

int main(){
    int N, K;
    cin >> N >> K;

    vector<int> A(N);
    for(int i = 0; i < N; i++) cin >> A[i];

    for(int i = 0; i < K; i++){
        vector<int> B(N+1, 0);
        for(int j = 0; j < N; j++){
            B[max(0, j-A[j])]++;
            B[min(N, j+A[j]+1)]--;
        }

        for(int j = 0; j < N; j++) B[j+1] += B[j];
        B.pop_back();

        if(A == B) break;
        A = B;
    }

    for(int i = 0; i < N; i++) cout << A[i] << ' ';
}

Measured memory_bytes: 4852
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace At
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = ReadInts();
            var n = input[0] - 1;
            var m = input[1] - 1;
            WriteLine(n * m);
        }

        private static string Read() { return ReadLine(); }
        private static string[] Reads() { return (Read().Split()); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
const long long INFLL = 1LL << 60;
const int INFINT = 1 << 30;
const long long MOD = 1e9 + 7;

template <class T> void vecout(T V) {
    auto t = V.begin();
    while(t != V.end()) {
        cout << *t++;
        if(t != V.end()) cout << " ";
    }
    cout << endl;
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, q, b, e, t;
    cin >> n;
    vector<int> v(n);
    rep(i, n) cin >> v[i];
    cin >> q;
    rep(i, q) {
        cin >> b >> e >> t;
        swap_ranges(v.begin() + b, v.begin() + e, v.begin() + t);
    }
    vecout(v);
}



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

int main() {
	int n, k;
	cin >> n >> k;
	vector<int>a(n);
	for (int i = 0; i < n; i++)cin >> a.at(i);
	//naive
	for (int i = 1; i <= k; i++) {
		vector<int>imos(n + 1, 0);
		for (int j = 0; j < n; j++) {
			int pp = max(0, j - a.at(j));
			int mp = min(n, j + a.at(j) + 1);
			imos.at(pp)++;
			imos.at(mp)--;
		}
		for (int j = 1; j < n; j++)imos.at(j) += imos.at(j - 1);
		bool x = false;
		for (int j = 0; j < n; j++) {
			if (a.at(j) != imos.at(j)) {
				x = true;
				break;
			}
		}
		if (!x)break;
		for (int j = 0; j < n; j++)a.at(j) = imos.at(j);
	}
	for (int i = 0; i < n; i++) {
		if (i == 0)cout << a.at(i);
		else cout << " " << a.at(i);
	}
}

Measured memory_bytes: 4844
/****************************
    > File Name: b.cpp
    > Author: caoyu01
  	> Mail: yalecyu@gmail.com 
    > Created Time: 2016年09月11日 星期日 20时11分04秒
*****************************/
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define cle(x) memset(x,0,sizeof(x))
#define rep(i,x) for(int i=0;i<x;i++)
const int N = 1000+10;
const int mod = 1e9+7;
const int inf = 0x3f3f3f3f;
int getnow(char c){
	if(c=='a')return 0;
	else if(c=='b')return 1;
	return 2;
}
int main()
{
#ifndef ONLINE_JUDGE
	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);
#endif
	int a,b,c;
	string sa,sb,sc;
	while(cin>>sa>>sb>>sc){
		a=b=c=0;
		int la=sa.size();
		int lb=sb.size();
		int lc=sc.size();
		int now=0;
		int f=0;
		while(true){
			if(now==0){
				now=getnow(sa[a]);
				a++;
			}
			else if(now==1){
				now=getnow(sb[b]);
				b++;
			}
			else{
				now=getnow(sc[c]);
				c++;
			}
			if(a>la)f=1;
			if(b>lb)f=2;
			if(c>lc)f=3;
			if(f)break;
		}
		if(f==1)puts("A");
		else if(f==2)puts("B");
		else puts("C");
	}
	return 0;
}


Measured memory_bytes: 256
// 本戦
#include <algorithm>
#include <cinttypes>
#include <cstdio>
#include <vector>
#include <queue>

int solve_F() {
  uint64_t N;
  scanf("%" SCNu64, &N);

  // 各値の個数を数える
  std::vector<uint64_t> counts(static_cast<size_t>(N));
  for (size_t i = 0; i < N; ++i) {
    uint64_t A;
    scanf("%" SCNu64, &A);
    counts[static_cast<size_t>(A - 1)]++;
  }

  // 0個の値を取り除く
  counts.erase(std::remove(counts.begin(), counts.end(), 0), counts.end());

  // 1. 実際に差し引いてみる方法
  //    O(N^3)より大きい
  auto solver1 = [&]() {
    std::priority_queue<uint64_t> queue(counts.begin(), counts.end());
    std::vector<uint64_t> buf;
    buf.reserve(counts.size());
    for (size_t K = 2; K <= counts.size(); ++K) {
      buf.resize(K - 1);
      auto q = queue;
      uint64_t result = 0;
      while (q.size() >= K) {
        for (auto& value : buf) {
          value = q.top();
          q.pop();
        }

        const uint64_t m = q.top();
        q.pop();

        for (const auto value : buf) {
          if (value > m) q.push(value - m);
        }

        result += m;
      }

      printf("%" PRIu64 "\n", result);
    }
  };

  // A. 個数に対する最大長から考える方法
  auto answer = [&]() {
    std::vector<uint64_t> counts2(static_cast<size_t>(N) + 1);
    for (const auto c : counts) {
      counts2[static_cast<size_t>(c)]++;
    }

    uint64_t u = 0;
    for (size_t i = 1; i <= N; ++i) {
      u += counts2[i];
    }

    std::vector<uint64_t> lengths(static_cast<size_t>(N));
    uint64_t l = 0;
    uint64_t K = 1;
    for (uint64_t i = 1; i <= N; ++i) {
      const auto c2 = counts2[static_cast<size_t>(i)];
      l += i * c2;
      u -= c2;
      lengths[static_cast<size_t>(i) - 1] = (l + i * u) / i;
    }

    for (uint64_t k = 2; k <= counts.size(); ++k) {
      for (size_t i = 1; i < lengths.size(); ++i) {
        if (k > lengths[i]) {
          printf("%zu\n", i);
          break;
        }
      }
    }
  };

  // K=1
  printf("%" PRIu64 "\n", N);

  answer();

  // その他
  for (uint64_t K = counts.size() + 1; K <= N; ++K) {
    printf("0\n");
  }

  return 0;
}

int main() { return solve_F(); }


Measured memory_bytes: 7680
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define int ll
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb emplace_back

const ll MOD = 1e9+7;


//verified KUPC2014-D,ABC034-C
//前処理O(n), クエリO(1)
ll power(ll a,ll b){
    ll ret=1;
    if(b>0){
        ret = power(a,b/2);
        if(b%2==0)ret = (ret*ret)%MOD;
        else ret = (((ret*ret)%MOD)*a)%MOD;
    }
    return ret;
}

vector<ll> fact,invfact;

void init(int n){
    fact.resize(n+1,1);
    invfact.resize(n+1,1);
    for(int i=2;i<=n;i++)fact[i] = (fact[i-1]*i)%MOD;
    
    invfact[n] = power(fact[n],MOD-2);
    for(int i=n-1;i>=1;i--) invfact[i] = (invfact[i+1]*(i+1))%MOD;
}


ll C(int n,int r){
    if(n<r)return 0;
    return ( ( fact[n]*invfact[r] )%MOD * invfact[n-r] )%MOD;
}

int f(int n, int k){
    int a = 2*k-n;
    int b = n-k-1;
    if(a<0 || b<0)return 0;
    
    return ((C(a+b,a) * fact[k])%MOD * fact[n-k-1])%MOD;
}

signed main(){
    int n;
    cin>>n;
    init(n+100);

    int ans = 0;
    for(int k=1; k<=n-1; k++){
        (ans += k*(f(n,k)-f(n,k-1)+MOD))%=MOD;
    }
    
    cout<<ans<<endl;
}


Measured memory_bytes: 15872
use std::io;
use std::io::prelude::*;
use std::iter::repeat;

fn solve(d: &[u64]) -> u64 {
    let n = d.len() - 1;
    let mut dp: Vec<Vec<u64>> = repeat(repeat(0).take(n).collect()).take(n).collect();

    for i in (0..n).rev() {
        for j in (i + 1)..n {
            dp[i][j] = (i..j)
                .map(|k| dp[i][k] + dp[k + 1][j] + d[i] * d[k + 1] * d[j + 1])
                .min()
                .unwrap();
        }
    }

    dp[0][n - 1]
}

fn main() {
    let stdin = io::stdin();
    let mut lines = stdin.lock().lines();
    let n = lines.next().unwrap().unwrap().parse().unwrap();

    let mut d = Vec::new();

    for (i, l) in (0..n).zip(lines) {
        let l = l.unwrap();
        let mut sw = l.split_whitespace();
        if i == 0 {
            d.push(sw.next().unwrap().parse().unwrap());
        } else {
            sw.next();
        }
        d.push(sw.next().unwrap().parse().unwrap());
    }

    println!("{}", solve(&d[..]));
}



Measured memory_bytes: 5044
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 1000000007
#define pb push_back
#define test cout<<"#"

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	ll n, wt;
	cin>>n>>wt;
	vector<ll> w(n);
	vector<ll> val(n);
	for(ll x = 0; x < n; x++)
		cin>>w[x]>>val[x];
	ll ans[wt+1] ={0};
	for(ll x = 0; x<n; x++)
	{
		for(ll y = wt; y>=0; y--)
		{
			if(w[x]<=y)
				ans[y] = max(ans[y], ans[y-w[x]]+val[x]);
		}
	}
	cout<<ans[wt];
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
using ll=long long;
#define rep(i,a,b) for(int i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+b,(a).begin()+c // コンテナ a の 要素 b から c へのイテレータ
// typedef
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;


int main() {
int N; cin >> N;
VI A(N); rep(i,0,N) scanf("%d", &A[i]);
map<int, bool> paper; // {言われた数，言われたことがあったらtrue,なかったらfalse}

rep(i, 0, N){
    paper[A[i]] = !paper[A[i]];
}
int cnt=0;
for(pair<int,bool> p : paper) {
    if (p.second) ++cnt;
}

cout << cnt << "\n";

return 0;
}

// 境界，出力文字列 チェック
// int は ± 2*10⁹.


Measured memory_bytes: 5376
n,m = gets.split(' ').map(&:to_i)
a = []
t1, t2 = 0, 0
m.times { a << gets.split(' ') }
a = a.group_by { |a| a[0] }
a.each do |b|
  tmp = b[1].transpose[1]
  if tmp.include?('AC')
    t1 += 1
    tmp.slice!(tmp.index('AC')..-1)
    t2 += tmp.count('WA')
  end
end
printf("%i %i\n", t1, t2)

Measured memory_bytes: 48508
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int asc(const void* a, const void* b) {
    return *(int*)b - *(int*)a;
}
int main() {
    int n, m;
    scanf("%d %d", &n, &m);
    if (n <= 2*m) printf("0");
    else printf("%d",n-2*m);
    return 0;
}


Measured memory_bytes: 128
import java.util.*;

public class Main {

    public static void main(String[] args) {
//        long startTime = System.currentTimeMillis();
        Scanner scanner = new Scanner(System.in);
        int A = scanner.nextInt();
        int B = scanner.nextInt();
        scanner.close();

        // check
        int count = 0;

        if (A >= 6 && A <= 12) {
            count = B / 2;
        } else if (A <= 5) {
            count = 0;
        } else {
            count = B;
        }


        System.out.println(count);

//        System.out.println(System.currentTimeMillis() - startTime);
    }


}


Measured memory_bytes: 22868
#include <stdio.h>
#include <string.h>
int main(void){
	int n,k;
	scanf("%d",&n);
	char S[n+1];
	scanf("%s",S);
	scanf("%d",&k);
	char mozi=S[k-1];
	for(int i=0;i<n;i++){
		if(S[i]==mozi)printf("%c",S[i]);
		else printf("*");
	}
	
	return 0;
}

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

int main(){
  int N,A,B;
  string S;
  cin >> N >> A >> B >> S;
  int aa=0;
  int bb=0;
  rep(i,N){
    if(S[i]=='a'){
      if(aa<A+B){
        cout << "Yes" << endl;
        aa++;
      }
      else{
        cout << "No" << endl;
      }
    }
    if(S[i]=='b'){
      bb++;
      if(aa<A+B and bb<=B){
        cout << "Yes" << endl;
        aa++;
      }
      else{
        cout << "No" << endl;
      }
    }
    if(S[i]=='c'){
      cout << "No" << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 896
import java.util.Scanner;

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

        String s = sc.next();
        int love = 753;
        int minDiff = 10000;

        for (int i = s.length() - 3; i >= 0; i--) {
            char c1 = s.charAt(i);
            char c2 = s.charAt(i+1);
            char c3 = s.charAt(i+2);
            int n = Character.getNumericValue(c1) * 100 + Character.getNumericValue(c2) * 10 + Character.getNumericValue(c3);
            int diff = Math.abs(love - n);
            if (minDiff > diff)
                minDiff = diff;
        }
        System.out.println(minDiff);
    }
}


Measured memory_bytes: 21588
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

for i in range(n):
    a[i] -= 1

s = b[a[0]]
prev = a[0]
for i in range(1, n):
    s += b[a[i]]
    if prev + 1 == a[i]:
        s += c[prev]
    prev = a[i]
print(s)


Measured memory_bytes: 3064
K, S = list(map(int, input().split()))
# ok_list = []
cnt = 0
for x in range(K + 1):
    if S - x > K:
        y_max = K + 1
    else:
        y_max = S - x + 1

    if S - x > 2 * K:
        continue
    else:
        # print(y_max, end=" ")
        pass

    for y in range(y_max):

        if S - (x + y) <= K:
            cnt += 1
print(cnt)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int N,M;
void solve(){
    cin>>N>>M;
    int ans=0;
    int k[M],s[M][10];
    int p[M];
    for(int i=0;i<M;i++){
        cin>>k[i];
        for(int j=0;j<k[i];j++)cin>>s[i][j];
    }
    for(int i=0;i<M;i++)cin>>p[i];
    
    for(int bit=0;bit<(1<<N);bit++){
        int kos=0;
        for(int es=0;es<M;es++){
            int cnt=0;
            for(int q=0;q<k[es];q++){
                if((bit>>(s[es][q]-1))&1)cnt++;
            }
            if(!((cnt%2)^p[es]))kos++;
        }
        if(kos==M)ans++;
    }
    cout<<ans<<endl;
}


int main(){
    solve();
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define inf 0x7fffffff
#define maxn 100005
#define maxm 120005
typedef long long ll;
using namespace std; 

int n, s;
struct node{
	int x;
	ll p;
	bool operator < (const node & a)const{
		return x < a.x;
	}
}home[maxn];

inline int read(){
	int x = 0, f = 1;char ch = getchar();
	while(ch > '9' || ch < '0'){if(ch == '-') f = -1;ch = getchar();}
	while(ch >= '0' && ch <= '9'){x = x * 10 + ch -'0';ch = getchar();}
	return x * f;
}

ll ans, sum[maxn];

int main(){
	int i,j,u,v,f;
	n = read(), s = read();
	for(i = 1;i <= n;i++) home[i].x = read(), home[i].p = read();
	sort(home + 1, home + n + 1);
	int l = 1, r = n;
	int flag = -1;
	while(home[l].x < s && home[r].x > s){
		if(home[l].p < home[r].p) home[r].p += home[l].p,  sum[r] += sum[l] + (flag != 0 ? home[r].x - home[l].x : 0), flag = 0, l++;
		else home[l].p += home[r].p, sum[l] += sum[r] + (flag != 1 ? home[r].x - home[l].x : 0), flag = 1, r--;
	}
	printf("%lld\n", home[l].x <= s ? sum[l] + s - home[l].x : sum[r] - s + home[r].x);
}

Measured memory_bytes: 5284
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

const int maxn = 100100;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(10);
    cout << fixed;

    int n, m;
    cin >> n >> m;
    vector<int> odd, even;
    if (m == 1) {
        int a;
        cin >> a;
        if (n == 1) {
            cout << "1\n1\n1\n";
            return 0;
        }
        cout << a << '\n' << "2\n" << "1 " << a - 1 << '\n';
        return 0;
    }
    for (int i = 0; i < m; i++) {
        int a;
        cin >> a;
        if (a % 2) {
            odd.push_back(a);
        } else {
            even.push_back(a);
        }
    }
    if (odd.size() > 2) {
        cout << "Impossible\n";
        return 0;
    }

    vector<int> a;
    if (!odd.empty()) {
        a.push_back(odd.back());
        odd.pop_back();
    }
    for (int i : even) {
        a.push_back(i);
    }
    if (!odd.empty()) {
        a.push_back(odd.back());
        odd.pop_back();
    }

    vector<int> b;
    if (a[0] % 2 == 0) {
        b.push_back(1);
        for (int i : a) {
            b.push_back(i);
        }
    } else {
        b.push_back(a[0] + 1);
        for (int i = 1; i < (int) a.size(); i++) {
            b.push_back(a[i]);
        }
    }
    b[b.size() - 1]--;
    if (b.back() == 0) {
        b.pop_back();
    }

    for (int i : a) {
        cout << i << ' ';
    }
    cout << '\n';
    cout << b.size() << '\n';
    for (int i : b) {
        cout << i << ' ';
    }
    cout << '\n';
    

    return 0;
}

Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <string>
#include <time.h>
#include <stdio.h>
#include <iomanip>
#include <vector>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
using namespace std;

struct Node {
    int key;
    Node *prev, *next;
};

Node *nil;
void init(){
    nil = (Node *)malloc(sizeof(Node));
    nil -> next = nil;
    nil -> prev = nil;
}

void insert(int key){
    Node *x = (Node *)malloc(sizeof(Node));
    x -> key = key;
    x -> next = nil -> next;
    nil -> next -> prev = x;
    nil -> next = x;
    x -> prev = nil;
}

void deleteNode(Node *t){
    if (t == nil) return;
    t -> prev -> next = t -> next;
    t -> next -> prev = t -> prev;
    free(t);
}

void deleteFirst() {
    deleteNode(nil->next);
}

void deleteLast() {
    deleteNode(nil->prev);
}

Node* search(int key){
    Node *cur = nil -> next;
    while(cur != nil && cur -> key != key){
        cur = cur -> next;
    }
    return cur;
}

void deleteKey(int key) {
    deleteNode(search(key));
}

void printList(){
    Node *cur = nil -> next;
    int isf = 0;
    while(true){
        if(cur == nil) break;
        if(isf++ > 0) cout << " ";
        cout << cur -> key;
        cur = cur -> next;
    }
    cout << endl;
}

int main()
{
    long long n;
    long long key;
    string order;
    cin >> n;
    init();
    for(long long i = 0; i < n; i++){
        cin >> order;
        if(order == "insert"){
            cin >> key;
            insert(key);
        } else if(order == "delete"){
            cin >> key;
            deleteKey(key);
        } else if(order == "deleteFirst"){
            deleteFirst();
        } else if(order == "deleteLast"){
            deleteLast();
        }
    }

    printList();

    return 0;
}


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

using namespace std;

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)

signed main(){

	lli n,m,k;
	cin>>n>>m>>k;

	for(lli a=0;a<=n;a++){
		for(lli b=0;b<=m;b++){
			if( (m-b)*a + (n-a)*b == k){
				cout<<"Yes"<<endl;
				return 0;
			}
		}
	}

	cout<<"No"<<endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
  int n,m;
  while(cin >> n >> m , n + m){
    int yasai[1000] = {0};

    for(int i = 1 ; i <= n ; i++){
      cin >> yasai[i];
    }

    sort(yasai,yasai+(n+1),greater<int>());

    for(int i = n ; i >0 ; i--){
      yasai[i] = yasai[i-1];
    }
    int sum = 0;
    for(int i = 1 ; i <= n ; i++){
      if(i%m != 0)sum+=yasai[i];
    }
    cout << sum << endl;
  }
}

Measured memory_bytes: 1176
import bisect

n = int(input())
a = sorted(list(map(int, input().split())))
b = sorted(list(map(int, input().split())))
c = sorted(list(map(int, input().split())))
ans = 0
for i in b:
  ai = bisect.bisect_left(a, i)
  # print(ai)
  ci = n - bisect.bisect_right(c, i)
  # print(ci)
  ans += ai*ci
print(ans)


# 2
# 1 5
# 2 4
# 3 6

# 6
# 3 14 159 2 6 53
# 58 9 79 323 84 6
# 2643 383 2 79 50 288


Measured memory_bytes: 23244
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<" ";

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin>>s;
    cout << (count(be(s),'1')) <<endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <climits>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>

using namespace std;

const int INF = 1e9;
const long long LINF = 1e18;
const double PI=3.14159265358979323846;

int main() {
    vector<int> d(5);
    for (int i = 0; i < 5; i++) {
        cin >> d[i];
    }

    int k;
    cin >> k;

    for (int i = 0; i < 4; i++) {
        for (int j = i + 1; j < 5; j++) {   
            int n = d[j] - d[i];
            if (n > k) {
                cout << ":(" << endl;
                return 0;
            }
        }        
    }

    cout << "Yay!" << endl;

    return 0;
}

Measured memory_bytes: 384
#include <algorithm>
#include <iostream>
#include <stdio.h>

using namespace std;

int main() {
  int a, b;
  cin >> a >> b;
  if (a > b) {
    swap(a, b);
  }
  if (0 < a || (b < 0 && (b - a) % 2 == 1)) {
    printf("Positive\n");
  } else if (a <= 0 && 0 <= b) {
    printf("Zero\n");
  } else {
    printf("Negative\n");
  }
}

Measured memory_bytes: 3084
N = int(input())
A = [int(_) for _ in input().split()]
now = 0
cnt = 0
for i, a in enumerate(A):
    b = (-1)**i
    now += a
    if now * b <= 0:
        cnt += abs(now - b)
        now = b
ans = cnt
now = 0
cnt = 0
for i, a in enumerate(A):
    b = (-1)**(i + 1)
    now += a
    if now * b <= 0:
        cnt += abs(now - b)
        now = b
ans = min(ans, cnt)
print(ans)


Measured memory_bytes: 20064
#C
N = input()
A_str = input().split(" ")
A_int = [int(str) for str in A_str]

res = list(A_int)

for i in range(len(A_int)):
    res[A_int[i]-1] = i+1

res_str = [str(n) for n in res]
res_out = ' '.join(res_str)
print(res_out)

Measured memory_bytes: 25248
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;


public class Main {

	/**
	 * @param args
	 * @throws IOException 
	 * @throws NumberFormatException 
	 */
	public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO Auto-generated method stub
		
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		/*
		String[] tmpArray = br.readLine().split(" ");
		int w = Integer.parseInt(tmpArray[0]);
		int h = Integer.parseInt(tmpArray[1]);
		int x = Integer.parseInt(tmpArray[2]);
		int y = Integer.parseInt(tmpArray[3]);
		int r = Integer.parseInt(tmpArray[4]);
		*/
		int i = 1;
		while(true){
			String str = br.readLine();
			if(str.equals("0")){
				break;
			}
			System.out.println("Case "+ i + ": "+str);
			i++;
		}

		//		int[] array = new int[3];
//		array[0] = a; array[1] = b; array[2] = c;
//
//		Arrays.sort(array);
//		System.out.printf("%d %d %d\n", array[0], array[1], array[2]);
		/*
		if(a < b && b < c){
			System.out.println("Yes");
		}
		else{
			System.out.println("No");
		}*/
	}

}

Measured memory_bytes: 31848
#include <math.h>
#include <stdio.h>
#include <string.h>
int count = 0, idct[102] = {0}, k, n, ppl, temp;
int main(void) {
    scanf("%d %d", &n, &k);
    for (int i = 0; i < k; i++) {
        scanf("%d", &ppl);
        for (int j = 0; j < ppl; j++) {
            scanf("%d", &temp);
            idct[temp] = 1;
        }
    }
    for (int i = 1; i <= n; i++) {
        if (idct[i] == 0) {
            count++;
        }
    }
    printf("%d", count);
}

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

#define ll long long
#define INF 99999999
#define INF_LL 1LL << 60
#define MOD (ll)1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = (int)(n); i >= 0; i--)
#define REP(i, a, n) for(int i = a; i < (int)(n); i++)
#define RREP(i, a, n) for(int i = (int)(n); i >= a; i--)
#define all(x) (x).begin(),(x).end()

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

void put_double(double obj){printf("%.12f\n",obj);};

template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}

int main()
{
    int H,W;
    cin >> H >> W;

    vector<string> s(H);
    rep(i,H) cin >> s[i];

    vector<vector<char> > ans(H,vector<char>(W,'0'));

    rep(i,H)
    {
        rep(j,W)
        {
            if( s[i][j] == '#' )
            {
                if( i > 0 )
                {
                    if( ans[i-1][j] != '#' ) ans[i-1][j] = (char)(ans[i-1][j]+1);
                    if( j+1 < W && ans[i-1][j+1] != '#' ) ans[i-1][j+1] = (char)(ans[i-1][j+1]+1);
                    if( j > 0 && ans[i-1][j-1] != '#' ) ans[i-1][j-1] = (char)(ans[i-1][j-1]+1);
                }
                if( i+1 < H )
                {
                    if( ans[i+1][j] != '#' ) ans[i+1][j] = (char)(ans[i+1][j]+1);
                    if( j+1 < W && ans[i+1][j+1] != '#' ) ans[i+1][j+1] = (char)(ans[i+1][j+1]+1);
                    if( j > 0 && ans[i+1][j-1] != '#' ) ans[i+1][j-1] = (char)(ans[i+1][j-1]+1);
                }
                ans[i][j] = '#';

                if( j > 0 )
                {
                    if( ans[i][j-1] != '#' ) ans[i][j-1] = (char)(ans[i][j-1]+1);
                }
                if( j+1 < W )
                {
                    if( ans[i][j+1] != '#' ) ans[i][j+1] = (char)(ans[i][j+1]+1);
                }
            }
        }
    }
    rep(i,H)
    {
        rep(j,W) cout << ans[i][j];
        cout << endl;
    }
}


Measured memory_bytes: 256
import java.util.List;
import java.util.Scanner;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Set;
import java.util.Map;
import java.util.HashMap;
import javax.swing.text.DefaultStyledDocument.ElementSpec;

import java.util.HashSet;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int count = 0;
        int n = sc.nextInt();
        int[] a = new int[n];
        int[] b = new int[n];
        int[] c = new int[n - 1];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }
        for (int i = 0; i < n; i++) {
            b[i] = sc.nextInt();
        }
        for (int i = 0; i < n - 1; i++) {
            c[i] = sc.nextInt();
        }
        for (int i = 0; i < n; i++) {

            count += b[a[i] - 1];

            if (i != 0 && a[i] == a[i - 1] + 1) {

                count += c[a[i - 1] - 1];
            }

        }
        System.out.println(count);
    }
}

Measured memory_bytes: 21844
import sys

def main():
    N = int(input())
    A = [int(_) for _ in input().split()]

    t = 0
    while True:
        for i in range(N):
            if A[i] % 2 == 0:
                A[i] //= 2
            else:
                print(t)
                sys.exit()
        t += 1

main()

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long
#define double long double

const int N= 1e5+10;
vector <int>g[N];
int n,t,k,a,b,h,m;
vector<int> dist(N);
vector<int> vis(N);
void bfs(int n){
    vis[n]=1;
    queue<int>q;
    q.push(n);
    while(!q.empty()){
        
        int u= q.front();
        
        q.pop();
        for(auto it:g[u]){
            if(!vis[it]){
                vis[it]=1;
                dist[it]= dist[u]+1;
                q.push(it);
                
            }
        }
    }
    return;
}
int32_t main()
{
	IOS;
	cin>>n>>m;
	
	for(int i=0;i<m;i++){
	    int u,v;
	    cin>>u>>v;
	    g[u].push_back(v);
	    g[v].push_back(u);
	    
	}
	bfs(1);
	int flag=0;
	for(int i=2;i<=n;i++){
	    if(dist[i]!=0){
	        flag=1;
	        break;
	    }
	}
	    vector<int>ans;
	   for(int i=2;i<=n;i++){
	       int mn_dist=1e7, sign= 0;
	        for(auto it: g[i]){
	            if(dist[it]<mn_dist && dist[i]>0){
	                mn_dist= dist[it];
	                sign= it;
	            }
	        }
	        if(sign!=0) 
	        ans.push_back(sign);
	   }

	   if(ans.size()==0){
	       cout<<"No"<<endl;
	   }
	   else{
	        cout<<"Yes"<<endl;
	        for(auto it:ans)
	        cout<<it<<endl;
	   }
	return 0;
}

Measured memory_bytes: 14588
n, k, q = map(int, input().split())
a = [int(input()) - 1 for i in range(q)]

nl = [k-q for i in range(n)]

for i in a:
    nl[i] += 1

for i in range(n): 
    if nl[i] > 0:
        print('Yes')
    else:
        print('No')


Measured memory_bytes: 56408
#include <algorithm>
#include <cmath>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <stack>
#include <string>
#include <vector>
typedef long long ll;
using namespace std;
const int MOD = (int)1e9 + 7;
const ll INF = (ll)1e18 + 7;
#define int long long
#define vint vector<int>
#define pint pair<int, int>
#define pb(a) push_back(a)
#define all(v) v.begin(), v.end()
#define dbg(x) cerr << #x << " = " << (x) << endl
#define yn(b) cout << ((b) ? "Yes" : "No") << endl
#define YN(b) cout << ((b) ? "YES" : "NO") << endl

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

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

	string S;
	cin >> S;

	if (S[0] == 'S') {
		cout << "Cloudy" << endl;
	}

	if (S[0] == 'C') {
		cout << "Rainy" << endl;
	}

	if (S[0] == 'R') {
		cout << "Sunny" << endl;
	}

	return 0;
}

Measured memory_bytes: 384
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func r() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func main() {
	sc.Split(bufio.ScanWords)

	c := make([]int, 9)
	for i := 0; i < 9; i++ {
		c[i] = r()
	}

	a1 := 0
	b1, b2, b3 := c[0]-a1, c[3]-a1, c[6]-a1

	if a2 := c[1] - b1; a2 != c[4]-b2 || a2 != c[7]-b3 {
		fmt.Println("No")
		return
	}
	if a3 := c[2] - b1; a3 != c[5]-b2 || a3 != c[8]-b3 {
		fmt.Println("No")
		return
	}

	fmt.Println("Yes")
}


Measured memory_bytes: 640
# -*- coding: utf-8 -*-
import sys
# ----------------------------------------------------------------
# Use Solve Function

class UnionFind:
    def __init__(self, n):
        # ノードとリストのインデックスを一致させるために長さN+1のリストを作成
        self.par = [i for i in range(n+1)]
        self.size = [1 for i in range(n+1)]
        self.rank = [0] * (n+1)

    def __str__(self):
        return ' '.join(map(str,self.par))

    def tree_size(self, x):
        x = self.find(x)
        return self.size[x]

    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def same_check(self, x, y):
        return self.find(x) == self.find(y)

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y: return

        if self.rank[x] < self.rank[y]:
            self.par[x] = y
            self.size[y] += self.size[x]
        else:
            self.par[y] = x
            self.size[x] += self.size[y]
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
# A,B = map(int, input().split(' '))
N,M = map(int, input().split(' '))
NLIST = []
for i in range(M):
    A,B = map(int, input().split(' '))
    NLIST.append((A,B))

res = N * (N-1) // 2
R = [res]
uf = UnionFind(N)

NLIST.reverse()
for i in range(M-1):
    x = NLIST[i]
    n1 = x[0]
    n2 = x[1]

    if not uf.same_check(n1,n2):
        res -= uf.tree_size(n1) * uf.tree_size(n2)
        uf.unite(n1,n2)
    R.append(res)

R.reverse()
for i in range(M):
    print(R[i])
# for i in range(M-1, -1, -1):
#     print(R[i])

Measured memory_bytes: 24088
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

#define rep(i, a, n) for(int i = a; i < (n); ++i)
#define ll long long

int main(){
  int n, m;
  cin >> n >> m;
  vector<ll> a(n);
  priority_queue<int> que;
  rep(i, 0, n) {
    cin >> a[i];
    que.push(a[i]);
  }
  int x;
  rep(i, 0, m) {
    x = que.top();
    que.pop();
    que.push(x / 2);
  }
  ll ans = 0;
  while (!que.empty()) {
    ans += que.top();
    que.pop();
  }
  cout << ans << endl;
}

Measured memory_bytes: 1660
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

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

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }
#define INF 1LL<<60

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

    if(N%2 == 0) {
        int a = N / 2, b = N/2 + 1;
        bool flag = false;
        FOR(i, 1, M) {
            cout << a << " " << b << endl;
            a--; b++;
            if(b - a >= N/2 && !flag) {
                a--;
                flag = true;
            }
        }
    } else {
        int a = N / 2, b = N / 2 + 1;
        FOR(i, 1, M) {
            cout << a << " " << b << endl;
            a--; b++;
        }
    }


    return 0;
}

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

int main(int argc, const char * argv[]) {
    
    string a,b;
    
    cin >> a;
    cin >> b;
    
    if(a[0]==b[2] && a[1]==b[1] && a[2]==b[0]){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define mk make_pair
#define ll long long
#define ss second
#define ff first
#define pll pair<ll,ll>
#define vll vector<ll>
#define mll map<ll,ll>
#define mod 1000000007
#define w(x) ll x; cin>>x; while(x--)
#define ps(x,y) fixed<<setprecision(y)<<x;
#define fo(i, j, k, in) for (ll i=j ; i<k ; i+=in)
#define re(i, j) fo(i, 0, j, 1)
#define pi 3.1415926535897932384626433832795
#define all(cont) cont.begin(), cont.end()
#define countbit(x) __builtin_popcount(x)
#define mod 1000000007
#define lo lower_bound
#define de(n) ll n;cin>>n;
#define def(a,n) ll n;cin>>n;ll a[n];re(i,n){cin>>a[i];}
#define defi(a,n,k) ll n;cin>>n; ll k;cin>>k;ll a[n];re(i,n){cin>>a[i];}
#define deb(x) cout<<#x<<"="<<x<<endl;
#define tr(it,a) for(auto it=a.begin();it!=a.end();it++)
#define nl cout<<endl;
using namespace std;
void cp()
{
    ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0); 
    #ifndef ONLINE_JUDGE  
    freopen("input.txt", "r", stdin);  
    freopen("output.txt", "w", stdout);
#endif
}
ll digit(ll n)
{
    ll q=0;
    while(n>0)
    {
        q++;
        n/=10;
    }
    return q; 
}
int main()
{
    //cp();
    //w(x)
    {
        de(n);
        if(n%2==1)
        cout<<"0";
        else
        {
            ll k=digit(n);
            ll ni=n;
            ll ans=0;
            ll kk=5;
            while(kk<=ni)
            {
                ll ch=ni/kk;
                    ans+=(ch/2);
                kk*=5;
            }
            cout<<ans;
        }
        
    }
    return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include <string>
#include <stdio.h>
#include <cmath>
#include <cfloat>
#include <algorithm>
#include <numeric>
#include <vector>
#include <iterator>
#include <set>
using namespace std;

const double PI=acos(-1);

int main(){
    int n, m;
    cin >> n >> m;
    vector<int> t(n, 0);
    for(int i = 0; i < m; i++){
        int a, b;
        cin >> a >> b;
        t[a-1]++;
        t[b-1]++;
    }
    for(int i = 0; i < n; i++){
        cout << t[i] << endl;
    }
    return 0;
}

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

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

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

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

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

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

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

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

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

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

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);    
    
    int K, X; cin >> K >> X;
    X -= (K-1);
    FOR(i, X, X+2*K-1) {
		cout << i << " ";
	} cout << endl;
    
    return 0;
}

// read the question correctly (ll vs int)
// template by bqi343


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

int main(){
  string a,b;
  cin >> a >> b;
  bool ok=false;
  if(a.size()==b.size()){
  for(int i=0;i<a.size();i++){
    ok=true;
    for(int j=0;j<a.size();j++){
      if(a.at(j)!=b.at((j+i)%a.size())){
        ok=false;
        break;
      }
    }
    if(ok)
      break;
  }
  }
  cout << (ok?"Yes":"No") << endl;
  return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast") 
#define int long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back 
#define eb emplace_back
#define fn for(int i =0 ;i <n;i++)
#define fn1 for( int i =1;i<=n;i++)
#define fm for(int j =0 ;j <m;j++)
#define fm1 for(int j =1;j<=m;j++)
#define fi first
#define se second
#define endl '\n'
# define PI  3.14159265358979323846
#define MOD 1000000007
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
const int N = 2e6+5;
const int INF = 1e18L;
#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...);
}
int ar[N];
int dp[N];
signed main(){
	// #ifndef ONLINE_JUDGE
	// freopen("input.txt","r",stdin);
	// freopen("output.txt","w",stdout);
	// #endif
	IOS;
	int T=1;
	// cin >> T;
	while(T--){
		int n;
		map<string,int>mp;
		cin >>n;
		fn{
			string s;
			cin>>s;
			mp[s]++;
		}
		cout << (int)(mp.size());
	
	
	}
	cerr << "Time Taken : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
	return 0;
}

Measured memory_bytes: 19412
import sys
import math
import heapq
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
DVSR = 1000000007
def POW(x, y): return pow(x, y, DVSR)
def INV(x, m=DVSR): return pow(x, m - 2, m)
def DIV(x, y, m=DVSR): return (x * INV(y, m)) % m
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def FLIST(n):
    res = [1]
    for i in range(1, n+1): res.append(res[i-1]*i%DVSR)
    return res

N=II()
res = (N//1000)*1000
if N%1000:
    res += 1000
print(res - N)


Measured memory_bytes: 9236