akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <utility>
#include <map>
#define llint long long
#define inf 1e18

using namespace std;
typedef pair<llint, llint> P;

llint V, E;
vector<llint> G[100005];
llint color[100005];
map<llint, llint> mp;
llint dp[2][100005];

P dfs(int v, int prev, int c)
{
	color[v] = c;
	P ret = make_pair(0, 0);
	if(c == 1) ret.first++;
	else ret.second++;
	
	for(int i = 0; i < G[v].size(); i++){
		if(G[v][i] == prev) continue;
		if(color[G[v][i]]){
			if(color[G[v][i]] != -c) return make_pair(-1, -1);
			else continue;
		}
		P res = dfs(G[v][i], v, -c);
		if(res.first == -1) return make_pair(-1, -1);
		ret.first += res.first;
		ret.second += res.second;
	}
	return ret;
}

int main(void)
{
	cin >> V >> E;
	llint a, b;
	for(llint i = 0; i < E; i++){
		cin >> a >> b;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	
	llint goal = 0;
	for(llint i = 1; i <= V; i++){
		if(color[i]) continue;
		P res = dfs(i, -1, 1);
		if(res.first == -1){
			cout << -1 << endl;
			return 0;
		}
		goal += abs(res.first - res.second);
		mp[2 * abs(res.first - res.second)]++;
	}
	llint N = mp.size();
	
	for(llint j = 0; j <= V; j++){
		dp[0][j] = dp[1][j] = -1;
	}
	dp[0][0] = 0;
	
	auto it = mp.begin();
	for(llint i = 1; i <= N; i++){
		for(llint j = 0; j <= V; j++){
			if(dp[(i+1)%2][j] >= 0) dp[i%2][j] = max(dp[i%2][j], it->second);
			if(j - it->first >= 0){
				if(dp[i%2][j - it->first] >= 1) dp[i%2][j] = max(dp[i%2][j], dp[i%2][j - it->first] - 1);
			}
		}
		it++;
	}
	
	llint close_val = inf, close_i;
	for(llint i = 0; i <= V; i++){
		if(dp[N%2][i] < 0) continue;
		if(close_val > abs(goal - i)){
			close_val = abs(goal - i);
			close_i = i;
		}
	}
	
	llint black = (close_i - goal + V) / 2;
	llint ans = black * (V - black) - E;
	cout << ans << endl;
	return 0;
}


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

int main() {
    string s[2];
    bool ans = false;
    
    cin >> s[0] >> s[1];
    
    ans = ((s[0][0] == s[1][2]) && (s[0][1] == s[1][1]) && (s[0][2] == s[1][0]));
    cout << (ans ? "YES" : "NO") << endl;
    return 0;
}

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

int main() {
  int N, M;
  cin >> N;
  M = N;
  int sum = 0;
  
  for (int i=8; i>=0; i--) {
    int W=1;
    for (int j=0; j<i; j++){
      W *= 10;
    }
    int x;
    x = N / W;
    sum += x;
    N = N - x*W;
  }
  if (M % sum == 0) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3616
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000000LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main() {
  int n[3], k;
  rep(i, 3) cin >> n[i];
  cin >> k;
  int index;
  if(n[0] >= n[1] && n[0] >= n[2]) index = 0;
  if(n[1] >= n[0] && n[1] >= n[2]) index = 1;
  else index = 2;


  rep(i, k)
  n[index] *= 2;

  cout << n[0] + n[1] + n[2] << ln;
}
  


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>
#include <tuple>


using namespace std;

int main(){

	long long N, H, W;
	long long ans = 0;

	cin >> N >> H >> W;
	for(long long i = 0; i< N;i++){
		long long h, w;
		cin >> h >> w;
		if(h >= H && w >= W){
			ans++;
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
# coding:utf-8

import sys
from collections import defaultdict

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


def inpl(): return list(map(int, input().split()))


N = int(input())

prime_cnt = defaultdict(int)
for n in range(N):
    n += 1
    i = 2
    while i * i <= n:
        if n % i == 0:
            cnt = 0
            while n % i == 0:
                cnt += 1
                n //= i
            prime_cnt[i] += cnt
        i += 1

    if n != 1:
        # nに素数が残っている場合処理をする
        prime_cnt[n] += 1


def num(n):
    cnt = 0
    for key in prime_cnt.keys():
        if prime_cnt[key] >= n - 1:
            cnt += 1

    return cnt


# 75 -> 3*5*5, 3*25, 5*15, 75
# 2^4*3^4*5^2と3^4*2^4*5^2は同じ，(重複の数)!で割る
print(num(75) + num(15) * (num(5) - 1) + num(25) * (num(3) - 1)
      + num(5) * (num(5) - 1) * (num(3) - 2) // 2)


Measured memory_bytes: 3316
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,a,n) for(ll i = a;i < n;i++)
#define rrep(i,a,n) for(ll i = n; i >= a;i--)
#define index_check(i,n) if(i > n-1 || i < 0) continue; 
#define LINF 1e18
#define INF 1e9
using namespace std;

#define fs first
#define sc second

using P = pair<ll,ll>;
using Pll = pair<P,ll>;
using PQ = priority_queue<P,vector<P>,greater<P>>;

const ll MOD = 1e9+7;

 
template <ll MOD>
struct modint{
    ll x;
    modint() : x(0) {}
    modint(ll a): x((a % MOD + MOD) % MOD) {}
    
    
 
    bool operator!() const{return !x;}
 
    bool operator<(const modint &a) const{
        modint res(*this);
        return res.x < a.x;
    }
    
    bool operator>(const modint &a) const{
        modint res(*this);
        return res.x > a.x;
    }
 
    modint &operator+=(const modint &a){
        if((x += a.x) >= MOD) x -= MOD;
        return *this;
    }
 
    modint &operator-=(const modint &a){
        if((x += MOD - a.x) >= MOD) x -= MOD;
        return *this;
    }
 
    modint &operator*=(const modint &a){
        (x *= a.x) %= MOD;
        return *this;
    }
 
    modint &operator/=(const modint &a){
        *this *= a.inv();
        return *this;
    }
 
    modint &operator%=(const modint &a){
        x %= a.x;
        return *this;
    }
 
    modint operator-() const{ return modint(-x); }
 
    modint operator+(const modint &a) const{ return modint(*this) += a; }
    modint operator-(const modint &a) const{ return modint(*this) -= a; }
    modint operator*(const modint &a) const{ return modint(*this) *= a; }
    modint operator/(const modint &a) const{ return modint(*this) /= a; }
    modint operator%(const modint &a) const{ return modint(*this) %= a; }
    bool operator==(const modint &a) const{ return x == a.x; }
    bool operator!=(const modint &a) const{ return x != a.x; }
 
 
    modint pow(ll n) const{
        modint res(1), a(x);
        while(n > 0){
            if(n & 1) res *= a;
            a *= a;
            n /= 2;
        }
        return res;
    }
 
    modint inv() const{
        return this->pow(MOD-2);
    }
 
    friend ostream &operator<<(ostream &os, const modint &m){
        return os << m.x;
    }
 
    friend istream &operator>>(istream &is, modint &m){
        ll t;
        is >> t;
        m = modint<MOD>(t);
        return (is);
    }
    
    static ll get_mod(){ return MOD; }
};
using mint = modint<MOD>;

signed main(){
    ll n;
    cin >> n;
    ll cnt[n] = {};
    mint ans = 1;
    rep(i,0,n){
        ll a;
        cin >> a;
        if(a == 0){
            ans *= (3-cnt[0]);
            cnt[0]++;
        }
        else{
            ans *= cnt[a-1] - cnt[a];
            cnt[a]++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
import numpy as np

N = input()
N = int(N)
A = []
for i in range(0,N):
    Ai=input()
    Ai = int(Ai)
    A.append(Ai)

A_set = set(A)
A_setlist = list(A_set)
Anp = np.array(A)
Amax = max(A)
maxidx = np.where(Anp==Amax)[0]

if(len(A_setlist)==1):
    for i in range(0,N):
        print(A_setlist[0])
else:
    if(len(maxidx)>1):
        ansNp = np.ones(N)*Amax
    else:
        Anp_bk =np.copy(Anp)
        Anp[Anp==Amax] = -1
        Anp2list = list(Anp)
        Amax2 = max(Anp2list)
        ansNp = np.where(Anp_bk==Amax,Amax2,Amax)
    for i in range(0,N):
        print(int(ansNp[i]))


Measured memory_bytes: 40656
#include <bits/stdc++.h>
using namespace std;
 
int main(){
int N;
  cin >> N;
int h[N];
  for(int i = 0; i < N;i++) cin >> h[i];
  
  int now = 0;
  int sum = 0;
  
  for(int i = 0; i < N;i++) {
  if(now <= h[i]){
  now = h[i];
    sum++;
  }  
  }
  
  cout << sum << endl;
  
 
return 0;
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
inline ll _() {
	ll x=0,f=1; char ch=getchar();
	for(;ch<'0'||ch>'9';ch=getchar())
		if(ch=='-')f=-f;
	for(;ch>='0'&&ch<='9';ch=getchar())
		x=x*10+ch-'0';
	return x*f;
}
#define _ _()
int main() {
	int a=_,b=_,c=_,res=0;
	if(a+b>=c) cout<<b+c;
	else cout<<min(a+b+1,c)+b;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
a=[list(map(int,input().split())) for i in range(n)]
b=[list(map(int,input().split())) for i in range(m)]


for i in range(n):
    x=[0]*m
    for j in range(m):
        x[j]=abs(a[i][0]-b[j][0])+abs(a[i][1]-b[j][1])
    print(x.index(min(x))+1)

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

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<pair<ll,ll>> vii;
typedef vector<vii> vvii;
typedef pair<ll,ll> ii;

#define pb push_back
#define mp make_pair
#define sz(vs) (ll)(vs.size())
#define rep(i,a,b) for (ll i=a;i<b;i++)
#define iter(i,c) for (auto i:c)
#define ss second
#define ff first
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define DEBUG2(x,a) cout << '>' << #x << ':' << x << " >" << #a << ':' << a <<  endl;
#define DEBUG3(x,a,b) cout << '>' << #x << ':' << x << " >" << #a << ':' << a << " >" << #b << ':' << b << endl;
#define DEBUG4(x,a,b,c) cout << '>' << #x << ':' << x << " >" << #a << ':' << a << " >" << #b << ':' << b << " >" << #c << ':' << c << endl;
#define printstr(a,st,e,s) if (st<e) {cout<<s<<a[st];rep(noname,st+1,e) cout<<""<<a[noname];}cout<<"\n"
#define printarr1(a,st,e,s) if (st<e) {cout<<s<<a[st];rep(noname,st+1,e) cout<<" "<<a[noname];}cout<<'\n'
#define printarr(a,st,e,s) cout<<s<<": [";if (st<e) {cout<<a[st];rep(noname,st+1,e) cout<<", "<<a[noname];}cout<<"]\n"
#define printus(c,s) cout<<s<<": {";for (auto noname:c) cout<<noname<<",";cout<<"}\n"
#define printum(c,s) cout<<s<<": {";for (auto noname:c) cout<<noname.first<<":"<<noname.second<<", ";cout<<"}\n"
#define MAXN 200005
#define mod 1000000007
 
ll n, m, k, a[MAXN], b[MAXN];
string s,s1;
char c;

void solve() {
	cin>>n>>m>>k;
	rep(i,0,n) cin>>a[i];
	rep(i,0,m) cin>>b[i];
	ll i = 0, j = 0;
	ll temp = 0;
	while (i<n) {
		if (temp+a[i]>k) break;
		else temp+=a[i++];
	}
	temp = k-temp;
	ll ans = i;
	while (j<m) {
		if (temp<b[j]) break;
		else {temp-=b[j++];ans++;}
	}
	ll bestans = ans;
	while (i) {
		temp += a[--i];
		ans--;
		while (j<m) {
			if (temp<b[j]) break;
			else {temp-=b[j++];ans++;}
		}
		bestans = max(ans,bestans);
	}
	cout<<bestans<<endl;
}
 
void aux() {
}
 
int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	aux();
	ll _ = 1;
	// cin>>_;
	while(_--) {
		solve();
	}
	return 0;
}

Measured memory_bytes: 6668
#include <iostream>
#include <vector>
typedef long long LL;
using namespace std;

LL ans;
vector<LL> p;
vector<LL> cnt;

LL find_root(LL x) {
  if (p[x] != x) p[x] = find_root(p[x]);
  return p[x];
}

void unite(LL x, LL y) {
  LL nx = find_root(x);
  LL ny = find_root(y);
  ans = 0;
  if (nx == ny) return;
  else {
    p[ny] = nx;
    ans = cnt[nx] * cnt[ny];
    cnt[nx] += cnt[ny];
  }
}

int main() {
  LL n, m;
  cin >> n >> m;
  p = vector<LL>(n);
  cnt = vector<LL>(n, 1);
  for (LL i = 0; i < n; i ++) p[i] = i;

  vector<LL> a(m), b(m);
  for (LL i = 0; i < m; i ++) {
    LL s, t; scanf("%lld%lld", &s, &t);
    s --, t --;
    a[i] = s, b[i] = t;
  }

  vector<LL> res(m);
  res[m - 1] = n * (n - 1) / 2;
  for (LL i = m - 1; i >= 1; i --) {
    unite(a[i], b[i]);
    res[i - 1] = res[i] - ans;
  }

  for (LL i = 0; i < m; i ++) {
    cout << res[i] << endl;
  }
}


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

void yes(){printf("Yes\n");exit(0);}
void no(){printf("No\n");exit(0);}

int main(){
    int n, i;
    int h[100000];
    scanf("%d", &n);
    for(i = 0;i < n; i++){
        scanf("%d", &h[i]);
    }
    
    if(n != 1){
        for(i = 0; i < n - 1; i++){
            if(0 <= h[i + 1] - h[i]){
                if(1 <= h[i + 1] - h[i]){
                    h[i + 1]--;
                }
            }else{ no();}
        }
        yes();
    }else{ yes();}
    
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC target("avx")
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;i<(n);i++)
#define rrep(i,n) for(int (i)=1;i<=(n);i++)
#define REP(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define MOD 1000000007
#define INF 1e18
#define int long long
#define endl "\n"
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)?"YES":"NO")
typedef long long ll;
typedef pair<int, int> P;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a/gcd(a,b)*b;};
int mod(int a,int b){return (a+b-1)/b;};
template<typename A, size_t N, typename T>
void Fill(A(&array)[N],const T &val){std::fill((T*)array,(T*)(array+N),val);}
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;};
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;};

int c[26];
int s[365][26];
int t[365];
int last[26];

signed main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);
	//cout << fixed << setprecision(15);
	
	int D;
	cin >> D;
	rep(i, 26) cin >> c[i];
	rep(i, D) {
		rep(j, 26) cin >> s[i][j];
	}
	int ans = 0;
	rep(i, D) {
		cin >> t[i];
		t[i]--;
		ans += s[i][t[i]];
		last[t[i]] = i + 1;
		rep(j, 26) ans -= c[j] * (i + 1 - last[j]);
		cout << ans << endl;
	}
	return 0;
}

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

static const int MAX_VALUE = 50000;

int main()
{
  int N;
  cin >> N;
  
  int table[MAX_VALUE + 1];
  for (int i = 1; i <= MAX_VALUE; i++)
  {
    table[i] = floor(i*1.08);
  }
  
  for (int i = 1; i <= MAX_VALUE; i++)
  {
    if (table[i] == N)
    {
      cout << i << endl;
      return 0;
    }
  }
  
  cout << ":(" << endl;
  
  return 0;
}


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

using namespace std;

int main(){

	int N,K,P;

	scanf("%d",&N);

	for(int i = 0; i < N; i++){
		scanf("%d %d",&K,&P);
		if(K%P==0){
			printf("%d\n",P);
		}else{
			printf("%d\n",K%P);
		}
	}

	return 0;
}

Measured memory_bytes: 2664
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <array>
#include <queue>
#include <algorithm>
#include <utility>
#include <cmath>
#include <map>
#include <set>

#define INF_LL 9000000000000000000
#define INF 2000000000

#define REP(i, n) for(int i = 0;i < (n);i++)
#define FOR(i, a, b) for(int i = (a);i < (b);i++)

using namespace std;

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

class RangeSeg{
	int n;
	vector<ll> data, datb;
public:
	RangeSeg(int n_){
		n = 1;
		while(n < n_) n <<= 1;

		REP(i, 2*n-1){
			data.push_back(0);
			datb.push_back(0);
		}
	}

	void add(int s, int t, int l, int r, int k, int x){
		if(s <= l && r <= t){
			data[k] += x;
		}else if(l < t && s < r){
			datb[k] += (min(r, t)-max(l, s))*x;
			add(s, t, (l+r)/2, r, k*2+2, x);
			add(s, t, l, (l+r)/2, k*2+1, x);
		}
	}

	void add(int s, int t, int x){
		add(s, t, 0, n, 0, x);
	}

	int sum(int s, int t, int l, int r, int k){
		if(t <= l || r <= s) return 0;
		if(s <= l && r <= t){
			return (min(r, t)-max(l, s))*data[k]+datb[k];
		}else{
			ll res = 0;
			res += (min(r,t)-max(l,s))*data[k];
			res += sum(s, t, l, (l+r)/2, k*2+1);
			res += sum(s, t, (l+r)/2, r, k*2+2);
			return res;
		}
	}

	int sum(int s, int t){
		return sum(s, t, 0, n, 0);
	}
};

int main(void){
	int n, q;
	cin >> n >> q;
	RangeSeg rs(n);
	REP(i, q){
		int com;
		cin >> com;
		if(com == 0){
			int s, t, x;
			cin >> s >> t >> x; s--; t--;
			rs.add(s, t+1, x);
		}else{
			int x;
			cin >> x; x--;
			cout << rs.sum(x, x+1) << endl;
		}
	}
}

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

using namespace std;

int main()
{
    long long int n, a[1000100];
    long long int rec, cnt = 0, ans = 0;

    cin >> n;

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

    for (int i = 1; i < n; i++) {
        a[i] += a[i-1];
    }

    sort(a, a+n);

    rec = a[0];

    for (int i = 0; i < n; i++) {
        if (rec != a[i]) {
            long long int tmp = 1;
            for (int j = cnt; j > cnt-2; j--) {
                tmp *= j;
            }
            ans += tmp/2;
            cnt = 1;
            rec = a[i];
        }
        else {
            cnt++;
        }
        if (a[i] == 0) {
            ans++;
        }
    }
    long long int tmp = 1;

    for (int i = cnt; i > cnt-2; i--) {
        tmp *= i;
    }
    ans += tmp/2;

    cout << ans << endl;
}


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

long long foo(long long H) {
    if (H == 1)
        return 1;
    return foo(H / 2) * 2 + 1;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    long long H;
    cin >> H;
    cout << foo(H) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(a, b, c) for(int a = (b); a <= (c); ++ a)
#define per(a, b, c) for(int a = (b); a >= (c); -- a)
using namespace std;
template <class T> void rd(T &x){
  x = 0; int f = 1; char ch = getchar();
  while(ch < '0' || ch > '9'){ if(ch == '-') f = -1; ch = getchar(); }
  while(ch >= '0' && ch <= '9') x = (x << 3) + (x << 1) + ch - '0', ch = getchar();
  x *= f;
}

const int maxn = 1e3 + 5;
int n;
int w[maxn];
bitset <5005> a[maxn];

struct edge{ int v, nxt; }; vector <edge> e; int head[maxn];

void adde(int u, int v){ e.push_back((edge){v, head[u]}); head[u] = e.size() - 1; }

int dfs(int u){
  int sum = 0, s;
  a[u][0] = 1;
  for(int i = head[u]; ~i; i = e[i].nxt){
	int v = e[i].v;
	s = dfs(v);
	sum += s + w[v];
	a[u] = (a[u] << s) | (a[u] << w[v]);
  }
  s = w[u];
  for(; (~s) && (!a[u][s]); -- s);
  if(s == -1){
	puts("IMPOSSIBLE");
	exit(0);
  }
  return sum - s;
}

int main(){
  memset(head, -1, sizeof(head));
  rd(n);
  rep(i, 2, n){
	int f; rd(f);
	adde(f, i);
  }
  rep(i, 1, n) rd(w[i]);
  dfs(1);
  puts("POSSIBLE");
  return 0;
}


Measured memory_bytes: 2048
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
  	String str=sc.next();
    char c[]=new char[200]; 
    char[] s=str.toCharArray();
    if(s[2]==s[3]&&s[4]==s[5]){
      System.out.print("Yes");
    }else{
      System.out.print("No");
    }
  }
}

Measured memory_bytes: 23892
import java.util.Scanner;
public class Main {

    public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
    	// 入力
    	int a = sc.nextInt();
    	int b = sc.nextInt();

    	int ans = 0;
    	int sum = 0;

    	if (b != 1){
    		for (int i = 0; true; i++){
    			ans++;
    			sum = sum + (a - 1);
    			if (b <= sum + 1){
    				break;
    			}
    		}
    	}

    	// 出力
    	System.out.println(ans);
    }
}

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

