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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

int main()
{
    ll i,j;
    ll w,h;
    cin >> w >> h;
    ll tate = h + 1;
    ll yoko = w + 1;
    priority_queue<pair<ll,ll>> pq;
    rep(i,w){
        ll p;
        cin >> p;
        pq.emplace(-p, 0);
    }
    rep(i,h){
        ll q;
        cin >> q;
        pq.emplace(-q, 1);
    }
    ll spare = (h + 1)*(w + 1) - 1;
    ll ans = 0;
    while(spare){
        auto x = pq.top();
        pq.pop();
        ll num = -x.first;
        ll flag = x.second;
        if(flag == 0){
            ans += num*tate;
            --yoko;
            spare -= tate;
        }else{
            ans += num*yoko;
            --tate;
            spare -= yoko;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 7408
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner scan = new Scanner(System.in);
		int X = scan.nextInt();
		int Y = scan.nextInt();
		int Z = scan.nextInt();
		System.out.println((int)Math.floor((X-Z)/(Y+Z)));
	}
}


Measured memory_bytes: 21844
import itertools
import copy

h, w, k = map(int, input().split())

rows = []
for i in range(h + 1):
    rows += list(itertools.combinations(list(range(0, h)), i))

cols = []
for i in range(w + 1):
    cols += list(itertools.combinations(list(range(0, w)), i))

data = []
for i in range(h):
    data.append(list(input()))

result = 0
for row in rows:
    for col in cols:
        temp = copy.deepcopy(data)
        for r in row:
            for j in range(w):
                temp[r][j] = 'r'
        for c in col:
            for i in range(h):
                temp[i][c] = 'r'
        count = 0
        for i in range(h):
            for j in range(w):
                if temp[i][j] == '#':
                    count += 1
        if count == k:
            result += 1

print(result)

Measured memory_bytes: 73636
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define BUF_SIZE 25

struct product {
  int weight;
  double value;
  int total_value;
};

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

int main(void) {
  FILE *fp = stdin;
  char line[BUF_SIZE];
  if(!fgets(line, BUF_SIZE, fp)) return 0;
  int num, weight;
  sscanf(line, "%d %d", &num, &weight);

  struct product *prods = malloc(sizeof(struct product)*num);

  int i, j;
  for(i = 0; i < num; i++) {
    if(!fgets(line, BUF_SIZE, fp)) return 0;
    int val, wei;
    sscanf(line, "%d %d", &val, &wei);
    prods[i].weight = wei;
    prods[i].value = (double)val/(double)wei;
    prods[i].total_value = val;
  }

  qsort(prods, num, sizeof(struct product), comp);
  int cur_weight = 0;
  double sum = 0;
  for(i = 0; i < num; i++) {
    int rem = weight - cur_weight;
    if(rem > prods[i].weight) {
      cur_weight += prods[i].weight;
      sum += prods[i].total_value;
    } else {
      sum += prods[i].value * rem;
      break;
    }
  }
  printf("%lf\n", sum);
  return 0;
}


Measured memory_bytes: 6080
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const ll MAX=1e5+3;
vector<ll>ed[MAX];

int main() {
    ll n;
    cin>>n;
    ll ans=0;
    map<string,ll>mp;
    for(ll i=0;i<n;i++)
    {
        string s;
        cin>>s;
        sort(s.begin(),s.end());
        mp[s]++;
    }
    for(auto it=mp.begin();it!=mp.end();it++)
    {
        ll fre=(*it).second;
        ans+=((fre)*(fre-1))/2;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 13568
// AOJ 0172: Doctor's Research Rooms
// 2018.1.24 bal4u@uu

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef struct { char rm; int light; } Q;
Q q[491520]; int top, end;
Q *used[15][32768];

int rm[15][15], s_rm[15];
int sw[15][15], s_sw[15];

char *msg[7] = {0,
"You can go home in %d steps.\n",
"You can not switch off all lights.",
"Help me!",
"Move to room %d.\n",
"Switch on room %d.\n",
"Switch off room %d.\n" };

typedef struct { char msg, rm; } T;
T res[500]; int sz;

//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0;
	int c = getchar_unlocked();
	while (c < '0') c = getchar_unlocked();
	do n = (n<<3)+(n<<1) + (c & 0xf), c = getchar_unlocked();
	while (c >= '0');
	return n;
}

int cmp(int *a, int *b) { return *a - *b; }

int main()
{
	int n, m, i, j, s, t, ans;
	int room, light;

	while (n = in()) {
		m = in();
		memset(s_rm, 0, sizeof(s_rm));
		memset(s_sw, 0, sizeof(s_sw));

		for (i = 0; i < m; i++){
			s = in()-1, t = in()-1;
			rm[s][s_rm[s]++] = t;
			rm[t][s_rm[t]++] = s;
		}

		light = 0; for (i = 0; i < n; i++) if (in()) light |= 1 << i;

		for (i = 0; i < n; i++) {
			j = in(); while (j--) sw[i][s_sw[i]++] = in()-1;
			qsort(sw[i], s_sw[i], sizeof(int), cmp);
        }

		memset(used, 0, sizeof(used));
		q[0].rm = 0, q[0].light = light; top = 0, end = 1;
		used[0][light] = q;

		ans = 3;
		while (top < end) {
			s = q[top].rm, t = q[top].light;

			if (s == n-1) {
				if (t == 1<<(n-1)) { ans = 1; break; }
				ans = 2;
			}

			for (i = 0; i < s_sw[s]; i++) if (sw[s][i] != s) {
				light = t ^ (1<<sw[s][i]);
				if (used[s][light] == 0) {
					used[s][light] = q + top;
					q[end].rm = s, q[end++].light = light;
				}
			}

			for (i = 0; i < s_rm[s]; i++) {
				room = rm[s][i];
				if (t & (1<<room)) {
					if (used[room][t] == 0) {
						used[room][t] = q + top;
						q[end].rm = room, q[end++].light = t;
					}
				}
			}

			top++;
		}
 
		if (ans > 1) puts(msg[ans]);
		else {
			Q p = q[top];
			sz = 0;
			while (1) {
				Q nxt = *used[p.rm][p.light];
				if (nxt.rm == p.rm && nxt.light == p.light) break;
				if (p.rm != nxt.rm) res[sz].msg = 4, res[sz++].rm = p.rm;
				else for (i = 0; i < n; i++) if ((p.light & (1<<i)) ^ (nxt.light & (1<<i))) {
					if (p.light & (1<<i)) res[sz].msg = 5; else res[sz].msg = 6;
					res[sz++].rm = i;
					break;
				}
				p = nxt;
			}
			printf(msg[ans], sz);
			while (sz--) printf(msg[res[sz].msg], 1 + res[sz].rm);
		}
    }
    return 0;
}


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

struct node
{
    int key;
    struct node *parent;
    struct node *left;
    struct node *right;
};


struct node *treeInsert(struct node *T, struct node *z)
{
    struct node *r, *x, *y;
    r = T;
    y = NULL;
    x = r;
    while (x != NULL)
    {
        y = x;
        if (z->key < x->key)
        {
            x = x->left;
        }
        else
        {
            x = x->right;
        }
    }
    z->parent = y;
    if (y == NULL)
    {
        r = z;
    }
    else
    {
        if (z->key < y->key)
        {
            y->left = z;
        }
        else
        {
            y->right = z;
        }
    }
    return r;
}

void inorder_tree_work(struct node *T)
{
    if (T != NULL)
    {
        inorder_tree_work(T->left);
        printf(" %d", T->key);
        inorder_tree_work(T->right);
    }
}

void preorder_tree_work(struct node *T)
{
    if (T != NULL)
    {
        printf(" %d", T->key);
        preorder_tree_work(T->left);
        preorder_tree_work(T->right);
    }
}

int main(void)
{
    struct node *Tree = NULL;
    struct node *z;
    int n;
    int key;
    char command[10];

    scanf("%d", &n);
    for (int i = 0; i < n; i++)
    {
        scanf("%s", command);
        if (command[0] == 'i')
        {
            scanf("%d", &key);
            z = (struct node *)malloc(sizeof(struct node));
            z->key = key;
            z->left = NULL;
            z->right = NULL;
            Tree = treeInsert(Tree, z);
        }
        else if (command[0] == 'p')
        {
            inorder_tree_work(Tree);
            printf("\n");
            preorder_tree_work(Tree);
            printf("\n");
        }
    }
    return 0;
}


Measured memory_bytes: 25296
// $%U%$
// $%D%$/$%M%$/$%Y%$
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define all(x) (x).begin(), (x).end()
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef long long int  ll;
const int INF = 1e9 + 7;
const ll mod = 998244353;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
int nxt() {int x;scanf("%d", &x);return x;}

int main(){
    ll n, x, m;
    cin >> n >> x >> m;
    VI a;
    set<int> s;
    a.push_back(x);
    while(a.size() < n){
        ll last = a[a.size()-1];
        ll next = (last*last) % m;
        if(s.count(next)){
            vector<ll> prefix(a.size(), 0);
            int marker = -1;
            REP(i, a.size()){
                prefix[i] = a[i];
                if(i) prefix[i] += prefix[i-1];
                if(a[i] == next) marker = i;
            }
            assert(marker != -1);
            ll no = 0;
            if(marker) no = prefix[marker - 1];
            ll repeat = prefix[prefix.size()-1] - prefix[marker-1];
            ll cycle = prefix.size() - marker;
            n -= marker;
            repeat *= (n/cycle);
            /* printf("%lld\n", no); */
            /* printf("%lld\n", repeat); */
            for(int i = 0; i < n%cycle; i++){
                repeat += a[marker+i];
            }
            printf("%lld\n", repeat + no);
            return 0;
        }
        else{
            s.insert(next);
            a.push_back(next);
        }
    }
    ll ans = 0;
    REP(i, n) ans += a[i];
    printf("%lld\n", ans);
}




Measured memory_bytes: 5944
#include <iostream>
#include <cmath>
#include <iomanip>

using namespace std;

double format(double value) {
    return ((int)(value*1000.0+0.5)) / 1000.0;
}

int main(){
    int a, b, c, d, e, f;
    double bufferX, bufferY;

    while (cin >> a >> b >> c >> d >> e >> f) {
        bufferY = ((double)(c*d-a*f))/((double)(b*d-a*e));
        bufferX = ((double)(c-b*bufferY))/((double)a);

        cout << fixed << setprecision(3) << bufferX << " " << bufferY << endl;
    }

    return 0;
}


Measured memory_bytes: 3264
#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

const int N = 2e3 + 5;

int n, m;
char c[N][N];
int a[N][N], l[N][N], u[N][N], r[N][N], d[N][N];


int32_t main()
{
	IOS;
	cin >> n >> m;
	for(int i = 1; i <= n; i++)
		for(int j = 1; j <= m; j++)
		{
			cin >> c[i][j];
			if(c[i][j] == '.')
				a[i][j] = 1;
		}
	for(int i = 1; i <= n; i++)
	{
		for(int j = 1; j <= m; j++)
		{
			if(!a[i][j])
				l[i][j] = 0;
			else
				l[i][j] = 1 + l[i][j - 1];
		}
	}
	for(int i = 1; i <= n; i++)
	{
		for(int j = m; j >= 1; j--)
		{
			if(!a[i][j])
				r[i][j] = 0;
			else
				r[i][j] = 1 + r[i][j + 1];
		}
	}
	for(int j = 1; j <= m; j++)
	{
		for(int i = 1; i <= n; i++)
		{
			if(!a[i][j])
				u[i][j] = 0;
			else
				u[i][j] = 1 + u[i - 1][j];
		}
	}
	for(int j = 1; j <= m; j++)
	{
		for(int i = n; i >= 1; i--)
		{
			if(!a[i][j])
				d[i][j] = 0;
			else
				d[i][j] = 1 + d[i + 1][j];
		}
	}
	int ans = 0;
	for(int i = 1; i <= n; i++)
	{
		for(int j = 1; j <= m; j++)
		{
			if(a[i][j])
			{
				ans = max(ans, l[i][j] + r[i][j] + u[i][j] + d[i][j] - 3);
			}
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 161152
package main

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

func main() {
	A := nextInt64()
	B := nextInt64()

	fmt.Println(lcm(A, B))
}

func gcd(a, b int64) int64 {
	if b > a {
		a, b = b, a
	}
	for b != 0 {
		a, b = b, a%b
	}
	return a
}
func lcm(a, b int64) int64 {
	return a * b / gcd(a, b)
}

var stdin = initStdin()

func initStdin() *bufio.Scanner {
	bufsize := 1 * 1024 * 1024 // 1 MB
	var stdin = bufio.NewScanner(os.Stdin)
	stdin.Buffer(make([]byte, bufsize), bufsize)
	stdin.Split(bufio.ScanWords)
	return stdin
}

func nextString() string {
	stdin.Scan()
	return stdin.Text()
}

func nextBytes() []byte {
	stdin.Scan()
	return stdin.Bytes()
}

func nextInt() int {
	i, _ := strconv.Atoi(nextString())
	return i
}

func nextInt64() int64 {
	i, _ := strconv.ParseInt(nextString(), 10, 64)
	return i
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define AC ios::sync_with_stdio(false);cin.tie(0);
#define ll long long

int main(){
    AC
    ll n;
    cin>>n;
    string a;
    set<string> s;
    while(n--)
    {
        cin>>a;
        s.insert(a);
    }
    cout<<s.size();
}


Measured memory_bytes: 19184
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <functional>
#include <utility>
#include <fstream>

using namespace std;

#define ll long long
#define INF 2000000000
#define LINF 9000000000000000000
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define dum(x) cout<<#x<<'='<<x<<endl
#define dum2(x,y) cout<<#x<<'='<<x<<' '<<#y<<'='<<y<<'\n'<<endl
#define dum3(x,y,z) cout<<#x<<'='<<x<<' '<<#y<<'='<<y<<' '<<#z<<'='<<z<<'\n'<<endl
#define darr(arr,n) rep(i,(n-arr)){cout<<*(arr+i)<<' ';}cout<<endl
#define ddarr(arr,a,b) rep(i,a){rep(j,b){cout<<*(arr+i*b+j)<<' ';}cout<<endl;}
#define ddd ifstream in("Text.txt");cin.rdbuf(in.rdbuf());


int main() {
    ll N;
    cin >> N;
    if (N % 2 == 0) {
        cout << N << endl;
    }
    else {
        cout << N * 2 << endl;
    }

}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>

using namespace std;


inline void print() {
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest) {
    cout << first << ' ';
    print(rest...);
}


void solve() {
    int N; cin >> N;
    map<char, int> mp;
    cin >> mp['A'] >> mp['B'] >> mp['C'];
    vector<string> s(N);
    for (int i = 0; i < N; i++) cin >> s[i];

    string ans;

    for (int i = 0; i < N-1; i++) {
        if (mp['A'] == 0 || mp['B'] == 0 || mp['C'] == 0) {
            if (mp[s[i][0]] == 1 && mp[s[i][1]] == 1) {
                if (s[i][0] == s[i+1][0] || s[i][0] == s[i+1][1]) {
                    mp[s[i][0]]++; mp[s[i][1]]--;
                    ans += s[i][0];
                }
                else {
                    mp[s[i][0]]--; mp[s[i][1]]++;
                    ans += s[i][1];
                }
                continue;
            }
        }

        if (mp[s[i][0]] > mp[s[i][1]]) {
            mp[s[i][0]]--; mp[s[i][1]]++;
            ans += s[i][1];
        }
        else {
            mp[s[i][0]]++; mp[s[i][1]]--;
            ans += s[i][0];
        }

        if (mp[s[i][0]] < 0 || mp[s[i][1]] < 0) {
            cout << "No" << endl;
            return;
        }
    }


    if (mp[s[N-1][0]] > mp[s[N-1][1]]) {
        mp[s[N-1][0]]--; mp[s[N-1][1]]++;
        ans += s[N-1][1];
    }
    else {
        mp[s[N-1][0]]++; mp[s[N-1][1]]--;
        ans += s[N-1][0];
    }

    if (mp[s[N-1][0]] < 0 || mp[s[N-1][1]] < 0) {
        cout << "No" << endl;
        return;
    }


    cout << "Yes" << endl;
    for (auto c : ans) cout << c << endl;
}


int main() {
    solve();
    return 0;
}

Measured memory_bytes: 6696
// 5_abc136_e
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define SZ(x) ((int)(x).size())
#define INF (1e16)
typedef long long ll;

int n, k;
vector<int> a;
vector<int> r;
int s;
int ans;

void func(int d){
    if(d == 1) return;

    rep(i, n){
        r[i] = a[i] % d;
    }
    sort(r.begin(), r.end());
    int its = 0;
    int itt = n - 1;
    int cnt = 0;
    while(its < itt){
        int diff = min(r[its], d - r[itt]);
        r[its] -= diff;
        r[itt] += diff;
        cnt += diff;

        if(r[its] == 0) its++;
        if(r[itt] == d) itt--;
    }
    if(cnt > k) return;

    ans = max(ans, d);
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n >> k;
    s = 0;
    ans = 1;
    a.resize(n);
    r.resize(n);
    rep(i, n){
        cin >> a[i];
        s += a[i];
    }

    for(int i = 1; i * i <= s; i++){
        if(s % i) continue;

        func(i);
        func(s / i);
    }

    cout << ans << endl;
    return 0;
}


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

int main() {
   int n;
   string s,t;
   cin>>n>>s>>t;
   int result=2*n;
   int max=0;
   for(int i=1;i<=n;i++){
       int loop=1;
       for(int j=1;j<=i;j++){
           if(s.at(n-i-1+j)==t.at(j-1)){
               continue;
           }else{
               loop=0;
               break;
           }

       }
       if(loop==0) continue;
       else if(max<i) max=i;
   }
   cout<<2*n-max<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep2(i,n) for (int i = 1; i < (n); ++i)
using namespace std;
typedef long long ll;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N;
    cin >> N;
    vector<int> d(N);
    rep(i,N) cin >> d[i];
    sort(d.begin(), d.end());
    int h = N/2;
    int ans = 0;
    if(d[h]>d[h-1]) ans = d[h]-d[h-1];
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
typedef long long ll;
using namespace std;
const int MOD =998244353;
const int N = 300003;
ll fact[N], inv[N];

ll bin(ll n, ll m){
    if(m==1) return n;
    ll nn = bin(n,m/2);
    if(m%2==0){
        return (nn*nn)%MOD;
        //n = (n*n)%MOD;
        //return bin(n,m/2)%MOD;
    }
    return ((n* nn)%MOD*nn)%MOD;
}

void fun(){
    fact[0] =1;
    for(int i=1;i<N;i++){
        fact[i] = (i*fact[i-1])%MOD;
        inv[i] = bin(fact[i],MOD-2);
    }
    inv[0] = 1;
}

ll ncr(int n,int r){
    return ((fact[n]*inv[r])%MOD*inv[n-r])%MOD;
}

int main() {
    ll ans =0;
    ll n,a,b,k;
    fun();
    cin>>n>>a>>b>>k;
    for(int i=0;i<=n;i++){
        if( (k-(a*i))%b!=0) continue;
        int j =  (k-(a*i))/b;
        if(j<0 || j>n) continue;
        ans+=(ncr(n,i)*ncr(n,j))%MOD;
        ans%=MOD;
    }
    cout<<ans;
}


Measured memory_bytes: 4992
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
ll dat[200000];
ll imos[200000];
int main()
{
	int num, query;
	scanf("%d%d", &num, &query);
	vector<ll>vec;
	vec.push_back(num);
	for (int i = 0; i < query; i++)
	{
		ll z;
		scanf("%lld", &z);
		for (;;)
		{
			if (vec.empty())break;
			ll t = vec[vec.size() - 1];
			if (t >= z)vec.pop_back();
			else break;
		}
		vec.push_back(z);
	}
	dat[vec.size() - 1] = 1;
	for (int i = vec.size() - 1; i >= 0; i--)
	{
		ll now = vec[i];
		for (;;)
		{
			int low = lower_bound(vec.begin(), vec.end(), now) - vec.begin() - 1;
			if (low == -1)
			{
				imos[0] += dat[i];
				imos[now] -= dat[i];
				break;
			}
			dat[low] += dat[i] * (now / vec[low]);
			now %= vec[low];
		}
	}
	for (int i = 0; i < num; i++)imos[i + 1] += imos[i];
	for (int i = 0; i < num; i++)printf("%lld\n", imos[i]);
}

Measured memory_bytes: 4212
#include <iostream>
#include <vector>
#include <numeric>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string>
#include <cstring>
#include <queue>
#define myfor(i,N) for(i=0;i<N;i++)
#define myforFL(i,f,l) for(i=f;i<l;i++)
#define myforInv(i,N) for(i=N;i>=0;i--)
#define myforFLInv(i,f,l) for(i=f;i>l;i--)

using namespace std;

int main(){
	int H1,M1,H2,M2,K,awake_time;
	cin >> H1 >> M1 >> H2 >> M2 >> K;
	awake_time = (H2- H1)*60 + (M2 - M1);
	cout << awake_time - K << endl;

	return 0;
}


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

#define ll long long;
mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x; }

struct fast_ios {
  fast_ios() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
  };
} fast_ios_;

int main() {
  int L, R, d;
  cin >> L >> R >> d;
  int res = 0;
  for (int i = L; i <= R; ++i) {
    if (i % d == 0)
      res++;
  }
  cout << res << "\n";

  return 0;
}

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

#define debug(x) cout <<"DEBUG"<<" "<<#x<<":"<<x<<'\n'

//↓0-originか1-originでn回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   //0-origin昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) //1-origin昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  //0-origin降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   //1-origin降順
//rep2 -> 第二引数 m から n 回繰り返し ex) m=5 n=3 なら i=5,i=6,i=7 まで
#define rep2(i,m,n) for(int i = ((int)(m)); i < ((int)(n))+((int)(m)); i++)
#define SIZE(x) ((int)((x).size()))
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii; //2次元配列
typedef vector<ll> vll;
typedef vector<string> vs;
template<class T,class U> inline bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U> inline bool chmin(T &a, const U &b){if(a>b){a=b;return 1;}return 0;}

/* 円周率は M_PI を使おうね */
const ll infll = (1LL<<62)-1;
const int inf = (1<<30)-1;

/*FUNCs=================================================*/


/*MAIN==================================================*/
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
    //cout << fixed << setprecision(10);

    string s; cin >> s;
    int cnt = 0;
    for(int i = 0; i < s.size()-1; ++i) {
        if(s[i] != s[i+1]) cnt++;
    }
    cout << cnt << '\n';
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define ll long long
#define rep(i, n) for(int i=0;i<(n);++i)
#define per(i, n) for(int i=(n)-1;i>=0;--i)
#define repa(i, n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
const ll MOD = (ll)1e9+7;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}

ll modpow(ll x, ll b){
	ll res = 1;
	while(b){
		if(b&1)res = res * x % MOD;
		x = x * x % MOD;
		b>>=1;
	}
	return res;
}

ll modinv(ll x){
	return modpow(x, MOD-2);
}

int n;
vector<pll> line;
vvector<ll> dp;

ll func(int l, int r){
	if(l==r)return 0;
	if(dp[l][r]>=0)return dp[l][r];
	ll res = INFLL;
	for(int mid=l;mid<r;++mid){
		chmin(res, func(l, mid) + func(mid+1, r) + line[l].first * line[mid].second * line[r].second);
	}
	return dp[l][r] = res;
}

int main(){
	cin >> n;
	line.resize(n);
	dp.resize(n, vector<ll>(n, -1));
	foreach(i, line)cin>>i.first>>i.second;
	cout << func(0, n-1) << endl;
	return 0;
}



Measured memory_bytes: 3216
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <list>
#include <algorithm>

using namespace std;

typedef unsigned long long u64;

int gcd(int a, int b)
{
	while (b != 0)
	{
		int r = a % b;
		a = b;
		b = r;
	}

	return a;
}

int main()
{
	u64 n, m;
	string s, t;

	cin >> n >> m;
	cin >> s >> t;

	if (s[0] != t[0])
	{
		cout << -1 << endl;
		return 0;
	}

	int g = gcd(n, m);
	
	u64 l = n * m / g;

	if (g == 1)
	{
		cout << l << endl;
		return 0;
	}

	u64 p = l / n;
	u64 q = l / m;
	u64 v = p * q;

	for (u64 i = 0; i < l; i += v )
	{
		if (s[i / p] == t[i / q])
		{
			continue;
		}

		cout << -1 << endl;
		return 0;
	}

	cout << l << endl;

	return 0;
}

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

// エイリアス
using  ll = long signed long;
using ull = long unsigned long;
using  ld = long double;
using   P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;

// 汎用マクロ
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(i,q) for (auto &i : q)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
#define SZ(x) ((int)(x).size())
template <class T>inline bool chmin(T &a, const T b) {if (a > b) { a = b; return true;} return false;}
template <class T>inline bool chmax(T &a, const T b) {if (a < b) { a = b; return true;} return false;}
template <class T>inline void line_out(const vector<T> vec) {int n = SZ(vec); rep(i, n) { cout << vec[i]; if(i < n-1) cout << " ";}cout << endl;}
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 55;
const int mod = 1000000007;
//const int mod = 998244353;
struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};


int main()
{
  int h, w, a, b;
  cin >> h >> w >> a >> b;
  vector<vector<int>> ans(h, vector<int>(w));
  rep(i, h) rep(j, w) {
    if(i < b && j < a) ans[i][j] = 1;
    else if(i >= b && j >= a) ans[i][j] = 1;
    else ans[i][j] = 0;
  }
  rep(i, h) {
    rep(j, w) cout << ans[i][j];
    cout << endl;
  }
}

Measured memory_bytes: 7540
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static StreamReader sr;

        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static long Mod = (long)998244353;
        static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            var NC = Sarray();
            var N = NC[0];
            var C = NC[1];

            var Di = new long[C][];
            for (var i = 0; i < C; ++i)
                Di[i] = Sarray();
            // 色をiからjに変更するときの違和感の最小値
            /*for (var k = 0; k < C; ++k)
                for (var i = 0; i < C; ++i)
                    for (var j = 0; j < C; ++j)
                        Di[i][j] = Min(Di[i][j], Di[i][k] + Di[k][j]);*/

            var Ci = Enumerable.Range(0, 3).Select(_ => new long[C]).ToArray();
            // %3のグリッドについて出てくる色の数
            for (var i = 0; i < N; ++i)
            {
                var cij = Sarray();
                for (var j = 0; j < N; ++j)
                    ++Ci[(i + j) % 3][cij[j] - 1];
            }

            // 色を3つ決めて違和感を計算
            var ans = long.MaxValue;
            for (var i = 0; i < C; ++i)
            {
                for (var j = 0; j < C; ++j)
                {
                    if (i == j) continue;
                    for (var k = 0; k < C; ++k)
                    {
                        if (j == k || i == k) continue;
                        var t = 0L;
                        for (var l = 0; l < C; ++l)
                        {
                            t += Di[l][i] * Ci[0][l];
                            t += Di[l][j] * Ci[1][l];
                            t += Di[l][k] * Ci[2][l];
                        }
                        ans = Min(ans, t);
                    }
                }
            }
            WriteLine(ans);
            //Out.Flush();
        }
    }
}

