akhauriyash/Code-Regression huggingface dataset:
using Yorukatsu029.Questions;
using Yorukatsu029.Extensions;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace Yorukatsu029.Questions
{
    /// <summary>
    /// ABC130 B
    /// </summary>
    public class QuestionA : AtCoderQuestionBase
    {
        public override IEnumerable<object> Solve(TextReader inputStream)
        {
            var nx = inputStream.ReadIntArray();
            var n = nx[0];
            var x = nx[1];
            var l = inputStream.ReadIntArray();

            var totalDistance = 0;
            for (int i = 0; i < l.Length; i++)
            {
                totalDistance += l[i];
                if (totalDistance > x)
                {
                    yield return i + 1;
                    yield break;
                }
            }
            yield return n + 1;
        }
    }
}


namespace Yorukatsu029
{
    class Program
    {
        static void Main(string[] args)
        {
            IAtCoderQuestion question = new QuestionA();    // 問題に合わせて書き換え
            var answers = question.Solve(Console.In);
            foreach (var answer in answers)
            {
                Console.WriteLine(answer);
            }
        }
    }
}

#region Base Classes

namespace Yorukatsu029.Questions
{

    public interface IAtCoderQuestion
    {
        IEnumerable<object> Solve(string input);
        IEnumerable<object> Solve(TextReader inputStream);
    }

    public abstract class AtCoderQuestionBase : IAtCoderQuestion
    {
        public IEnumerable<object> Solve(string input)
        {
            var stream = new MemoryStream(Encoding.Unicode.GetBytes(input));
            var reader = new StreamReader(stream, Encoding.Unicode);

            return Solve(reader);
        }

        public abstract IEnumerable<object> Solve(TextReader inputStream);
    }

}

#endregion

#region Extensions

namespace Yorukatsu029.Extensions
{
    internal static class TextReaderExtensions
    {
        internal static int ReadInt(this TextReader reader) => int.Parse(ReadString(reader));
        internal static long ReadLong(this TextReader reader) => long.Parse(ReadString(reader));
        internal static double ReadDouble(this TextReader reader) => double.Parse(ReadString(reader));
        internal static string ReadString(this TextReader reader) => reader.ReadLine();

        internal static int[] ReadIntArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(int.Parse).ToArray();
        internal static long[] ReadLongArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(long.Parse).ToArray();
        internal static double[] ReadDoubleArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(double.Parse).ToArray();
        internal static string[] ReadStringArray(this TextReader reader, char separator = ' ') => reader.ReadLine().Split(separator);
    }
}

#endregion


Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define inf 1145141919810893364
#define PI 3.141592653589
#define int long long
typedef pair<int,int> P;
#define REP(i,n) for(int i=0;i<(n);i++)
#define all(x) (x).begin(), (x).end()

signed main(){
  int n;
  cin >> n;
  vector<P> p;
  int a,b;
  REP(i,n){
    cin >> a >> b;
    p.push_back(make_pair(b, a));
  }
  sort(all(p));
  int t = p[n-1].first;
  P pp;
  REP(_i,n){
    int i = n-_i-1;
    pp = p[i];
    t=min(t,pp.first);
    t-=pp.second;
  }
  cout << (t<0?"No":"Yes") << endl;
}


Measured memory_bytes: 6384
// B - Battle
#include <bits/stdc++.h>
using namespace std;

int main(){
	int m[2][2];
	cin>>m[0][0]>>m[0][1]>>m[1][0]>>m[1][1];
	bool ans = false;
	for(int at=0,df=1; m[at][0]>0; swap(at,df)){
		m[df][0] -= m[at][1];
		if(m[df][0] <= 0){ ans = df%2; break; }
	}
	cout<< (ans? "Yes":"No") <<endl;
}

Measured memory_bytes: 3596
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <iomanip>

typedef long long ll;
using namespace std;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;
  cin >> n;
  double sum = 0;
  for(int i = 0; i < n; i++) {
    int a_i;
    cin >> a_i;
    sum += (double) 1 / a_i;
  }
  double ans = 1.f / sum;
  cout << setprecision(10) << ans << "\n";
  return 0;
}



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

#define int         long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define sz(x)       (int)x.size()
#define endl        "\n"
#define repp(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a,b) 	for(int i=a;i<=b;i++)
#define IOS         ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

const int N=1e5 + 5;
const int M=1e9 + 7;

