akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>

typedef long long ll;

struct shp {
    int a;
    ll b;

    bool operator<(const shp &another) const
    {
        //メンバ変数であるnum1で比較した結果を
        //この構造体の比較とする
        return a < another.a;
    }
};

int main () {
    int n, m;
    std::cin >> n >> m;

    std::vector<shp> s (n);
    for (int i = 0; i < n; i++)
    {
        std::cin >> s[i].a;
        std::cin >> s[i].b;
    }

    std::sort(s.begin(), s.end());

    ll ans = 0;
    ll i = 0;
    ll num = 0;
    while (1)
    {
        if(m - num > s[i].b) {
           ans += s[i].a * s[i].b;
           num += s[i].b;
           i++;
        } else {
            ans += s[i].a * (m - num);
            num += m - num;
            break;
        }
    }

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

Measured memory_bytes: 1792
#include<map>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define ll long long
#define N 3005
#define inf (1ll<<60)
#define rep(i,j,k) for (ll i=j;i<=k;++i)
#define per(i,j,k) for (ll i=j;i>=k;--i)
using namespace std;
inline ll read(){
	char ch=getchar(); ll x=0,f=1;
	while (ch<'0'||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	while (ch>='0'&&ch<='9') { x=x*10+ch-'0'; ch=getchar(); }
	return x*f;
}
ll A,B,C,D,E,F,x,y;
int main(){
	A=read(); B=read(); C=read(); D=read(); E=read(); F=read();
	rep(i,0,F/(100*A)){
		ll a=i*100*A;
		if (a>F) break;
		rep(j,0,F/(200*B)){
			ll b=j*100*B;
			if (a+b>F) break;
			rep(k,0,(F/C)-1){
				ll c=k*C;
				if(a+b+c>F) break;
				rep(l,0,(F/D)-1){
                    ll d=l*D;
                    if ((a+b+c+d)>F||(c+d)>(a+b)/100*E) break;
                    ll tz=(c+d);
                    ll tm=(a+b);
                    if(x*(tm+tz)<=tz*(y+x)){
                        x=tz;
                        y=tm;
                    }
                }
			}
		}
	}
	printf("%lld %lld",x+y,x);
}

Measured memory_bytes: 128
#include"bits/stdc++.h"
using namespace std;
using ll=long long;
using ull=unsigned long long;
constexpr auto inf=static_cast<ll>(1e18);
template<typename T=ll>inline T in(){T ret;cin>>ret;return ret;}
template<typename T=ll>inline auto vec2(size_t h,size_t w,T v=T()){return vector<vector<T>>(h,vector<T>(w,v));}
inline void setp(int n){cout<<fixed<<setprecision(n);}
inline void delnl(){cin.ignore(numeric_limits<streamsize>::max(),'\n');}

int main()
{
    ll n=in();
    vector<pair<ll,ll>>c(n);
    for(ll i=0;i<n;++i){
        ll x=in(),y=in();
        c[i]=make_pair(x,y);
    }
    vector<ll>seq(n);
    iota(seq.begin(),seq.end(),0);
    ll facn=0;
    double ans=0;
    do{
        for(ll i=0;i<n-1;++i){
            ans+=hypot(
                c[seq[i+1]].first-c[seq[i]].first,
                c[seq[i+1]].second-c[seq[i]].second
            );
        }
        ++facn;
    }while(next_permutation(seq.begin(),seq.end()));
    setp(20);
    cout<<ans/facn<<endl;
}


Measured memory_bytes: 256
import math

N, L = map(int, input().rstrip().split())

# N 個のリンゴ全てを材料としてできるアップルパイの「味」
taste_all = L * N + N * (N - 1) // 2

# taste_all と 食べていない N−1 個のリンゴを材料としてできる
# アップルパイの「味」との差の絶対値が最小のものを求める

# 絶対値が最小の1個のリンゴの「味」を求める
taste_abs_min = 0
if L >= 0:
    taste_abs_min = L
elif L + N - 1 < 0:
    taste_abs_min = L + N - 1
else:
    taste_abs_min = 0

result_taste = taste_all - taste_abs_min

print(result_taste)


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

const int INF = 1e9;

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

  vector<int> A(N);
  rep(i, N) cin >> A[i];

  int pos = 0;
  rep(i, N) if (A[i] == 1) pos = i;

  int ans = INF;
  rep(i, K) {
    int nl = pos - (K - 1) + i;
    int nr = N - pos - i - 1;
    int tmp = (nl + K - 2) / (K - 1) + (nr + K - 2) / (K - 1) + 1;
    ans = min(ans, tmp);
  }

  cout << ans << endl;
}

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

int main() {
  int N,P=0;
  cin >> N;
  vector<int> C(N),V(N);
  for(int i=0; i<N; i++){
    cin >> V.at(i);
  }
  for(int i=0; i<N; i++){
    cin >> C.at(i);
  }
  for(int i=0; i<N; i++){
    if(V.at(i)-C.at(i)>0){
      P+=V.at(i)-C.at(i);
    }
  }
  cout << P << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#define INF 1000000009
#define LINF 1000000000000000009
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
template<class T> bool chmax(T &a, const T&b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T&b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll n, ll m) { return (m ? gcd(m, n%m) : n); }
ll lcm(ll n, ll m) { return n / gcd(n, m)*m; }

int pcnt(int n) {
	int ans = 0;
	for (int i = 0; i < 20; i++) {
		if ((1 << i)&n) ans ^= 1;
	}
	return ans;
}

vector<vector<int>> graph;
vector<vector<int>> st;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<int> a(n - 1), b(n - 1);
	graph.assign(n, vector<int>());
	vector<vector<int>> dis(n, vector<int>(n, INF));
	for (int i = 0; i < n; i++) dis[i][i] = 0;
	map<P, int> mp;
	for (int i = 0; i < n - 1; i++) {
		cin >> a[i] >> b[i];
		a[i]--; b[i]--;
		graph[a[i]].push_back(b[i]);
		graph[b[i]].push_back(a[i]);
		dis[a[i]][b[i]] = 1;
		dis[b[i]][a[i]] = 1;
		mp[{a[i], b[i]}] = i;
		mp[{b[i], a[i]}] = i;
	}
	for (int k = 0; k < n; k++) {
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				chmin(dis[i][j], dis[i][k] + dis[k][j]);
			}
		}
	}
	/*for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			if (dis[i][j] == INF) cout << "INF" << ' ';
			else cout << dis[i][j] << ' ';
		}
		cout << endl;
	}*/
	int m;
	cin >> m;
	vector<int> u(m), v(m);
	st.assign(m, vector<int>());
	for (int i = 0; i < m; i++) {
		cin >> u[i] >> v[i];
		u[i]--; v[i]--;
		int np = u[i];
		while (np != v[i]) {
			for (int j : graph[np]) {
				if (dis[j][v[i]] < dis[np][v[i]]) {
					st[i].push_back(mp[{np, j}]);
					np = j;
					//cout << j << endl;
					continue;
				}
			}
		}
	}
	/*for (int i = 0; i < m; i++) {
		for (int j : st[i]) {
			cout << j << ' ';
		}
		cout << endl;
	}*/
	ll ans = 0;
	int sz = (1 << m);
	ans += (1LL << (n - 1));
	bitset<1100010> pcnts;
	for (int i = 0; i < sz; i++) {
		if (pcnt(i)) pcnts[i] = 1;
	}
	for (int i = 1; i < sz; i++) {
		set<int> sts;
		for (int j = 0; j < m; j++) {
			if (i&(1 << j)) {
				for (int k : st[j]) {
					if (!sts.count(k)) {
						sts.insert(k);
					}
				}
			}
		}
		int nm = sts.size();
		//cout << nm << endl;
		if (!(pcnts[i])) ans += (1LL << (n - 1 - nm));
		else ans -= (1LL << (n - 1 - nm));
		//cout << dp[i] << endl;
	}
	cout << abs(ans) << endl;
}


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

