akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <queue>
#include <cmath>

using namespace std;
using ll = long long;
using lli = long long int;

void ABC080D()
{
	int N, C;
	cin >> N >> C;
	vector < pair<int, pair<int, int> > > program(N);
	for (int i = 0; i < N; ++i)
	{
		int a, b, c;
		cin >> a >> b >> c;
		program[i] = { a,{b,c} };
	}
	sort(program.begin(), program.end());

	vector<pair<int, int> > endChPair;
	for (int i = 0; i < N; ++i)
	{
		int start = program[i].first;
		int end = program[i].second.first;
		int ch = program[i].second.second;
		size_t j = 0;
		for (; j < endChPair.size(); ++j)
		{
			if (endChPair[j].first < start || endChPair[j].first == start && endChPair[j].second == ch)
			{
				endChPair[j].first = end;
				endChPair[j].second = ch;
				break;
			}
		}
		if (j == endChPair.size())
		{
			endChPair.push_back({ end , ch });
		}
	}
	cout << endChPair.size() << endl;
}

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

Measured memory_bytes: 1536
N=int(input())
M=N-1
graph=[[]  for i in range(N+1)]
weight={}
for _ in range(M):
    a,b,c=list(map(int,input().strip().split(' ')))
    graph[a]+=[b]
    graph[b]+=[a]
    weight[(a,b)]=c
    weight[(b,a)]=c
checked={}
paint=[0]*(N+1)
def dfs(root):
    connected=[]
    stack=[]
    stack+=[root]
    parent={}
    parent[root]=-1
    checked[root]=1
    while stack:
        v=stack.pop()
        for node in graph[v]:
            if node!=parent[v] and node not in checked:
                if weight[(node,v)]%2==0:
                    paint[node]=paint[v]
                else:
                    paint[node]=paint[v]^1    
                checked[node]=1
                parent[node]=v
                stack+=[node]
    return stack
dfs(1)
for i in range(1,len(paint)):
    print(paint[i])



Measured memory_bytes: 114080
#coding:utf-8
a,b,c,x,y = map(int,input().split())
minv = a * x + b * y
c *= 2
big = max(x,y)
sml = min(x,y)
if a+b > c:
    minv = minv - (a+b) * sml + c * sml
if sml == x and b > c:
    minv = minv - (b-c) * (big - sml)
if sml == y and a > c:
    minv = minv - (a-c) * (big - sml)

print(minv)
    


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define REP(i, j, n) for (int i = j; i < (n); ++i)
using namespace std;
typedef long long ll;
const double pi = acos(-1);
int main()
{
    double a, b, x;
    cin >> a >> b >> x;
    double s = x / a;
    double rad;
    if (s/a > 0.5 * b)
    {
        double h = ((a * b - s) * 2.0) / a;
        rad = atan2(h, a);
    }
    else
    {
        double h = 2*s/b;
        rad = atan2(b, h);
    }
    double deg = rad/(2*pi)*360;
    printf("%.10f\n",deg);
    return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
struct node
{
    int x,y;
}r[105],b[105];
int n;
bool cmp(node x, node y)
{
    if(x.x==y.x)
        return x.y<y.y;
    return x.x<y.x;
}
int main()
{
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>r[i].x>>r[i].y;
    for(int i=0;i<n;i++)
        cin>>b[i].x>>b[i].y;
    sort(r,r+n,cmp);
    sort(b,b+n,cmp);
    int c[105];
    memset(c,0,sizeof(c));
    int ans=0;
    for(int i=0;i<n;i++)
    {
        int max1=-1;int z=-1;
        for(int j=0;j<n;j++)
        {
            if(!c[j]&&r[j].x<b[i].x&&r[j].y<b[i].y&&r[j].y>max1)
            {
                max1=r[j].y;
                z=j;
            }

        }
        if(max1!=-1)
        {
            c[z]=1;
            ans++;
    }

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


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

/* #pragma */
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")


/*alias*/
#define F first
#define S second

#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define itn int

/*template*/
template<class T>inline bool amax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>inline bool amin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }

/* func */
int32_t GCD(int32_t a, int32_t b){return b ? GCD(b, a%b) : a;}
int64_t GCD(int64_t a, int64_t b){return b ? GCD(b, a%b) : a;}
int32_t LCM(int32_t a, int32_t b){return a * b / GCD(a, b);}
int64_t LCM(int64_t a, int64_t b){return a * b / GCD(a, b);}

/*struct*/
struct aaa {
	aaa() {
		cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20);
	};
}aaaaaaa;

/* const */
constexpr int32_t INF = 1001001001;
constexpr int64_t LINF = 1001001001001001001ll;
constexpr int32_t MOD = 1e9 + 7; //10^9
constexpr int64_t EPS = 1e-9;
constexpr int32_t dx[] = { 1, 1, 0, -1, -1, -1, 0, 1 }, dy[] = { 0, 1, 1, 1, 0, -1, -1, -1 };
//constexpr int32_t dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
//Counterclockwise from the 6o'clock direction
//Take the x-axis downward and the y-axis right


//g++ -std=c++14 -Wall --pedantic-errors -o template template.cpp
//g++ -std=c++14 -Wall --pedantic-errors template.cpp
//chcp 65001

/*global*/



//#define int int64_t
signed main()
{
	string s; cin >> s;
	//dp[i][k]->iを13で割った余りがKのパターン数
	vector<int> dp(13, 0);

	dp[0] = 1;

	int carry = 1;
	for(int i = s.size()-1; i >= 0; --i){
		vector<int> nextdp(13, 0);
		if(s[i] == '?'){
			for(int k = 0; k < 10; ++k){
				for(int j = 0; j < 13; ++j){
					nextdp[(k*carry+j)%13] += dp[j];
					nextdp[(k*carry+j)%13] %= MOD;
				}
			}
		}
		else{
			int k = s[i] - '0';
			for(int j = 0, i_len = (int)13; j < i_len; ++j){
				nextdp[(k*carry+j)%13] += dp[j];
				nextdp[(k*carry+j)%13] %= MOD;
			}
		}
		carry *= 10;
		carry %= 13;
		for(int i = 0; i < 13; ++i){
			dp[i] = nextdp[i];
		}
	}
	cout << dp[5] << endl;
}

Measured memory_bytes: 512
#include <stdio.h>

int A[100][100],n,p[100],d[100],f[100],t;

void dfs_v(int i){
  int j;
  p[i]=1;
  t++;
  d[i]=t;

  for(j=0;j<n;j++){
    if(A[i][j]==0) continue;
    if(p[j]==0)dfs_v(j);
  }
  p[i]=2;
  t++;
  f[i]=t;
}

void dfs(){
  int i;
  
  for(i=0;i<n;i++)p[i]=0;
  t=0;

  for(i=0;i<n;i++)if(p[i]==0) dfs_v(i);

  for(i=0;i<n;i++) printf("%d %d %d\n",i+1,d[i],f[i]);
}


int main(){
  int i,j;
  int x,y,z;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      A[i][j]=0;
    }
  }

  for(i=0;i<n;i++){
    scanf("%d%d",&x,&y);
    x--;
    for(j=0;j<y;j++){
      scanf("%d",&z);
      z--;
      A[x][z]=1;
    }
  }

 
  dfs();

  return 0;
}