int32_t main()
{
	IOS;
	//memset(dp,-1,sizeof(dp));
	int n;
	cin >> n;
	vector<int> v;
	rep(i,1,n)
	{
		int x;
		cin >> x;
		v.pb(x);
	}
	sort(all(v));
	int res = 0;
	repp(i,0,n-1)
	{
		repp(j,i+1,n)
		{
			int maxx = v[i]+v[j];
			int minn = max(v[i],v[j]) - min(v[i],v[j]);
			int p = upper_bound(v.begin(), v.end(),minn) - v.begin();
			int q = lower_bound(v.begin(), v.end(),maxx) - v.begin();
			q--;
			int ans = (q-p+1);
			if(ans>0 && v[i]>=v[p] && v[i]<=v[q])
			{
				ans--;
			}
			if(ans>0 && v[j]>=v[p] && v[j]<=v[q])
			{
				ans--;
			}
			res += ans;
		}
	}
	cout << res/3 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define inf 2100000000
using namespace std;

int h, w, a, b, ans = inf;
string c[1005];
int memo[1005][1005] = {0};
bool ch[1005][1005] = {0};
pair<int, int> s, g;
int d[4] = {0, 1, 0, -1};
int ds[4] = {1, -1, -1, 1};

void solve();

int main() {
  cin >> h >> w >> a >> b;
  for(int i = 0; i < h; ++i) cin >> c[i];
  for(int i = 0; i < h; ++i)
    for(int j = 0; j < w; ++j) memo[i][j] = inf;
  for(int i = 0; i < h; ++i)
    for(int j = 0; j < w; ++j) {
      if(c[i][j] == 's') {
        s = {i, j};
        c[i][j] = '.';
        memo[i][j] = 0;
      }
      if(c[i][j] == 'g') {
        g = {i, j};
        c[i][j] = '.';
      }
    }
  for(int i = 0; i < h; ++i)
    for(int j = 0; j < w; ++j) {
      bool nowch = 1, block = 0;
      for(int k = -1; k <= 1; ++k)
        for(int l = -1; l <= 1; ++l)
          if(k + i >= 0 && k + i < h && l + j >= 0 &&
             l + j < w) {
            if(c[k + i][l + j] == '*') nowch = 0;
            if(c[k + i][l + j] == '#') block = 1;
          }
      ch[i][j] = nowch & block;
    }
  solve();
  if(ans == inf)
    cout << "INF" << endl;
  else
    cout << ans << endl;
  return 0;
}

void solve() {
  priority_queue<pair<int, pair<int, int>>,
                 vector<pair<int, pair<int, int>>>,
                 greater<pair<int, pair<int, int>>>>
      pq;
  pq.push({0, {s.fi, s.se}});
  while(!pq.empty()) {
    pair<int, pair<int, int>> now, nextp;
    now = pq.top();
    pq.pop();
    if(memo[now.se.fi][now.se.se] < now.fi) continue;
    for(int i = 0; i < 4; ++i) {
      nextp = now;
      nextp.se.fi += d[i];
      nextp.se.se += d[i ^ 1];
      nextp.fi += a;
      if(nextp.se.fi < 0 || nextp.se.fi >= h ||
         nextp.se.se < 0 || nextp.se.se >= w ||
         memo[nextp.se.fi][nextp.se.se] <= nextp.fi)
        continue;
      if(c[nextp.se.fi][nextp.se.se] == '#') {
        if(ch[now.se.fi][now.se.se] &&
           memo[nextp.se.fi][nextp.se.se] > nextp.fi + b)
          nextp.fi += b;
        else
          continue;
      }
      memo[nextp.se.fi][nextp.se.se] = nextp.fi;
      pq.push(nextp);
    }
    if(!ch[now.se.fi][now.se.se]) continue;
    for(int i = 0; i < 4; ++i) {
      nextp = now;
      nextp.se.fi += ds[i];
      nextp.se.se += ds[(i + 1) % 4];
      nextp.fi += 2 * a + b;
      if(nextp.se.fi < 0 || nextp.se.fi >= h ||
         nextp.se.se < 0 || nextp.se.se >= w ||
         c[nextp.se.fi][nextp.se.se] != '#' ||
         memo[nextp.se.fi][nextp.se.se] <= nextp.fi)
        continue;
      memo[nextp.se.fi][nextp.se.se] = nextp.fi;
      pq.push(nextp);
    }
  }
  ans = memo[g.fi][g.se];
}


Measured memory_bytes: 8956
#include <iostream>

using namespace std;

int main(int argc, char* argv[]) {
  int n, m; cin >> n >> m;
  int A[n][m];
  int b[m];
  long long ans[n];

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> A[i][j];
    }
  }
  for (int i = 0; i < m; i++) {
    cin >> b[i];
  }
  for (int i = 0; i < n; i++) {
    ans[i] = 0;
    for (int j = 0; j < m; j++) {
      ans[i] += A[i][j]*b[j];
    }
  }

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

Measured memory_bytes: 1196
input = gets.chomp.split(" ").map(&:to_i)
N = input[0]
K = input[1]

people = gets.chomp.split(" ").map(&:to_i).sort
foods = gets.chomp.split(" ").map(&:to_i).sort.reverse
products = []
people.each_with_index do |e,i|
  products << e*foods[i]
end

maximum = products.max
minimum = 0

# 二分探索
while minimum + 1 <= maximum do
  count = K
  center_value = ((minimum + maximum)/2)
  foods.each_with_index do |food,i|
    if people[i] > center_value / food
      count -= people[i] - center_value / food
    end
  end
  if count >= 0
    maximum = center_value
  else
    minimum = center_value + 1
  end
end


puts maximum


Measured memory_bytes: 40016
#include <stdio.h>
#include <stdlib.h>

int gcd(int *a,int *b)
{
    int c;
    
    if ((*a)<=(*b))
    {
        
        c = (*b)%(*a);
        *b = c;
    }
    else
    {
        c = (*a)%(*b);
        *a = c;
    }
    return 0;
}


int main()
{
    int c, d;
    scanf("%d%d", &c, &d);
    
    int *a, *b;
    a = malloc(sizeof(int));
    b = malloc(sizeof(int));
    *a = c;
    *b = d;
    while ((*a) *  (*b) != 0)
    {
        gcd(a,b);
    
    }
    if((*a)==0) printf ("%d\n",*b);
    else printf("%d\n",*a);
    
    return 0;
}

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

#define FOR(i,b,e) for (int i = (b); i <= (e); i++)
#define FORD(i,b,e) for (int i = (b); i >= (e); i--)
#define SIZE(c) ((int) (c).size())

#define pb push_back
#define st first
#define nd second

using namespace std;


typedef long long ll;
typedef pair <int,int> pii;

typedef vector <int> VI;
typedef vector <ll> VL;
typedef vector <bool> VB;
typedef vector <pii> VP;

typedef vector <VI> VVI;
typedef vector <VL> VVL;
typedef vector <VB> VVB;
typedef vector <VP> VVP;

const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000000000000001LL;

int dfs(int v, int par, VVI &g, VB &vis, VP &ans) {
    vis[v] = true;

    int outc = 0;
    for (int u : g[v]) {
        if (!vis[u]) {
            outc += 1 - dfs(u, v, g, vis, ans);
        } else if (u != par) {
            if (u < v) {
                ans.pb({v, u});
                outc++;
            }
        }
    }

    if (par != -1) {
        if (outc % 2) {
            ans.pb({v, par});
        } else {
            ans.pb({par, v});
        }
    } else {
        assert(outc % 2 == 0);
    }

    return outc % 2;
}

VP solve(int n, int m, VVI &g) {
    VP ans;
    VB vis(n, false);

    int up = dfs(0, -1, g, vis, ans);

    assert(up == 0);
    assert(SIZE(ans) == m);

    return ans;
}

int main() {
    ios_base::sync_with_stdio(false);

    int n, m;
    cin >> n >> m;

    if (m % 2) {
        cout << -1;
        return 0;
    }

    VVI g(n);
    FOR(_,1,m) {
        int u, v;
        cin >> u >> v; u--; v--;

        g[u].pb(v);
        g[v].pb(u);
    }

    auto ans = solve(n, m, g);

    for (auto &e : ans) {
        cout << 1 + e.st << ' ' << 1 + e.nd << '\n';
    }

    return 0;
}

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