int main(){
    ll n,k;
    cin>>n>>k;
    vector<ll> a(n),rec(n,-1);
    rep(i,n){
        cin>>a[i];
        a[i]--;
    }
    ll cnt=0,now=0;
    rec[0]=0;
    while(1){
        now=a[now];
        cnt++;
        if(k==cnt) break;
        if(rec[now]==-1) rec[now]=cnt;
        else{
            ll len=cnt-rec[now],rem=(k-cnt)%len;
            rep(i,rem) now=a[now];
            break;
        }
    }
    cout<<now+1<<endl;
    return 0;
}

Measured memory_bytes: 6432
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

const ll mod = 1e9+7;

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

    map<ll,ll> m;
    for(int i=1; i*i<=n; ++i){
       ll x = n/i;
       m[x] = i;
    }

    for(int x=2; (x-1)*(x-1)<=n; ++x){
        ll i = n/x + 1;

        if(!m.count(x-1)) m[x-1] = i;
        m[x-1] = min(m[x-1],i);
    }

    vector<int> v;
    for(const auto &p:m){
        v.pb(p.fi+1);
        v.pb(p.se);
    }
    v.pb(n+1);

    sort(all(v));
    v.erase(unique(all(v)), v.end());
    int V = v.size();

    vector<ll> dp(V-1);
    rep(i,V-1) dp[i] = v[i+1]-v[i];

    rep(loop,k-1){
        vector<ll> pre(dp);
        for(int i=1; i<V-1; ++i) (pre[i] += pre[i-1]) %= mod;

        vector<ll> nx(V-1);

        rep(i,V-1){
            ll x = n/v[i];
            int idx = upper_bound(all(v), x) - v.begin();
            --idx;

            ll num = v[i+1]-v[i];
            nx[i] = (pre[idx]*num)%mod;
        }
        dp = nx;
    }

    ll ans = 0;
    for(ll i:dp) (ans += i) %= mod;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 6264
#include<bits/stdc++.h>
using namespace std;
#define FIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define mod 1000000007
#define test ll tx; tx=1; while(tx--)
typedef long long int ll;
int main() {
    FIO;
    test
    {
        string s,t;
        cin>>s>>t;
        ll flag=1;
        for(ll i=0;i<s.length();i++){
            if(s[i]!=t[i]){
                flag=0;
            }
        }
        flag==1 ? cout<<"Yes\n" : cout<<"No\n";
    }
	return 0;
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pi 3.14159265

int main(){
  
ll n; cin>>n;
vector<double>p(n);
ll i,j;
for(i=0;i<n;i++){
    cin>>p[i];
}
double dp[n+1][n+1];
dp[0][0]=1.000;
for(i=1;i<=n;i++) dp[0][i]=0.00;
for(j=1;j<=n;j++) dp[j][0]=dp[j-1][0]*(1-p[j-1]);

for(i=1;i<=n;i++){
    for(j=1;j<=i;j++){
        dp[i][j]=(double)p[i-1]*dp[i-1][j-1] + (double)(1-p[i-1])*dp[i-1][j];
       // cout<<dp[i][j]<<" ";
    }
   // cout<<endl;
}
double sum=0.000;
for(i=n/2+1;i<=n;i++){
    sum+=dp[n][i];
}
cout<<setprecision(10)<<fixed<<sum<<endl;


    return 0;
}

Measured memory_bytes: 70272
#include<iostream>
#include<string>
#include<queue>

using namespace std;

int main(){
    int a,b;
    string shiki;
    queue<int> q;
    while(1){
        cin >>a >>shiki >>b;
        if(shiki == "+")q.push(a+b);
        else if(shiki == "-")q.push(a-b);
        else if(shiki == "/")q.push(a/b);
        else if(shiki == "*")q.push(a*b);
        else if(shiki == "?")break;
    }
    while(1){
        cout << q.front() << endl;
        q.pop();
        if(q.empty())break;
    }
}


Measured memory_bytes: 3152
from functools import reduce
 
n,a,b=map(int,input().split())
DIV = 10**9 + 7

def nCr(N,R,DIV):
  f=lambda x,y:x*y%DIV
  X=reduce(f,range(N-R+1,N+1))
  Y=reduce(f,range(1,R+1))
  return X*pow(Y,DIV-2,DIV)%DIV


print((pow(2,n,DIV) - 1 - nCr(n,a,DIV) - nCr(n,b,DIV) ) % DIV)


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

int main()
{
  int N;
  std::cin >> N;

  int ans = 0;
  while ( ans <= N ) {
    if ( N < std::pow(2, ans) ) {
      ans--;
      break;
    }
    ans++; 
  }

  std::cout << std::pow(2, ans) << std::endl;
  return 0;
}


Measured memory_bytes: 256
n,m,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
from bisect import bisect_right
sa=[0]*(n+1)
sb=[0]*(m+1)
for i in range(n):
  sa[i+1]=sa[i]+a[i]
# print(sa)
for i in range(m):
  sb[i+1]=sb[i]+b[i]
# print(sb)
ans=0
for i in range(n+1):
  t=k-sa[i]
  if t<0:continue
  idx=bisect_right(sb,t)
  ans=max(ans,idx+i-1)
print(ans)

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

#define REP(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))

typedef long long ll;

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

	if(k > (n-1)*(n-2)/2){
		cout << -1 << endl;
		return 0;
	}

	int num = (n-1)*(n-2)/2-k+n-1;
	cout << num << endl;

	for(int i = 1; i < n; i++){
		cout << "1 " << i+1 << endl;
	}

	num -= n-1;
	for(int i = 1; i < n-1; i++){
		for(int j = i+1; j < n; j++){
			if(!num) break;
			cout << i+1 << ' ' << j+1 << endl;
			num--;
		}
		if(!num) break;
	}

	return 0;
}


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

