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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;

namespace
{
	struct UnionFind
	{
		UnionFind(int n) : par(n), rank(n, 0), ct(n, 1) {
			iota(par.begin(), par.end(), 0);
		}
		int Find(int i)
		{
			if (par[i] == i)
				return i;
			else
				return par[i] = Find(par[i]);
		}
		void Unite(int i, int j)
		{
			i = Find(i);
			j = Find(j);
			if (i == j)
				return;
			if (rank[i] < rank[j])
			{
				par[i] = j;
				ct[j] += ct[i];
			}
			else
			{
				par[j] = i;
				ct[i] += ct[j];
				if (rank[i] == rank[j])
					++rank[i];
			}
		}
		ll Count(int i)
		{
			return ct[Find(i)];
		}
		vector<int> par;
		vector<int> rank;
		vector<ll> ct;
	};
}

void ABC097D()
{
	int N, M;
	cin >> N >> M;
	vi p(N);
	for (auto& x : p)
	{
		cin >> x;
		--x;
	}
	UnionFind uf(N);
	for (int i = 0; i < M; ++i)
	{
		int a, b;
		cin >> a >> b;
		--a; --b;
		uf.Unite(a, b);
	}
	map<int, vector<int> > graph;
	for (int i = 0; i < N; ++i)
	{
		graph[uf.Find(i)].push_back(i);
	}
	for (auto& x : graph)
	{
		sort(x.second.begin(), x.second.end());
	}
	int ct = 0;
	for (auto& x : graph)
	{
		vi vals(x.second.size());
		for (int i = 0; i < vals.size(); ++i)
		{
			vals[i] = p[x.second[i]];
		}
		for (int i = 0; i < vals.size(); ++i)
		{
			auto p = lower_bound(x.second.begin(), x.second.end(), vals[i]);
			if (p != x.second.cend() && vals[i] == *p)
				++ct;
		}
	}
	cout << ct << endl;
}

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



Measured memory_bytes: 13184
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 55;

ll n, x, ans;
ll dp[50], len[50];

void sim(int layer) {
    if (!x) return;
    if (layer == 0) {
        x--;
        ans++;
    } else {
        x--;
        if (!x) return;
        if (x >= len[layer - 1]) {
            x -= len[layer - 1];
            ans += dp[layer - 1];

            if (x) {
                x--;
                ans++;
            } else return;
            
            if (!x) return;
            if (x >= len[layer - 1]) {
                x -= len[layer - 1];
                ans += dp[layer - 1];
            } else {
                sim(layer - 1);
                x--;
            }
        } else {
            sim(layer - 1);
            x--;
        }   
    }   
}

int main() {
    cin.sync_with_stdio(0); cin.tie(0);
    cin >> n >> x;
    dp[0] = 1, len[0] = 1;
    for (int i = 1; i < n; i++) {
        dp[i] = 2ll * dp[i - 1] + 1ll;
        len[i] = len[i - 1] * 2 + 3;
    }

    sim(n);
    cout << ans;
}
    



Measured memory_bytes: 256
a, b = map(int, input().split())
c = 0
li = []
for i in range(1, 1000):
	c += i
	li.append(c)
for i in range(999):
	if li[i] - a == li[i+1] - b:
		d = li[i] - a
		break
print(d)


Measured memory_bytes: 3060
main :: IO ()
main = do
  [k, s] <- map read . words <$> getLine
  print $ numbers k s

numbers
  :: Int -> Int -> Int
numbers k = length . numbers' k 

numbers' :: Int -> Int -> [(Int,Int,Int)]
numbers' k s 
  = [ (x,y,z) | x <- [0..k]
              , y <- [0..k]
              , let z = s - x - y
              , 0 <= z && z <= k
              ]
                      


Measured memory_bytes: 764
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <map>
#include <algorithm>  // std::unique
#include <cmath>
#include <limits.h>
#include <queue>
#include <unordered_map>
#include <sstream>      // std::ostringstream
#include <bitset>
#include <iomanip>
#include <functional>
#include <set>
#include <list>

#define _USE_MATH_DEFINES
#include <math.h>
using namespace std;

using ll = long long;
constexpr auto PrimeBigNum10_9_7 = 1000000007;
const long long INF = 1LL << 60;

#define rep(i,a,b) for(ll i=a;i<=b;++i)
#define repb(i,a,b) for(ll i=a;i>=b;--i)

template <typename T>
void DisplayAnswer(const T& v) {
	cout << v << endl;
}
template <typename T>
void DisplayAnswers(const vector<T>& vs) {
	for (const auto& v : vs) {
		cout << v << endl;
	}
}

template <typename T>
void DisplayAnswerOneLine(const vector<T>& vs) {
	for (const auto& v : vs) {
		cout << v << ' ';
	}
	cout << endl;
}


std::vector<std::string> split(const std::string &str, char sep)
{
	std::vector<std::string> v;
	std::stringstream ss(str);
	std::string buffer;
	while (std::getline(ss, buffer, sep)) {
		v.push_back(buffer);
	}
	return v;
}



template<class T>
void chmin(T& a, T b) {
	if (a > b) {
		a = b;
	}
}


// 素数判定
template <typename T>
bool IsPrimeNumber(T value) {

	for (int i = 2; i * i <= value; ++i) {
		if ((value % i) == 0) {
			return true;
		}
	}
	return false;
}