int main(){	
	int N;
	double R=0;
	cin >> N;
	vector<pair<int, int>> Town(N);
	for (int i=0; i<N; i++){
		int x,y;
		cin >> x >> y;
		Town.at(i) = make_pair(x,y);
	}
	
	for (int i=0; i<N; i++){
		for (int j=i+1; j<N; j++){
			R += sqrt(pow(Town.at(i).first-Town.at(j).first,2) + pow(Town.at(i).second-Town.at(j).second,2));
		}
	}

	R = R*2/N;
	
	printf("%f\n", R);
//	cout << R << endl;

}

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

#define rep(ver,n) rep2(ver,0,n)
#define rep2(ver,m,n) for(int ver=m;i<(n);i++)
#define vecadd emplace_back

int main(){
  string str;
  cin>>str;
  
  bool isL=false;
  int p=0;
  int size;
  
  int num[100000]={0};
  
  rep(i,str.size()){
    char c=str[i];
    if(isL){
      if(c=='R'){
        isL=false;
        if(size%2==0){
          int h=size/2;
          num[p]=h;
          num[p+1]=h;
        }else{
          int h=i-p-1;
          if(h%2==1){
          num[p]=size/2;
          num[p+1]=size/2+1;
          }
          else{
          num[p+1]=size/2;
          num[p]=size/2+1;
          }
        }
        size=0;
      }
      size++;
    }
    else{
      if(c=='L'){
        p=i-1;
        isL=true;
      }
      size++;
    }
  }
  if(size%2==0){
          int h=size/2;
          num[p]=h;
          num[p+1]=h;
        }else{
          int h=str.size()-p;
    if(h%2==0){
          num[p]=size/2;
          num[p+1]=size/2+1;
          }
          else{
          num[p+1]=size/2;
          num[p]=size/2+1;
          }
        }
  
  rep(i,str.size()){
    cout<<num[i]<<" ";
  }
  
  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    int N,M,Q;
    cin >> N >> M >> Q;
    int cnt[N+1][N+1];
    rep(i,0,N+1)rep(j,0,N+1)cnt[i][j] = 0;
    rep(i,0,M){
        int l,r;
        //cin >> l >> r;
        scanf("%d%d",&l ,&r);
        cnt[l-1][r-1]++;
    }
    rep(i,0,N)rep(j,1,N)cnt[i][j] += cnt[i][j-1];
    rep(j,0,N)for(int i = N-2;i >= 0;i--)cnt[i][j] += cnt[i+1][j];
    rep(i,0,Q){
        int sum = 0;
        int l,r;
        //cin >> l >> r;
        scanf("%d%d",&l ,&r);
        l--,r--;
        //cout << cnt[l][r] << endl;
        printf("%d\n",cnt[l][r]);
    }
}