Measured memory_bytes: 15680
#include<stdio.h>

int main(){
	int n,i,a[100001],ans=0;
	scanf("%d",&n);
	for(i=1;i<=n;i++)scanf("%d",&a[i]);
	for(i=1;i<=n;i++){
		if(i==a[a[i]])ans++;
	}
	printf("%d\n",ans/2);
	return 0;
}

Measured memory_bytes: 512
#pragma GCC optimize("O3")
#pragma GCC target("avx")
#include <bits/stdc++.h>
#define rep(i ,n) for(int i=0;i<(int)(n);++i)
#define repr(i ,n) for(int i=n;i>(int)(n);--i)
#define rep1(i ,n) for(int i=1;i<=(int)(n);++i)
#define ALL(a) a.begin(), a.end()
#define RSORT(a) sort(ALL(a),greater<>())
#define SORT(a) sort(ALL(a))
#define bit_check(bit, i) ((bit>>(i)) & 1)
#define PRINT(x) cout << (x) << endl;
#define ENDL cout << endl;
using namespace std;
typedef long long int i64;
typedef unsigned long long u64;
template<class T> using V = vector<T>;
using VI = V<int>;
const int INF = 2e9;
const i64 MOD = 1e9 + 7;

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;}
struct Init_On{
    Init_On(){
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(16);
    }
};