// 桁数判定
template <typename T>
T GetFigureLength(T value) {
	T figure = 1;
	while (value >= 10) {
		value /= 10;
		++figure;
	}
	return figure;
}

// 素因数分解結果
template <typename T>
map<T, T> GetPrimeFactorize(T value) {

	map<T, T> res;

	for (T i = 2; i * i <= value; ++i) {
		if ((value%i) != 0)	continue;

		T count = 0;
		while ((value % i) == 0) {
			value /= i;
			++count;
		}

		res[i] = count;
	}

	if (value != 1) {
		res[value] = 1;
	}
	return res;
}


void DebugPrint(const vector<ll>& vec) {
	cout << "{";
	for (auto itr = vec.begin(); itr != vec.end(); ++itr) {
		cout << *itr << ",";
	}
	cout << "}" << endl;
}

// valueが2のx乗以下である計算
ll calc2x(ll value) {
	ll n = 0;
	while (value > 0) {
		value /= 2;
		++n;
	}
	return n;
}
int main(void) {

	string str;
	cin >> str;

	ll count = 0;
	char c = str[0];
	for (ll i = 1; i < str.size(); ++i) {
		if (c != str[i]) {
			c = str[i];
			count++;
		}
	}

	cout << count << endl;
	return 0;
}


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

ll sum(ll n)
{
    ll s = 0;
    while(n)
    {
        s += n % 10;
        n /= 10;
    }
    return s;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll k;
    cin >> k;

    ll start = 1, add = 1;
    for(int i = 1; i <= k; i++)
    {
        cout<<start<<endl;
        while(1)
        {
            double q,qq;
            q = (double)(start + add)/sum(start + add);
            qq = (double)(start + 2*add)/sum(start + 2*add);
            if(q <= qq)break;
            else add *= 10;
        }
        start += add;
    }
    return 0;

}


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