Measured memory_bytes: 1920
#include "bits/stdc++.h"
#define int long long
#define endl '\n'
using namespace std;
 
typedef long long ll;
#define db(x) cerr << #x << ": " << x << '\n';
#define read(a) int a; cin >> a;
#define readb(a, b) int a, b; cin >> a >> b;
#define readc(a, b, c) int a, b, c; cin >> a >> b >> c;
#define readarr(a, n) int a[(n) + 1] = {}; FOR(i, 1, (n)) {cin >> a[i];}
#define readmat(a, n, m) int a[n + 1][m + 1] = {}; FOR(i, 1, n) {FOR(j, 1, m) cin >> a[i][j];}
 
#define print(a) cout << a << endl;
#define printarr(a, n) FOR (i, 1, n) cout << a[i] << " "; cout << endl;
#define printv(v) for (int i: v) cout << i << " "; cout << endl;
#define printmat(a, n, m) FOR (i, 1, n) {FOR (j, 1, m) cout << a[i][j] << " "; cout << endl;} cout << endl;
#define all(v) v.begin(), v.end()
#define sz(v) (int)(v.size())
#define rz(v, n) v.resize((n) + 1);
#define pb push_back
#define fi first
#define se second
#define vi vector <int>
#define pi pair <int, int>
#define vpi vector <pi>
#define vvi vector <vi>
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORD(i, a, b) for (int i = (a); i >= (b); i--)
const ll inf = 1e18;
const ll mod = 1e9 + 7;
const ll N = 2e4 + 1;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	read(n);
	int sum = 0;
	FOR (i, 1, n)
	{
	    if ((i % 3) && (i % 5)) sum += i;
	}
	cout << sum;
        
}