Measured memory_bytes: 2068
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define ll  long long
#define endl '\n'
#define pi 3.14159265
//seen soln
int main()
{       
    IOS;
    ll n;
    cin>>n;
    vector<ll> v(n);
    vector<ll> tmp;
    map<ll,ll> mp;
    for(ll i=0;i<n;i++)
    	cin>>v[i];
    tmp=v;
    sort(tmp.begin(),tmp.end());
    ll ind=1;
    for(ll i=0;i<n;i++)
    	mp[tmp[i]]=ind++;
    for(ll i=0;i<n;i++)
    	v[i]=mp[v[i]];
    ll ans=0;
    for(ll i=0;i<n;i+=2)
    {
    	ll ind=v[i]-1;
    	if(ind%2!=0)
    		ans++;
    }
    cout<<ans;
}   

Measured memory_bytes: 8064
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from bisect import bisect, bisect_left, bisect_right

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

H, W = MAP()
C = LIST()
D = LIST()
S = [input() for i in range(H)]

visited = [[False] * W for i in range(H)]
dist = [[INF] * W for i in range(H)]
q = deque([(C[0]-1, C[1]-1)])

dist[C[0]-1][C[1]-1] = 0
visited[C[0]-1][C[1]-1] = True
dh = [0, 1, 0, -1]
dw = [1, 0, -1, 0]
warp = [[-1] * W for i in range(H)]
warp[C[0]-1][C[1]-1] = 0
warp_time = 0
warp_stock = deque([[C[0]-1, C[1]-1]])

while q or warp_stock:
    while q:
        ch, cw = q.popleft()
        warp_stock.append([ch, cw])
        dh = [0, 1, 0, -1]
        dw = [1, 0, -1, 0]
        for i in range(4):
            nh = ch + dh[i]
            nw = cw + dw[i]
            if 0 <= nh < H and 0 <= nw < W:
                if visited[nh][nw] == False and S[nh][nw] != "#":
                    # dist[nh][nw] = dist[ch][cw] + 1
                    visited[nh][nw] = True
                    warp[nh][nw] = warp_time
                    # warp_stock.append([nh, nw])
                    q.append([nh, nw])
        # print(warp_stock)
    while warp_stock:
        ch, cw = warp_stock.popleft()
        for dh in [-2, -1, 0, 1, 2]:
            for dw in [-2, -1, 0, 1, 2]:
                nh = ch + dh
                nw = cw + dw
                if 0 <= nh < H and 0 <= nw < W:
                    if visited[nh][nw] == False and S[nh][nw] != "#":
                        # dist[nh][nw] = dist[ch][cw]
                        visited[nh][nw] = True
                        q.append([nh, nw])
                        warp[nh][nw] = warp_time + 1
    warp_time += 1
print(warp[D[0]-1][D[1]-1]) 
# print(warp)

    

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

int main() {
  long long n, m;
  cin >> n >> m;

  long long ans = 0;
  if (m / n >= 2) {
    ans += n;
    m -= n * 2;
    ans += m / 4;
  } else {
    ans += m / 2;
  }
  cout << ans << endl;

  return 0;
}


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

using namespace std;
typedef long long int LL;
typedef long long int ll;
typedef pair<long long int, long long int> pii;
typedef pair<double, double> pdd;

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SP << " " <<

LL mod = 1000000007;

const int MAX = 5000;
const int MOD = 1000000007;

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

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  LL N,K;
  cin>>N>>K;

  COMinit();

  LL blue = K;
  LL red = N - K;

  FOR(i,1,K+1){
    //blue-i , i-1
    //red-i+1,i
    cout << (COM(blue - 1, blue - i) * COM (red+1,red-i+1)) % MOD<< endl;
  }
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
typedef long long ll;
long long MOD = 1e9 + 7;
const long long INF = 1LL << 60;
using namespace std;

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