typedef long long ll;
const int N = 2e4;

int dp[N + 5];

int a[N + 5], b[N + 5];

int main() {
	int h, n;
	cin>>h>>n;
	h += 1e4;
	for(int i = 0;i <= N;i++) dp[i] = 1e9;
	dp[h] = 0;
	for(int i = 0;i < n;i++) cin>>a[i]>>b[i];
	int res = 1e9;
	for(int i = h;i >= 0;i--) {
		for(int j = 0;j < n;j++) {
			if(i - a[j] >= 0) dp[i - a[j]] = min(dp[i - a[j]], dp[i] + b[j]);
		}
		if(i <= 1e4) res = min(res, dp[i]);
	}
	cout<<res<<endl;
}

Measured memory_bytes: 384
from math import ceil, sqrt
x = int(input())

def can_exp(x):
    if x==1:
       return True
    d = []
    for i in range(2,ceil(sqrt(x))+1):
        if x%i!=0:
            continue
        n = 0
        while x%i==0:
            n += 1
            x //= i
        d.append(n)
    if x!=1:
        d.append(1)
    m = d[0]
    for e in d[1:]:
        m = gcd(m,e)
    return m>1

def gcd(a,b):
        while b!=0:
            a,b = b, a%b
        return a

for i in range(x,0,-1):
    if can_exp(i):
        print(i)
        break

Measured memory_bytes: 3064
import math

a,b,h,m = map(int,input().split())

c = (h*30)+(m*(1/2))
d = m*6

e = abs(c - d)

theta = min(360-e,e)

ans = math.sqrt(a*a + b*b - 2*a*b*math.cos(math.radians(theta)))

print(ans)

Measured memory_bytes: 9392
fun main(args :Array<String>) {
    val (a, b) = readLongList()
    (a / gcd(a, b) * b).let { println(it) }
}

fun gcd(a: Long, b: Long): Long {
    var c = a
    var d = b
    while (d > 0) {
        val e = c % d
        c = d
        d = e
    }

    return c
}

fun readInteger() = readLine()!!.toInt()
fun readStringList() = readLine()!!.split(" ")
fun readIntegerList() = readStringList().map(String::toInt)
fun readLongList() = readStringList().map(String::toLong)