Measured memory_bytes: 3644
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
int n,m;
int k[100],a[100][100],sum[100],conter;
cin >> n >> m;
for(int i = 0; i < n; ++i){
    cin >> k[i];
    for(int j =0; j<k[i];++j){
    cin >> a[i][j];
    }
}
for(int i = 0; i < n; ++i){
    for(int j =0; j<k[i];++j){
        for(int k=1; k<=m;k++){
        if(a[i][j] == k) sum[k]++;
    }
    }
}
for(int k=1; k<=m;k++){
        if(sum[k] == n) conter++;
}

cout << conter << endl;
return 0;

}


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

using namespace std;
using ll = long long;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll A, B, C, K;
  cin >> A >> B >> C >> K;
  ll res;
  if (K % 2 == 0)
    res = A - B;
  else
    res = -(A - B);
  cout << res << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define Repr(i, n, a) for (int i = (n); i >= (a); i--)
#define rep(i, n) Rep(i, 0, n)
#define repr(i, n) Repr(i, n, 0)
#define all(a) a.begin(), a.end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

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

    string s;
    cin >> s;
    int num1 = 0, num2 = 0;
    num1 = 10 * (s[0] - '0') + (s[1] - '0'), num2 = 10 * (s[2] - '0') + (s[3] - '0');
    bool f1, f2, f3, f4;
    f1 = 0 <= num1;
    f2 = 0 <= num2;
    f3 = 1 <= num1 && num1 <= 12;
    f4 = 1 <= num2 && num2 <= 12;
    if (f1 && f2 && f3 && f4)
        cout << "AMBIGUOUS" << endl;
    else if (f1 && f4)
        cout << "YYMM" << endl;
    else if (f2 && f3)
        cout << "MMYY" << endl;
    else
        cout << "NA" << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <queue>