signed main(){
    string s;
    int n , q;
    cin >> n >> q >> s;
    vector<int> l(q) , r(q);
    rep(i , q) cin >> l[i] >> r[i];
    vector<int> sum(n+1 , 0);
    for(int i = 1 ; i < n ; ++i){
        if(s[i-1] == 'A' && s[i] =='C') sum[i+1] = sum[i]+1;
        else sum[i+1] = sum[i];
    }
    rep( i , q){
        cout << sum[r[i]]-sum[l[i]] << endl;
    }
}

Measured memory_bytes: 2176
import java.util.Scanner;
public class Main{
	public static void main (String[] args){
		int i;
		int[] a = new int[3];
		Scanner scan = new Scanner(System.in);
			for(i=0;i<3;i++){
			a[i] = Integer.parseInt(scan.next());
			}
			for(i=0;i<3;i++){
				for(int j=i+1;j<3;j++){
					if(a[i]>a[j]){
						int b = a[i];
						a[i] = a[j];
						a[j] = b;
					}
				}
			}
		System.out.println(a[0]+" "+a[1]+" "+a[2]);
	}
}

Measured memory_bytes: 25984
#include <iostream>
#include <algorithm>
using namespace std;
int N; long long W, v[55], w[55], pv[16777222], pw[16777222], lv[16777222], lw[16777222], rv[16777222], rw[16777222];
int main() {
	cin >> N >> W;
	for (int i = 0; i < N; i++) cin >> v[i] >> w[i];
	int lp = N / 2, rp = N - lp;
	for (int i = 0; i < lp; i++) {
		for (int j = 1 << i; j < 2 << i; j++) {
			lv[j] = lv[j - (1 << i)] + v[i];
			lw[j] = lw[j - (1 << i)] + w[i];
		}
		int lc = 0, rc = 1 << i; long long nv = 0;
		for (int j = 0; j < 2 << i; j++) {
			long long lt = (lc != 1 << i ? lw[lc] : 1LL << 60);
			long long rt = (rc != 2 << i ? lw[rc] : 1LL << 60);
			if (lt < rt) nv = max(nv, lv[lc]), pv[j] = nv, pw[j] = lw[lc++];
			else nv = max(nv, lv[rc]), pv[j] = nv, pw[j] = lw[rc++];
		}
		for (int j = 0; j < 2 << i; j++) lv[j] = pv[j], lw[j] = pw[j];
	}
	for (int i = 0; i < rp; i++) {
		for (int j = 1 << i; j < 2 << i; j++) {
			rv[j] = rv[j - (1 << i)] + v[i + lp];
			rw[j] = rw[j - (1 << i)] + w[i + lp];
		}
		int lc = 0, rc = 1 << i; long long nv = 0;
		for (int j = 0; j < 2 << i; j++) {
			long long lt = (lc != 1 << i ? rw[lc] : 1LL << 60);
			long long rt = (rc != 2 << i ? rw[rc] : 1LL << 60);
			if (lt < rt) nv = max(nv, rv[lc]), pv[j] = nv, pw[j] = rw[lc++];
			else nv = max(nv, rv[rc]), pv[j] = nv, pw[j] = rw[rc++];
		}
		for (int j = 0; j < 2 << i; j++) rv[j] = pv[j], rw[j] = pw[j];
	}
	int pos = (1 << rp) - 1; long long ret = 0;
	for (int i = 0; i < 1 << lp; i++) {
		while (pos >= 0 && lw[i] + rw[pos] > W) pos--;
		if (pos != -1) ret = max(ret, lv[i] + rv[pos]);
	}
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 52248
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int x = sc.nextInt();
		int y = sc.nextInt();

		System.out.println(y%2==0 && 2*x<=y && y<=4*x ? "Yes" : "No" );
	}
}