int main()
{
	int n, ts, hs;
	ts = 0;
	hs = 0;
	char taro[101] = {0};
	char hana[101] = {0};
	scanf("%d", &n);

	while (n)
	{
		int tlen, hlen, len, c;
		scanf("%s %s", taro, hana);
		tlen = strlen(taro);
		hlen = strlen(hana);
		len = tlen < hlen ? hlen : tlen;
		c = strncmp(taro, hana, len);
		if (c > 0)
			ts += 3;
		else if (c < 0)
			hs += 3;
		else
		{
			ts++;
			hs++;
		}
		n--;
	}
	printf("%d %d\n", ts, hs);
	return 0;
}

Measured memory_bytes: 608
n = int(input())
a = list(map(int, input().split()))
first_half = 0
latter_half = sum(a)
min_diff = latter_half
for i in range(n):
    first_half += a[i]
    latter_half -= a[i]
    diff = abs(first_half - latter_half)
    min_diff = min(min_diff, diff)
print(min_diff)



Measured memory_bytes: 31560
#BFS
from collections import deque
from sys import stdin
input = stdin.readline

N,M = map(int, input().split())
neighbor = [[] for _ in range(N)]
for i in range(M):
    a,b = map(lambda x: int(x) - 1, input().split())
    neighbor[a].append(b)
    neighbor[b].append(a)

checked = [0]*N
queue = deque()
group = [0]*N
groupnum = 0
for i in range(N):
    if group[i] == 0:
        groupnum += 1
        queue.append(i)
        group[i] = groupnum
        while queue:
            x = queue.popleft()
            for p in neighbor[x]:
                if group[p] == 0:
                    queue.append(p)
                    group[p] = groupnum

group_membercnt = [0]*(N+1)
for num in group:
    group_membercnt[num] += 1
print(max(group_membercnt[1:]))

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

int main() {
    int a, b;
    cin >> a >> b;
    if (a > b) {
        cout << "a > b" << endl;
    } else if (a < b) {
        cout << "a < b" << endl;
    } else {
        cout << "a == b" << endl;
    }
}


Measured memory_bytes: 3100
/*author : Yashvardhan
Sunday, April 19, 2020
5:38 PM
*/

#include <bits/stdc++.h>
using namespace std;

using ll = long long;

#define int ll
#define pb push_back
#define vi vector<int>
#define pi pair<int,int>
#define vpi vector<pi>
#define ff first
#define ss second
#define mp make_pair
#define endl '\n'
#define all(a) a.begin(), a.end()
#define initialise(a, x) memset(a, x, sizeof(a))
#define rev(Y) reverse(all(Y))

#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS

#ifdef __APPLE__
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){cerr << name << " : " << arg1 << endl;}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');
	cerr.write(names, comma - names) << " : " << arg1 << "  ";
	__f(comma + 1, args...);}
#else
#define debug(...)
#endif

template <typename T> ostream& operator << (ostream& os,const vector<T>& v){for(int i=0;i<v.size();++i) os<<v[i]<<" ";return os;} 
template <typename T> ostream& operator << (ostream& os,const set<T>& v){for(auto it:v) os<<it<<" ";return os;} 
template <typename T, typename S> ostream& operator << (ostream& os, const pair<T,S>& v) {os<<v.ff<<" "<<v.ss;return os;}

const int mod = 1e9 + 7;
const int inf = 2e18;
const int ninf = -2e18;

int takemod(int a){return ((a%mod)+mod)%mod;}

int pow(int a, int b, int m)
{
	int ans = 1;
	a %= m;
	while (b)
	{
		if (b & 1)
			ans = (ans * a) % m;
		b /= 2;
		a = (a * a) % m;
	}
	return ans;
}

int modinv(int a){return takemod( pow( takemod(a), mod-2,mod ) );}


signed main()
{

	ios_base::sync_with_stdio(false);
	cin.tie(0);

	#ifdef __APPLE__
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
		freopen("error.txt","w",stderr);
	#endif

	time_t t1, t2;
	t1 = clock();
	
	int n;
	cin >> n;

	vi arr(n + 1, 0);
	for(int i = 0; i < n - 1; i++){
		int x;
		cin >> x;
		arr[x]++;
	}


	for(int i = 1; i <= n; i++) cout << arr[i] << endl;
	

	t2 = clock();
	cerr << endl << t2-t1 << endl;
	
	return 0;
}



Measured memory_bytes: 4788
#include <bits/stdc++.h>
#define endl '\n'
#define FAST_IO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define IT set<node>::iterator
#define mem(a) memset(a,0,sizeof(a))
typedef long long LL;
typedef long long ll;
using namespace std;
const int N = 2e5 + 5;
const int mod = 1e9 + 7;
ll a[N], sum[N];
int main() {
  int n; cin >> n;
  for(int i = 1; i <= n; i++) cin >> a[i], sum[i] = sum[i - 1] + a[i], sum[i] %= mod;
  ll ans = 0;
  for(int i = 1; i <= n; i++) {
    ans += (a[i] * ((sum[n] - sum[i] + mod) % mod)) % mod;
    ans %= mod;
  }
  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 6740
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define dup(x,y) (((x)+(y)-1)/(y))
#define v(T) vector<T>
#define vv(T) v(v(T))
using ll = int64_t;
using ull = uint64_t;
using uint = uint32_t;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using pil = pair<int,ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,v.size())i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,v.size())s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(v.size())o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
const double eps = 1e-6;
const ll LINF = 100200300400500600ll;
const int INF = 1001001001;
//--------------------------------------------------------
#define fastio cin.tie(nullptr); std::ios::sync_with_stdio(false);
#define myio ifstream iofi; if(argc>1){iofi.open(argv[1]); std::cin.rdbuf(iofi.rdbuf());}
#define myloopset int loop = 1; if(argc>2) loop =stoi(argv[2]); rep(i,loop)
//--------------------------------------------------------------
template <class T> T chmin(T &a,T b){if(a>b){a=b; return 1;}else return 0;}
template <class T> T chmax(T &a,T b){if(a<b){a=b; return 1;}else return 0;}
const int dx[4] = {0,1,0,-1};
const int dy[4] = {-1,0,1,0};
const int mod = 1000000007;