using namespace std;

struct Node {
  double x, y, r;

  Node(double x, double y, double r) : x(x), y(y), r(r) {}
};

int n, k;
vector<int> x, y, c;

double distance(double px, double py) {
  vector<double> dis(n);
  for (int i = 0; i < n; ++i) {
    dis[i] = c[i] * hypot(px - x[i], py - y[i]);
  }
  nth_element(dis.begin(), dis.begin() + k - 1, dis.end());
  return dis[k - 1];
}

double distance_lb(double px, double py, double r) {
  vector<double> dis(n);
  for (int i = 0; i < n; ++i) {
    dis[i] = c[i] * hypot(max(abs(px - x[i]) - r, 0.0), max(abs(py - y[i]) - r, 0.0));
  }
  nth_element(dis.begin(), dis.begin() + k - 1, dis.end());
  return dis[k - 1];
}

int main() {
  cin >> n >> k;
  x.resize(n);
  y.resize(n);
  c.resize(n);
  for (int i = 0; i < n; ++i) {
    cin >> x[i] >> y[i] >> c[i];
  }
  queue<Node> que;
  double res = distance(0, 0);
  que.emplace(0, 0, 1000);
  while (!que.empty()) {
    auto node = que.front();
    que.pop();
    for (double dx : {-0.5, 0.5}) {
      for (double dy : {-0.5, 0.5}) {
        double nx = node.x + dx * node.r, ny = node.y + dy * node.r, nr = node.r / 2;
        double dis_lb = distance_lb(nx, ny, nr);
        if (res - dis_lb > 5e-7 * max(1.0, dis_lb)) {
          res = min(res, distance(nx, ny));
          que.emplace(nx, ny, nr);
        }
      }
    }
  }
  cout << fixed << setprecision(15) << res << endl;
}


Measured memory_bytes: 256
na = int(input())
nb = int(input())
nc = int(input())
xx = int(input())
counter = 0
for aa in range(na+1):
    for bb in range(nb+1):
        residue = xx-500*aa-100*bb
        if residue >= 0 and residue / 50 <= nc:
            counter += 1
print(counter)

Measured memory_bytes: 64428
H, W = map(int, input().split())

if H % 3 == 0 or W % 3 == 0:
    print(0)