int main()
{
  int n, k;
  cin >> n >> k;
  int tmp = n;
  int ans = 0;
  while (tmp > 0)
  {
    tmp /= k;
    ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
using ll = long long;
int N;
int C[100010],S[100010], F[100010];
int func(int now, int i){
    if(i == N){
        return now;
    }
    else {
        if(now % F[i] != 0)now += F[i] - (now % F[i]);
        if(now < S[i])now = S[i];
        now += C[i];
        return func(now, i+1);
    }
}
int main(){
    cin >> N;
    for(int i = 1;i < N;i++){
        cin >> C[i] >> S[i] >> F[i];
    }
    for(int i = 1;i < N;i++){
        cout << func(S[i], i) << endl;
    }
    cout << 0 << endl;
}


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

int main() {
  string S;
  cin >> S;
  int count1 = 0;
  int count2 = 0;
  for(int i = 0; i < S.size(); i++) {
    if(i % 2 == 0) {
      if(S.at(i) == '0') {
        count2++;
      }
      else {
        count1++;
      }
    }
    else {
      if(S.at(i) == '0') {
        count1++;
      }
      else {
        count2++;
      }
    }
  }
  cout << min(count1, count2) << endl;
}

Measured memory_bytes: 3772
n = gets.to_i
x = gets.to_s
x = x.split(" ").map(&:to_i)
ans = true
x.each do |x|
  if (x % 2 == 0) then
    if (!(x % 3 == 0) && !(x % 5 == 0)) then
      ans = false
      break
    end
  end
end

if ans then
  puts "APPROVED"
else
  puts "DENIED"
end


Measured memory_bytes: 1916
#include<iostream>
#include<vector>
#include<set>
#include<stack>

struct vert{
	int key;
	int prev;
};

int main(){
	int n, m;
	std::vector<int> aList;
	std::vector<std::vector<int>> graph;
	std::vector<int> coloredNode;
	std::cin>>n>>m;

	coloredNode.resize(n, -1);
	aList.resize(n);
	for(int i=0; i<n; i++){
		int tmp;
		std::cin>>tmp;
		aList[i]= tmp-1;
	}

	graph.resize(n);
	for(int i=0; i<m; i++){
		int src, dst;
		std::cin>>src>>dst;
		graph[src-1].push_back(dst-1);
		graph[dst-1].push_back(src-1);
	}

	int color= 0;	
	for(int i=0; i<n; i++){
		if(coloredNode[i]>= 0)
			continue;

		std::stack<int> path;
		std::stack<vert> dfs;
		dfs.push({i, -1});

		while(!dfs.empty()){
			int cur= dfs.top().key;
			dfs.pop();	

			coloredNode[cur]= color;
			path.push(cur);

			bool isLeaf= true;
			for(int i=0; i<graph[cur].size(); i++){
				int dst= graph[cur][i];
				if(coloredNode[dst]<0){
					dfs.push({dst, cur});
					isLeaf= false;
				}
			}

			if(isLeaf){
				while(!dfs.empty()){
					if(dfs.top().prev==path.top())
						break;
					else
						path.pop();
				}
			}
		}
		color++;	
	}

	int ans= n;
	std::vector<std::set<int>> sList(color);
	std::vector<int> sizeList(color, 0);
	std::vector<int> deltaList(color, 0);

	for(int i=0; i<n; i++)
		sList[coloredNode[i]].insert(i);

	for(int i=0; i<color; i++)
		sizeList[i]= sList[i].size();
	
	for(int i=0; i<n; i++)
		sList[coloredNode[i]].insert(aList[i]);

	for(int i=0; i<color; i++)
		deltaList[i]= sList[i].size()- sizeList[i];

	for(int i=0; i<color; i++)
		ans-= deltaList[i];

	std::cout<<ans<<std::endl;

	return 0;
}

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

int main() {
	int x1, y1, x2, y2;
	cin >> x1 >> y1 >> x2 >> y2;
	int x3, y3, x4, y4;
	x3 = x2-y2+y1;
	y3 = y2+x2-x1;
	x4 = x1-y2+y1;
	y4 = y1+x2-x1;
	cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;
	return 0;
}

Measured memory_bytes: 256
r, g, b, n = map(int, input().split())

maxR = int(n/r)

ans = 0
for i in range(maxR+1):
    maxG = int((n-r*i)/g)
    for j in range(maxG+1):
        if((n-(i*r+j*g))%b==0):
            ans += 1

print(ans)

Measured memory_bytes: 3060
import sys

# import bisect
# from collections import Counter, deque, defaultdict

# import copy
# from heapq import heappush, heappop, heapify
# import itertools

# from operator import attrgetter, itemgetter
# import math

# from numba import jit
# import numpy as np

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    from math import gcd
    k = int(input())
    ans = 0

    for i in range(1, k + 1):
        for j in range(1, k + 1):
            ab = gcd(i, j)
            for l in range(1, k+1):
                ans += gcd(ab, l)

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 67668
#include <bits/stdc++.h>
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
#define IOS cin.tie(0),ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }
template<class Type>struct is_vector : std::false_type {};
template<class ValueType, class Alloc>struct is_vector<std::vector<ValueType, Alloc>> : std::true_type {};
template <typename T> inline ostream& operator << (ostream& out, const vector<T>& v) {
	if (v.empty())return out;
	constexpr bool is_vector_v = is_vector<T>::value;
	if (is_vector_v)for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? "\n" : "");
	else for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? " " : "");
	return out;
}
inline void put() {}
template<class T> inline void put(const T& first) { std::cout << first << "\n"; }
template<class T, class... N> inline void put(const T& first, const N& ... rest) { std::cout << first << " "; put(rest...); }
inline void putn() {}
template<class T, class... N> inline void putn(const T& first, const N& ... rest) { std::cout << first << "\n"; putn(rest...); }

template <typename T>
vector<pair<int, T>> rle(vector<T> a)
{
	int n = (int)a.size();
	vector<pair<int, T>> res;
	if (n == 0)
	{
		return res;
	}
	T now = a[0];
	int con = 0;
	for (int i = 0; i < n; ++i)
	{
		if (a[i] == now)
		{
			con++;
		} else
		{
			res.push_back(pair<int, T>(con, now));
			now = a[i];
			con = 1;
		}
	}
	res.push_back(pair<int, T>(con, now));
	return res;
}