Measured memory_bytes: 35684
s = input()
p = input()

def search_string_in_cycle_string(s, p):
    code = s + s
    for index in range(len(s)):
        tmp = code[index:index+len(p)]
        if p == tmp:
            return True
    return False

if search_string_in_cycle_string(s, p):
    print("Yes")
else:
    print("No")


Measured memory_bytes: 5564
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

const int N = 1e5 + 7;
const int INF = 1e9 + 239;

int v[N];
vector<int> g[N];
pair<int, int> dp[N];

void dfs(int cur, int p) {
	int l = -INF;
	int r = INF;
	for (auto t : g[cur]) {
		if (t != p) {
			dfs(t, cur);
			if (dp[t].first != -INF) {
				l = max(l, dp[t].first - 1);
				r = min(r, dp[t].second + 1);
			}
		}
	}
	if (l > r) {
		cout << "No" << endl;
		exit(0);
	}
	if (v[cur] != -1) {
		if (l == -INF && r == INF) {
			l = v[cur];
			r = v[cur];
		} else {
			if ((l - v[cur]) % 2) {
				cout << "No" << endl;
				exit(0);
			}
			if ((v[cur] < l || r < v[cur])) {
				cout << "No" << endl;
				exit(0);
			}
			l = v[cur];
			r = v[cur];
		}
	}
	dp[cur] = {l, r};
}