void Main(){
  int a,b,c;
  cin>>a>>b>>c;
  map<int,int> m;
  m[a]++;
  m[b]++;
  m[c]++;
  if(m.size()==2){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
} signed main(int argc,char** argv)
{fastio; myio; myloopset Main();}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
//#include<boost/multiprecision/cpp_int.hpp>
//#include<boost/multiprecision/cpp_dec_float.hpp>
//namespace mp=boost::multiprecision;
//#define mulint mp::cpp_int
//#define mulfloat mp::cpp_dec_float_100
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
constexpr int MOD=1000000007;
//constexpr int MOD=998244353;
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcountll(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
#define fi first
#define se second
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};
const int MAX_N=2e5+5;
//struct edge{lint to,num;};
//vector<int> bucket[MAX_N/1000];

int dp[667][2001];

int main(void){
    int S;
    cin >> S;
    dp[0][0]=1;
    for(int i=0;i<667;i++) for(int j=3*i;j<=1997;j++) for(int k=3;k<=2000;k++){
        if(dp[i][j]==0) break;
        if(j+k>2000) break;
        dp[i+1][j+k]=(dp[i+1][j+k]+dp[i][j])%MOD;
    }
    int ans=0;
    rep(i,667) ans=(ans+dp[i][S])%MOD;
    cout << ans << endl;
}


Measured memory_bytes: 8204
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    static class APassword
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());

            int count = 0;

            for (int i = 1; i <= n; i++)
            {
                for (int j = 1; j <= n; j++)
                {
                    for (int k = 1; k <= n; k++)
                    {
                        count++;
                    }
                }
            }

            Console.WriteLine(count);
            Console.ReadLine();
        }
    }
}

Measured memory_bytes: 13140
while True:
    c = 0
    [n,x] = map(int,input().split())
    if n==0 and x==0: break
    for i in range(1,n+1):
        for j in range(i+1,n+1):
            for k in range(j+1,n+1):
                if i+j+k == x:
                    c += 1
    print(c)

Measured memory_bytes: 7692
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <vector>

using namespace std;

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

ll l[100005]; // l[i] == (x[i] + x[i+1]) / 2
ll pref[300005];

ll ret[100005];

void solve() {
  int n;
  cin >> n;
  for(int i = 0; i < n; i++) cin >> l[i];
  for(int i = 0; i < 6*n; i += 2) {
    pref[(i/2)+1] = pref[(i/2)] + l[i%n];
  }
  ll tot = pref[n];
  for(int i = 0; i < 2*n; i+=2) {
    ret[i%n] = 2*(pref[i/2+n/2+1] - pref[i/2]) - tot;
  }
  for(int i = 0; i < n; i++) {
    cout << ret[i];
    if(i == n-1) cout << "\n";
    else cout << " ";
  }
}


void casesolve() {
  int t;
  cin >> t;
  for(int i = 1; i <= t; i++) {
    cout << "Case #" << i << ": ";
    solve();
  }
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  solve();
  // casesolve();
}


Measured memory_bytes: 5248
#include <set>
#include <map>
#include <list>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)

signed main(void){
  int N;
  int A[100];
  scanf("%d", &N);
  for(int i=0;i<N;i++){
    scanf("%d", &A[i]);
  }
  int low = 1000000000;
  int high = 1;

  for(int i=0;i<N;i++){
    if(A[i]<low){
      low = A[i];
    }
    if(A[i]>high){
      high = A[i];
    }
  }
  printf("%d\n", high-low);
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <assert.h>
#define N_MAX (100000)
#define min(a,b) (((a)<(b))?(a):(b))
typedef struct {
	int pos,value;
} Info;

signed main(){
	int damage_total[N_MAX]={};
	Info deque[N_MAX];
	int head=0,tail=0;
	int N,H;
	long long answer = 0;

	scanf("%d%d",&N,&H);	
	int currentHP = H;
	for(int i = 0 ; i < N-1 ; i++){
		int d,h;
		scanf("%d%d",&d,&h);
		while( head != tail && deque[tail-1].value <= h ) tail--;

		deque[tail++] = (Info){i,h};
		while( head != tail ){
			int maximumRecover = H - (damage_total[i] - damage_total[deque[head].pos]);
			if( maximumRecover > 0 ) break;
			head++;
		}

		for(int j = head ; j < tail && currentHP <= d ; j++){
			// ????????§???????????§????????????
			int maximumRecover = H - (damage_total[i] - damage_total[deque[j].pos]);
			
			// ??¨???????????§????????????????£???°???
			if( maximumRecover <= currentHP) continue;

			// j??????????????§?????????????????? needRecover ????¨????
			int needRecover = min( maximumRecover - currentHP , d - currentHP + 1);  
			// ???????????? needRecover ?????????????????????????????° useCount ????±????????????????????????????
			int useCount = (needRecover+deque[j].value-1) / deque[j].value - 1;
			answer += useCount;
			currentHP += useCount*deque[j].value;

			// ???j?????????????????§????°???????????????????j????????£?????´?????¨???j+1????????£?????´?????????????????????j+1????????£????????????????????????j?????????????????????
			// ??¨) ???????????¶???????????\??£?????????????????¨???????????? currentHP > d ???????????????
			if( j+1 ==  tail || maximumRecover > currentHP + deque[j+1].value ){
				currentHP = min(currentHP+deque[j].value,maximumRecover);
				answer++;
			}
		}
		currentHP -= d;
		damage_total[i+1] = damage_total[i] + d;
	}
	printf("%lld\n",answer);

}

Measured memory_bytes: 1632
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

#define rep(i,a) for(int i = 0 ; i < a ; i ++)
#define loop(i,a,b) for(int i = a ; i < b ; i ++)

int ans;
char maze[27][27];
void dfs(int x,int y){
	int dx[4] = {1,-1, 0, 0};
	int dy[4] = {0, 0, 1, -1};
	maze[x][y]='#';
	rep(i,4){
		int nx = dx[i] + x;
		int ny = dy[i] + y;
		if(maze[nx][ny]=='.'){
			ans++;
			dfs(nx,ny);
		}
	}
}

int main(void){
	int w,h;
	while(cin>>w>>h){
		rep(i,25)rep(j,25)
			maze[i][j]='#';
		ans=0;
		if(w==0&&h==0)return 0;
		rep(i,h)rep(j,w)
			cin>>maze[i][j];
		rep(i,h)rep(j,w){
			if(maze[i][j]=='@'){
				dfs(i,j);
				cout<<ans+1<<endl;
			}
		}
	}
}

Measured memory_bytes: 1172
#include <stdio.h>

int main(void)
{
	int W, H, x, y, r;
	scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);

	if((x >= r) && (y >= r) && (W >= (r+x)) && (H >= (r+y)))
		printf("Yes\n");
	else
		printf("No\n");
	return 0;
}