Measured memory_bytes: 37816
/*
[abc139] B - Power Socket
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
#define ALL(c) (c).begin(), (c).end()

int A, B;

ll solve() { return (B + A - 3) / (A - 1); }

int main() {
    cin >> A >> B;

    cout << solve() << endl;

    return 0;
}


Measured memory_bytes: 256
program answer
  implicit none

  character(len=100) :: w
  character(len=26) :: c="abcdefghijklmnopqrstuvwxyz"
  integer :: s(26), count(26), n, i, j
  do i = 1, 26
     s(i)=i
  end do

  read(*,*) w
  n=len_trim(w)
  count=0
  do i = 1, n
     do j = 1, 26
        if(w(i:i)==c(j:j)) then
           count(j)=count(j)+1
           exit
        end if
     end do
  end do

  do i = 1, 26
     if(mod(count(i),2)==1) then
        write(*,*) 'No'
        stop
     end if
  end do

  write(*,*) 'Yes'
  stop
 end program answer

Measured memory_bytes: 2784
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll linf = (1ll << 61);
const int inf = 1001001001;
const int mod = 1000000007;

int n, m;
struct edge { int to, cost; };
vector<edge> g[105];
int d[205];
vector<tuple<int, int, int>> rec(1005);
map<P, bool> mp;

void dijkstra(int v) {
	priority_queue<P, vector<P>, greater<P>> pq;
	fill(d, d + n, inf);
	pq.emplace(0, v);
	d[v] = 0;
	while (pq.size()) {
		P p = pq.top(); pq.pop();
		int v = p.second;
		if (d[v] < p.first) continue;
		for (auto& c : g[v]) {
			edge e = c;
			if (d[e.to] > d[v] + e.cost) {
				d[e.to] = d[v] + e.cost;
				pq.emplace(d[e.to], e.to);
			}
		}
	}
	rep(i, m) {
		int a = get<0>(rec[i]), b = get<1>(rec[i]), c = get<2>(rec[i]);
		if (d[a] == d[b] + c || d[b] == d[a] + c) {
			mp[P(a, b)] = true;
		}
	}
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> n >> m;
	rep(i, m) {
		int a, b, c;
		cin >> a >> b >> c;
		a--; b--;
		g[a].push_back({ b, c });
		g[b].push_back({ a, c });
		rec[i] = tie(a, b, c);
	}
	rep(i, n) dijkstra(i);
	int ans = 0;
	rep(i, m) if (!mp[P(get<0>(rec[i]), get<1>(rec[i]))]) ans++;
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 384
// Problem : A - Kyu in AtCoder
// Contest : AtCoder - M-SOLUTIONS Programming Contest 2020
// URL : https://atcoder.jp/contests/m-solutions2020/tasks/m_solutions2020_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define sort(a) sort(all(a))
#define ff first
#define ss second
#define vi vector<int>
#define pii pair<int, int>
#define vll vector<ll>
#define pll pair<ll,ll>
#define mod (int)1e9+7
#define FAST std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define repf(i,a,b) for(i=a;i<b;i++)
#define repb(i,a,b) for(i=a;i>=b;i--)
#define N 100005
int main()
{
	FAST
    int t=1;
    // cin>>t;
    while(t--)
    {
		int x;
		cin>>x;
		x/=100;
		if(x<6) cout<<8;
		else if(x<8) cout<<7;
		else if(x<10) cout<<6;
		else if(x<12) cout<<5;
		else if(x<14) cout<<4;
		else if(x<16) cout<<3;
		else if(x<18) cout<<2;
		else if(x<20) cout<<1;
    }
    return 0;
} 


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

long long gcd(long long x, long long y){
    if(y == 0){
        return x;
    }

    return gcd(y, x%y);
}

int main(){
    long long a, b, c, d;
    cin >> a >> b >> c >> d;

    long long l = c*d/gcd(c, d);

    //printf("%lld\n", c*d/gcd(c, d));

    long long t = l - l/c - l/d + 1;

    //printf("%lld\n", t);

    long long count_a = t*((a-1)/l) + (a-1)%l - (((a-1)%l)/c + ((a-1)%l)/d);
    
    long long count_b = t*(b/l) + (b)%l - (((b)%l)/c + ((b)%l)/d);
    //printf("count_a %lld\n", count_a);
    //printf("count_b %lld\n", count_b);

    printf("%lld\n", count_b - count_a);

    return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <climits>

constexpr int SINT_MAX = std::numeric_limits<int>::max();
constexpr int SINT_MIN = std::numeric_limits<int>::min();

using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;

template<class T>
T choose(bool b, T t, T f)
{
    if (b) return t;
    else return f;    
}

const char *YesNo(bool b)
{
    return choose(b, "Yes", "No");
}

const char *YESNO(bool b)
{
    return choose(b, "YES", "NO");
}

template<class NumT>
NumT diffabs(NumT l, NumT r)
{
    if (l < r) return r-l;
    else return l-r;    
}

struct myinout_t {} io;

template<class T>
myinout_t &operator >>(myinout_t &my, T &i)
{
    cin >> i;
    return my;
}

myinout_t &operator >>(myinout_t &my, int &i)
{
    int r = scanf("%d", &i);
    if (r != 1) exit(EXIT_FAILURE);
    return my;
}

myinout_t &operator >>(myinout_t &my, ll &i)
{
    int r = scanf("%lld", &i);
    if (r != 1) exit(EXIT_FAILURE);
    return my;
}

template<class T>
myinout_t &operator <<(myinout_t &my, const T &i)
{
    cout << i;
    return my;
}

myinout_t &operator <<(myinout_t &my, int i)
{
    printf("%d", i);
    return my;
}

myinout_t &operator <<(myinout_t &my, ll i)
{
    printf("%lld", i);
    return my;
}

myinout_t &operator <<(myinout_t &my, double i)
{
    printf("%.20f", i);
    return my;
}

constexpr char BR = '\n';


///////////////////////////////////////////////////
#include <map>


int prepare(vi &shita, vi &ue, const string &s, int N)
{
    int pop = 0;
    for (size_t i = 0; i < s.size(); i++)
        pop += (s[i] - '0');

    if (pop == 1)
        for (int i = 0; i <= N; i++)
            shita[i] = 0;

    int k_ue = 1, k_shita = 1;
    int m_ue = 0, m_shita = 0;

    size_t i = N;
    while (i-- > 0)
    {
        int ii = s[i] - '0';
        if (pop > 1)
        {
            shita[i] = k_shita;
            k_shita = (k_shita * 2) % (pop - 1);
            m_shita = (m_shita + ii * shita[i]) % (pop - 1);
        }
        
        ue[i] = k_ue;
        k_ue = (k_ue * 2) % (pop + 1);
        m_ue = (m_ue + ii * ue[i]) % (pop + 1);
    }

    shita[N] = m_shita;
    ue[N] = m_ue;
    return pop;
}

int main()
{
    int N;
    string X;
    io >> N >> X;

    vi s(N+1), u(N+1);
    int pop = prepare(s, u, X, N);

    vi aans(N);

    for (int i = 0; i < N; i++)
    {
        int ans, mm;
        if (X[i] == '0')
        {
            int mod = pop + 1;
            ans = 1;
            mm = (u[N] + u[i]) % mod;
        }
        else if (pop == 1)
        {
            ans = 0;
            mm = 0;
        }
        else
        {
            int mod = pop - 1;
            ans = 1;
            mm = (s[N] - s[i] + mod) % mod;
        }

        while (mm > 0)
        {
            mm = mm % __builtin_popcount(mm);
            ++ans;
        }
        io << ans << BR;
    }
    
}


Measured memory_bytes: 6020
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<pair<ll, ll>>> vvpll;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 1100010;  // デフォルトでnの最大値は300000

// aのn乗を求める。計算量はO(logn)
ll modpow(ll a, ll n) {
    if(n == 0) {
        return 1;
    }
    if(n%2 == 1) {
        return (a * modpow(a, n-1))%mod;
    }
    return (modpow(a, n/2) * modpow(a, n/2))%mod;
}

ll Comb(ll x, ll y) {
    if(y > x-y) {
        return Comb(x, x-y);
    }
    ll resMul = 1, resDiv = 1;
    rep(i, y) {
        resMul *= (x-i);
        resDiv *= (i+1);
        resMul %= mod;
        resDiv %= mod;
    }
    // resMul/resDivをresDivの逆元を使って求める
    ll res = resMul * modpow(resDiv, mod-2) % mod;
    return res; 
}

int main() {
    ll x, y;
    cin >> x >> y;
 
    ll z = x+y;
    if(z%3 != 0) {
        out(0);
        re0;
    }
 
    ll n = z/3; 
    if(x < n || y < n) {
        out(0);
        re0;
    }
 
    out(Comb(n, x-n));
    re0;
}

Measured memory_bytes: 384
import java.io.BufferedReader;
import java.io.InputStreamReader;

class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		while(true){
			String[] array = br.readLine().split(" ");
	        int x = Integer.parseInt(array[0]);
	        int y = Integer.parseInt(array[1]);
	        if(x==0&&y==0){
	        	break;
	        }else if(x>y){
	    		System.out.println(y+" "+x);
	        }else{
	        	System.out.println(x+" "+y);
	        }
		}
	}
}

Measured memory_bytes: 24408
#include <bits/stdc++.h>
#define pi 3.14159
using namespace std;
int main()
{
	long long int i,n,p,x,c=0,k,q,j;
	cin>>n>>k>>q;
	int a[q],b[n];
	for(i=0;i<q;i++)
		cin>>a[i];
	for(i=0;i<n;i++)
		b[i]=k-q;
	for(i=0;i<q;i++)
		{
			b[a[i]-1]++;
		}
	
	for(i=0;i<n;i++)
		{
			if(b[i]>0)
				cout<<"Yes"<<endl;
			else
				cout<<"No"<<endl;
		}
}

Measured memory_bytes: 4332
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <array>
#include <vector>
#include <cmath>

using namespace std;

int main() {
  for ( int i = 0; i < 7; i++ ) {
	int a, b;
	cin >> a >> b;
	cout << a - b << endl;
  }
}

Measured memory_bytes: 1160
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main(){

    input!{
        n: usize,
        k: usize,
        p: [usize;n],
    }

    let mut p_tmp:Vec<usize> = Vec::new();
    for i in p {
        p_tmp.push(i);
    }

    p_tmp.sort();

    let mut ans = 0;
    let mut cnt = 0;
    for i in 0..n {
        ans += p_tmp[i];
        cnt += 1;
        if cnt == k {
            println!("{}", ans);
            return;
        }
    }


}

Measured memory_bytes: 2184
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  int ans=0;
  rep(i,n){
    cin >> a.at(i);
    ans+=a.at(i)-1;
    
  }
  cout << ans;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

struct Point {
    double x;
    double y;
};

void koch(int n, struct Point a, struct Point b) {
    if (n == 0) {
        return;
    }
    struct Point s, u, t;
    double th = M_PI * 60.0 / 180.0;  //转弧度
    s.x = (2.0 * a.x + 1.0 * b.x) / 3.0;
    s.y = (2.0 * a.y + 1.0 * b.y) / 3.0;
    t.x = (1.0 * a.x + 2.0 * b.x) / 3.0;
    t.y = (1.0 * a.y + 2.0 * b.y) / 3.0;
    u.x = (t.x - s.x) * cos(th) - (t.y - s.y) * sin(th) + s.x;
    u.y = (t.x - s.x) * sin(th) + (t.y - s.y) * cos(th) + s.y;
    koch(n - 1, a, s);
    printf("%.8f %.8f\n", s.x, s.y);
    koch(n - 1, s, u);
    printf("%.8f %.8f\n", u.x, u.y);
    koch(n - 1, u, t);
    printf("%.8f %.8f\n", t.x, t.y);
    koch(n - 1, t, b);
}   

int main() {
    struct Point p1, p2;
    int n = 0;
    scanf("%d", &n);
    p1.x = 0;
    p1.y = 0;
    p2.x = 100;
    p2.y = 0;
    printf("%.8f %.8f\n", p1.x, p1.y);
    koch(n, p1, p2);
    printf("%.8f %.8f\n", p2.x, p2.y);
    return 0;
}


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

#define ll long long
#define pb push_back
#define mp make_pair
int main() 
{
	 ios_base::sync_with_stdio(false);
     cin.tie(NULL);
     
		 int n;
		 cin>>n;
		 int a[n];
		 for(int i=0;i<n;i++)
		 cin>>a[i];
		 map<int,int>m;
		 for(int i=0;i<n;i++)
		 {  m[a[i]]++;
		 }
		int ans=0;
		for(auto x: m)
		{
			int p=x.first;
			int q=x.second;
			if(p>q)
			ans+=q;
			else
			ans+=q-p;
		}
		cout<<ans<<endl;
	
}


Measured memory_bytes: 5120
H,W,K=map(int,input().split())
C=[[] for i in range(H)]
for i in range(H):
    C[i]=input()
sum_=0
for i in range(H):
    for j in range(W):
        if C[i][j]=="#":
            sum_+=1
r = [i for i in range(H)]
c = [i for i in range(W)]
count=0
for i in range(2 ** H):
    for j in range(2 ** W):
        P=sum_
        a = []
        b = []
        for k in range(H):
            if ((i >> k) & 1):
                a.append(r[k])
        for l in range(W):
            if ((j >> l) & 1):
                b.append(c[l])
        for m in a:
            for n in range(W):
                if C[m][n]=="#":
                    P-=1
        for m in range(H):
            for n in b:
                if C[m][n]=="#":
                    P-=1
        for m in a:
            for n in b:
                if C[m][n]=="#":
                    P+=1
        if P==K:
            count+=1
print(count)

Measured memory_bytes: 68828
n, h = map(int, input().split())
slash = 0
throw = []

for i in range(n):
    a, b = map(int, input().split())
    slash = max(slash, a)
    throw.append(b)

throw.sort(reverse=True)
count = 0

for damage in throw:
    if h <= 0:
        print(count)
        exit()
    if damage <= slash:
        break
    h -= damage
    count += 1

count += h//slash
count += bool(h % slash)
print(count)

Measured memory_bytes: 7384
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE MultiWayIf #-}


import Control.Arrow
import Control.Concurrent
import Control.Monad
import qualified Data.ByteString.Char8 as C
import Data.Complex
import Data.Function
import Data.Function.HT
import qualified Data.IntMap.Strict as IM
import qualified Data.IntSet as IS
import Data.List
import Data.Ord
import qualified Data.Sequence as Sq
import Data.Vector.Algorithms.Search
import qualified Data.Vector as V
import qualified Data.Vector.Mutable as VM
import qualified Data.Vector.Unboxed as U
import qualified Data.Vector.Unboxed.Mutable as UM
import Debug.Trace


------------------
-- #   Read   # --
------------------

r :: Int -> IO (U.Vector Int)
r n = U.unfoldrN n (C.readInt . C.dropWhile (==' ')) <$> C.getLine

r' :: IO [Int]
r'  =   unfoldr    (C.readInt . C.dropWhile (==' ')) <$> C.getLine



main :: IO ()
main = do
    [a,v] <- r'
    [b,w] <- r'
    t <- readLn :: IO Int
    putStrLn $ if a < b
        then if b+t*w <= a+t*v then "YES" else "NO"
        else if a-t*v <= b-t*w then "YES" else "NO"

Measured memory_bytes: 3892
#include <bits/stdc++.h>
#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long
#define map unordered_map
#define set unordered_set

using namespace std;

const ll MOD = 1000000007;

const int MAX = 510000;

ll fac[MAX], finv[MAX], inv[MAX];

void init_com() {
  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;
  }
}

ll 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;
}

ll mul(ll a, ll b) {
  //
  return ((a % MOD) * (b % MOD)) % MOD;
}

int main() {
  init_com();

  ll n, k;
  scanf("%lld %lld", &n, &k);

  vector<ll> a(n);
  for (ll i = 0; i < n; i++) {
    ll v;
    scanf("%lld", &v);
    a[i] = v;
  }

  sort(a.begin(), a.end());

  ll ans = 0;
  for (ll i = n - 1; i >= (k - 1); i--) {
    ll remaining = i;
    ll v = com(remaining, k - 1);
    ans += mul(a[i], v);
    ans %= MOD;
  }

  for (ll i = 0; i < n - (k - 1); i++) {
    ll remaining = (n - i - 1);
    ll v = com(remaining, k - 1);
    ans -= mul(a[i], v);
    ans %= MOD;
  }

  cout << (ans + MOD * 2) % MOD << endl;
}


Measured memory_bytes: 12928
#define _CRT_SECURE_NO_WARNINGS

#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>

using namespace std;

typedef long long int lli;

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);
}

#define N_MAX 5
#define MOD 1000000007

void solv()
{
	int N; scanf("%d", &N);

	int M;
	if (0 == N % 2){
		M = N*(N - 1) / 2 - N / 2;
		printf("%d\n", M);
		for (int i = 1; i <= N; i++){
			for (int j = i + 1; j <= N; j++){
				if (i + j != (N + 1)){
					printf("%d %d\n", i, j);
				}
			}
		}
	}
	else{
		M = N*(N - 1) / 2 - (N - 1) / 2;
		printf("%d\n", M);
		for (int i = 1; i <= N; i++){
			for (int j = i + 1; j <= N; j++){
				if (i + j != N){
					printf("%d %d\n", i, j);
				}
			}
		}
	}

	return;
}

int main()
{
	FILE *fin = NULL, *fout = NULL;
	//fin = freopen("input.txt", "r", stdin);
	//fout = freopen("output.txt", "w", stdout);

	solv();

	//finalize
	if (NULL != fin) fclose(fin);
	if (NULL != fout) fclose(fout);

	return 0;
}

Measured memory_bytes: 128
# https://atcoder.jp/contests/abc088/tasks/abc088_d

from collections import deque

def solve(R, C, sy, sx, gy, gx, mz):
  queue = deque()
  checked = set( )
  queue.append((sx, sy, 0))
  while queue:
    x, y, n = queue.popleft()
    if x == gx and y == gy:
      return n
    if x < 1 or x > C or y < 1 or y > R or mz[y-1][x-1] == '#':
      continue
    if (x, y) in checked:
      continue
    checked.add((x, y))
    queue.append((x+1, y, n+1))
    queue.append((x-1, y, n+1))
    queue.append((x, y+1, n+1))
    queue.append((x, y-1, n+1))
  return -1


if __name__ == '__main__':
  R, C = map(int, input().split(' '))
  sy, sx = 1, 1
  gy, gx = R, C
  mz = []
  whites = 0
  for r in range(R):
    tmp = input()
    mz.append(tmp)
    whites += tmp.count('.')
  n = solve(R, C, sy, sx, gy, gx, mz)
  if n < 0:
    print(-1)
  else:
    print(whites - n - 1)

Measured memory_bytes: 3692
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i ,n) for(int i = 0 ; i < (n) ; i ++ )
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using vin=vector<int>;
const int inf=1e9+7;
const ll INF=1e18;


bool guu(string s){
  bool ans=true;
  int n=s.size();
  rep(i,n/2){
  // cout<<s[i]<<s[n/2+i]<<endl;
    if(s[i]!=s[n/2+i]){
      ans=false;
      break;
    }
  }
      return ans;
}



int main() {
  string s;
  cin>>s;
  if(s.size()%2==0){
    s.pop_back();s.pop_back();
  }
  else{
   s.pop_back(); 
  }
  while(!guu(s)){
   s.pop_back(); s.pop_back(); 
  }
  cout<<s.size()<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define mod 1000000007
int main()
{
    lli n,m;
    cin>>n>>m;
    vector<string> v;
    for(int i=0;i<n;i++)
    {
        string str;
        cin>>str;
        v.push_back(str);
    }
    vector<vector<lli>> dp(n,vector<lli>(m,0));
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            if(v[i][j]!='#')
            {
                if(i==0 & j==0) dp[i][j]=1;
                else if(i==0 && j!=0) dp[i][j]=dp[i][j-1];
                else if(i!=0 && j==0) dp[i][j]=dp[i-1][j];
                else dp[i][j]=(dp[i][j-1]+dp[i-1][j])%mod;
            }
        }
    }
    cout<<dp[n-1][m-1]%mod<<endl;
    return 0;
}

Measured memory_bytes: 9216
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<random>
#include <iomanip>

//使い方がよくわからない
#include<stack>
#include<queue>
#include<bitset>
#include<sstream>

#define rep(i,n) for(int i=0;i<(n);i++) 
#define rep1(i,n) for(int i=1;i<(n);i++)
#define co(x) cout << x << endl
#define cosp(x) cout << x << " "

using namespace std;
using ll = long long;

int main(int argc, const char *argv[]){
    int n;
    cin >> n;
    std::cout << std::fixed;
    std::cout << std::setprecision(10) << (double(int((n+1)/2))/double(n)) << endl;
    return 0;
}

Measured memory_bytes: 256
N, D = map(int, input().split())
X = [0]*N
Y = [0]*N
count = 0
for i in range(N):
    X[i], Y[i] = map(int, input().split())
for i in range(N):
    if(X[i]*X[i]+Y[i]*Y[i] <= D*D):
        count += 1
print(count)

Measured memory_bytes: 24700
#C
n, k = map(int, input().split())
x = n
tmp1 = x / k
if tmp1 == 0:
    print(0)
elif tmp1 > 1:
    print(min(abs(x - k * (x//k)), abs(x - k * (x//k + 1))))
else:
    print(min(x, abs(x - k )))



Measured memory_bytes: 3060
A = gets.to_i
B = gets.to_i
C = gets.to_i
X = gets.to_i

result = 0

(0..A).each do |i|
  (0..B).each do |j|
    (0..C).each do |k|
      total = 500 * i + 100 * j + 50 * k
      result += 1 if total == X
    end
  end
end

puts result

Measured memory_bytes: 1788
N,Y = map(int,input().split())

check = False
for i in range(N+1):
  for j in range(N+1):
    k = (Y - 10000 * i - 5000 * j) / 1000
    if k != int(k) or k < 0 or k != N - i - j:
      continue
    else:
      check = True
      ans = [i,j,int(k)]
      
if not check:
  ans = [-1,-1,-1]
print(*ans)

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

using namespace std;
#define int long long
#define N 666666
#define mod 1000000007
int n,k;
int arr[N];
int pre[N],sum[N];
map<int,int> vis,mp;
signed main(){
	cin>>n>>k;
	for(int i=1;i<=n;i++) scanf("%lld",&arr[i]);
	mp[arr[n]]++;
	int ans=0;
	for(int i=n-1;i>=1;i--){
		int tot=0;
		for(int j=1;j<arr[i];j++){
			tot+=mp[j]; 
		}
		pre[i]=tot;
		mp[arr[i]]++;
	}
	for(int i=1;i<=n;i++){
		int tot=0;
		for(int j=1;j<arr[i];j++){
			tot+=mp[j];
		}
		sum[i]=tot;
	}
	int temp;
	temp=(k-1)*k/2;
	//temp-=k;
	temp%=1000000007;
	for(int i=1;i<=n;i++){
		int b=sum[i];
		int a=pre[i];
		ans+=(((k)*a)%mod+(b*(temp)%mod+mod)%mod)%mod;
		ans=ans%mod;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 4480
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
using ll = long long;
int main(void){
  string S;
  cin>>S;
  int len=S.size();
  int cnt=0,MAX=0;
  
  rep(i,len){
      if(S[i]=='A'||S[i]=='C'||S[i]=='G'||S[i]=='T'){
          cnt++;
          MAX=max(MAX,cnt);
      }
      else{
          cnt=0;
      }
  }
  cout<<MAX<<endl;
}

Measured memory_bytes: 3556
#include <bits/stdc++.h>
using namespace std;
#define repr(i,k,n) for(int i = (k); i < (n); i++)
#define rep(i,n) repr(i,0,n)
#define ALL(a) begin(a),end(a)
const int MOD = 1000000007;
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
int ctoi(const char c){
  switch(c){
    case '0': return 0;
    case '1': return 1;
    case '2': return 2;
    case '3': return 3;
    case '4': return 4;
    case '5': return 5;
    case '6': return 6;
    case '7': return 7;
    case '8': return 8;
    case '9': return 9;
  }
}
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll A, B;
    cin >> A >> B;
    rep (K ,1000000000){
        if (abs(A-K) == abs(B-K)){
            cout << K << endl;
            return 0;
        }
    }
    cout << "IMPOSSIBLE" << endl;
    return 0;
}

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

#define ALL(c) (c).begin(), (c).end()
#define CALL(c) (c).cbegin(), (c).cend()
#define RALL(c) (c).rbegin(), (c).rend()
#define CRALL(c) (c).crbegin(), (c).crend()
#define REP(i, n) for (int i = 0; i < static_cast<int>(n); i++)
#define FOR(i, s, n) for (int i = s; i < static_cast<int>(n); i++)
#define PSORT(s,p,e) partial_sort((s), next((s), (p)), (e))
#define VIEW(v,t) for_each((v).begin(), (v).end(), [](t& a) { cout << a << " "; }); cout << endl;

const int INF = INT_MAX;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};

using PII = pair<int, int>;
using LL = long long;
using ULL = unsigned long long;
template<class T> using V = vector<T>;
template<class T> using V2 = vector<vector<T>>;
template<class T, int W=255> using A = array<T, W>;
template<class T, int W=255, int H=255> using A2 = array<array<T, W>, W>;

int n;
V<int> l;

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cin >> n;
    REP(i,n) {
        int x; cin >> x; l.push_back(x);
    }
    std::sort(ALL(l), [](int& x, int& y) { return x > y; });

    int m = l[0];
    FOR(i,1,n) {
        m -= l[i];
    }
    cout << ((m < 0) ? "Yes" : "No") << "\n";
}

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

int main() {
    int N;
    cin >> N;
    vector<ll> vec(N);
    for(int i = 0; i < N; i++){
        cin >> vec.at(i);
    }

    int ans = 0;
    for(ll i = 0; i < N; i++){
        if(vec.at(i) % 2 == 0){
            for(int j = 0; j < 1000000000; j++){
                vec.at(i) /= 2;
                ans++;
                if(vec.at(i) % 2 != 0) break;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3732
#include<iostream>
#include<string>

using namespace std;

int main()
{
  string s;
  
  int ans=700;
  
  cin>>s;
  
  if(s[0]=='o')
  {
    ans+=100;
  }
  
  if(s[1]=='o')
  {
    ans+=100;
  }
  
  if(s[2]=='o')
  {
    ans+=100;
  }
  
  cout<<ans<<endl;
  
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
public class AGC037A {
    public static void Main() {
        int ans = 0;
        string S;
        char before = '*';
        S = Console.ReadLine();

        for (int i = 0; i < S.Length; i++) {
            //Console.WriteLine(before.ToString() + " | " + S[i] +'\n');
            if (before == '*') {
                if (i == S.Length - 2) {
                    if (S[i] == S[i + 1]) {
                        ans++;
                        break;
                    }
                }
                before = S[i];
                ans++;
                continue;
            }
            if (before == '+') {
                before = '*';
                ans++;
                continue;
            }

            if (S[i] == before) {
                before = '+';
            } else {
                if (i == S.Length - 2) {
                    if (S[i] == S[i + 1]) {
                        ans++;
                        break;
                    }
                }
                ans++;
                before = S[i];
            }
        }
        Console.WriteLine(ans);
    }
}


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

using namespace std;
#define ll long long
const int N = 1e5 + 5;
vector < int > g[N];
int z, ans[N];
bool vis[N];
void bfs() {
    queue < pair < int, int > > q;
    q.push({1, 1});
    vis[1] = 1;
    while(!q.empty()) {
        int node = q.front().first;
        int parent = q.front().second;
        z++;
        ans[node] = parent;
        q.pop();
        for(auto child : g[node]) {
            if (!vis[child]) {
                vis[child] = 1;
                q.push({child, node});
            }
        }
    }
}
int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int n, m;
    cin >> n >> m;
    for(int i = 1 ; i <= m ; i++) {
        int a, b;
        cin >> a >> b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    bfs();
    if (z == n) {
        cout << "Yes\n";
        for(int i = 2 ; i <= n ; i++) cout << ans[i] << "\n";
    }
    else {
        cout << "No\n";
    }
    return 0;
}


Measured memory_bytes: 10836
#include<stdio.h>
#include<stdlib.h>
int main(){
  int ope[100], top=0, flag=0;
  char c;
  while((c=getchar()) != '\n'){
    if(c == ' '){
      if(flag){
	top++;
	flag = 0;
      }
    }
    if(c == '+'){
      if(top > 1){
	top--;
      }
      ope[top-1] += ope[top];
      ope[top] = 0;
    }else if(c == '-'){
      if(top > 1){
	top--;
      }
      ope[top-1] -= ope[top];
      ope[top] = 0;
    }else if(c =='*'){
      if(top > 1){
	top--;
      }
      ope[top-1] *= ope[top];
      ope[top] = 0;
    }else if(c - '0' >= 0 && c - '0' <= 9){
      if( flag ) {
        ope[top] = ope[top] * 10 + (c - '0');
      } else {
        ope[top] = (c - '0');
        flag++;
      }
    }
  }

  printf("%d\n", ope[0]);
  return 0;
}



Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repo(j,o,n) for(int j=o;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define pb(a) push_back(a)
#define eraser(v,i) (v).erase(v.begin()+(i))
#define pbpair(a,b) push_back(make_pair(a,b))
#define MOD 1000000007
#define INF 9223372036854775807
#define pairint pair<int,int>

signed main()
{
int x=0,y=0,z=0,w=0,n=0,m=0,a=0,b=0;
string s;
std::cin >> x>>y>>z;
std::vector<int> v(x);
rep(i,x){
  v[i]=y-z;
}
rep(i,z){
  std::cin >> w;
v[w-1]++;
}
rep(i,x){
  if(v[i]>0)std::cout << "Yes" << '\n';
  else std::cout << "No" << '\n';
}
}


Measured memory_bytes: 1408
#include <cstdio>
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <cmath>
#include <list>
#include <iomanip>
#include <fstream>

using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }
template<class T> inline T sqr(T x) { return x*x; }
typedef pair<int, int> P;
typedef long long ll;
typedef unsigned long long ull;

#define rep(i,n)  for(int (i) = 0;(i) < (n);(i)++)
#define clr(a) memset((a), 0 ,sizeof(a))
#define mclr(a) memset((a), -1 ,sizeof(a))
#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define sz(a) (sizeof(a))
#define Fill(a,v) fill((int*)a,(int*)(a+(sz(a)/sz(*(a)))),v)
bool cheak(int x, int y, int xMax, int yMax){ return x >= 0 && y >= 0 && xMax > x && yMax > y; }
const int dx[4] = { -1, 0, 1, 0 }, dy[4] = { 0, 1, 0, -1 };
const int mod = 1000000007;
const int INF = 2147483647;

int main()
{
	int n;
	cin >> n;
	rep(_, n){
		string s[2];
		cin >> s[0] >> s[1];
		int m = 0, c = 0, x = 0, i = 0;

		rep(j, 2){
			int t = 1;
			rep(q, s[j].size()){
				if (s[j][q] == 'm'){
					m += t; t = 1;
				}else
				if (s[j][q] == 'c'){
					c += t; t = 1;
				}else
				if (s[j][q] == 'x'){
					x += t; t = 1;
				}else
				if (s[j][q] == 'i'){
					i += t; t = 1;
				}else{
					t = s[j][q] - '0';
				}
			}
		}

		while (c >= 10 || x >= 10 || i >= 10){
			m += c / 10; c -= c / 10 * 10;
			c += x / 10; x -= x / 10 * 10;
			x += i / 10; i -= i / 10 * 10;
		}

		stringstream ans;
		if (m > 1){ ans << m; }
		if (m){ ans << 'm'; }
		if (c > 1){ ans << c; }
		if (c){ ans << 'c'; }
		if (x > 1){ ans << x; }
		if (x){ ans << 'x'; }
		if (i > 1){ ans << i; }
		if (i){ ans << 'i'; }

		cout << ans.str() << endl;
	}

	return 0;
}

Measured memory_bytes: 1216
#include <iostream>
#include <map>
using namespace std;
map <int,int> c;
int a[200001],b[200001],n,m;
int main() {
	ios::sync_with_stdio(0);
	cin >> n;
	for(int i=0;i<n;i++){
		cin >> a[i];
		c[a[i]]++;
	}
	cin >> m;
	for(int i=0;i<m;i++){
		cin >> b[i];
		if(c[b[i]]>0){
			c[b[i]]--;
		}else{
			cout << "NO";
			return 0;
		}
	}
	cout << "YES";
	return 0;
}

Measured memory_bytes: 11264
N = input("")
X = input("").split(" ")
M = input("")
A = input("").split(" ")

for a in A:
    index = int(a) - 1
    if X[index] == "2019":
        continue
    if not str(int(X[index]) + 1) in X:
        X[index] = str(int(X[index]) + 1)
for x in X:
    print(x)


Measured memory_bytes: 5612
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>

using namespace std;

bool kaibun(string s){
    size_t len = s.length();
    for(int i = 0; i < len/2; i++){
        if(s[i] != s[len-i-1]) return false;
    }
    return true;
}

int main(){
    int N,R,K=0;
    cin >> N >> R >> K;
    if(N==R and R!=K){cout << "Yes" << endl;return 0;}
    if(R==K and K!=N){cout << "Yes" << endl;return 0;}
    if(N==K and R!=N){cout << "Yes" << endl;return 0;}
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

int main(){
    using namespace std;
    int n, m;
    cin >> n >> m ;
    int vec[n][m];
    for(int i{0}; i<n; i++){
        for(int j{0}; j<m; j++){
            cin >> vec[i][j];
        }
    }
    int b[m];
    for(int k{0}; k<m; k++){
        cin >> b[k];
    }
    int c{0};
    for(int i{0}; i<n; i++){
        for(int j{0}; j<m; j++){
           c = c + vec[i][j] * b[j] ;
        }
        cout << c << endl;
        c =0;
    }
}


Measured memory_bytes: 3160
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    string ans = "";
    rep(i, 3) {
        string c;
        cin >> c;
        ans += c;
    }

    cout << ans[0] << ans[4] << ans[8] << endl;
    return 0;
}

Measured memory_bytes: 256