int ans[N];

void jfs(int cur, int p, int val) {
	ans[cur] = val;
	for (auto t : g[cur]) {
		if (t != p) {
			for (auto dt : {-1, 1}) {
				if (dp[t].first <= ans[cur] + dt && ans[cur] + dt <= dp[t].second) {
					jfs(t, cur, ans[cur] + dt);
					break;
				}
			}
		}
	}
}

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

	int n;
	cin >> n;
	for (int i = 0; i + 1 < n; i++) {
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	fill(v, v + n, -1);
	int k;
	cin >> k;
	while (k--) {
		int tv, val;
		cin >> tv >> val;
		tv--;
		v[tv] = val;
	}
	dfs(0, -1);
	jfs(0, -1, dp[0].first);
	cout << "Yes\n";
	for (int i = 0; i < n; i++) {
		cout << ans[i] << '\n';
	}
}


Measured memory_bytes: 15744
#include <stdio.h>
#include <string.h>
#include <vector>
#include <algorithm>
#include <string>
#include <random>
#include <map>
#include <math.h>
#pragma warning(disable : 4996)

int abs(int a) {
	if (a < 0) a *= -1;
	return a;
}
int main(void) {
	int X;
	scanf("%d", &X);
	X = abs(X);
	int n = 1;
	int sum = 0;
	while (true) {
		sum += n;
		if (sum >= X) {
			break;
		}
		++n;
	}
	printf("%d", n);
	return 0;
}


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