int main() {
	IOS;
	int n, m;
	cin >> n >> m;
	vector<ll> x(n);
	REP(i, n) {
		cin >> x[i];
	}
	sort(all(x));
	auto rl = rle(x);
	vector<ll> mod(m, 0), mp(m, 0);
	REP(i, rl.size()) {
		mod[rl[i].second % m]+= rl[i].first;
		mp[rl[i].second % m] += rl[i].first / 2;
	}
	ll res = 0;
	res += mod[0]/2;
	if (m % 2 == 0) {
		res += mod[m / 2]/2;
	}
	FOR(i, 1, (m+1)/2) {
		ll temp = min(mod[i], mod[m - i]);
		res += temp;
		res += min((mod[i] - temp)/2, mp[i]);
		res += min((mod[m-i] - temp)/2, mp[m-i]);
	}
	put(res);
	return 0;
}


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

#define ll long long
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define endl "\n"
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define rev(a) (a).rbegin(),(a).rend()
#define pll pair<ll,ll>
#define rep(i,a,b) for(long long i = (a); i <= (b); i++)

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

int main(){
	fast;
	ll t = 1;
// 	cin >> t;
	while(t--){
	    ll n,m;  cin >> n >> m;
	    ll arr[n+5];
	    double s = 0;
	    rep(i,1,n) cin >> arr[i];
	    rep(i,1,n) s += arr[i];
	    
	    ll cnt = 0;
	    
	    rep(i,1,n){
	        if(s / (4 * m) <= arr[i]) cnt++;
	    }
	    
	    if(cnt >= m) cout << "Yes\n";
	    else cout << "No\n";
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
ll a,b,va,vb,t;

int main(){
	ios::sync_with_stdio(false);
	cin>>a>>va>>b>>vb>>t;
	if(a<b){
		a+=va*t;
		b+=vb*t;
		if(a<b)
			cout<<"NO";
		else	
			cout<<"YES";
	}
	else{
		a-=va*t;
		b-=vb*t;
		if(a>b)
			cout<<"NO";
		else
			cout<<"YES";
	}
	
	
	return 0;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
#define mod 998244353
#define G 3
#define Gi 332748118
#define P 200003
#define PG 2
using namespace std;
typedef long long int ll;
const int maxn=1E6+5;
int n;
ll c[maxn];
inline ll qpow(ll x,ll y,ll m)
{
	ll ans=1,base=x;
	while(y)
	{
		if(y&1)
			ans=ans*base%m;
		base=base*base%m;
		y>>=1;
	}
	return ans;
}
int what[P+5];
inline void init()
{
	int now=1;
	for(int i=0;i<=P-2;++i)
	{
		what[now]=i;
		now=now*PG%P;
	}
}
typedef long double ld;
const ld pi=acos(-1);
struct com
{
	ld a,b;
	com(ld x=0,ld y=0):a(x),b(y){}
	com operator+(const com&A){return com(a+A.a,b+A.b);}
	com operator-(const com&A){return com(a-A.a,b-A.b);}
	com operator*(const com&A){return com(a*A.a-b*A.b,b*A.a+a*A.b);}
}a[maxn],b[maxn];
int r[maxn];
inline void DFT(com*A,int limit,int type)
{
	for(int i=0;i<limit;++i)
	{
		r[i]=(r[i>>1]>>1)|(i&1?limit>>1:0);
		if(i<r[i])
			swap(A[i],A[r[i]]);
	}
	for(int len=2;len<=limit;len<<=1)
	{
		com d;
		if(type==1)
			d=com(cos(2*pi/len),sin(2*pi/len));
		else
			d=com(cos(2*pi/len),-sin(2*pi/len));
		for(int i=0;i<limit/len;++i)
		{
			com w(1,0);
			for(int j=0,pos1=i*len,pos2=i*len+len/2;j<len/2;++j,++pos1,++pos2)
			{
				com a=A[pos1],b=A[pos2]*w;
				A[pos1]=a+b;
				A[pos2]=a-b;
				w=w*d;
			}
		}
	}
}
int main()
{
	ios::sync_with_stdio(false);
	init();
	cin>>n;
	ll ans=0;
	for(int i=1;i<=n;++i)
	{
		ll x;
		cin>>x;
		if(x==0)
			continue;
		ans-=x*x%P;
		a[what[x]].a+=1;
	}
	for(int i=0;i<=P;++i)
		a[i].b=a[i].a;
	int limit=1;
	while(limit<=2*P)
		limit<<=1;
	DFT(a,limit,1);
	for(int i=0;i<limit;++i)
		a[i]=a[i]*a[i];
	DFT(a,limit,0);
	for(int i=0;i<=2*P;++i)
		c[i]=(ll)(a[i].b/limit/2+0.5);
	for(int i=P-1;i<=2*P;++i)
		c[i-(P-1)]+=c[i];
	for(int i=0;i<=P-2;++i)
		ans+=qpow(PG,i,P)*c[i];
	cout<<ans/2<<endl;
	return 0;
}


Measured memory_bytes: 72488
n=int(input())
a=list(map(int,input().split()))
s=sum(a)
l=[s]
for i in range(n-1):
 l.append(l[i]-2*a[i])
ans=float("inf")
del l[0]
for i in l:
 ans=min(ans,abs(i))
print(ans)

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

#define pr pair<int, int>

using namespace std;

const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;

//#define DEBUG

#ifdef DEBUG
#define PRINT(A) std::cout << (#A) << ":" << (A) << std::endl;
#else
#define PRINT(A)
#endif

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

// int a[10010][10010], b[1000];
// int dp[10010][3];

int S[10][1000];

void chAllVal(int before, int after, int h, int w) {
    rep(i, h * w) {
        if (S[i / w][i % w] == before) {
            S[i / w][i % w] = after;
        }
    }
}

int main() {

    string S; cin >> S;
    if(S == "AAA" || S == "BBB"){
        cout << "No" << endl;
    }
    else{
        cout << "Yes" << endl;
    }

    return 0;
}


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

const int MAXN = 2000 + 200 + 20 + 2;
const int MAX = MAXN * MAXN;
const int mod = 1e9 + 7;
int fact[MAX];
int ifact[MAX];
int dp[MAXN][MAXN];

int bpow(int base, int exp) {
  int ans = 1;
  for(; exp; exp >>= 1, base = 1LL * base * base % mod )
    if(exp & 1) ans = 1LL * ans * base % mod;
  return ans;
}

void init() {
  fact[0] = 1;
  for(int i = 1; i < MAX; i++) fact[i] = 1LL * fact[i - 1] * i % mod;
  ifact[MAX - 1] = bpow(fact[MAX - 1], mod - 2);
  for(int i = MAX - 1; i > 0; i--)
    ifact[i - 1] = 1LL * ifact[i] * i % mod;
}

int C(int n,int r) {
  if(n < r) return 0;
  return 1LL * (1LL * fact[n] * ifact[r] % mod) * ifact[n - r] % mod;
}

int& add(int&x, int s) {
  return x = (1LL * x + s) % mod;
}

int main() {
  init();
  int N,K; scanf("%d %d", &N, &K);
  if(K == 1) {
    printf("1\n");
    return 0;
  }
  dp[N][N] = 1;
  for(int i = N; i >= 0; i--)
  {
    for(int j = N; j > i; j--) 
    {
      add(dp[i][j-1], 1LL * dp[i][j] * C(i + (K - 1) * j - 1, K - 2) % mod);
      if(i) add(dp[i-1][j], dp[i][j]);
    }
    if(i) add(dp[i-1][i], dp[i][i]);
  }
  int ans = 1LL * dp[0][0] * fact[N] % mod;
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 58112
// C.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef long long LL;

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

int main(int argc, char* argv[]) {
	LL k, ans = 0;
	cin >> k;
	for (LL a = 1; a <= k; ++a) {
		for (LL b = 1; b <= k; ++b) {
			LL g = gcd(a, b);
			for (LL c = 1; c <= k; ++c) {
				ans += gcd(g, c);
			}
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3632
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(true){
			int n = sc.nextInt();
			int m = sc.nextInt();
			if(n==0 && m==0) break;
			
			int r = sc.nextInt();
			int[][] map = new int[m+1][n+1];
			int[][] rec = new int[m+1][721];
			int a, b, c, d;
			for(int i=0;i<r;i++){
				a = sc.nextInt()-540;
				b = sc.nextInt();
				c = sc.nextInt();
				d = sc.nextInt();
				if(d==1) map[c][b] = a;
				else{
					for(int j=map[c][b]+1;j<=a;j++) rec[c][j]++;
				}
			}
			
			int q = sc.nextInt();
			int sum;
			for(int i=0;i<q;i++){
				a = sc.nextInt()-540;
				b = sc.nextInt()-540;
				c = sc.nextInt();
				sum = 0;
				for(int j=a+1;j<=b;j++){
					if(rec[c][j]>0) sum++;
				}
				System.out.println(sum);
			}
		}	
	}	
}

Measured memory_bytes: 214760
# from scipy.sparse import csr_matrix
# import string
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():
    n,k=map(int,input().split())
    if k==1:
        print(0)
    else:
        n-=k
        print(n)
    
resolve()

Measured memory_bytes: 38384
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>

using namespace std;
#define int  long long

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()


template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

//-----CODE------//

void solve(void)
{
  int N,K;cin>>N>>K;
  vector<int> vec (N+1,0);
  for (int i = 0; i < N; i++)
  {
     cin>>vec[i+1];
  }
  int prev = 0;
  int ANS = 0;
  for (int i = 0; i < N; i++)
  {
    if(vec[i] + vec[i+1] > K)
    {
      ANS += vec[i+1] + vec[i] - K;
      vec[i+1] -= vec[i+1] + vec[i] - K;
    }
  }
  cout<<ANS<<endl;
  
  return; 
}
int32_t main(int32_t argc, const char *argv[])
{
std::ios::sync_with_stdio(false);
std::cin.tie(0);

std::cout << std::fixed;
std::cout << std::setprecision(9);
solve();

return 0;
}

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

using namespace std;

int main()
{
    int H, W;
    cin >> H >> W;
    vector<string> board(H);
    for (int i = 0; i < H; ++i)
    {
        cin >> board[i];
    }
    vector<vector<char>> ans(H, vector<char>(W));
    for (int i = 0; i < H; ++i)
    {
        for (int j = 0; j < W; ++j)
        {
            if (board[i][j] == '#')
            {
                ans[i][j] = '#';
            }
            else
            {
                int count = 0;
                for (int m = max(0, i - 1); m < min(H, i + 2); ++m)
                {
                    for (int n = max(0, j - 1); n < min(W, j + 2); ++n)
                    {
                        if (board[m][n] == '#') ++count;
                    }
                }
                ans[i][j] = '1' + count - 1;
            }
        }
    }

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

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdio>
#include <queue>
#include <algorithm>
#include <functional>
#include <string>
#include <queue>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <random>
#include <unordered_map>
#include <unordered_set>
#define ll long long
#define fr(i,k,N) for(ll i=k; i<N;i++)
#define rep(i,N) for(ll i=0; i<N;i++)
#define ALL(v) v.begin(),v.end()
#define mp make_pair
using namespace std;
template <class X> void pr(X test){cout<<test<<endl;}
template <class X> void prr(X test){for(auto it:test){cout<<it<<endl;}}
template <class X> void prrr(X test){int f=0;for(auto it:test){cout<<(f++!=0?" ":"")<<it;}cout<<endl;}
template<typename X>
istream&operator>>(istream&i,vector<X>&v){for(X&x:v)i>>x;return i;}

class UF { // union find from https://github.com/kartikkukreja/blog-codes (MIT)
    // [usage]
    // auto uf = new UF(n);
    // uf->merge(l, r); // 0 <= l, r <= n-1
    // ...
public:
    int *id; // inner id
    int cnt; // number of all vartices
    int *sz; // sz[i] means size of i's set
    UF(int N)   {
        cnt = N;
        id = new int[N];
        sz = new int[N];
        for(int i=0; i<N; i++) {
            id[i] = i;
            sz[i] = 1;
        }
    }
    ~UF() {
        delete [] id;
        delete [] sz;
    }
    int find(int p) {
        int root = p;
        while (root != id[root]) root = id[root];
        while (p != root) {
            int newp = id[p];
            id[p] = root;
            p = newp;
        }
        return root;
    }
    void merge(int x, int y) {
        int i = find(x);
        int j = find(y);
        if (i == j) return;
        
        if (sz[i] < sz[j]) {
            id[i] = j;
            sz[j] += sz[i];
        } else {
            id[j] = i;
            sz[i] += sz[j];
        }
        cnt--;
    }
    bool connected(int x, int y) {
        return find(x) == find(y);
    }
    int count() {
        return cnt;
    }
};

// return sorted 約数list 1 <= x <= n
vector<ll> divv(ll n) {
  vector<ll> v;
  for(ll i = 1; i*i <= n; i++) {
    if(n%i == 0) {
      v.push_back(i);
      if(i*i != n) v.push_back(n/i);
    }
  }
  sort(ALL(v));
  return v;
}

int main() {
    ll n,a,b;
    cin>>n>>a>>b;
    pr(min(a*n,b));
    

    return 0;
}


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

int main()
{
    int t,n,s,f,sum;
    
    while(cin>>t&&t){
        cin>>n;
        sum=0;
        for(int i=0; i<n; i++){
            cin>>s>>f;
            sum +=(f-s);
        }
        
        if(sum>=t){
            cout<<"OK"<<endl;
        }
        else{
            cout<<t-sum<<endl;
        }
    }
    
    return 0;
}

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

using namespace std;

int main(){
	ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    
    int l, r, d;
    cin >> l >> r >> d;
    l = (l - 1) / d;
    r = r / d;

    cout << (r - l);

	return 0;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;

int toi(char c){
    assert(c>='0'&&c<='9');
    return c-'0';
}

int main(void) {
    string s;
    cin >> s;
    int n;
    n = s.size();
    ll dp[n+1][13]={};
    DEBUG{
        cout << toi('4') << endl;
    }
    rep(i,n){
        if(i==0){
            if(s[i]=='?'){
                rep(k,10){
                    dp[i+1][k]=1;
                }
            }else{
                dp[i+1][toi(s[i])]=1;
            }
        }
        rep(j,13){
            if(s[i]=='?'){
                rep(k,10){
                    dp[i+1][(j*10+k)%13] += dp[i][j];
                    dp[i+1][(j*10+k)%13] %= MOD;
                }
            }else{
                dp[i+1][(j*10+toi(s[i]))%13] += dp[i][j];
                dp[i+1][(j*10+toi(s[i]))%13] %= MOD;
            }
        }
    }
    DEBUG{
        rep(i,n+1){
            cout << dp[i][5] << endl;
        }
    }
    cout << dp[n][5] << endl;
    return 0;
}


Measured memory_bytes: 10624
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <queue>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstring>
#include <cstdio>

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;

int main(void){
  int w, h, n;
  cin >> w >> h >> n;
  int x[n], y[n], a[n];

  for (int i = 0; i < n; i++) {
    cin >> x[i] >> y[i] >> a[i];
  }

  int min_w_right = w, max_w_left = 0;
  int min_h_up = h, max_h_down = 0;

  for (int i = 0; i < n; i++) {
    if (a[i] == 1 && max_w_left < x[i]) {
      max_w_left = x[i];
    } else if (a[i] == 2 && x[i] < min_w_right) {
      min_w_right = x[i];
    } else if (a[i] == 3 && max_h_down < y[i]) {
      max_h_down = y[i];
    } else if (a[i] == 4 && y[i] < min_h_up) {
      min_h_up = y[i];
    }
  }

  if (min_w_right <= max_w_left || min_h_up <= max_h_down) {
    cout << 0 << endl;
  } else {
    int result = (min_w_right - max_w_left) * (min_h_up - max_h_down);

    cout << result << endl;
  }


  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
using namespace std;

int main(){
    int N, A, B;
    cin >> N >> A >> B;
    vector<int> p(N);
    for(int i=0; i<N; i++)
        cin >> p[i];
    vector<int> pinv(N+1);
    for(int i=0; i<N; i++)
        pinv[p[i]] = 2*i+1;

    vector<long long> dp0(2*(N+1), 1LL<<60);
    dp0[0] = 0;
    for(int i=1; i<=N; i++){
        vector<long long> dp1(2*(N+1), 1LL<<60);
        long long mn = 1LL<<60;

        for(int j=0; j<pinv[i]; j+=2){
            mn = min(mn, dp0[j]);
            dp1[j] = mn + B;
            mn = min(mn, dp0[j+1]);
        }

        dp1[pinv[i]] = mn;

        for(int j=pinv[i]+1; j<=2*N; j+=2){
            mn = min(mn, dp0[j]);
            dp1[j] = mn + A;
            mn = min(mn, dp0[j+1]);
        }
        dp0 = dp1;
    }
    long long ans = 1LL<<60;
    for(int i=0; i<2*(N+1); i++)
        ans = min(ans, dp0[i]);

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

Measured memory_bytes: 384
n = int(input())
a = input().split(" ")
a = [int(i) for i in a]

t = 1
b = 0

for i in range(n):
  if a[i] == t:
    t = t + 1
  else:
    b = b + 1

if b == n:
  print(-1)
else:
  print(b)

Measured memory_bytes: 25768
#pragma GCC optimize("Ofast")
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include <cmath>
#include <limits>
#include <iostream>
#include <map>
#include<tuple>
using namespace std;
#define INF 1LL<<62
#define MAX 100000
#define MOD 1000000007
typedef long long ll;
typedef pair<int,int> P;
typedef pair<pair<int,int>,int> p;
#define bit(n,k) ((n>>k)&1) /*nのk bit目*/
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)
struct edge{ll to,cost,val;};
template<class T,class U>bool chmin(T&a,const U&b){if(a<=b)return false;a=b;return true;}
template<class T,class U>bool chmax(T&a,const U&b){if(a>=b)return false;a=b;return true;}
//__builtin_popcount(S);
//C.erase(unique(C.begin(),C.end()),C.end());
//#define int ll

ll a[410],sum[410];
ll dp[410][410];

ll dfs(int r,int l){
    if(r==l) return 0;
    if(dp[r][l]!=0) return dp[r][l];
    ll temp=INF;
    for(int x=r;x<l;x++){
        temp=min(dfs(r,x)+dfs(x+1,l)+sum[l]-sum[r-1],temp);
    }
    return dp[r][l]=temp;
}


signed main(){
    int N;
    cin>>N;
    for(int i=1;i<=N;i++){
        cin>>a[i];
        sum[i]=a[i]+sum[i-1];
    } 
    cout<<dfs(1,N)<<endl;



}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define FOR(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
using namespace std;

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

    int r, n;
    while (cin >> r >> n, r) {
        vector<int> xl(n), xr(n), h(n), L(41), R(41);
        REP (i, n) {
            cin >> xl[i] >> xr[i] >> h[i];
            FOR (j, xl[i], xr[i] + 1) {
                if (j != xl[i]) L[j + 20] = max(L[j + 20], h[i]);
                if (j != xr[i]) R[j + 20] = max(R[j + 20], h[i]);
            }
        }

        const double EPS = 1e-10;
        auto check = [&](double m) -> bool {
            bool res = true;
            FOR (i, -r, r + 1) {
                double hh = sqrt(r * r - i * i) + m - r;
                int j = i + 20;
                if (i != -r) res &= (hh <= L[j] + EPS);
                if (i != r) res &= (hh <= R[j] + EPS);
            }
            return res;
        };

        double ok = 0, ng = 20;
        REP (i, 100) {
            double m = (ok + ng) / 2;
            if (check(m)) ok = m;
            else ng = m;
        }
        cout << ok << endl;
    }
}


Measured memory_bytes: 3272
#abc167_e
n,m,k = map(int,input().split())

mod = 998244353

ans = 0

#precalculation of the factorial
#fact[i] = i!
num = n
fact = [0] * num
fact[0] = 1
for i in range(1,num):
    fact[i] = (fact[i-1] * i) % mod

    
#precalculation of the (M-1)**i
#M_pow[i] = (M-1)^i
M_pow = [0] * num
M_pow[0] = 1
for i in range(1,num):
    M_pow[i] = (M_pow[i-1] * (m-1)) % mod


for i in range(k+1):
    f = M_pow[n-i-1] * pow(fact[i]*fact[n-i-1], mod-2, mod)
    ans += f % mod

ans *= m * fact[n-1]
print(ans % mod)

Measured memory_bytes: 24572
#!/usr/bin/env python3

from pprint import pprint
from collections import deque, defaultdict
import itertools
import math
import sys

sys.setrecursionlimit(10 ** 6)
INF = float('inf')


S = list(input())
T = list(input())

res = 0
for i in range(len(S)):
    if S[i] == T[i]:
        continue
    res += 1

print(res)


Measured memory_bytes: 13108
#[allow(unused_imports)]
use std::char::*;
#[allow(unused_imports)]
use std::cmp::*;
use std::io::*;
use std::str::FromStr;
#[allow(unused_imports)]
use std::collections::*;

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

#[derive(PartialEq, PartialOrd)]
pub struct Total<T>(pub T);

impl<T: PartialEq> Eq for Total<T> {}

impl<T: PartialOrd> Ord for Total<T> {
    fn cmp(&self, other: &Total<T>) -> std::cmp::Ordering {
        self.0.partial_cmp(&other.0).unwrap()
    }
}


//const MAX:usize = 100006;
//const INF:u64 = u64::max_value();

fn main() {
    let n:usize = read();
    let m:usize = read();
    let c:i32 = read();
    let b:Vec<i32> = (0..m).map(|_| read()).collect();
    let mut a:Vec<Vec<i32>> = Vec::new();
    a.resize(n, Vec::new());

    for i in 0..n {
        a[i] = (0..m).map(|_| read()).collect();
    }

    let mut cnt:u32 = 0;
    for i in 0..n {
        let sum:i32 = a[i].iter().enumerate().map(|(j,x)| x*b[j]).sum();
        //debug!(sum+c);
        if sum+c > 0 {cnt+=1}
    }

    println!("{}", cnt);

}


Measured memory_bytes: 4352
#include <cstdio>
using namespace std;
int H, W; char s[52][52];
int main() {
  scanf("%d %d\n", &H, &W);
  for(int i = 1; i <= H; i++) scanf("%s", &s[i][1]);
  int ok = 1;
  for(int i = 1; i <= H && ok; i++) {
    for(int j = 1; j <= W && ok; j++) {
      if(s[i][j] == '.') continue;
      if(s[i-1][j] != '#' && s[i+1][j] != '#'
        && s[i][j-1] != '#' && s[i][j+1] != '#') {
        ok = 0;
      }
    }
  }
  printf("%s", ok?"Yes":"No");
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define reps(i, n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define repi(i,n,m) for(int i=(int)(n);i<(int)(m);i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;
int main(){
    string s;
    cin>>s;
    int n=s.size();
    
    ll ans=0;
    int w=0;
    rep(i,n){
        if(s.at(i)=='W'){
            ans+=i-w;
            w++;
        }
    }
    
    cout<<ans<<endl;
}


Measured memory_bytes: 644
#include<bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define REP(i,n) for(int i=0;i<(int)(n);i++)

using namespace std;

int main(){ _;
  int H,W,h,w;cin>>H>>W>>h>>w;
  cout<<(H-h)*(W-w)<<endl;
}


Measured memory_bytes: 256
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors

min_value = 1000000000000
data = int(input())
ng_flag = False
divisors_array = make_divisors(data)

if len(divisors_array) % 2 == 1:
    divisors_array.append(divisors_array[len(divisors_array)-1])
for i in range(0, len(divisors_array)):
    if(i % 2 == 0):
        first = divisors_array[i] -1 
        second = divisors_array[i+1] -1 
        if first + second < min_value:
            if i == 1:
                min_value = first + second
            else:
                min_value = first + second
print(min_value)

Measured memory_bytes: 3268
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll a[22][22];
ll n;
const ll m = 1e9 + 7;
ll dp[22][1<<21];
ll solve(ll index,ll mask){
    if(index == n){
        return 1;
    }
    if(dp[index][mask] != -1){
        return dp[index][mask];
    }
    ll ans = 0;
    for(int i=0;i<n;i++){
        if(((mask >> i) & 1) && a[index][i]){
            ans = (ans + solve(index+1,mask^(1<<i)))%m;
        }
    }
    return dp[index][mask] = ans;
}
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin>>n;
    memset(dp,-1,sizeof(dp));
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            cin>>a[i][j];
        }
    }
    cout<<solve(0,(1<<n) - 1)<<"\n";
}

Measured memory_bytes: 364056
#include<cstdio>
#include<cmath>
#include<climits>
#include<algorithm>
#include<sstream>
#include<iostream>
#include<string>
#include<queue>
#include<stack>
#include<set>
#include<list>
#include<map>
#include<vector>

using namespace std;


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

#define IMIN INT_MIN;
#define IMAX INT_MAX;


int main(){
	char b;
	cin >> b;
	switch (b) {
		case 'A':
			cout << 'T' << endl;
			break;
		case 'T':
			cout << 'A' << endl;
			break;
		case 'C':
			cout << 'G' << endl;
			break;
		case 'G':
			cout << 'C' << endl;
			break;
	}


	return 0;
}



Measured memory_bytes: 256
#pragma GCC optimize("O2")
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007LL
#define eps 1e-8

using namespace std;

string a3[3]={"aa.","..b","..b"};
string a4[4]={"aabc","ddbc","efgg","efhh"};
string a5[5]={"aabbc","dde.c","ffegg","..hij","..hij"};
string a6[6]={"aabbcc","ddeeff","ghi...","ghi...","...jkl","...jkl"};
string a7[7]={"aabbcc.","ddeef..","gg..fhh","..ij..k","..ij..k","....lmn","....lmn"};
string *ap[8]={NULL,NULL,NULL,a3,a4,a5,a6,a7};
string a[1005];

int main()
{
	cin.tie(0),ios::sync_with_stdio(0);
	int n;
	cin>>n;
	if(n<3) cout<<"-1\n";
	else if(n==3){
		for(int i=0;i<3;i++)
			cout<<a3[i]<<"\n";
		cout<<"\n";
	}
	else{
		fill(a,a+n,string(n,'.'));
		while(n>=8){
			for(int i=0;i<4;i++){
				for(int j=0;j<4;j++)
					a[i+n-4][j+n-4]=a4[i][j];
			}
			n-=4;
		}
		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++)
				a[i][j]=ap[n][i][j];
		}
		n=a[0].size();
		for(int i=0;i<n;i++)
			cout<<a[i]<<"\n";
	}
	return 0;
}

Measured memory_bytes: 2304
/*
Knapsack 2  ナップザック問題2
メモ再帰による解法
W<10^9なのでこれを第２インデックスにするとDPテーブルが巨大化し計算量が爆発する
dp[index][sum_value]=sum_weight　に転換する
 */

#include <string.h>
#include<iostream>
#include<vector>
using namespace std;

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;
}
const int MAX_N=110;
const int MAX_V=100100;

const long long INF=1LL<<60;

int N;

long long W,weight[110],value[110];

long long dp[MAX_N][MAX_V];

//i番目以下のindexの品から重量がsum_wになるように選んだときの
//取りうる価値の総和の最大値を返す関数
long long rec(long long i,long long sum_v)
{
    if(sum_v==0)
    {
        return 0;
    }

    if(i==-1)
    {
        return INF;
    }

    //すでに探索していたら結果を再利用
    if(dp[i][sum_v]!=-1)
    {
        return dp[i][sum_v];
    }

    //現在重量を表す変数
    long long res;

    if(sum_v<value[i]) res=rec(i-1,sum_v);
    else
    {
        res=min(
        rec(i-1,sum_v),
        rec(i-1,sum_v-value[i])+weight[i]);
    }

    return dp[i][sum_v]=res;
}

int main()
{   
    // メモ化テーブルを-1で初期化　以下のforループと等価
    //<string.h>をincludeすると利用可能
    memset(dp, -1, sizeof(dp));
            

    cin>>N>>W;
    for(int i=0;i<N;++i)
    {
        cin>>weight[i]>>value[i];
    }

    long long ans=0;
    for(long long sum_v=0;sum_v<=100*1000;++sum_v)
    {
        if(rec(N-1,sum_v) <=W)ans=max(ans,sum_v);
    }
    cout <<  ans << endl;
}



Measured memory_bytes: 86272