else:
    ans = 10000000000
    pieces = []
    for i in range(1, H):
        if (H - i) % 2 == 0:
            pieces = [i * W, (H - i)  // 2 * W, (H - i) // 2 * W]
        else:
            pieces = [i * W,  ((H - i) // 2 + 1) * W, ((H - i) // 2) * W]
        ans = min(ans, max(pieces) - min(pieces))
        
        if W % 2 == 0:
            pieces = [i * W, (H - i) * W // 2, (H - i) * W // 2]
        else:
            pieces = [i * W, (H - i) *  (W // 2 + 1), (H - i) * (W // 2)]
        ans = min(ans, max(pieces) - min(pieces))
        
    for i in range(1, W):
        if (W - i) % 2 == 0:
            pieces = [i * H, (W - i)  // 2 * H, (W - i) // 2 * H]
        else:
            pieces = [i * H,  ((W - i) // 2 + 1) * H, ((W - i) // 2) * H]
        ans = min(ans, max(pieces) - min(pieces))
        
        if H % 2 == 0:
            pieces = [i * H, (W - i) * H // 2, (W - i) * H // 2]
        else:
            pieces = [i * H, (W - i)  * (H // 2 + 1), (W - i) * (H // 2)]
        ans = min(ans, max(pieces) - min(pieces))
        
    print(ans)

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

int main(){
    ll h, n, s = 0;
    cin >> h >> n;
    rep(i,n){
        int a;
        cin >> a;
        s += a;
    }
    if(s >= h) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
h,w = gets.split.map(&:to_i)

r = 0
c = [true] * w
a = []
h.times do
    s = gets.chomp
    next if s == '.' * w
    w.times do |i|
        c[i] = false if s[i] == '#' 
    end
    a.push(s)
    r += 1
end

r.times do |i|
    w.times do |j|
        next if c[j]
        print a[i][j]
    end
    print "\n"
end
        


Measured memory_bytes: 1788
//http://drken1215.hatenablog.com/entry/2018/08/13/123600
//参考にさせて頂いた解説

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const ll LongINF=1e13+7;
const int INF=1e9+7;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};

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;}
template <class T, class Y>T GCD(T a, Y b){if(a<b){int c=a;a=b;b=c;}if (a % b == 0){return b;}return GCD(b, a % b);}
void clear(queue<pair<int, int>> &q){queue<pair<int, int>> empty;swap(q, empty);} //queueの中身の型は適時変更を忘れない

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back

int main(){
    int N;
    cin>>N;
    string A;
    if(N==0)A="0";
    while(N!=0){
        int r=N%2;
        if(r<0)r+=2;//rのあまりは0,1なので2を足すことで正の1にできる
        //二進数への変換と同じことをするが、-2なので一部手順を変える必要がある？
        //-9を例に考えると、(-9-1)/(-2)=5,(5-1)/(-2)=-2,(-2-0)/(-2)=1,(1-1)/(-2)=0;
        //二進数の変換で必要なのは余りなので、1,1,0,1となる、これを反転させたのが答え。反転させる行為は自明として、
        //なぜ-rをするのか。二進法変換のコードを書くのと同じことで、/2をするために、数を整える必要があるため、

        //Nから余りを取り除いて -2 で割る。
        N=(N-r)/(-2);

        //答えに追加
        A+=(char)('0'+r);//stringに数を付け加えるにはこうしないと正常に行われない……
    }
    reverse(A.begin(),A.end());
    cout<<A<<endl;

    return 0;
}

//a=97,z=122

Measured memory_bytes: 256
from datetime import datetime
s = input()
def is_yymm(ss):
  try:
    datetime.strptime(ss, '%y%m')
    return True
  except:
    pass
def is_mmyy(ss):
  try:
    datetime.strptime(ss, '%m%y')
    return True
  except:
    pass
if is_yymm(s) and is_mmyy(s):
  print('AMBIGUOUS')
elif is_yymm(s):
  print('YYMM')
elif is_mmyy(s):
  print('MMYY')
else:
  print('NA')

Measured memory_bytes: 4568
#include<stdio.h>
int main (){
	int a,b;
	int c,d;
	for(;;){
	scanf("%d %d",&a,&b);
	if(a==0&&b==0)break;
		for(c=0;c<a;c++){
		for(d=0;d<b;d++){
			printf("#");
			}
		printf("\n");
		}
		printf("\n");
	}
	return 0;
}

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

const int MAXV = 101;
int visited[MAXV][MAXV], dist[MAXV][MAXV];
pair<int, int> parent[MAXV][MAXV];

const int offset[4][2] = {
    { -1, 0 }, { 0, -1 }, { 1, 0 }, { 0, 1 }
};



int grid[MAXV][MAXV];
int H, W;
int black = 0;

void bfs(int i, int j){
    memset(parent, -1, sizeof(parent));
    memset(dist, 0, sizeof(dist));
    memset(visited, 0, sizeof(visited));
    
    
    queue<pair<int, int>> q;
    q.push(make_pair(i, j));
    visited[i][j] = 1, dist[i][j] = 0;
    
    while (!q.empty()) {
        pair<int, int> u = q.front();
        q.pop();
        
        for (int k = 0; k < 4; k++) {
            int ii = u.first + offset[k][0], jj = u.second + offset[k][1];
            if (ii < 0 || jj < 0 || ii >= H || jj >= W) {
                continue;
            }
            if (!visited[ii][jj] && grid[ii][jj] == 1) {
                visited[ii][jj] = 1;
                parent[ii][jj] = make_pair(u.first, u.second);
                dist[ii][jj] = dist[u.first][u.second] + 1;
                q.push(make_pair(ii, jj));
            }
        }
    }
}



int main(int argc, char *argv[])
{
    
 
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    memset(grid, -1, sizeof(grid));
    cin >> H >> W;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            char c;
            cin >> c;
            if (c == '.') {
                grid[i][j] = 1;
            } else {
                grid[i][j] = 0;
                black++;
            }
        }
    }
    
    bfs(0, 0);
    if (!dist[H - 1][W - 1]) {
        cout << "-1" << endl;
        return 0;
    }
    
    
    cout << H * W - dist[H - 1][W - 1] - 1 - black << endl;
    
    return 0;
}


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

using namespace std;

#define REP(i, n)   for(int i = 0; i < (n); i++)
#define REPS(i, n)  for(int i = 1; i <= (n); i++)
#define RREP(i, n)  for(int i = (n)-1; i >= 0; i--)
#define RREPS(i, n) for(int i = (n); i > 0; i--)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define mp make_pair
#define mt make_tuple
#define pb push_back

using ll  = long long;
using pi  = pair<int, int>;
using pl  = pair<ll, ll>;
using vi  = vector<int>;
using vl  = vector<ll>;
using vs  = vector<string>;
using vb  = vector<bool>;
using vvi = vector<vi>;
using vvl = vector<vl>;

const int MOD = 1e9 + 7;
const int INF = 1e9 + 7;
const ll  INFL = 1e18;
const double PI = 3.141592653589793;
const double EPS = 1e-9;

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

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

    vi a(3); REP(i, 3) cin >> a[i];
    sort(ALL(a));
    if(a[0] + a[1] == a[2]) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3636
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstring>
#include<queue>
#include<tuple>
#include<utility>
#include<map>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include<stdlib.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define range(a) a.begin(), a.end()
#define endl "\n"
#define Yes() cout << "Yes" << endl
#define No() cout << "No" << endl
using Graph = vector<vector<int>>;
const unsigned long long mod = 1e9 + 7;
const long long INF = 1LL<<60;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
void chmin(long long &a, long long b) { if (a > b) a = b; }
void chmax(long long &a, long long b) { if (a < b) a = b; }

int main(void){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int x;	cin>>x;
	x=x-200;
	int count=0;
	while(x>=200){
		count++;
		x=x-200;
	}

	cout<<9-count<<endl;


    return 0;
}




Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define pli pair<ll, int>
#define pil pair<int, ll>
#define pll pair<ll, ll>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define endl '\n'
const int inf = 1000000007;
const ll INF = 1e18;
// int mod = 998244353;
int mod = 1000000007;
const double eps = 1e-8;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
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; }
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
template<typename T, typename U> T pow_(T a, U b) { return b ? pow_(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { rep(i, sz(vec)) { if (i) os << " "; os << vec[i]; } return os; }
template<class T> ostream& operator << (ostream& os, const set<T>& s) { for (auto si : s) os << si << " "; return os; }
template<typename T> inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T, class T2> inline void add(T &a, T2 b) { (a += (b % mod + mod)) %= mod; }
template<class T> void operator += (vector<T>& v, vector<T> v2) { rep(i, sz(v2)) v.eb(v2[i]); }

void solve();

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(12);
    int T;
    T = 1;
    while (T--) solve();
}

void solve() {
    int k;
    cin >> k;
    set<ll> s;
    auto dfs = [&](auto&& dfs, ll x, int d) -> void {
        s.emplace(x);
        if (d == 9) return;
        
        rep3(i, x % 10 - 1, x % 10 + 2) {
            if (i < 0 || i >= 10) continue;
            ll y = x * 10 + i;
            dfs(dfs, y, d + 1);
        }
    };
    rep3(i, 1, 10) dfs(dfs, i, 0);
    int cnt = 0;
    for (ll si : s) {
        ++cnt;
        if (cnt == k) {
            cout << si << endl;
            return;
        }
    }
}


Measured memory_bytes: 12992
//本数 = N-つなげたジョイントの数,長さ = N本のパイプの長さ+つなげたジョイントの長さ
//同じ本数のジョイントをつなげるのなら、長いジョイントからつなげたほうがよくねえか？
//となると…どのパイプをつなげたかも関係なくなる。
#include<iostream>
#include<algorithm>
#include<functional>
using namespace std;
typedef unsigned int Int;

Int n,sumlen;
Int jyo[64999];
Int ans[100],cor = 0;

int main(){
	Int i;
	while(cin >> n){
		if(n == 0)
			break;
		sumlen = 0;
		for(i = 0;i < n;i++){
			Int paipu;
			cin >> paipu;
			sumlen += paipu;
		}
		for(i = 0;i < n-1;i++){
			cin >> jyo[i];
		}
		sort(jyo,jyo+n-1,greater<int>());
		Int now = 0;
		for(i = 0;i < n;i++){
			if(sumlen*(n-i) > ans[cor])
				ans[cor] = sumlen*(n-i);
			if(i < n-1)
				sumlen += jyo[i];
		}
		cor++;
	}
	for(i = 0;i < cor;i++){
		cout << ans[i] << endl;
	}
	return 0;
}

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

int main() {
  
  int64_t A, B, C, D; cin >> A >> B >> C >> D;
  
  int64_t numberA = 0, numberB = 0, lcm = C / __gcd(C, D) * D;
  
  numberA = (A - 1) - ((A - 1) / C + (A - 1) / D - (A - 1) / lcm);
  
  numberB = B - (B / C + B / D - B / lcm);
  
  cout << numberB - numberA << endl;
  
}

Measured memory_bytes: 3588
num_500 = int(input())
num_100 = int(input())
num_050 = int(input())
total = int(input())

count = 0
for count_500 in range(0, num_500 + 1):
    sum_500 = count_500 * 500
    for count_100 in range(0, num_100 + 1):
        sum_100 = count_100 * 100
        for count_050 in range(0, num_050 + 1):
            sum_050 = count_050 * 50
            if total == (sum_500 + sum_100 + sum_050):
                count += 1

print(count)


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <map>

struct UnionFindTree {
  std::vector<long> par;

  UnionFindTree(long N) : par(N) {
    for (long i=0; i<N; i++) {
      par[i] = i;
    }
  }

  long root(long x) {
    if (par[x] == x) {
      return x;
    } else {
      return par[x] = root(par[x]);
    }
  }

  bool same(long x, long y) {
    return root(x) == root(y);
  }

  void unite(long x, long y) {
    long root_x = root(x);
    long root_y = root(y);
    if (root_x == root_y) return;
    par[root_x] = root_y;
  }
};

int main() {
  ssize_t H, W;

  std::cin >> H >> W;

  std::vector<bool> grid(H*W);

  for (ssize_t i=0; i<H; i++) {
    for (ssize_t j=0; j<W; j++) {
      char c;
      std::cin >> c;
      grid[W*i+j] = c == '#';
    }
  }


  UnionFindTree group(H*W);

  for (ssize_t i=0; i<H; i++) {
    for (ssize_t j=0; j<W; j++) {
      auto self = W*i+j;
      if (i>0) {
        auto up = W*(i-1)+j;
        if (grid[self] != grid[up]) {
          group.unite(self, up);
        }
      }
      if (j>0) {
        auto left = W*i+j-1;
        if (grid[self] != grid[left]) {
          group.unite(self, left);
        }
      }
      if (j+1<W) {
        auto right = W*i+j+1;
        if (grid[self] != grid[right]) {
          group.unite(self, right);
        }
      }
      if (i+1<H) {
        auto down = W*(i+1)+j;
        if (grid[self] != grid[down]) {
          group.unite(self, down);
        }
      }
    }
  }

  std::map<ssize_t, size_t> cnt_b;
  std::map<ssize_t, size_t> cnt_w;

  for (ssize_t i=0; i<H; i++) {
    for (ssize_t j=0; j<W; j++) {
      auto r = group.root(W*i+j);

      if (grid[W*i+j])
        cnt_b[r]++;
      else
        cnt_w[r]++;
    }
  }

  size_t ans = 0;

  for (auto p : cnt_b) {
    auto r = std::get<0>(p);
    auto b = std::get<1>(p);
    auto w = cnt_w[r];

    ans += b*w;
  }

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

  return 0;
}


Measured memory_bytes: 18816
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>

using namespace std;

int main(void)
{
    string s;
    int k;
    cin >>s >>k;
    vector<pair<string, int> > vt;
    for(int i = 0; i < s.size(); i++){
        vt.push_back(make_pair(s.substr(i,s.size()-i), i));
    }

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

    set<string> subs;
    for(int i = 0; i < min(5, (int)vt.size()); i++){
        for(int j = 1; j < s.size() - vt[i].second + 1; j++){
            subs.insert(s.substr(vt[i].second, j));
        }
    }
    int ct = 1;
    for(set<string>::iterator it = subs.begin(); it != subs.end(); it++){
        if(ct == k){
            printf("%s\n", (*it).c_str());
            break;
        }
        ct++;
    }

    return 0;
}

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

using namespace std;
int main(){

string s,k;
cin>>s>>k;
int flag=1;
for(int i=0;i<(int)s.length();i++){
    if(s[i]!=k[i])flag=0;
}
if(flag==1)cout<<"Yes";
else cout<<"No";


}


Measured memory_bytes: 3624
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#include<cmath>


#define REP(i,n) for (int i = 0; (i) < (n); ++ (i))
#define FOR(i,n) for (int i = 1; (i) <= (n); ++ (i))
#define dump(x)  cout << #x << " = " << (x) << endl;
#define pb push_back
#define int long long
//#define lint long long

const int INF = 1e18;
const int MOD = 1e9+7;
//const lint LINF = 1e18;
const double eps = 0.000000001;//もとの値の10^(-16)まで

using namespace std;

//typedef pair<int, int> P;
//priority_queue< P, vector<P>, greater<P> > q;//ダイクストラの時、greaterで小さい順

signed main(){
  int a;
  cin >> a;
  string s;
  cin >> s;
  if(a>=3200) cout << s << endl;
  else cout << "red" << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;

// This file is a "Hello, world!" in Java language by OpenJDK for wandbox.

class Main
{
    public static void main(String[] args)
    {
        new Main().run();
    }
    
    void run(){
        Scanner sc=new Scanner(System.in);
        int N=sc.nextInt();
        int M=sc.nextInt();
        long[] A=new long[N];
        for(int i=0;i<N;++i){
        	A[i]=sc.nextLong();
        }
		long base=0;
		long lcm=1;
		for(int i=0;i<N;++i){
			//h*lcm==A[i]/2-base mod A[i]
			long gcd=gcd(lcm,A[i]);
			long diff=((A[i]/2)-base)%A[i];
			diff=(diff+A[i])%A[i];
			if(diff==0)continue;
			if(gcd(diff,gcd)!=gcd){
				System.out.println(0);
				return;
			}
			long hoge=inv(lcm/gcd,A[i]/gcd)*(diff/gcd)%(A[i]/gcd);
			base=base+hoge*lcm;
			lcm=lcm(lcm,A[i]);
			if(base>M){
				System.out.println(0);
				return;
			}
		}
		System.out.println((M-base)/lcm+1);
    }
	
	long inv(long a, long mod) {
		a %= mod;
		if (a < 0)
			a += mod;
		if (a == 0) {
			throw new AssertionError();
			// return 1;
		}
		long b = mod;
		long p = 1, q = 0;
		while (b > 0) {
			long c = a / b;
			long d;
			d = a;
			a = b;
			b = d % b;
			d = p;
			p = q;
			q = d - c * q;
		}
		long ret = p < 0 ? (p + mod) : p;
		return ret;
	}
	
	long gcd(long a,long b){
		if(a>b)return gcd(b,a);
		if(a==0)return b;
		return gcd(a,b%a);
	}
	
	long lcm(long a,long b){
		return a/gcd(a,b)*b;
	}
	
	void tr(Object...o){
		System.out.println(Arrays.deepToString(o));
	}
}
// OpenJDK reference:
//   http://openjdk.java.net/

// Java language references:
//   http://docs.oracle.com/javase


Measured memory_bytes: 55828
#include<iostream>
using namespace std;
int main()
{
	long long a,b;
	cin>>a>>b;
	if(b>0&&a>0)
	cout<<"Positive"<<endl;
	if(b>=0&&a<=0)
	cout<<"Zero"<<endl;
	if(b<0&&a<0)
	{
		if((b-a+1)%2==0)
		cout<<"Positive"<<endl;
		else
		cout<<"Negative"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#B
n = int(input())
ans = 0
for i in range(1,n+1):
    if i % 2 == 1:
        count = 0
        for j in range(1,i+1):
            if i % j == 0:
                count += 1
        if count == 8: 
            ans += 1 
print(ans)

Measured memory_bytes: 38768
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    ll n,i,j,c,d,an=0,k,mod;
    mod=1000000007;
    cin>>n;
    ll ar[n+2];
    for(i=0;i<n;i++)
    {
        cin>>ar[i];
    }
    for(i=0;i<60;i++)
    {
        k=(1LL<<i);
        c=0;
        d=0;
        for(j=0;j<n;j++)
        {
            if((ar[j] & k)==0)
                c++;
            else
                d++;
        }
        an=an+((k%mod)*((c*d)%mod))%mod;
        an=an%mod;
    }
     cout<<an<<endl;
}


Measured memory_bytes: 5936
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define sz(A) (int)(A.size())
#define all(x) (x).begin(),(x).end()
#define get(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
typedef long long ll;
typedef pair<int, int> PII;
typedef vector<int> VI;
const ll mod = 998244353;
ll powmod(ll a, ll b) { ll res = 1; a %= mod; assert(b >= 0); for (; b; b >>= 1) { if (b & 1)res = res*a%mod; a = a*a%mod; }return res; }
ll dp[3005][3005];
ll a, b, c, d;
void solve() {
	cin >> a >> b >> c >> d;
	dp[a][b] = 1;
	rep(j,1,d-b+1) {
		dp[a][b + j] = powmod(a, j);
	}
	rep(i, 1, c - a + 1) {
		dp[a + i][b] = powmod(b, i);
	}
	for (int i = a + 1; i <= c; i++) {
		for (int j = b + 1; j <= d; j++) {
			dp[i][j] = dp[i][j - 1] * i + dp[i - 1][j] * j - dp[i - 1][j - 1] * (i - 1)*(j - 1);
			
			dp[i][j] %= mod;
			dp[i][j] += mod;
			dp[i][j] %= mod;
		}
	}
	cout << dp[c][d] << endl;
}
int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int T_ = 1;
	//cin >> T_;
	for (int i = 0; i < T_; i++)solve();
	return 0;
}







Measured memory_bytes: 73908
#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <cassert>

#define REP(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define eb emplace_back

typedef long long ll;
using namespace std;
vector<int> G[100010];
vector<pair<int,int> > B;
int used[100010];
int sz[100010];
int cnt[100010];
int n,m,k;
int id;
void dfs(int x){
    used[x] = id;
    for(auto i : G[x]){
//        cout << x << ' ' << i << '\n';
        if(!used[i]){
            dfs(i);
        }
    }
}
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    // cout << fixed << setprecision(20);
    cin >> n >> m >> k;
    vector<pair<int,int> > FF(m);
    REP(i,m){
       int a,b;cin >> a >> b;a--,b--;
       FF[i] = mp(a,b);
       G[a].pb(b);
       G[b].pb(a);
    }
    B.resize(k);
    REP(i,k){
        int a,b;cin >> a >> b;a--,b--;
        B[i] = mp(a,b);
    }
    REP(i,n){
        if(!used[i]){
//            cout << i << ',';
            id++;
 //           cout << id << '\n';
            dfs(i);
        }
    }
    REP(i,n){
        cnt[used[i]]++;
    }
    vector<int> F(n);
    REP(i,n)F[i] = cnt[used[i]];
 //   REP(i,n)cout  << F[i] << '\n';
    vector<int> Minus(n,0);
    REP(i,k){
        if(used[B[i].first] == used[B[i].second])Minus[B[i].first]++,Minus[B[i].second]++;
    }
    REP(i,m){
        if(used[FF[i].first] == used[FF[i].second])Minus[FF[i].first]++,Minus[FF[i].second]++;
    }
    REP(i,n){
        if(i == 0)cout << F[i] - Minus[i] - 1;
        else cout << ' ' << F[i] - Minus[i] - 1;
    }
    cout << '\n';
    return 0;
}


Measured memory_bytes: 9600