Measured memory_bytes: 2112
//author:luckYrat(twitter:@luckYrat_)
//#include <bits/stdc++.h>

//def
#include <iostream>

#include <cmath>
#include <algorithm>
#include <iomanip>

//array
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <utility>
#include <climits>



using namespace std;

using ll = long long;
using P = pair<ll,ll>;

#define anyfill(n,s) setw(n) << setfill(s)
#define loop(s) for(int i = 0; s > i; i++)
#define rep(i,q) for(int i = 0; (q) > i; i++)
#define repp(i,n,q) for(int i = n; (q) > i; i++)
#define dep(i,q) for(int i = (q); 0 < i; i--)


#define MAX 1000000000
const int mod = 1000000007;
#define EPS (1e-10)

#define pb push_back
#define fir first
#define scn second
#define ednl endl

#define YesNo(a) (a?"Yes":"No")
#define YESNO(a) (a?"YES":"NO")
#define yesno(a) (a?"yes":"no")


P ar4[4] = {{0,1},{0,-1},{1,0},{-1,0}};
P ar8[8] = {{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}};
/*
確認ポイント
cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる
vector.unique()は隣接した同じ要素を削除するので先にソートをする

計算量は変わらないが楽できるシリーズ
C++11以降でmin({a,b,c...})で複数個のmic,maxを処理できる
min(max)_element(iter,iter)で一番小さい(大きい)値のポインタが帰ってくる
count(iter,iter,int)でintがiterからiterの間にいくつあったかを取得できる

*/
__attribute__((constructor))
void initial() {
 cin.tie(0);
 ios::sync_with_stdio(false);
}



int main(){
  
  int a,b;cin>>a>>b;
  if(500*a < b)cout << "No" << endl;
  else cout << "Yes" << endl;

}

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

int main() {
	int A[3], K; cin >> A[0] >> A[1] >> A[2] >> K;
	sort(A, A+3);
	cout << A[0]+A[1]+A[2]*pow(2, K);
	return 0;
}


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

int main(){
	string s;
	cin>>s;
	for(int i=0;i<5;i++){
		if(i==4){
			cout<<"Good"<<endl;
			return 0;
		}
		if(s[i]==s[i+1]){
			cout<<"Bad"<<endl;
			return 0;
		}
	}
}

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

const static ll MOD = (1e+9)+7;

ll modpow(ll a,ll n){
    if(n==0)return 1;
    if(n%2==1)return a*modpow(a,n-1)%MOD;
    ll t = modpow(a,n/2) % MOD;
    return t*t % MOD;
}

int main(){
    ll n,k;cin>>n>>k;
    ll ans = 0;
    if(k%2 == 0){
        ans += pow(n/k,3)+pow(n/(k/2)-n/k,3);
        cout<<ans<<endl;
    }else{
        ans += pow(n/k,3);
        cout<<ans<<endl;
    }
    return 0;
}

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