int main() {
	IOS;
	int a, b;
	cin >> a >> b;
	if (a < 10 && b < 10) {
		put(a * b);
	} else {
		put(-1);
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(long long i=0; i<(long long)(n); i++)
#define REP(i, k, n) for(long long i=(long long)(k); i<(long long)(n); i++)
#define all(a) (a).begin(), (a).end()
#define pb push_back
#define PQ(T) priority_queue<T>
#define PQS(T) priority_queue<T, vector<T>, greater<T> >
#define deci cout << fixed << setprecision(15);
typedef long long ll;
const ll inf = 1020304050607080910;
const int mod = 1000000007;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
template<class T> bool chmin(T&x,T y){if(x>y){x=y;return true;}return false;}
template<class T> bool chmax(T&x,T y){if(x<y){x=y;return true;}return false;}
ll gcd(ll x,ll y){if(x>y)swap(x, y);while(x!=0){y%=x;swap(x, y);}return y;}
ll mpow(ll x,ll r){if(r==0)return 1;if(r%2==1){return x*mpow(x,r-1)%mod;}else{ll aa=mpow(x,r/2);return aa*aa%mod;}}

int N, M;
vector<int> G[100010];

int main(){
	cin >> N >> M;
	rep(i, M){
		int a, b; cin >> a >> b;
		a--; b--;
		G[a].pb(b);
		G[b].pb(a);
	}
	queue<int> que;
	vector<int> d(N, 1e9);
	que.push(0);
	d[0] = 0;
	int ans[N];
	while(que.size()){
		int aa = que.front(); que.pop();
		for(auto to:G[aa]){
			if(d[to] == 1e9){
				d[to] = d[aa] + 1;
				ans[to] = aa;
				que.push(to);
			}
		}
	}
	cout << "Yes" << endl;
	rep(i, N-1) cout << ans[i+1]+1 << endl;
	return 0;
}


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

#define REP(i,n) for(int i=0;i<(n);++i)
#define ll long long
const long long INF = 1LL<<60;
const long long mod = 1e9 + 7;
int Ds(int x){
    int a = 0;
    while(x > 0){
        a += x % 10;
        x /= 10;
    }
    return a;
}
int main(){
    int N;
    cin >> N;
    if(N % Ds(N) == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<vector>
#include<iostream>

#define ll long long
using namespace std;

int main()
{
    int N;
    cin >> N;
    int A[2][N];
    for (int i=0; i<2; i++) {
      for (int j=0; j<N; j++) {
        cin >> A[i][j];
      }
    }

    ll max=0;
    for (ll i=0; i<N; i++) {
      ll sum=0;
      for (ll x=0; x<=i; x++) {
        sum += A[0][x];
      }
      for (int x=i; x<N; x++) {
        sum += A[1][x];
      }
      if (max < sum) {
          max = sum;
      }
    }

    cout << max;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <algorithm>
using namespace std;
int main(){
    int N, T;
    cin >> N >> T;
    int c[N], t[N];
    int ans = 1001;
    for (int i = 0; i < N; i++){
        cin >> c[i] >> t[i];
        if (t[i] <= T){
            if(ans >= c[i]){
                ans = c[i];
            }
        }
    }
    if (ans == 1001){
        cout << "TLE" <<endl;
    } else {
        cout << ans << endl;
    }
    return 0;
}


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

//数列a0,,,an-1があるとき
//s,tが与えられた時as,,,atの最小値を求める
//i,xが与えれられたときaiの値をxに変更する
//セグ木を作る
#define MAX_INF  2147483647
//セグメント木を持つグローバル配列
int n;
vector<int>value;
//Nは葉の数datはノードの値を持つ配列
//k番目の値をaに変更
void update(int k, int a) {
	//i番目の葉の値をxに変える
	k += n - 1;//i番目の葉のノード番号
	value[k] = a;
	while (k > 0) {
		k = (k - 1) / 2;//ノードiのノードの便号に変える
		value[k] = min(value[k * 2 +1], value[k * 2 + 2]);
	}
}
//[a,b)の最小値を求める
//後ろのほうの引数は計算の簡単のための引数
//kは節点の番号、l,rはその節点が[l,r)に対応づいていることを表す
//従って外からはquery(a,b,0,0,n)として呼ぶ
int query(int a, int b, int k, int l, int r) {
	//[a,b)と[l,r)が交差しなければINT_MAX
	if (r <= a || b <= l)return MAX_INF;
	//[a,b)が[l,r)を完全に含んでいればこの節点の値
	if (a <= l && r <= b)return value[k];
	else {
		//そうでなければ二つの子の最小値
		int vl = query(a, b, k * 2 + 1, l, (l + r) / 2);//左の子に値を聞く
		int vr = query(a, b, k * 2 + 2, (l + r) / 2, r);//右の子に値を聞く
		return min(vl, vr);
	}
}
int main() {
	int N, Q; cin >> N >> Q;
	n = 1;
	while (n < N)n *= 2;
	value = vector<int>(2 * n - 1, MAX_INF);
	for (int j = 0; j < Q; ++j) {
		int c; cin >> c;
		if (c == 0) {
			//update(i,x)
			int i, x; cin >> i >> x;
			update(i, x);
		}
		else {
			//find(s,t)
			int s, t;
			cin >> s >> t;
			cout << query(s, t + 1, 0, 0, n) << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 4972
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
using namespace std;
typedef long long ll;
int main(){
  int k,s;
  cin >> k >> s;
  int res = 0;
  for(int i = 0;i <= k;i++){
    for(int j = 0;j <= k;j++){
      if(s - i - j >= 0 && s - i - j <= k)res++;
    }
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O0")
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define Rep(i,a,n) for (ll i = (a); i < (n); ++i)
const ll mod = 1e9+7;
const ll INF = 1e18;
#define All(a) (a).begin(),(a).end()
#define Pi acos(-1)
using Graph = vector<vector<ll>>;
using V = vector<ll>;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << setprecision(15) << fixed;
  chrono::system_clock::time_point start,end;
  start = chrono::system_clock::now();

  ll n;
  cin >> n;
  V a(n);
  rep(i,n) cin >> a[i];
  sort(All(a));
  ll ans = 0;
  rep(i,n) ans += a[i];
  if (ans%10 == 0) {
    rep(i,n) {
      if (a[i]%10 != 0) {
        ans -= a[i];
        goto p;
      }
    }
    ans = 0;
  }
  p:
  cout << ans << '\n';

  end = chrono::system_clock::now();
  auto elapsed = chrono::duration_cast< chrono::milliseconds >(end - start).count();
  cerr << elapsed << "ms" << '\n';
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
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; }
const int INF=1001001001;
const int mod=1e9+7;

int main() {
  int K,X;
  cin>>K>>X;
  for(int i=X-K+1;i<=X+K-1;i++){
    cout<<i;
    if(i<X+K-1){cout<<" ";}
  }cout<<endl;
  return 0;
}

Measured memory_bytes: 3640
#include<cstdio>
using namespace std;
const int maxn=1000005;
int n,a[maxn],ans,chk;char s[maxn];
int main(){
	scanf("%d%s",&n,s+1);
	for (int i=1;i<=n;i++) a[i]=s[i]-'0';
	if(n==1){printf("%d\n",a[1]);return 0;}
	n--;
	for (int i=1;i<=n;i++){
		a[i]-=a[i+1];
		if(a[i]<0) a[i]=-a[i];
		if(a[i]==1&&(i-1&n-1)==i-1) ans^=1;
		if(a[i]==1) chk=1;
	}
	if(ans==1){puts("1");return 0;}
	if(chk==1){puts("0");return 0;}
	for (int i=1;i<=n;i++) a[i]>>=1;
	for (int i=1;i<=n;i++)
	if(a[i]==1&&(i-1&n-1)==i-1) ans^=1;
	puts(ans?"2":"0");
	return 0;
}

Measured memory_bytes: 4992
#include <iostream>

using namespace std;

int table[501][501];

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

  int N, M, Q;
  cin >> N >> M >> Q;

  int l, r;
  for (int i = 0; i < M; i++) {
    cin >> l >> r;
    table[l][r]++;
  }
  for (int i = 1; i <= N; i++) {
    for (int j = 1; j <= N; j++) {
      table[i][j] += table[i - 1][j] + table[i][j - 1] - table[i - 1][j - 1];
    }
  }
  int p, q;
  for (int i = 0; i < Q; i++) {
    cin >> p >> q;

    const int ans =
        table[q][q] - table[p - 1][q] - table[q][p - 1] + table[p - 1][p - 1];
    cout << ans << endl;
  }

  return 0;
}


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

using namespace std;

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

const char sp = ' ';
const char cmm = ',';
const int MOD = 1000000007;

using ll = long long;

ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powMod(ll b, ll e, ll m){ll r=1;while(e>0){if(e&1)r=(r%m)*(b%m)%m;b=(b%m)*(b%m)%m;e>>=1;}return r;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

template<typename T>
void ppp(T n){cout << n << endl;}
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
    int len = v.size();
    cout << '[';
    for (int i = 0; i < len; ++i) {
        s << v[i]; if (i < len-1) s << ", ";
    }
    cout << ']';
    return s;
}

template<typename T>
map<T, T> factorization(T n){

    map<T, T> factor;
    while (n % 2 == 0){
        ++factor[2];
        n /= 2;
    }
    for (T i = 3; i*i <= n; i += 2){
        while (n%i == 0){
            ++factor[i];
            n /= i;
        }
    }
    if (n > 2)
        ++factor[n];

    return factor;
}

const int MAX = 510000;

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

void combinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAX; ++i){
        fac[i] = fac[i-1]*i % MOD;
        inv[i] = MOD-inv[MOD%i] * (MOD/i) % MOD;
        finv[i] = finv[i-1]*inv[i] % MOD;
    }
}


ll com(int n, int k){
    if(n < k) return 0;
    if(n < 0 or k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}

int main(){

    combinit();
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll n, m;
    cin >> n >> m;

    map<ll, ll> div = factorization(m);

    ll ans = 1LL;
    for(auto d : div){
        ans = ans*com(d.second+n-1, n-1) % MOD;
    }

    ppp(ans);

    return 0;
}


Measured memory_bytes: 12160
//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
//#include<unordered_map>//イテレータあるけど順序保持しないmap
//#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
#include<valarray>//なんとなく追加
//メモ：表示桁数を大きくする　　cout << fixed << setprecision(20) << cm << endl;
using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define PI acos(-1.0)
#define answer(ans) cout<<ans<<endl;
#define input(N) cin >> N ;


signed main() {
ll N,H=1000,D=0,ite=1,kabu=0;
cin >> N;
vector<ll> A(N);
REP(i,N){
    cin >> A[i];
}

while(D<N-1){
ite=1;
//いつ買うか
if(A[D]<A[D+ite]){
kabu=H/A[D];
H=H - kabu*A[D];


//いつ売るか
while(ite!=0){
    //買った日＋ite日目が最終日の時
    if(D+ite == N-1){
        H=H + kabu*A[D+ite];
        break;
    }
    if(A[D+ite]>=A[D+ite+1]){
        H=H+kabu*A[D+ite];
        D=D+ite;
        ite=0;
    }
    else{
        ite++;
    }

}

}
D++;
}


answer(H);

return 0;
}


Measured memory_bytes: 3620
#include<stdio.h>

int main() {
	int f=0,k;
	int x[5];

	scanf("%d", &x[0]);
	scanf("%d", &x[1]);
	scanf("%d", &x[2]);
	scanf("%d", &x[3]);
	scanf("%d", &x[4]);
	scanf("%d", &k);
	
	for (int i = 0;i < 4;i++) {
		for (int j = i + 1;j < 5;j++) {
			if (x[j] - x[i] > k) {
				f = 1;
				break;
			}
		}

		if (f == 1) {
			break;
		}
	}

	if (f == 0) {
		printf("Yay!");
	}
	else {
		printf(":(");
	}
	

	return 0;
}

Measured memory_bytes: 128
s = input()
t = s[::-1]
N = len(s)

ss = ""
for i in s:
	if i != "x":
		ss += i

if ss != ss[::-1]:
	print(-1)
else:
	i = 0
	j = 0
	xcount = 0
	while i < N and j < N:
		if s[i] == t[j]:
			i += 1
			j += 1
		else:
			if s[i] == "x":
				i += 1
			else:
				j += 1
				xcount += 1
	print(xcount + N - j)

Measured memory_bytes: 3444
#include <iostream>
#include <string>
#include <stack>
#include <math.h>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <vector>

using namespace std;






int main()
{
	int n;
	int tmax;
	int a[1000], b[1000], c[1000];
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i] >> b[i] >> c[i];
	}
	for (int i = 0 ; i < n; i++) {
		tmax = max({ a[i], b[i], c[i] });
		if (tmax == a[i]) {
			if (a[i] * a[i] == b[i] * b[i] + c[i] * c[i]) cout << "YES" << endl;
			else cout << "NO" << endl;
		}
		else if (tmax == b[i]) {
			if (b[i] * b[i] == a[i] * a[i] + c[i] * c[i]) cout << "YES" << endl;
			else cout << "NO" << endl;
		}
		else if (tmax == c[i]) {
			if (c[i] * c[i] == b[i] * b[i] + a[i] * a[i]) cout << "YES" << endl;
			else cout << "NO" << endl;
		}
	}

	
}

Measured memory_bytes: 1160
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;
using vi = vector<int>;
#define rep(i,n) for(int i=0,_i=(n);i<_i;++i)

template<class T>using vv = vector<vector<T>>;
constexpr ll INF = 1e15;
int main() {
  int N, M;
  cin >> N >> M;

  vv<ll> cost(N, vector<ll>(N, INF));
  vi A(M), B(M), C(M);
  rep(i, M) {
    cin >> A[i] >> B[i] >> C[i];
    --A[i], --B[i];
    cost[A[i]][B[i]] = cost[B[i]][A[i]] = C[i];
  }
  rep(i, N)
    cost[i][i] = 0;

  rep(k, N) rep(i, N) rep(j, N)
    cost[i][j] = min(cost[i][j], cost[i][k] + cost[k][j]);

  int ans = 0;
  rep(i, M) {
    bool ok = false;
    rep(from, N) {
      rep(to, N) {
        if (cost[from][to] == cost[from][A[i]] + C[i] + cost[B[i]][to]) {
          ok = true;
          break;
        }
      }
      if (ok)
        break;
    }
    if (!ok)
      ++ans;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 384
//{{{
#include<algorithm>
#include<cmath>
#include<deque>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<random>
#include<set>
#include<sstream>
#include<sys/time.h>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(printde) FUNC(printdbe) FUNC(printdwe) FUNC(printdu);
#endif
template <template <class T, class = std::allocator<T>> class V, class E>
istream& operator >> (istream& in, V<E>& v){ for(auto& e : v){ in >> e; } return in; }
//}}}

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    long double a, b, x;
    cin >> a >> b >> x;
    long double ab = a * b;
    if(a * ab == x){
        cout << 0 << '\n';
    }else if(a * ab / 2 <= x){
        printde(1, a * a * a / 2 / (a * ab - x));
        cout << fixed << setprecision(20) << 90 - 180 / M_PI * atan(a * a * a / 2 / (a * ab - x)) << '\n';
    }else{
        printde(2, 2 * x / a / b / b);
        cout << fixed << setprecision(20) << 90 - 180 / M_PI * atan(2 * x / a / b / b) << '\n';
    }
}


Measured memory_bytes: 888
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <memory>
#include <cstring>
#include <cassert>
#include <numeric>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cctype>
#include <unordered_map>
#include <unordered_set>
using namespace std;

#define REP2(i, m, n) for (int i = (int)(m); i < (int)(n); i++)
#define REP(i, n) REP2(i, 0, n)
#define ALL(S) (S).begin(), (S).end()
typedef long long ll;

int rec(const string &str, size_t &cur){
  cur++;
  if (isdigit(str[cur])){
    int number = 0;
    while (isdigit(str[cur])){
      number = number * 10 + str[cur++] - '0';
    }
    cur++;
    return (number + 1) / 2;
    
  } else {
    vector<int> nums;
    while (str[cur] == '['){
      nums.push_back(rec(str, cur));
    }
    cur++;

    int res = 0;
    sort(ALL(nums));
    REP(i, nums.size() / 2 + 1){
      res += nums[i];
    }
    return res;
  }
}

int main(){
  ios::sync_with_stdio(false);
  int T;
  cin >> T;
  
  while (T--){
    string str;
    cin >> str;

    size_t cur = 0;
    cout << rec(str, cur) << endl;
  }
  return 0;
}

Measured memory_bytes: 1284
# -*- coding: utf-8 -*-

s = input()
t = input()

sd = sorted(list(str(s)))
#print(sd)

td = sorted(list(str(t)), reverse = True)
#print(td)

lis = ["".join(sd), "".join(td)]

c_lis = sorted(lis)

if lis[0] == c_lis[0]:
    if lis[0] == lis[1]:
        print("No")
    else:
        print("Yes")
else:
    print("No")
    



Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int max(vector<int> &a,int b){
    vector<int> hh(b);
    for(int i=0;i<b;i++){
        hh[i]=a[i];
    }
    sort(hh.begin(),hh.end());
    reverse(hh.begin(),hh.end());
    return hh[0];
}

int main(){
    int n,m;
    m=1;
    cin >> n;
    vector <int>h(n);
    for(int i=0;i<n;i++){
        cin >> h.at(i);
    } 
    for(int i=0;i<n-1;i++){
        if(max(h,i+1)<= h[i+1]) m++; 
        //cout << i << endl;;
    } 
    
    cout << m << endl;

}

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

int main() {
	int m, n;
	bool a[1000010];
	int b[1000010];

	for(int i = 0; i < 1000010; i++)
		a[i] = false;

	for(int i = 1; i < 1000010; i *= 5) {
		for(int j = 1; i * j< 1000010; j *= 3) {
			for(int k = 1; i * j * k < 1000010; k *= 2) {
				a[i * j * k] = true;
			}
		}
	}

	b[0] = 0;
	for(int i = 1; i < 1000010; i++) {
		b[i] = b[i - 1] + (a[i] ? 1 : 0);
	}

	while(cin >> m, m) { cin >> n;
		cout << b[n] - b[m - 1] << endl;
	}

	return 0;
}

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

#define ll long long
#define PB push_back
#define PII pair<int, int>
#define MP make_pair
#define all(x) x.begin(), x.end()
#define REP(x, y, z) for(int x = y; x <= z; x++)
#define REPP(x, y, z) for(int x = y; x >= z; x--)
#define F first
#define S second
#define MSET(x, y) memset(x, y, sizeof(x)) 
#define EB emplace_back
#define maxn

//structure

//declaration

//functions

int main(void)
{
	#ifdef DBG
	freopen("in.in", "r", stdin);
	freopen("out.out", "w", stdout);
	#endif

    int n;
    string a;
    string b;

    cin >> n >> a >> b;

    REP(i, 0, n-1)
    {
        cout << a[i] << b[i];
    }
    puts("");

	return 0;
}

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

int h, w, k;

int b[6][6];

int total_black = 0;
int black_col[6], black_row[6];

int main() {
    cin >> h >> w >> k;
    for (int i = 0; i < h; i++)
        for (int j = 0; j < w; j++) {
            char c;
            cin >> c;
            b[i][j] = (c == '#' ? 1 : 0);
        }
//    fill(black_col, black_col + 6, 0);
//    fill(black_row, black_row + 6, 0);
//    for (int i = 0; i < h; i++)
//        for (int j = 0; j < w; i++) {
//            black_row[i] += (c[i][j] == '#' ? 1 : 0);
//            black_col[j] += (c[i][j] == '#' ? 1 : 0);
//            total_black += (c[i][j] == '#' ? 1 : 0);
//        }
    //
    int ans = 0;

    int sel_row[6];
    int sel_col[6];
    int blacks;
    
    for (int seth = 0; seth < (1<<h); seth++)
        for (int setw = 0; setw < (1<<w); setw++) {
            blacks = 0;
            fill(sel_row, sel_row + 6, 0);
            fill(sel_col, sel_col + 6, 0);

            for (int r = 0; r < h; r++)
                if (seth & (1 << r))
                    sel_row[r] = 1;
            for (int c = 0; c < w; c++)
                if (setw & (1 << (c)))
                    sel_col[c] = 1;

            for (int r = 0; r < h; r++)
                if (not sel_row[r])
                    for (int c = 0; c < w; c++)
                        if (not sel_col[c]) {
                            blacks += b[r][c];
                        }

            ans += (blacks == k);
        }
    cout << ans << endl;
}

Measured memory_bytes: 3592
W, H, x, y, r = gets.chomp.split(" ").map(&:to_i)

is_x_in_range = r <= x && x <= W - r
is_y_in_range = r <= y && y <= H - r

if is_x_in_range && is_y_in_range then
  puts "Yes"
else
  puts "No"
end

Measured memory_bytes: 8608
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using pii = pair<int, int>;

//const ll INF = 1e18L + 5;
//const int INF = 1e9 + 5;
//const double pi = 3.14159265358979323846;

int		main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);

	int a, b, c;
	cin >> a >> b >> c;
	if (a < b  && b < c)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}




Measured memory_bytes: 3184
#include "bits/stdc++.h"
#include "math.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define drep(i,a,b) for(ll i=(a);i>=(b);--i)
#define SIZE(a) int((a).size())
#define out(a) cout<<(a)<<endl;
const int INF=INT_MAX;
const int MAX = 510000;
const ll MOD = 1000000007;
ll fac[MAX], finv[MAX], inv[MAX];

int main(){
  ll n;cin>>n;
  rep(i,1,n+1){
    if(i<6){cout<<0<<endl;}
    else{
      ll ans=0;
      bool ok=true;
      for(int x=1;x*x<=i;x++){
        rep(y,1,x+1){
          rep(z,1,y+1){
            if(x*x+y*y+z*z+x*y+y*z+z*x==i){
              ok=false;
              if(x==y&&y==z){ans+=1;}
              else if(x!=y&&y!=z){ans+=6;}
              else{ans+=3;}
              break;
            }
          }
        }
      }
      if(ok){cout<<0<<endl;}
      else{cout<<ans<<endl;}
    }
  }
  
}







Measured memory_bytes: 3676
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
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 (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    ll P,Q,R;
    cin >>P>>Q>>R;
    

    cout << min({P+Q,P+R,Q+R}) << endl;


    return 0;
    

}

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

const int INF = 2e9;

int main(){
    int n,a,b,c,d;
    cin >> n >> a >> b >> c >> d;
    string s;
    cin >> s;
    int p = 0;
    for(int i = a;i < max(c,d);i++){
        if(s[i] == '#' && s[i-1] == '#'){
            p++;
            break;
        }
    }
    if(d < c){
        p++;
        for(int i = b;i <= d;i++){
            if(s[i] == '.' && s[i-1] == '.' && s[i-2] == '.'){
                p--;
                break;
            }
        }
    }
    if(p == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 640
import sys
sys.setrecursionlimit(10**7)


def DFS(s,p):
    global timer
    prenum[s]=lowest[s]=timer
    timer +=1
    parent[s]=p
    color[s]="gray"

    for i in G[s]:
        if color[i]=="white":
            DFS(i,s)
            lowest[s]=min(lowest[s],lowest[i])
        else:
            lowest[s]=min(lowest[s],prenum[i])
    color[s]="black"


def art_point():
    A=set()
    root=0
    for i,j in enumerate(parent):
        if j==-1:continue
        elif prenum[j]<=lowest[i]:
            A.add(j)
        if j==0:root +=1
    if root==1:A.remove(0)

    return set(A)


v,e=map(int,input().split())
G=[[] for _ in range(v)]

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

prenum=[0 for _ in range(v)]
parent=[0 for _ in range(v)]
lowest=[float("inf") for _ in range(v)]
timer=1
color=["white" for _ in range(v)]

DFS(0,-1)
A=art_point()

for i in sorted(A):
    print(i)


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

using namespace std;
typedef long long ll;


int main(){
    int a,p;
    cin >> a >> p;
    int ans=a*3+p;
    cout << ans/2 << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <ctype.h>
#include <climits>
#include <queue>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;


int main(){
	int n;
	cin >> n;
	vector<ll> a(n);
	REP(i,n){
		cin >> a[i];
	}
	
	sort(a.begin(),a.end(),greater<ll>());
	
	ll ans=0;
	queue<pair<ll,ll>> w;
	for(int i=1;i<n;i++){
		if(i==1){
			ans+=a[0];
			w.push(make_pair(a[i],a[i-1]));
			w.push(make_pair(a[i],a[i-1]));
		}else{
			ans+=w.front().first;
			w.push(make_pair(a[i],w.front().second));
			w.push(make_pair(a[i],w.front().first));
			w.pop();
		}
		
		
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 8260
N = int(input())
sum = 0

for n in range(N):
    if (n+1)%3==0 and (n+1)%5==0:
        continue
    elif (n+1)%3==0:
        continue
    elif (n+1)%5==0:
        continue
    else:
        sum += n+1

print(sum)



Measured memory_bytes: 9172
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<array>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<numeric>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<queue>
#include<vector>
using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define ALL(a) (a).begin(),(a).end()
#define DUMP(o) {cerr<<#o<<" "<<o<<endl;}
#define DUMPC(o) {cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
const int MOD = 1e9 + 7;

signed main() {
	while (true) {
		vector<int> l(10);
		int v1, v2;
		if (!(cin >> l[0]))break;
		char c;
		FOR(i, 1, 10)cin >> c >> l[i];
		cin >> c >> v1 >> c >> v2;
		int sum = accumulate(ALL(l), 0);
		double a = (double)sum*v1 / (v1 + v2);
		int temp = 0;
		FOR(i, 0, 10) {
			temp += l[i];
			if (temp >= a) {
				cout << i + 1 << endl;
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 3020
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

int main(){
    ll a, b, c;
    cin >> a >> b >> c;
    if(a == b && b == c){
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;
    return 0;
}

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

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    string s;
    cin >> s;

    int win = 15 - s.size();
    for (int i = 0; i < s.size(); i++) {
        if (s[i] == 'o') {
            win++;
        }
    }

    if (win >= 8) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF (ll)1<<62
#define MAX 510000
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(), (x).rend()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;



int main(){
    ll n,k; cin >> n >> k;
    ll ans = n*n;
    REP(i,1,n+1){
        if(i<=k) ans -= n;
        else{
            ll q = n/i;
            ans -= q*k;
            if(n%i>=k) ans -= max(0LL,k-1);
            else ans -= n%i;
        }
        //cout << ans << endl;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
public class ABC
{
    //          int[] split = Console.ReadLine().Split().Select(int.Parse).ToArray();

    public static void Main()
    {
        long[] split = Console.ReadLine().Split().Select(long.Parse).ToArray();
        long A, B, C, D;
        A = split[0];
        B = split[1];
        C = split[2];
        D = split[3];

        long GCD_C_D = gcd(C, D);
        long E = C * D / GCD_C_D;

        long benleft = n_canBeDividedUnderA(B, C) - n_canBeDividedUnderA(A - 1, C);
        long benright = n_canBeDividedUnderA(B, D) - n_canBeDividedUnderA(A - 1, D);

        long benboth = n_canBeDividedUnderA(B, E) - n_canBeDividedUnderA(A - 1, E);

        long output = B - A - benleft - benright + benboth + (long)1;
        Console.WriteLine(output);

    }

    public static long gcd(long A,long B)
    {
        if (A < B)
        {
            long temp = A;
            A = B;
            B = temp;
        }
        if (A % B == 0)
        {
            return B;
        }
        else
        {
            return gcd(B, A % B);
        }

    }
    public static long n_canBeDividedUnderA(long A, long div)
    {
        return A / div;
    }


    

}

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

int main() {
	long long count=0;
	string N;
	cin >> N;
	for (int i = 0; i < N.size(); i++) {
		if (N.at(i) == '1') {
			count++;
		}
		if (N.at(i) == '2') {
			count += 2;
		}
		if (N.at(i) == '3') {
			count += 3;
		}
		if (N.at(i) == '4') {
			count += 4;
		}
		if (N.at(i) == '5') {
			count += 5;
		}
		if (N.at(i) == '6') {
			count += 6;
		}
		if (N.at(i) == '7') {
			count += 7;
		}
		if (N.at(i) == '8') {
			count += 8;
		}
		if (N.at(i) == '9') {
			count += 9;
		}
	}
	if (count % 9 == 0) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

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

int main() {

  int N, M;
  cin >> N >> M;

  vector<vector<int>> v(M);
  for (int i = 0; i < N; i++) {
    int A, B;
    cin >> A >> B;
    if (M < A) {
      continue;
    }
    v[M - A].push_back(B);
  }

  priority_queue<int> q;
  long long ans = 0;

  for (int i = M - 1; 0 <= i; i--) {
    for (int j = 0; j < v[i].size(); j++) {
      q.push(v[i][j]);
    }
    if (!q.empty()){
      ans += q.top();
      q.pop();
    }
  }

  cout << ans << endl;
  return 0;

}

Measured memory_bytes: 8292
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const ll INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

template<typename T> T chmax(T& a, const T& b){return a = (a > b ? a : b);}
template<typename T> T chmin(T& a, const T& b){return a = (a < b ? a : b);}

int main(){
    int n;
    cin >> n;
    cout << n  * n  << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
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; }
#define ll long long
#define rep(i,n) for (int i = 0; i < (n); i++)

int main() {
  int N;
  cin >> N;
  int ans=0;
  int cnt=0;
  int temp=0;
  for(int i=N;i>0;--i){
    temp=i;
    while(1){
      cnt++;
      temp=temp/10;
      if(temp==0) break;
    }
    if(cnt%2==1) ans++;
    cnt=0;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
using namespace std;
int main() {
  
  int A, B;cin>>A>>B;
  
  if(B==1){
    cout<<0<<endl;
  }
  else{  
  vector<int> vec(50);
  for(int i=1;i<=50;i++){
    vec[i]=(A-1)*i+1;
  }
  
  for(int i=1;i<=50;i++){
    if(vec[i]>=B){
      cout<<i<<endl;
      break;
    }
  }
  }
}

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

int main(){
  ll N, K;
  cin >> N >> K;
  ll ans =  N;
  if(N == K){
    cout << 0 << endl;
    return 0;
  }
  if(N > K){
    ans %= K;
    ans = min(ans, abs(ans - K));
  }
  else{
    ans = min(ans, abs(ans - K));
  }
  cout << ans << endl;
}

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

int main() {
	string S;
	cin >> S;
	char s = S[0];
	char t;
	int cnt = 0;
	for (int i = 1; i < 4; i++) {
		if (s == S[i]) {
			cnt++;
		} else {
			t = S[i];
		}
	}
	if (cnt != 1) {
		cout << "No" << endl;
	} else {
		cnt = 0;
		for (int i = 0; i < 4; i++) {
			if (t == S[i]) {
				cnt++;
			}
		}
		if (cnt == 2) {
			cout << "Yes" << endl;
		} else {
			cout << "No" << endl;
		}
	}
}


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

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

    int nb_nodes; cin >> nb_nodes;
    vector<vector<int>> graph( nb_nodes, vector<int>(nb_nodes, 0));
    
    int node;
    while (cin>>node){
        int nb_edges; cin >>nb_edges;
        int edge;
        for (int i=0; i<nb_edges; ++i){
            cin >> edge;    
            graph[node-1][edge-1] = 1;
        }
    }
    
    for(auto& a:graph){
        for(auto&& b:a) cout<<b<<(&b!=&a.back()? " ":"\n");
    }
}

Measured memory_bytes: 3224
a, b, c, d = map(int, input().split())

if b<=c or d<=a:
  print(0)
else:
    if a < c:
        if b < d:
            print(b-c)
        else:
            print(d-c)
    else:
        if d < b:
            print(d-a)
        else:
            print(b-a)



Measured memory_bytes: 3064
N=int(input())
ans=0
for _ in range(N-1):
    u,v=map(int,input().split())
    u,v=min(u-1,v-1),max(u-1,v-1)
    ans-=(u+1)*(N-v)
for i in range(1,N+1):
    ans+=i*(i+1)//2
print(ans)

Measured memory_bytes: 9148
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    cout << "ABC" << n;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdlib>
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

const long long INF = 1LL << 60;

// 入力
int N;
long long h[110000];

// DP テーブル
long long dp[110000];

int main() {
    int N, K; cin >> N >> K;
    for (int i = 0; i < N; ++i) cin >> h[i];

    // 初期化 (最小化問題なので INF に初期化)
    for (int i = 0; i < 110000; ++i) dp[i] = INF;

    // 初期条件
    dp[0] = 0;

    // ループ
    for (int i = 0; i < N - 1; ++i) {
        for (int j = 1; j <= K; ++j) {
            chmin(dp[i + j], dp[i] + abs(h[i] - h[i + j]));
        }
    }

    // 答え
    cout << dp[N-1] << endl;
}

Measured memory_bytes: 1920
use itertools::Itertools;
use std::cmp;
use std::collections::BinaryHeap;
use std::collections::HashMap;
use std::collections::HashSet;
use std::collections::VecDeque;
use std::io::Read;
use std::usize::MAX;

macro_rules! input {(source = $s:expr, $($r:tt)*) => {let mut iter = $s.split_whitespace();let mut next = || { iter.next().unwrap() };input_inner!{next, $($r)*}};($($r:tt)*) => {let stdin = std::io::stdin();let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));let mut next = move || -> String{bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect()};input_inner!{next, $($r)*}};}
macro_rules! input_inner {($next:expr) => {};($next:expr, ) => {};($next:expr, $var:ident : $t:tt $($r:tt)*) => {let $var = read_value!($next, $t);input_inner!{$next $($r)*}};}
macro_rules! read_value {($next:expr, ( $($t:tt),* )) => {( $(read_value!($next, $t)),* )};($next:expr, [ $t:tt ; $len:expr ]) => {(0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()};($next:expr, chars) => {read_value!($next, String).chars().collect::<Vec<char>>()};($next:expr, usize1) => {read_value!($next, usize) - 1};($next:expr, [ $t:tt ]) => {{let len = read_value!($next, usize);(0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()}};($next:expr, $t:ty) => {$next().parse::<$t>().expect("Parse error")};}

fn solve() {
    input! {
        n: usize,
        a: [usize;n]
    }
    let mut plus_count: HashMap<usize, usize> = HashMap::new();

    for i in 0..n {
        let count = plus_count.entry(i + 1 + a[i]).or_insert(0);
        *count += 1;
    }

    //println!("{:?}", plus_count);

    let mut ans = 0;
    for i in 0..n {
        if i + 1 >= a[i] {
            ans += plus_count.get(&(i + 1 - a[i])).unwrap_or(&0);
            //println!("{} {}", i, ans);
        }
    }

    println!("{}", ans);
}

fn main() {
    let thd = std::thread::Builder::new().stack_size(104_857_600);
    thd.spawn(|| solve()).unwrap().join().unwrap();

    /*
    // 入力を一括で読み込む場合
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut input = buf.split_whitespace();

    // inputに対しnext()で読み込んでいく
    let q: usize = input.next().unwrap().parse().unwrap();
    */
}

const LARGE_PRIME: u64 = 1_000_000_007;

// @〜でsnippet


Measured memory_bytes: 9200