using namespace std;

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

	long long ans = 0;
	n -= 1;
	for(int i = 1; i <= n; ++i) {
		ans += n / i;
	}

	cout << ans << '\n';

	return 0;
}

Measured memory_bytes: 3632
n=int(input())
a=list(map(int,input().split()))
t=1
p=a[0]
m=0
for i in a:
  if(p==i):
    continue
  if(m>0):
    if(i<p):
      t+=1
      m=0
  elif(m<0):
    if(i>p):
      t+=1
      m=0
  else:
    if(i>p):
      m=1
    elif(i<p):
      m=-1
  p=i
print(t)

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

int main(){
  int n;
  bool zero = false;
  cin >> n;
  vector<ll> nums(n);
  rep(i,n){
  cin >> nums[i];
  if(nums[i] == 0){zero = true;break;}
  }
  ll ans = 0;
  if(!zero){
  ans = 1;
  rep(i,n){
    if(ans > powl(10,18)/nums[i]){
      ans = -1;
      break;
    }
    ans *= nums[i];
  }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3960
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define all(x)    (x).begin(),(x).end()
typedef long long ll;
const int MOD = (int)1e9 + 7;

int main(){
  int t,x;
  cin >> t >> x;
  cout<< (double) t/x <<endl;
}



Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h>
#include<string>
using namespace std;
typedef long long int ll;
void solve()
{
    int N,L,i;
    cin>>N>>L;
    string S[N];
    for(i=0;i<N;i++) cin>>S[i];
    sort(S,S+N);
    for(i=0;i<N;i++) cout<<S[i];
    return;
}
int main()
{
    solve();
}

Measured memory_bytes: 3576
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;

int main(){
  int n,a[1000],sa;
  while (1){
    cin >> n;
    if (n==0)return 0;
    for (int i=0;i<n;i++)cin >> a[i];
    sort(a,&a[n]);
    sa=1000001;
    for (int i=1;i<n;i++)
      if (abs(a[i-1]-a[i])<sa)sa=abs(a[i-1]-a[i]);
    cout << sa << endl;
  }
}

Measured memory_bytes: 3040
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> p;
vector<pair<p,ll>>v;
int main()
{
    char str;
    cin >> str;
    if(str>='A' && str<='Z')
    	cout << "A" << endl;
    else
    	cout << "a" << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <stdio.h>


int main(void){
    long long n, a, b;
    scanf("%lld %lld %lld", &n, &a, &b);
    long long x, y, ans;
    ans = 0;
    x = n / (a + b);
    ans += x * a;
    y = n % (a + b);
    if(a < y){
        ans += a;
    }
    else{
        ans += y;
    }
    if(a == 0){
        printf("0\n");
    }
    else{
        printf("%lld\n", ans);
    }

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  string s;cin >> s;
  int num = 0;
  for(auto&c : s)if(c=='1') ++num;
  cout << num << endl;
  return 0;
}


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

int main(){
  int n,m;
  cin>>n>>m;
  
  int lis[n+1];
  memset(lis,0,sizeof(lis));
  rep(i,0,m*2){
    int tmp;
    cin>>tmp;
    lis[tmp]++;
  }

  rep(i,1,n+1){
    cout<<lis[i]<<endl;
  }

  return 0;
}


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

int main() {
    int n;
    cin >> n;
    int p[n];
    rep(i, n) cin >> p[i];

    int ans = 0;
    for (int i = 1; i < n - 1; i++) {
        if (p[i - 1] < p[i] && p[i] < p[i + 1] ||
            p[i - 1] > p[i] && p[i] > p[i + 1])
            ans++;
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define INF INT_MAX 
#define mod 1000000007
using namespace std;
int main(){
    ll N,K;
    cin >> N >> K;
    ll ans = K;
    for(int i=0;i<N-1;i++){
        ans *= (K-1);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
N = int(input())
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

import collections
c = collections.Counter(prime_factorize(N))
sosu = list(c.values())
answer = 0
for i in range(len(sosu)):
    if sosu[i]==1:
        answer += 1
    else:
        answer += int(-1/2+((1+8*(sosu[i]))**(1/2))/2)
print(answer)
        

Measured memory_bytes: 66444
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;

#define repr(i, n) for(int i = n; i >= 0; i--)
#define reprl(i, n) for(ll i = n; i >= 0; i--)
#define all(v) v.begin(), v.end()

const ll mod=1000000007;

int countBits(int in){
  int res=0;
  for(int i=0;i<10;i++){
    int msk=1<<i;
    if((in&msk)!=0){
      res++;
    }
  }
  return res;
}

template<typename T>
void show2dVector(vector<vector<T>>& v){
  for(int i=0;i<v.size();i++){
    int m=v[i].size();
    cout<<i<<" : ";
    for(int j=0;i<m;i++){
      cout<<v[i][j]<<" ";
    }
    cout<<endl;
  }
}

void bfs(const vector<vector<int>>&g, int v, vector<bool>& seen){
  seen[v]=true;
  cout<<v<<" ";
  for(auto next: g[v]){
    if(seen[next]){
      continue;
    }
    bfs(g,next,seen);
  }
}

bool dfs(vector<vector<int>> &g,int start,int goal,vector<bool>&seen){
  bool res=false;
  seen[start]=true;
  if(start==goal){
    return true;
  }
  for(auto next: g[start]){
    if(seen[next]){
      continue;
    }
    res=dfs(g,next,goal,seen);
    if(res){
      break;
    }
  }
  return res;
}

ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
bool isLowerCase(char c){
  return (c>='a'&&c<='z');
}
const string outputYesNo(bool ans){
  return (ans?"Yes":"No");
}
int main() {
  ll n,k;cin>>n>>k;
  vector<ll> g(n);
  for(int i=0;i<n;i++){
    ll a;cin>>a;
    a--;
    g[i]=a;
  }
  ll ans=0;
  ll cnt=0;
  vector<ll> seen(n,-1);
  while(seen[ans]==-1){
    seen[ans]=cnt++;
    ans=g[ans];
  }
  if(k>=seen[ans]){
    k-=seen[ans];
    k%=(cnt-seen[ans]);
  }else{
    ans=0;
  }
  while(k-->0){
    ans=g[ans];
  }
  ans++;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 6428
using System;

namespace p3 {
	class prg {
		static void Main() {
			int a, b;
			{
				string[] str = (Console.ReadLine()).Split(' ');
				a = int.Parse(str[0]);
				b = int.Parse(str[1]);
			}
			switch(Math.Sign(a - b)) {
				case 0:
				Console.WriteLine("a == b");
				break;

				case 1:
				Console.WriteLine("a > b");
				break;

				case -1:
				Console.WriteLine("a < b");
				break;
			}
		}
	}
}

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

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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repp(i, s, e) for (int i = (s); i < (e); i++)
#define all(x) x.begin(), x.end()

#define endl "\n"

void use_cio() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
}

template <class L, class R>
ostream &operator<<(ostream &os, pair<L, R> P) {
    return os << "(" << P.first << "," << P.second << ")";
}
template <class T>
ostream &operator<<(ostream &os, vector<T> V) {
    os << "[";
    for (auto x : V) os << x << ", ";
    return os << "]";
}
//--------------------------------------------------//

int main() {
    use_cio();
    int n, m;
    cin >> n >> m;
    vector<int> Va(n + 1, 0), cnt(n + 1, 1);
    Va[1] = 1;
    rep(i, m) {
        int x, y;
        cin >> x >> y;
        cnt[x]--, cnt[y]++;
        if (Va[x]) {
            Va[y] = 1;
            if (cnt[x] == 0) Va[x] = 0;
        }
    }
    cout << count(all(Va), 1);
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,b,n) for(int i=b;i<(int)n;i++)
#define rep(i,n) REP(i,0,n)
ll mod=1e9+7;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m,x;cin>>n>>m>>x;
    ll ans=mod;
    vector<int> c(n);
    vector<vector<int>> A(n,vector<int>(m));
    rep(i,n){
      cin>>c[i];
      rep(j,m)cin>>A[i][j];
    }
    for(int i=0;i<(1<<n);i++){
      vector<int> dp(m,0);
      bitset<13>s(i);
      ll tmp=0;
      for(int j=0;j<n;j++){
        if(s.test(j)){
          rep(k,m)dp[k]+=A[j][k];
          tmp+=c[j];
        }
      }
      rep(k,m){
        if(dp[k]<x)break;
        if(k==m-1)ans=min(tmp,ans);
      }
    }
    if(ans==mod)cout<<-1<<endl;
    else cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3660
#include<iostream>

using namespace std;

int main(){
  int N;
  cin >> N;
  int h[N];
  int takasa[N];
  for(int i = 0; i < N ; i++){
    cin >> h[i];
    takasa[i] = 0;
  }
  int kaisu = 0;
  int flag = 1;
  int mae;
  while(flag ==1){
    mae = 0;
    flag = 0;
    for(int i = 0; i < N; i++){
      if(takasa[i] == h[i]){
        if(mae == 1){
          kaisu++;
          mae = 0;
        }
      }else{
        mae = 1;
        flag = 1;
        takasa[i]++;
      }
    }
    if(mae==1) kaisu++;
  }
  cout << kaisu << endl;
  return 0;
}


Measured memory_bytes: 256