int main(){

  int a[5];

  int k;

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

  cin>>k;

  bool judge=0;
  
  for(int i=0;i<4;i++){
	for(int j=i+1;j<5;j++){
	  if(a[j]-a[i]>k){
		judge=1;
	  }
	}
  }

  if(judge){
	cout<<":("<<endl;
  }else{
	cout<<"Yay!"<<endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10**6)

INF = 100000 + 1
V, E = map(int, input().split())
G = [[] * V for _ in range(V)]
visited = [False] * V
prenum = [INF] * V
parent = [INF] * V
lowest = [INF] * V
timer = 1

for _ in range(E):
    s, t = map(int, input().split())
    G[s].append(t)
    G[t].append(s)

def dfs(cur, prv):
    global timer
    prenum[cur] = lowest[cur] = timer
    timer += 1
    visited[cur] = True
    for nxt in G[cur]:
        if not visited[nxt]:
            parent[nxt] = cur
            dfs(nxt, cur)
            lowest[cur] = min(lowest[cur], lowest[nxt])
        elif nxt != prv:
            lowest[cur] = min(lowest[cur], prenum[nxt])

dfs(0, -1)

np = 0
ap = []
for i in range(V):
    p = parent[i]
    if p == 0:
        np += 1
    elif p != INF and prenum[p] <= lowest[i]:
        ap.append(p)

if np > 1:
    ap.insert(0, 0)

for ans in sorted(set(ap)):
    print(ans)



Measured memory_bytes: 19364
from bisect import bisect
import sys

p = 10 ** 9 + 7
n, m = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

if n != len(set(a)) or m!= len(set(b)):
  print(0)
  sys.exit()
A = set(a)
B = set(b)
a.sort()
b.sort()

q = 1
for x in range(n*m, 0, -1):
  if x in A and x in B:
    q *= 1
  elif x in A:
    q = q * max(m - bisect(b, x), 0)  % p
  elif x in B:
    q = q * max(n - bisect(a, x), 0) % p
  else:
    u = bisect(a, x)
    v = bisect(b, x)
    q = q * (max((n-u) * (m-v) - (n * m - x), 0) % p) % p
print(q)
    
    
    

Measured memory_bytes: 3316
// AtCoder ABC103: B - String Rotation
// 2019.10.17 bal4u

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

char S[210], T[105];

int main()
{
	int i, w;
	
	scanf("%s%s", S, T);
    w = strlen(S);
    memcpy(S+w, S, w);
    for (i = 0; i < w; i++) if (memcmp(S+i, T, w) == 0) break;
    puts(i < w? "Yes": "No");
	return 0;
}

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

int N;
int s[10][10];


int make(int n) {
	int c = 0;
	for (int i = 0; i < (n - 1) * 2 + 1; i++) {
		if (i % 2 == 0) {
			for (int j = 0; j < n; j++) {
				int p = i - j;
				if (p < n && p >= 0) {
					s[p][j] = ++c;
				}
			}
		}
		else {
			for (int j = 0; j < n; j++) {
				int p = i - j;
				if (p < n && p >= 0) {
					s[j][p] = ++c;
				}
			}
		}
	}
	return 0;
}

int main(){

	int c = 0;
	while (cin >> N && N != 0) {
		cout << "Case " << ++c << ":" << endl;
		make(N);
		for (int i = 0; i < N; i++) {
			for (int j = 0; j < N; j++) {
				if (s[i][j] >= 100) {
					cout << s[i][j];
				}
				else if (s[i][j] >= 10) {
					cout << " " << s[i][j];
				}
				else {
					cout << "  " << s[i][j];
				}
			}
			cout << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 2956
#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define INF 1e9+7
#define LLINF 1e18
using namespace std;
const int MOD = 1e9 +7;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h,w,data[600][600];
    cin>>h>>w;
    rep(i,h){
        rep(j,w){
            cin>>data[i][j];
        }
    }
    vector<int> a,b,c,d;
    rep(i,h){
        rep(j,w-1){
            if(data[i][j]%2==1){
                a.pb(i),b.pb(j),c.pb(i),d.pb(j+1);
                data[i][j+1]++;
            }
        }
    }
    rep(i,h-1){
        if(data[i][w-1]%2==1){
            a.pb(i),b.pb(w-1),c.pb(i+1),d.pb(w-1);
            data[i+1][w-1]++;
        }
    }
    cout<<a.size()<<endl;
    rep(i,a.size()){
        cout<<a[i]+1<<" "<<b[i]+1<<" "<<c[i]+1<<" "<<d[i]+1<<endl;
    }
    return 0;
}

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

using namespace std;

typedef long long ll;

int main() {
	ll A, B, K;
	cin >> A >> B >> K;
	if (A >= K) {
		cout << A - K << " " << B << endl;
	}
	else if (A < K && K <= A + B) {
		cout << 0 << " " << A + B - K << endl;
	}
	else cout << 0 << " " << 0 << endl;
	return 0;
}

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

typedef long long ll;

int main(){
	cin.tie(0);
	cout.tie(0);
	ios_base::sync_with_stdio(0);
	int cur = 1;
	int cnt = 0;
	int n;
	cin >> n;
	while(n--){
		int x;
		cin >> x;
		if(x == cur){
			++cur;
		}
		else{
			++cnt;
		}
	}
	cout << (cur != 1?cnt:-1) << '\n';
}


Measured memory_bytes: 384
#include <stdio.h>
main(){
  int a[28],b[2],i,j,k,l=0;
 for(i=0;i<28;i++){
    scanf("%d",&a[i]);
  }
  for(i=1;i<=30;i++){
    k=0;
    for(j=0;j<28;j++){
      if(i!=a[j]) k++;
    }
    if(k==28){
      b[l]=i;
      l++;
    }
  }
  printf("%d\n%d\n",b[0],b[1]);
return 0; 
}

Measured memory_bytes: 0
#include<stdio.h>
#include<string.h>
#include<utility>
#include<iostream>
#include<queue>
#include<math.h>
#include<algorithm>
#include<vector>
#include<map>

using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0;i<(int)(n);i++)


int main()
{
    char s[12];
    char mo[12]="2019/04/30";
    int j=0;
    scanf("%s",s);
    REP(i,10){
        if(s[i]>mo[i]){
            printf("TBD\n");
            j=1;
            break;
        }
        if(s[i]<mo[i]){
            j=0;
            break;
        }
    }
    if(j==0)printf("Heisei\n");
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
int *a;
int findRoot (int x){
	if (a[x]<0) return x;
	else return a[x]=findRoot(a[x]);
}
void unite(int k1,int k2){
	int q=findRoot(k1);
	int w=findRoot(k2);	
	if (w!=q) a[w]=q;
}
int ans(int *p,int n){
	int k=0;
	while (n) {
		if(p[n-1]<0) k++;
		n--;
	}
	return k;
}
int main(){
	int n,m,i;
	scanf("%d%d",&n,&m);
	a=(int*)malloc(n*sizeof(int));
	for (i=0;i<n;i++) a[i]=-1;
	while(m){
		int k1,k2;
		scanf("%d%d",&k1,&k2);
		k1--;
		k2--;
		unite (k1,k2);
		m--;
	}
	int q=ans(a,n);
	printf("%d\n",q-1);
	free(a);
	return 0;
}


Measured memory_bytes: 1760
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner in = new Scanner(System.in);
		int num = in.nextInt();
		int hour = num/3600;
		int mum = num%3600/60;
		int sec = num%3600%60;
		System.out.println(hour+":"+mum+":"+sec);

	}
}

Measured memory_bytes: 26316
#include<bits/stdc++.h>
#define N 
#define mod
#define inf 
#define rg register
typedef double db;
typedef long long ll;

using namespace std;

inline int gi(){
	int w=0,q=0; char c=getchar();
	while((c<'0'||c>'9')&&(c!='-')) c=getchar();
	if(c=='-') q=1,c=getchar();
	while (c>='0'&&c<='9') w=w*10+c-'0',c=getchar();
	return q?-w:w;
}

int n,r;

int main(){
	//freopen (".in","r",stdin);
	//freopen (".out","w",stdout);
	n=gi(),r=gi();
	if (n>=10) printf ("%d\n",r);
	else{
		r+=100*(10-n);
		printf ("%d\n",r);
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int ar[1000005];
int main()
{
    int n,a;
    cin>>n;
    for(int i=1;i<=n-1;i++){
        cin>>a;
        ar[a]++;
    }
    for(int i=1;i<=n;i++)
        cout<<ar[i]<<endl;
}

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

int main(){
    long n, m; cin >> n >> m;
    vector<pair<long long, long long>>data(n); //2個1セットの配列を用意
    long long a, b;
    for(int i=0;i<n;i++){
        cin >> a >> b;
        data[i] = make_pair(a, b); //各入力を一組として扱う
    }
    sort(data.begin(), data.end());

    long long ans = 0;
    for(int i=0;i<n;i++){
        if(data[i].second < m){
            ans += data[i].first * data[i].second;
            m -= data[i].second;
        }
        else{
            ans += data[i].first * m;
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
import math
n=int(input())
cnt=0
temp=math.ceil(math.sqrt(n))
for i in range(1, temp+1):
  for j in range(1, temp+1):
    if i!=j and i*j<n:
      cnt+=1
    elif i==j and i*j<n:
      cnt+=1
for k in range(temp+1, n):
  for l in range(1, temp+1):
    if k*l<n:
      cnt+=2
    else:
      break;
print(cnt)

Measured memory_bytes: 9204
#include <iostream>
#include <string.h>
#include <math.h>
#include <vector>
using namespace std;


int main() {
        unsigned long long int check = 1e18;
        unsigned long long int answer = 1;

        int N = 0;
        cin >> N;

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

        for (int i = 0; i < N; i++) {
            if (A[i] == 0) {
                cout << 0 << endl;
                return 0;
            }
        }
   
        for (int i = 0;i < N; i++) {

            if (A[i] > check ) {
                cout << -1 << endl;
                return 0;
            }
            check /= A[i];
            if (check < 1) {

                cout << -1 << endl;
                return 0;
            }
            
            answer = answer * A[i];
        }
        
        cout << answer << endl;
        

      return 0;
}

Measured memory_bytes: 3620
package main

import "fmt"

func main() {
    var n int
    var s string
    fmt.Scan(&n, &s)
    black, white := 0, 0
    for _, v := range s {
        if v == '.' {
            white++
        }
    }
    ans := white
    for _, v := range s {
        if v == '.' {
            white--
        } else {
            black++
        }
        if ans > white + black {
            ans = white + black
        }
    }
    fmt.Println(ans)
}


Measured memory_bytes: 1920
#include<bits/stdc++.h>
#define MN 500000
using namespace std;
inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int n,m,head[MN+5],cnt,num,vis[MN+5],id[MN+5],q[MN+5],top,d[MN+5];
struct edge{int to,next,w;}e[MN*4+5];
vector<pair<int,int> >v[1000005];
inline void ins(int f,int t,int w){e[++cnt]=(edge){t,head[f],w};head[f]=cnt;}
void Update(int x)
{
    for(int i=head[x];i;i=e[i].next)
        if(d[x]+e[i].w<d[e[i].to])
        {
            d[e[i].to]=d[x]+e[i].w;
            if(e[i].w) q[++top]=e[i].to;
            else Update(e[i].to);
        }
}
int main()
{
    n=num=read();m=read();
    for(int i=1;i<=m;++i)
    {
        int x=read(),y=read(),c=read();
        v[c].push_back(make_pair(x,y));
    }
    for(int i=1;i<=1000000;++i)
        for(int j=0;j<v[i].size();++j)
        {
            int x=v[i][j].first,y=v[i][j].second;
            if(vis[x]!=i) vis[x]=i,id[x]=++num,ins(num,x,0),ins(x,num,1);
            if(vis[y]!=i) vis[y]=i,id[y]=++num,ins(num,y,0),ins(y,num,1);
            ins(id[x],id[y],0);ins(id[y],id[x],0);
        }
    memset(d,40,sizeof(d));d[q[top=1]=1]=0;
    for(int i=1;i<=top;++i) Update(q[i]);
    printf("%d\n",d[n]>1e8?-1:d[n]);
	return 0;
}


Measured memory_bytes: 56448
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define FOR(i,a,b) for(int i=(a); i<=(b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define loop(k) rep(author_is_masa,k)
#define chmin(a,b) if((a)>(b)) (a)=(b);
#define chmax(a,b) if((a)<(b)) (a)=(b);
#define vi vector<int>
#define pii pair<int,int>
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define pb push_back
#define pf push_front
int gcd(int a,int b){/*a>=0,b>=0,￢(a=b=0)*/
  while(min(a,b)>0){if(a<b)swap(a,b);a%=b;}return max(a,b);
}
int dx[]={1,0,-1,0,1,-1,-1,1};
int dy[]={0,1,0,-1,1,1,-1,-1};
const int MOD = 1e9+7;
const long long INF = 1e18+10;

/*--------------------------------------------------------------------*/

signed main(){
	int n,m;
	cin>>n>>m;
	string s,t;
	cin>>s>>t;
	if(s[0]!=t[0]){
		cout<<-1<<endl;
		return 0;
	}

	int l=n/gcd(n,m)*m;
	vi sv(n),tv(m);
	vector<tuple<int,int,int>> x;
	rep(i,n){
		x.pb(make_tuple(i*l/n,0,i));
	}
	rep(i,m){
		x.pb(make_tuple(i*l/m,1,i));
	}
	sort(all(x));
	int ok=1;
	rep(i,n+m-1){
		auto p=x[i-1];
		auto q=x[i];
		if(get<0>(p)==get<0>(q)){
			int a=get<2>(p);
			int b=get<2>(q);
			if(s[a]!=t[b]) ok=0;
		}
	}

	if(ok){
		cout<<l<<endl;
	}else{
		cout<<-1<<endl;
	}

	return 0;
}



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

using i64 = long long;
using P = pair<i64, i64>;

#define overload3(_1, _2, _3, name, ...) name
#define rep1(i, n) for(i64 i = 0LL; i < (n); ++i)
#define rep2(i, a, b) for(i64 i = (a); i < (b); ++i)
#define rep(...) overload3(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)
#define all(v) v.begin(), v.end()



struct IoSetup {
    IoSetup() {
        // cin.tie(nullptr);
        // ios::sync_with_stdio(false);
        cout << fixed << setprecision(10);
        cerr << fixed << setprecision(10);
    }
} iosetup;

int main(){
    i64 n;
    cin >> n;
    vector<i64> a(n);
    rep(i, n) cin >> a[i];
    vector<i64> b(n);
    rep(i, n) b[i] = (i + 1) - a[i];
    unordered_map<i64, i64> mp;
    rep(i, n) mp[b[i]]++;
    i64 ans = 0;
    rep(i, n){
        mp[b[i]]--;
        ans += mp[a[i] + i + 1];
    }
    cout << ans << endl;
}


Measured memory_bytes: 21608
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int cmp(const void *a,const void *b)
{
    return *(int *)a-*(int *)b;
}
int main()
{
    int n,a[100],t,i,sum=1;
    scanf("%d",&n);
    for(i=0;i<n;i++)
        scanf("%d",&a[i]);
    qsort(a,n,sizeof(a[0]),cmp);
    t=a[0];
    for(i=0;i<n;i++)
    {
        if(t!=a[i])
        {
            t=a[i];
            sum++;
        }
    }
    printf("%d",sum);
    return 0;
}


Measured memory_bytes: 128
read n
(( n > 10000 )) && M=16384 || M=32768
while read t1 x1 y1; do
    (( RANDOM < M )) &&
    (( d = (t1 - t2) - (x1 > x2 ? x1 - x2 : x2 - x1) - (y1 > y2 ? y1 - y2 : y2 - y1),
       d < 0 || d % 2 )) && echo No && exit
    read t2 x2 y2 || break
    (( RANDOM < M )) &&
    (( d = (t2 - t1) - (x1 > x2 ? x1 - x2 : x2 - x1) - (y1 > y2 ? y1 - y2 : y2 - y1),
       d < 0 || d % 2 )) && echo No && exit
done
echo Yes


Measured memory_bytes: 376
#include<bits/stdc++.h>
#define ll long long
#define MOD 1e9+7;

using namespace std;
int main(){
    int n;cin>>n;
    string s;
    cin>>s;
    int count=0;
    for(int i=2;i<s.length();i++){
        if(s[i]=='C'&&s[i-1]=='B'&&s[i-2]=='A'){
            count++;
        }
    }
    cout<<count<<endl;
    return 0;
}


Measured memory_bytes: 256
from itertools import accumulate

n, m = map(int, input().split())
x = sorted(list(map(int, input().split())))

if n >= m:
    print(0)
    exit()

ans = []
for i in range(m - 1, 0, -1):
    ans.append(x[i] - x[i - 1])

ans = sorted(ans, reverse=True)
print(sum(ans[n-1:]))

Measured memory_bytes: 58408
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <utility>
#define maxn 100005
#define mod 1000000007
using namespace std;
typedef long long ll;
inline int getint(){
  char c; int res = 0;
  for(c = getchar();c < '0' || c > '9';c = getchar());
  for(;c >= '0' && c <= '9';c = getchar()) res = res * 10 + (c - '0');
  return res;
}
int n,cnt[35];
char s[maxn];
int main(){
  scanf("%d",&n);
  scanf("%s",s + 1);
  for(int i = 1;i <= n;i++) cnt[s[i] - 'a']++;
  int ans = 1;
  for(int i = 0;i < 26;i++) ans = (ll)ans * (cnt[i] + 1) % mod;
  printf("%d\n",(ans + mod - 1) % mod);
  return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#include<bitset>
#include<sstream>
#include<string>
#include<iostream>
#include<cmath>
#define rep(i,n) for (int i=0;i<(n);++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

const int MX = 1000000;

int main(){
    int N;
    cin >> N;
    vector<ll> A(N);
    ll goukei=0;
    int takasa = 0;

    rep(i,N){
        cin >> A[i];
        if(A[i]>takasa){
            takasa = A[i];
        }else if(A[i] == takasa){
            continue;
        }else{
            goukei += takasa-A[i];
        }
    }

    cout << goukei << endl;
    return 0;
}


Measured memory_bytes: 4832
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <bitset>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include<iomanip>

#define i64 int64_t
#define ff(ii,nn,mm) for(int ii=nn;ii<mm;ii++)
#define ffrvs(ii,nn,mm) for(int ii=nn;ii>=mm;ii--)
#define srt(vvv) sort(vvv.begin(),vvv.end())
#define srtrvs(vvv) reverse(vvv.begin(),vvv.end())
#define Graph vector<vector<int>>
i64 inf = 1000000007;
i64 giant = 4000000000000000037;

using namespace std;

//メモリ置き場
Graph G;
int n;
map<pair<i64, i64>, i64> dist;
vector<int> color;

//inputします
void input() {
    cin >> n;
    color.resize(n+1);
}

//ライブラリ置き場
//グラフ生成
void build_G(Graph& GG33, int nn33, int mm33) {//GG:グラフ nn:頂点数 mm:辺の数
    GG33.resize(nn33 + 1);
    ff(ii33, 0, mm33) {
        int aa33, bb33;
        cin >> aa33 >> bb33;
        GG33[aa33].push_back(bb33);
        GG33[bb33].push_back(aa33);
        int yy33;
        cin >> yy33;
        dist[{aa33, bb33}] = yy33 % 2;
        dist[{bb33, aa33}] = yy33 % 2;
    }
}

//深さ優先探索するなら使う
vector<bool> seen34;
vector<int> first_order34;
vector<int> last_order34;

void set_order(int nn35) {
    seen34.assign(nn35 + 1, 0);
    first_order34.resize(nn35);
    last_order34.resize(nn35);
}

//深さ優先探索
void dfs(const Graph& GG34, int vv34, int& first_ptr34, int& last_ptr34) {
    seen34[vv34] = 1;//vを訪れました（現在地：vv)
    //ここで行う操作を下に書く
    first_order34[vv34] = first_ptr34++;

    //vから行ける場所を見つけ次第潜るのでどんどん深くなっていく
    for (auto next_vv34 : GG34[vv34]) {
        color[next_vv34] = color[vv34] + dist[{vv34, next_vv34}];
        if (seen34[next_vv34])continue;
        dfs(GG34, next_vv34, first_ptr34, last_ptr34);
    }

    last_order34[vv34] = last_ptr34++;
}

//main
int main() {
    input();
    build_G(G, n, n - 1);
    set_order(n+1);
    color[1] = 0;
    int a = 0, b = 0;
    dfs(G, 1, a, b);
    ff(i, 1, n+1) {
        cout << color[i]%2 << endl;
    }
	return 0;
}

Measured memory_bytes: 25984
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
count = 0
A.append(0)
for i in range(N):
    if A[i] < B[i]:
        a = B[i] - A[i]
        if A[i+1] >= a:
            A[i+1] -= a
            count+=B[i]
        else:
            count+=A[i] + A[i+1]
            A[i+1] = 0
    else:
        count += B[i]
print(count)

Measured memory_bytes: 19116