akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); ++i)

using namespace std;
using ll = long long;
using v1 = vector<int>;
using v2 = vector<vector<int>>;
using v3 = vector<vector<char>>;

struct Node{
	int parent = -1;
	int left_child = -1;
	int right_child = -1;
};

int checksib(vector<Node>& a, int i){
	int p = a[i].parent;
	if(p == -1) return -1;
	if(a[p].left_child == i) return a[p].right_child;
	if(a[p].right_child == i) return a[p].left_child;
}

int cal_depth(vector<Node>& a, int i, int depth){
	if(a[i].parent == -1) return depth;
	int d = cal_depth(a, a[i].parent, depth) + 1;
	return d;
}

int cal_height(vector<Node>& a, int i){
	int h1 = 0;
	int h2 = 0;
	if(a[i].left_child != -1) h1 = cal_height(a, a[i].left_child)+1;
	if(a[i].right_child != -1) h2 = cal_height(a, a[i].right_child)+1;
	return max(h1, h2);
}

int main(){
	int n;
	cin >> n;
	vector<Node> a(n);
	rep(i, n){
		int x;
		cin >> x;
		int l, r;
		cin >> l >> r;
		if(l != -1) a[l].parent = x;
		if(r != -1) a[r].parent = x;
		a[x].left_child = l;
		a[x].right_child = r;
	}
	rep(i, n){
		cout << "node " << i << ": ";
		cout << "parent = " << a[i].parent << ", ";
		int sib = checksib(a, i);
		cout << "sibling = " << sib << ", ";
		int d = 0;
		if(a[i].right_child != -1) d++;
		if(a[i].left_child != -1) d++;
		cout << "degree = " << d << ", ";
		int depth = cal_depth(a, i, 0);
		cout << "depth = " << depth << ", ";
		int height = cal_height(a, i);
		cout << "height = " << height << ", ";
		if(a[i].parent == -1){
			cout << "root" <<endl;
		}else if(a[i].left_child == -1 && a[i].right_child == -1){
			cout << "leaf" << endl;
		}else{
			cout << "internal node" << endl;
		}
	}
}



Measured memory_bytes: 3100
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define fore(i,a) for(auto &i:a)
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
//---------------------------------------------------------------------------------------------------
int getrand(int L, int R) { // [L,R]
    random_device rd;
    mt19937 mt(rd());
    uniform_int_distribution<> rand(L, R);
    return rand(mt);
}
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/



int N, M;
int A[303][303];
//---------------------------------------------------------------------------------------------------
int naive() {
    int ans = 1010;
    rep(mask, 1, 1 << M) {
        map<int, int> m;
        rep(y, 0, N) {
            rep(x, 0, M) if (mask & (1 << A[y][x])) {
                m[A[y][x]]++;
                break;
            }
        }
        int ma = 0;
        fore(p, m) ma = max(ma, p.second);
        ans = min(ans, ma);
    }

    return ans;
}
//---------------------------------------------------------------------------------------------------
int check(int x) {
    vector<queue<int>> vq(N);
    vector<int> used(M, 0);
    vector<int> ok(N, 0);
    rep(y, 0, N) rep(x, 0, M) vq[y].push(A[y][x]);

    int loop = 1;
    while(loop) {
        map<int, int> m;
        rep(y, 0, N) m[vq[y].front()]++;
        vector<int> ng;
        fore(p, m) if (x < p.second) ng.push_back(p.first);

        if (ng.size() == 0) return 1;

        fore(j, ng) used[j] = 1;

        rep(y, 0, N) {
            while (!vq[y].empty() && used[vq[y].front()]) vq[y].pop();
            if (vq[y].empty()) return 0;
        }

        loop = 1;
    }

    return 0;
}
int solve() {
    int ng = 0, ok = N;
    while (ng + 1 != ok) {
        int x = (ng + ok) / 2;
        if (check(x)) ok = x;
        else ng = x;
    }
    return ok;
}
//---------------------------------------------------------------------------------------------------
void debug() {
    N = getrand(1, 10);
    M = getrand(1, 10);
    rep(y, 0, N) {
        rep(x, 0, M) A[y][x] = x;
        rep(i, 0, 100) {
            int a = getrand(0, M - 1);
            int b = getrand(0, M - 1);
            swap(A[y][a], A[y][b]);
        }
    }
}
void print() {
    printf("%d %d\n", N, M);
    rep(y, 0, N) {
        rep(x, 0, M) printf("%d ", A[y][x] + 1);
        printf("\n");
    }
}
void _main() {
    cin >> N >> M;
    rep(y, 0, N) rep(x, 0, M) {
        cin >> A[y][x];
        A[y][x]--;
    }

    //cout << naive() << endl;
    cout << solve() << endl;
    return;

    rep(i, 0, 100) {
        debug();
        int a = naive();
        int b = solve();
        if (a != b) {
            print();
            return;
        }
    }

    return;
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
#define N 100003
int bas,son;
#define orta (bas+son)/2

int main(){
	int a,b;
	cin>>a>>b;
	for(int i = 1;i<=1000;i++){
		if(int(i*0.08) == a and int(i*0.1) == b){
			cout<<i;
			return 0;
		}
	}
	cout<<-1;
    return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll; 

#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define test() int t;cin>>t;while(t--)
#define all(v) v.begin(),v.end()
#define prinp(p) cout<<p.first<<" "<<p.second<<endl
#define prinv(V) for(auto v:V) cout<<v<<" ";cout<<endl
#define take(V,f,n) for(int in=f;in<f+n;in++) cin>>V[in]
#define what(x) cerr<<#x<<" = "<<x<<endl
#define KStest() int t,t1;cin>>t;t1=t;while(t--)
#define KScout cout<<"Case #"<<t1-t<<": "

const int MOD = 1e9+7,MAX = 1e5+5;
const ll INF = 1e15+5;
/////////////////FastExp///////////////////
ll powN(ll a,ll p)
{
	if(p==0) return 1;
	ll z=powN(a,p/2);
	z=(z*z)%MOD;
	if(p%2) z=(z*a)%MOD;
	return z;
}
/////////////////FastExp///////////////////
///////////////////PnC/////////////////////
vl Fac(MAX),Inv(MAX);
void CalcFac()
{
	Fac[0]=Inv[0]=1;
	for(int i=1;i<MAX;i++)
	{
		Fac[i]=(Fac[i-1]*i)%MOD;
		Inv[i]=powN(Fac[i],MOD-2);
	}
}

ll NCR(int n,int r)
{
	if(r>n) return 0;
	return (((Fac[n]*Inv[r])%MOD)*Inv[n-r])%MOD;
}
///////////////////PnC/////////////////////
//////////////////Sieve////////////////////
vector<bool> is_prime(MAX, true);
vi MinDiv(MAX);
void Sieve()
{
	is_prime[0] = is_prime[1] = false;
	int i,j;
	for (i = 2; i*i <= MAX; i++) 
	{
    	if (is_prime[i]) 
    	{
    		MinDiv[i]=i;
        	for (j = i * i; j <= MAX; j += i)
            {
				is_prime[j] = false;
				MinDiv[j]=i;
    		}
    	}
	}
	for(int i=2;i<=MAX;i++) if(is_prime[i]) MinDiv[i]=i;
}
//////////////////Sieve////////////////////

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
vi C(26);
vvi S(366,vi(26));
int D;
int score(vi t)
{
	int Sat=0;
	vi L(26);
	for(int i=1;i<=D;i++)
	{
		Sat+=S[i][t[i]];
		L[t[i]]=i;

		for(int c=0;c<26;c++)
		{
			Sat-= C[c]*(i-L[c]);
		}
	}
	return Sat;
}

int main()
{
	cin>>D;
	take(C,0,26);
	for(int i=1;i<=D;i++)
	{
		take(S[i],0,26);
	}
	int maxscore=-1000000000;
	vi bestT(D+1);
	for(int times=0;times<100;times++)
	{
		vi T(D+1);
		for(int i=1;i<=D;i++)
		{
			T[i] = rng()%26;
		}
		int thiscore=score(T);
		if(thiscore>maxscore)
		{
			maxscore=thiscore;
			bestT=T;
		}
	}

	for(int i=1;i<=D;i++)
	{
		cout<<bestT[i]+1<<endl;
	}
	// cout<<maxscore<<endl;
		


}		

Measured memory_bytes: 5232
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
int main(){ 
    int n;
    cin>>n;
    int b=0;
    vector<int> a(n);
    REP(i,n) cin>>a[i];
    REP(i,n){
    while(a[i]%2==0){
        a[i]/=2;
        b++;
    }
    }
    cout<<b;
    return 0;
}


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

using namespace std;
int main(){
    int K,S,kazu=0;
    cin >> K >> S;
    for(int x=0;x<=K;x++){
        for(int y=0;y<=K;y++){
            if(K>=S-(x+y)&&x+y<=S){
                kazu++;
            }
        }
    }
    cout << kazu;
    return 0;
}

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

const double pi  = 2 * acos(0.0);
const double eps = 1e-8;

#define REP(i,a,b) for(int i=(a); i<(b);++i)
#define rep(i,n) REP(i,0,n)
#define INF (1<<29)
#define INFLL (1LL<<62)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

int dx[8] = {0, 1, 0, -1, 1, -1, 1, -1};
int dy[8] = {1, 0, -1, 0, 1, -1, -1, 1};

int main(void) {
  ios_base::sync_with_stdio(false); cin.tie(0);
  int h, w;
  cin >> h >> w;
  vector<string> a(h);
  rep(i, h) cin >> a[i];

  cout << string(a[0].size() + 2, '#') << endl;
  rep(i, h) {
    cout << "#" << a[i] << "#" << endl;
  }
  cout << string(a[0].size() + 2, '#') << endl;
  return 0; 
}


Measured memory_bytes: 256
def main():
    n,k=map(int,input().split())
    A=list(map(int,input().split()))
    Neg=[-a for a in A if a<0]
    Pos=[a for a in A if a>=0]
    Neg.sort(); Pos.sort()
    ln,lp=len(Neg),len(Pos)

    def cnt(x):
        ret=0
        if x<0:
            x=-x
            pos_idx=0
            for num in Neg[::-1]:
                while pos_idx<lp and Pos[pos_idx]*num<x:
                    pos_idx+=1
                ret+=lp-pos_idx
                if pos_idx==lp:
                    break
            return ret
        idx=0
        for num in Neg[::-1]:
            if num**2<=x:
                ret-=1
            while idx<ln and Neg[idx]*num<=x:
                idx+=1
            ret+=idx
        idx=0
        for num in Pos[::-1]:
            if num**2<= x:
                ret-=1
            while idx<lp and Pos[idx]*num<=x:
                idx+=1
            ret+=idx
        ret//=2
        ret+=ln*lp
        return ret
    
    l,r=-(10**18+1),10**18+1
    while r-l>1:
        m=(l+r)//2
        if cnt(m)<k:
            l=m
        else:
            r=m
    print(r)
    
if __name__=='__main__':
    main()

Measured memory_bytes: 119812
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
using namespace std;
#define REP(i,n) for(int i = 0; i < (int)n; i++)
#define FOR(i,a,b) for(int i = a; i < (int)b; i++)
#define pb push_back
#define mp make_pair
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef long long ll;
const int INF = 1<<28;
const ll MOD = 1000000007;
const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};

bool des(string a, string b, map<string, string> &m) {
	string s = a;
	while(s != "") {
		if(s == b)
			return true;;
		s = m[s];
	}
	return false;
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n, m;
	while(cin >> n >> m, n|m) {
		cin.ignore();
		vector<string> v(1000);
		map<string, string> ma;
		REP(i, n) {
			string s;
			getline(cin, s);
			int cnt = 0;
			while(s[cnt] == ' ')
				cnt++;
			s = s.substr(cnt);
			ma[s] = cnt ? v[cnt-1] : "";
			v[cnt] = s;
		}
		REP(i, m) {
			string in1, in2, in3;
			cin >> in1;
			cin >> in2 >> in2 >> in2;
			cin >> in3 >> in3;
			in3.erase(in3.end() - 1);
			bool ans = false;
			if(in2 == "child" && ma[in1] == in3)
				ans = true;
			else if(in2 == "parent" && ma[in3] == in1)
				ans = true;
			else if(in2 == "sibling" && ma[in1] == ma[in3])
				ans = true;
			else if(in2 == "descendant")
				ans = des(in1, in3, ma);
			else if(in2 == "ancestor")
				ans = des(in3, in1, ma);
			cout << (ans ? "True" : "False") << endl;
		}
		cout << endl;
	}
	return 0;
}

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

int main()
{
	string nums;
	cin >> nums;
	for (int i = 0; i < nums.size() - 1; ++i)
	{
		if (nums[i] == nums[i + 1])
		{
			cout << "Bad";
			return 0;
		}
		
	}
	cout << "Good";
}



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

int main() {
  int n, i;
  cin >> n;
  vector<ll> a(n + 1, 0);
  for (i = 1; i <= n; ++i) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  ll ans = 0, tmp = 0;
  int mid = n / 2;
  if (n % 2 == 0 && n > 2) {
    for (i = 1; i <= mid; ++i) {
      ans -= 2 * a[i];
    }
    for (i = mid + 1; i <= n; ++i) {
      ans += 2 * a[i];
    }
    ans = ans - a[mid + 1] + a[mid];
  } else if (n % 2 != 0 && n > 2) {
    for (i = 1; i <= mid; ++i) {
      ans -= 2 * a[i];
    }
    for (i = mid + 2; i <= n; ++i) {
      ans += 2 * a[i];
    }
    ans = ans - a[mid + 1] + a[mid];
    for (i = 1; i <= mid; ++i) {
      tmp -= 2 * a[i];
    }
    for (i = mid + 1; i <= n; ++i) {
      tmp += 2 * a[i];
    }
    tmp = tmp - a[mid + 1] - a[mid + 2];
    ans = max(ans, tmp);
  } else {
    ans = a[2] - a[1];
  }
  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 1024
from itertools import permutations

N = int(input())
XY = []
for _ in range(N):
    x, y = map(int, input().split())
    XY.append((x, y))

M = list(permutations(list(range(N))))
ans = 0
for m in M:
    for i in range(N-1):
        a, b = m[i], m[i+1]
        x_a, y_a = XY[a]
        x_b, y_b = XY[b]
        d = ((x_a - x_b) ** 2 + (y_a - y_b) ** 2) ** 0.5
        ans += d

print(ans / len(M))

Measured memory_bytes: 8052
#include <stdio.h>

typedef struct{
  int id;
  int left;
  int right;
  int parent;
} node;

node tree[25];

void Inorder(int);
void Preorder(int);
void Postorder(int);

int main(){

  int n,i,j,count,k,m,l,r;


  scanf("%d",&n);

  for(i=0;i<n;i++) tree[i].parent = -1;
  
  for(i=0;i<n;i++){
    scanf("%d",&m);
    tree[m].id = m;
    scanf("%d%d",&tree[m].left,&tree[m].right);
    tree[tree[m].left].parent = tree[m].id;
    tree[tree[m].right].parent = tree[m].id;
  }

  
  
  for(i=0;tree[i].parent != -1;i++);
  printf("Preorder\n");
  Preorder(i);
  printf("\n");
  printf("Inorder\n");
  Inorder(i);
  printf("\n");
  printf("Postorder\n");
  Postorder(i);
  printf("\n");
  
  return 0;
}    
    
    
void Preorder(int x){
   printf(" %d",tree[x].id);
   if(tree[x].left != -1) Preorder(tree[x].left);
   if(tree[x].right != -1) Preorder(tree[x].right);
}
void Inorder(int x){
   if(tree[x].left != -1) Inorder(tree[x].left);
   printf(" %d",tree[x].id);
   if(tree[x].right != -1) Inorder(tree[x].right);
}
void Postorder(int x){
   if(tree[x].left != -1) Postorder(tree[x].left);
   if(tree[x].right != -1) Postorder(tree[x].right);
   printf(" %d",tree[x].id);
}

Measured memory_bytes: 616
#include<stdio.h>
int main(void){
    int aj=0,am=0,as=0,ae=0,atotal=0;
    int bj=0,bm=0,bs=0,be=0,btotal=0;
    scanf("%d %d %d %d",&aj,&am,&as,&ae);
    scanf("%d %d %d %d",&bj,&bm,&bs,&be);
    atotal=aj+am+as+ae;
    btotal=bj+bm+bs+be;
    if(atotal<btotal)printf("%d\n",btotal);
    else printf("%d\n",atotal);
    return 0;
}

Measured memory_bytes: 592
n, m = map(int, input().split())

a = [list(map(int, input().split())) for _ in range(m)]

cnt = 0

from collections import deque

for i in a:
    b = a[:]
    start = i[0]
    goal = i[1]
    b.remove(i)
    q = deque()
    q.append(start)

    searched = {start}
    while q:
        current = q.popleft()
        if current == goal:
            break
        for j in b:
            if current == j[0] and j[1] not in searched:
                q.append(j[1])
                searched.add(j[1])
            elif current == j[1] and j[0] not in searched:
                q.append(j[0])
                searched.add(j[0])
    else:
        cnt += 1


print(cnt)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N, M; cin >> N >> M;
    using Node = pair<int, int>; // {station, company}
    map<Node, vector<pair<int, Node>>> graph;
    for (int i = 0; i < M; i++) {
        int p, q, c; cin >> p >> q >> c;
        graph[Node(p, c)].emplace_back(0, Node(q, c));
        graph[Node(q, c)].emplace_back(0, Node(p, c));
    }
    for (auto it = begin(graph); it != end(graph); ++it) {
        int station, company;
        tie(station, company) = it->first;
        graph[Node(station, -1)].emplace_back(1, Node(station, company));
        graph[Node(station, company)].emplace_back(0, Node(station, -1));
    }
    priority_queue<pair<int, Node>, vector<pair<int, Node>>, greater<pair<int, Node>>> Q;
    map<Node, int> dist;
    Q.emplace(0, Node(1, -1));
    dist[Node(1, -1)] = 0;
    while (!Q.empty()) {
        int d; Node n; tie(d, n) = Q.top(); Q.pop();
        if (d != dist[n]) {
            continue;
        }
        if (n.first == N) {
            cout << d << endl;
            return 0;
        }
        for (auto& t : graph[n]) {
            int c; Node m; tie(c, m) = t;
            auto it = dist.lower_bound(m);
            if (it == end(dist) || it->first != m) {
                dist.insert(make_pair(m, d+c));
                Q.emplace(d+c, m);
            } else if (d + c < it->second) {
                it->second = d+c;
                Q.emplace(d+c, m);
            }
        }
    }
    cout << -1 << endl;
    return 0;
}


Measured memory_bytes: 89140
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <random>
#include <chrono>
#include <tuple>
#include <random>

using namespace std;

typedef long long ll;
typedef long double ld;
#define fastInp cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);

const ll SIZE = 1e6 * 2 + 10, INF = 1e9 * 1e9 + 10;



int main()
{
    fastInp;

    ll x;
    cin >> x;

    if (x >= 30) { 
        cout << "Yes";
    } else {
        cout << "No";
    }

    return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (long long i = 0, _n = (n); i < _n; i++)
#define debug(x) cout<<#x<<": "<<x<<endl
/*Author Ritick Goenka || ritick(codechef) ||doped.silicon(codeforces) */
/*IIT Roorkee = <3 */
#define ll long long
#define ld double
#define all(ar) ar.begin(), ar.end()
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define PI 3.1415926535897932385
#define INF 1000000000000000
#define MOD 1000000007
int main () 
{
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        cout<<setprecision(11);
            ll n;
            cin>>n;
            string s;
            cin>>s;
            ll ar[26];
            rep(i,26)
            {
                ar[i]=1;
            }
            rep(i,n)
            {
                ar[s[i]-'a']++;
            }
            ll x=1;
            rep(i,26)
            {
                x=(x*ar[i])%MOD;
            }
            cout<<x-1;
            return 0;
}

Measured memory_bytes: 512
#include<cstdio>
#include<algorithm>
#include<vector>
#define rep(i,a) for( int i = 0; i != (a); ++i )

int N;
char s[101];

int hold[10], place = 0;

int main()
{
	while( scanf( "%d", &N ), N )
	{
		std::fill( hold, hold+10, 0 );
		place = 0;

		scanf( "%s", s );

		rep( i, 100 )
		{
			int p = i % N;

			if( s[i] == 'M' )
				++hold[p];
			else if( s[i] == 'S' )
			{
				place += hold[p]+1;
				hold[p] = 0;
			}
			else if( s[i] == 'L' )
			{
				hold[p] += place+1;
				place = 0;
			}
		}

		std::sort( hold, hold+N );

		rep( i, N )
			printf( "%d ", hold[i] );

		printf( "%d\n", place );
	}

	return 0;
}

Measured memory_bytes: 1048
#!/usr/bin/env python3
import sys
import math
import decimal
import itertools
from itertools import product
from functools import reduce
def input():
    return sys.stdin.readline()[:-1]
def sort_zip(a:list, b:list):
    z = zip(a, b)
    z = sorted(z)
    a, b = zip(*z)
    a = list(a)
    b = list(b)
    return a, b

def warikirenai(n, warukazu):
    return n - n // warukazu
def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)
def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def main():
    A, B, C, D = map(int, input().split())

    ansA = 0
    ansA += warikirenai(A - 1, C)
    ansA += warikirenai(A - 1, D)
    ansA -= warikirenai(A - 1, lcm(C, D))

    ansB = 0
    ansB += warikirenai(B, C)
    ansB += warikirenai(B, D)
    ansB -= warikirenai(B, lcm(C, D))

    print(ansB - ansA)


if __name__ == '__main__':
    main()


Measured memory_bytes: 77476
N = parse(readline())
A = parse.(split(readline()))
function isOdd(n)
  return n % 2 == 0
end

function isOk(n)
  return n % 3 == 0 || n % 5 == 0
end
  
flag = true

for i in A
	if isOdd(i) && !(isOk(i))
    	flag = false
      	break
    end  
end    
  
println(flag ? "APPROVED" : "DENIED")


Measured memory_bytes: 120936
(A, B, K) = map(int, input().split())


def ChgCookie(a, b) :
    if a%2 == 1:
        a = a-1

    (a, b) = (a//2, b+a//2)
    return (a, b)


for i in range(K):
    if i%2 == 0:
        (A, B) = ChgCookie(A, B)
        #print(A, B)
    else:
        (B, A) = ChgCookie(B, A)
        #print(A, B)

print(A, B)


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

int main(){
  int a, b;
  int sum = 0;
  cin >> a >> b;

  for(int i = a; i <= b; i++){
    int w, x, y, z;
    w = i % 10; x = i / 10000;
    y = (i / 10) % 10; z = (i / 1000) % 10;
    if(w == x && y == z) sum++;
  }
  cout << sum << endl;
  return 0;
}


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

int f[101][11];

int main(){
    int n;
    cin >> n;
    for(int i=0; i<n; i++){
        for(int j=0; j<10; j++){
            int info;
            cin >> info;
            f[i][j] = info;
        }
    }

    int p[101][12] = {0};
    for(int i=0; i<n; i++){
        for(int j=0; j<11; j++) cin >> p[i][j];
        }

    long long ans = -9999999999;

    for(int bit=1; bit < (1<<10); bit++){
        long long sub_ans = 0;
        vector<int> v;
        for(int i=0; i<10; i++){
            if(bit & (1<<i)) v.push_back(i);
        }
        for(int i=0; i<n; i++){
            int cnt = 0;
            for(int j=0; j<v.size(); j++){
                cnt += f[i][v[j]];
            }
            sub_ans += p[i][cnt];
        }
        ans = max(ans, sub_ans);
    }
    cout << ans << endl;
    return 0;

}

Measured memory_bytes: 256
n, w_max = gets.split.map(&:to_i)
items = Array.new(n){gets.split.map(&:to_i)}
dp = Array.new(100100, Float::INFINITY)
dp[0] = 0
items.each do |w, v|
  prev = dp.dup
  prev.each_with_index do |pw, pv|
    if pw+w <= w_max && pw+w < prev[pv+v]
      dp[pv+v] = pw+w
    end
  end
end
puts dp.rindex{|v| v != Float::INFINITY}


Measured memory_bytes: 27700
#include<cstdio>
#include<cstring>
#include<algorithm>
#define rep(a,b,c) for (int a=b;a<=c;a++)
#define per(a,b,c) for (int a=b;a>=c;a--)
#define go(u) for (int o=ft[u],v;v=E[o].t;o=E[o].n)
#define fi first
#define se second
using namespace std;
typedef long long LL;
typedef pair<int,int> par;
const int N=4010,P=1000000007;
void upd(LL &x,LL y){x=(x+y)%P;}
int n,m,p;
LL f[N][N],g[N][N],ans;
bool equ(int a,int b){
	if ((a==0)^(b==0)) return 0;
	a=(a-1)%(p-1)+1;
	b=(b-1)%(p-1)+1;
	return a==b;
}
int main(){
//	freopen("t.txt","r",stdin);
	scanf("%d%d%d",&n,&m,&p);
	int len=(n+m-1)/(p-1);
	f[0][0]=1;
	rep(i,1,len) rep(j,0,n){
		rep(k,0,p-1){
			if (j<k) continue;
			upd(f[i][j],f[i-1][j-k]);
		}
		rep(k,1,p-1){
			if (j<k) continue;
			upd(g[i][j],f[i-1][j-k]);
		}
		int x=j,y=i*(p-1)-j+1;
		if (equ(x,n)&&equ(y,m)&&y<=m){
			upd(ans,g[i][j]);
//			printf("ans=%lld ,from g[%d][%d]=%lld\n",ans,i,j,g[i][j]);
		}
	}
	printf("%lld\n",ans);
	return 0;
}


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

namespace ABC042B___文字列大好きいろはちゃんイージー
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int n = int.Parse(input[0]);
            int l = int.Parse(input[1]);

            List<string> inputList = new List<string>();
            for (int index = 0; index < n; index++)
            {
                inputList.Add(Console.ReadLine());
            }

            List<string> sortedInputList = inputList.OrderBy(x => x).ToList();

            string output = "";
            foreach (string sortedInput in sortedInputList)
            {
                output += sortedInput;
            }

            Console.WriteLine(output);

        }
    }
}


Measured memory_bytes: 13536
#include <stdio.h>

int main( int argc , char** argv )
{
	int number_table[ 6 ];
	scanf( "%d %d %d %d %d %d" ,
		&number_table[ 0 ] ,
		&number_table[ 1 ] ,
		&number_table[ 2 ] ,
		&number_table[ 3 ] ,
		&number_table[ 4 ] ,
		&number_table[ 5 ] );

	int left = 4;
	int bottom = 6;
	int back = 5;

	while( 1 )
	{
		int c = getchar();
		if( c == EOF )
		{
			break;
		}

		if( c == 'E' )
		{
			int temp = left;
			left = bottom;
			bottom = 7 - temp;
		}
		if( c == 'W' )
		{
			int temp = bottom;
			bottom = left;
			left = 7 - temp;
		}
		if( c == 'S' )
		{
			int temp = back;
			back = bottom;
			bottom = 7 - temp;
		}
		if( c == 'N' )
		{
			int temp = bottom;
			bottom = back;
			back = 7 - temp;
		}
	}

	printf( "%d\n" , number_table[ 7 - bottom - 1 ] );


	return 0;
}

Measured memory_bytes: 1032
import heapq
n, m = map(int, input().split())
lst = list(map(lambda x:-1*int(x), input().split()))
heapq.heapify(lst)
for i in range(m):
  heapq.heappush(lst, -(-heapq.heappop(lst)//2))
print(-1*sum(lst))

Measured memory_bytes: 72088
def resolve():
    N, M = map(int, input().split())
    a = [[] for _ in range(N)]
    for _ in range(M):
        p, s = input().split()
        a[int(p)-1].append(s)
    correct = 0
    pena = 0
    for q in a:
        if 'AC' in q:
            correct += 1
            for qq in q:
                if qq == 'WA':
                    pena += 1
                else:
                    break
    print(correct, pena)

resolve()

Measured memory_bytes: 20376
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
 
public class Main {
    public static void main(String[] args) throws Exception {
 
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line = br.readLine();
        //文字列に先頭又は最後に空白文字がくっ付いている場合、それらを全て取り除きます。
        line = line.trim();
        //半角スペースを区切り文字として扱う
        String[] readLineArray = line.split("[\\s+]");

        int[] threeNum  = new int[3];
        threeNum[0] = Integer.parseInt(readLineArray[0]);
        threeNum[1] = Integer.parseInt(readLineArray[1]);
        threeNum[2] = Integer.parseInt(readLineArray[2]);

        Arrays.sort(threeNum);

        System.out.println(threeNum[0]+" "+threeNum[1]+" "+threeNum[2]);
    }
}

Measured memory_bytes: 17036
#include<bits/stdc++.h>
#define pii pair<int,int>
#define ff first
#define ss second
#define ll long long
#define pb push_back
using namespace std;

const int lim=3000;

int n;

long double t[lim];

long double dp[lim][6000];

long double wyn;

void ustaw(int x){
	for(int i=lim-x;i<=x+lim;i++){
		dp[x][i]=dp[x-1][i-1]*t[x]+dp[x-1][i+1]*(1.0-t[x]);
	}
}

int x3;

int main(){

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

	cin>>n;
	
	for(int i=1;i<=n;i++) cin>>t[i];
	
	dp[0][lim]=1;
	for(int i=1;i<=n;i++){
		ustaw(i);
	}
	
	for(int i=lim+1;i<=n+lim;i++) wyn+=dp[n][i];	
	
	cout<<setprecision(10)<<fixed<<wyn;
	return 0;
}

Measured memory_bytes: 279680
#include<bits/stdc++.h>
#define ll long long
#define int long long
#define M 1000000007
#define sz(c) c.size()
#define fr first
#define sc second
#define pb push_back
#define sz(c) c.size()
#define ppb  pop_back
#define mp make_pair
#define all(a)      (a).begin(),(a).end()
#define rep(i,a,n)   for( int i=a ; i<n ; i++)
#define what_is(x)  cout << #x << " is " << x << endl;
#define U 1000000007
#define N 100005
using namespace std;
signed main()
{
  ios_base::sync_with_stdio(false);
 

  int a,b;
  cin>>a>>b;
  int z=(a+b)/2;
  if(abs(a-z)==abs(b-z)) cout<<z;
  else cout<<"IMPOSSIBLE";

}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <numeric>
#include <cmath>
#include <bitset>

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

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 ll MOD = 1000000007;
const int INF = 1<<30;
//const ll INF = (ll)1e18 + 1;

int main(){
  int N, M; cin >> N >> M;
  map<ll, ll> mp;
  rep(i, N){
    ll a; cin >> a;
    mp[a]++;
  }
  rep(i, M){
    ll b, c; cin >> b >> c;
    mp[c] += b;
  }

  ll ans = 0;
  ll num = 0;
  for (auto itr = mp.rbegin(); itr != mp.rend(); ++itr){
    for (int i = 0; i < itr->second; ++i) {
      if (num == N) break;
      ans+= itr->first;
      num++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 12800
s = io.read()
t = {}
t[0], t[1] = {}, {}
t[0][0], t[0][1], t[1][0], t[1][1] = 0, 0, 0, 0
for i = 1, #s do
    a = tonumber(string.sub(s, i, i))
    t[i % 2][a] = t[i % 2][a] + 1
end
print(math.min(t[0][1] + t[1][0], t[0][0] + t[1][1]))

Measured memory_bytes: 604
var fs = require('fs'),
    length = fs.fstatSync(process.stdin.fd).size,
    buffer = new Buffer(length),
    bytesRead = fs.readSync(process.stdin.fd, buffer, 0, length, 0),
    input = buffer.toString('utf8', 0, bytesRead).split('\n');
main();

function main(){
  var localInput = input;
  var f = [
    [0,0,0,0,0,0,0,0,0,0,0,0,0,0]
    ,[0,0,0,0,0,0,0,0,0,0,0,0,0,0]
    ,[0,0,0,0,0,0,0,0,0,0,0,0,0,0]
    ,[0,0,0,0,0,0,0,0,0,0,0,0,0,0]
    ,[0,0,0,0,0,0,0,0,0,0,0,0,0,0]
    ,[0,0,0,0,0,0,0,0,0,0,0,0,0,0]
    ,[0,0,0,0,0,0,0,0,0,0,0,0,0,0]
    ,[0,0,0,0,0,0,0,0,0,0,0,0,0,0]
    ,[0,0,0,0,0,0,0,0,0,0,0,0,0,0]
    ,[0,0,0,0,0,0,0,0,0,0,0,0,0,0]
    ,[0,0,0,0,0,0,0,0,0,0,0,0,0,0]
    ,[0,0,0,0,0,0,0,0,0,0,0,0,0,0]
    ,[0,0,0,0,0,0,0,0,0,0,0,0,0,0]
    ,[0,0,0,0,0,0,0,0,0,0,0,0,0,0]
    ];
  
  var len = localInput.length - 1;
  for(;len--;){
    var l = localInput[len];
    var ix = parseInt(l[0]) + 2;
    var iy = parseInt(l[2]) + 2;
    switch(l[4]){
    case '3': // no-break case;
      f[iy+2][ix]++;
      f[iy-2][ix]++;
      f[iy][ix-2]++;
      f[iy][ix+2]++;
    case '2':
      f[iy+1][ix-1]++;
      f[iy+1][ix+1]++;
      f[iy-1][ix-1]++;
      f[iy-1][ix+1]++;
    case '1':
      f[iy+1][ix]++;
      f[iy][ix-1]++;
      f[iy][ix]++;
      f[iy][ix+1]++;
      f[iy-1][ix]++;
      break;
    }
  }
  
  var nd=0;//not dropped
  var md=0;//most dropped
  var y = 10;
  for(;y--;){
    var x = 10;
    for(;x--;){
      nd += !(f[y+2][x+2]);
      md = mx(f[y+2][x+2], md);
    }
  }
  
  console.log(nd);
  console.log(md);
}
   
function mx(a, b){
 return a - ((a-b) & ((a-b) >> 31));
}

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

int main()
{
    int n,a,b;cin>>n>>a>>b;
    string s; cin>>s;
    int i = 0;
    int j = 0;
    for(int k = 0; k < n; k++){
        if(s[k] == 'a'){
            if(i < a + b) {
                cout << "Yes" << endl;
                i++;
            } else cout << "No" << endl;
        }else if(s[k] == 'b'){
            if(i < a + b && j < b){
                cout << "Yes" << endl;
                i++;
                j++;
            } else cout << "No" << endl;
        }else cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 896
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) throws IOException {
		Main mainObj = new Main();
		mainObj.solve();
	}

	public void solve() throws IOException {
		FastScanner fs = new FastScanner();
		
		int n = fs.nextInt();
		long[] tallArr = new long[n];
		
		for(int i = 0; i < n; i++) {
			tallArr[i] = fs.nextLong();
		}
		
		HashMap<Long, Long> map = new HashMap<>();
		
		long ans = 0;
		for(int i = 0; i < n; i++) {
			long val = tallArr[i];
			long jNum = i + 1 - val;
			if(map.containsKey(jNum)) {
				ans += map.get(jNum);
			}
			
			long generalVal = i+1+val;
			if(map.containsKey(generalVal)) {
				long num = map.get(generalVal);
				map.put(generalVal, num+1);
			}else {
				map.put(generalVal, 1L);
			}
		}
		
		System.out.println(ans);
	}

	

	public class FastScanner {

		BufferedReader reader;
		private StringTokenizer st;

		public FastScanner() {
			st = null;
			reader = new BufferedReader(new InputStreamReader(System.in));
		}

		public String next() throws IOException {
			if (st == null || !st.hasMoreElements()) {
				st = new StringTokenizer(reader.readLine());
			}
			return st.nextToken();
		}

		public String nextLine() throws IOException {
			st = null;
			String readLine = null;
			readLine = reader.readLine();
			return readLine;
		}

		public int nextInt() throws NumberFormatException, IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}

		public int[] nextIntArr(int n) throws NumberFormatException, IOException {
			int[] retArr = new int[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextInt();
			}
			return retArr;
		}

		public long[] nextLongArr(int n) throws NumberFormatException, IOException {
			long[] retArr = new long[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextLong();
			}
			return retArr;
		}

		public void close() throws IOException {
			reader.close();
		}
	}

}


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

int main()
{
    long long a, b, c;
    cin >> a >> b >> c;
    long long a2 = a * a, b2 = b * b, c2 = c * c;
    long long ab = a * b, bc = b * c, ca = c * a;
    if (c - a - b < 0)
    {
        cout << "No" << endl;
    }
    else if ((long long)a2 + b2 + c2 - 2 * (ab + bc + ca) > 0)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

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

using namespace std;

int tode(char c){
  switch(c){
    case 'm' : return 1000;
    case 'c' : return 100;
    case 'x' : return 10;
    case 'i' : return 1;
  }
}
int toint(string str){
  int sum = 0;
  for(int i = 0 ; i < str.size() ; i ++){
    if('2'<=str[i] && str[i]<='9'){
      sum += (str[i]-'0') * tode(str[i+1]);
      i++;
    }else{
      sum += tode(str[i]);
    }
  }
  return sum;
}


void tore(int num){
  if(num>=1000){
    if(num/1000!=1)cout<<num/1000;
    cout<<"m";
    num = num % 1000;
  }
  if(num>=100){
    if(num/100%10!=1)cout<<num/100%10;
    cout<<"c";
    num = num % 100;
  }
  if(num>=10){
    if(num/10%10!=1)cout<<num/10%10;
    cout<<"x";
    num = num % 10;
  }
  if(num>=1){
    if(num%10!=1)cout<<num%10;
    cout<<"i";
  }
  cout<<endl;
}

int main(void){
  int n;
  cin>>n;
  for(int i = 0 ; i < n ; i ++){
    string str1,str2;
    cin>>str1>>str2;
    //cout<<toint(str1)+toint(str2)<<endl;
    tore(toint(str1)+toint(str2));
  }
}

Measured memory_bytes: 1212
#include <bits/stdc++.h>
#define whlie while
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repr(i,N) for(int i = (N) - 1; i >= 0; i--)
#define rep1(i,N) for(int i = 1; i <= (N) ; i++)
#define repr1(i,N) for(int i = (N) ; i > 0 ; i--)
#define each(x,v) for(auto& x : v)
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
#define vrep(v,it) for(auto it = v.begin(); it != v.end(); it++)
#define vrepr(v,it) for(auto it = v.rbegin(); it != v.rend(); it++)
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) ll __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
using namespace std; void solve();
using ll = long long; using vl = vector<ll>;
using vi = vector<int>; using vvi = vector< vector<int> >;
constexpr int inf = 1001001001;
constexpr ll infLL = (1LL << 61) - 1;
struct IoSetupNya {IoSetupNya() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(7);} } iosetupnya;
template<typename T, typename U> inline bool amin(T &x, U y) { return (y < x) ? (x = y, true) : false; }
template<typename T, typename U> inline bool amax(T &x, U y) { return (x < y) ? (x = y, true) : false; }
template<typename T, typename U> ostream& operator <<(ostream& os, const pair<T, U> &p) { os << p.first << " " << p.second; return os; }
template<typename T, typename U> istream& operator >>(istream& is, pair<T, U> &p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator <<(ostream& os, const vector<T> &v) { int s = (int)v.size(); rep(i,s) os << (i ? " " : "") << v[i]; return os; }
template<typename T> istream& operator >>(istream& is, vector<T> &v) { for(auto &x : v) is >> x; return is; }
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
template<typename T>void die(T x){out(x); exit(0);}
#ifdef NyaanDebug
  #include "NyaanDebug.h"
  #define trc(...) do { cerr << #__VA_ARGS__ << " = "; dbg_out(__VA_ARGS__);} while(0)
  #define trca(v,N) do { cerr << #v << " = "; array_out(v , N);} while(0)
#else
  #define trc(...)
  #define trca(...)
  int main(){solve();}
#endif

using P = pair<int,int>;
using vp = vector<P>;
constexpr int MOD = /**/ 1000000007; //*/ 998244353;
/////////////////


void solve(){
  /*
  int N = 30;
  vvi dp(N*3 , vi(N*3 , -1));
  dp[1][0] = dp[0][1] = 0;
  auto func = [&](auto f,int x,int y)->int{
    if(dp[x][y] != -1) return dp[x][y];
    for(int i = 1; i <= x/2 ; i++){
      if( f(f , x-i*2 ,y+i ) == 0){
        dp[x][y] = 1; return 1;
      }
    }
    for(int j = 1; j<=y/2; j++){
      if( f( f , x+j ,y-j*2 ) == 0){
        dp[x][y]=1; return 1;
      }
    }
    dp[x][y] = 0; return 0;
  };
  rep(i , N+1) rep(j , N+1) func(func , i , j);
  rep(i,N+1){
    rep(j,N+1) cout << " " << dp[i][j];
    cout << endl;
  }
  */
  inl(X,Y);
  out(abs(X-Y)<=1 ? "Brown" : "Alice");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>                                           
 
#define int long long
//#pragma GCC optimize("Ofast")
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4")
 
 
#define file(s) freopen(s".in","r",stdin); freopen(s".out","w",stdout);
#define forev(i, b, a) for(int i = (b); i >= (a); --i)
#define forn(i, a, b) for(int i = (a); i <= (b); ++i)
#define all(x) x.begin(), x.end()
#define sz(s) (int)s.size()
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define s second
#define f first
 
 
using namespace std;
 
 
typedef pair < long long, long long > pll;    
typedef pair < int, int > pii;
typedef unsigned long long ull;         
typedef vector < pii > vpii;
typedef vector < int > vi;
typedef long double ldb;  
typedef long long ll;  
typedef double db;                             
 
 
const int dx[] = {1, -1, 0, 0}, dy[] = {0, 0, 1, -1}, block = 555;
const pii base = mp(1171, 3307), Mod = mp(1e9 + 7, 1e9 + 9);
const int inf = 1e9, maxn = 4e5 + 148, mod = 1e9 + 7, N = 2e5 + 11;
const db eps = 1e-12, pi = 3.14159265359;
const ll INF = 1e18;


int a, v, b, w, t;

main () {
	cin >> a >> v >> b >> w >> t;
	bool ok = 0;
	if (a < b && a + v*t >= b + w*t) {
		ok = 1;
	}	
	if (a > b && a - v*t <= b - w*t)
		ok = 1;
	cout << (ok ? "YES" : "NO");
}


Measured memory_bytes: 3632
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ABC101_B solver = new ABC101_B();
        solver.solve(1, in, out);
        out.close();
    }

    static class ABC101_B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            String n = in.nextLine();
            long l = Long.parseLong(n);

            long sum = 0;

            for (char c : n.toCharArray()) {
                sum += Character.digit(c, 10);
            }

            if (l % sum == 0) {
                out.print("Yes");
            } else {
                out.print("No");
            }
        }

    }
}



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

int main() {
    int N;
    cin >> N;
    int ans = 0, cont = 0, last = 0;
    for (int i = 0; i < N; i++) {
        int a;
        cin >> a;
        if (a == last) {
            cont++;
        } else {
            last = a;
            ans += cont / 2;
            cont = 1;
        }
    }
    ans += cont / 2;
    cout << ans << endl;
    return 0;
}

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

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

  vector<long long> A(N);
  for (int i = 0; i < N; i++) cin >> A.at(i);

  vector<long long> B;
  B.push_back(0);

  long long ans = 0;
  long long tot = 0;
  for (int i = 0; i < M; i++) {
    long long b;
    cin >> b;
    tot += b;
    if (tot <= K) ans = i + 1;
    B.push_back(tot);
  }

  for (int i = 0; i < N; i++) {
    K -= A.at(i);
    if (K < 0) break;
    long long cnt = (upper_bound(B.begin(), B.end(), K) - B.begin()) + i;
    ans = max(ans, cnt);
  }

  cout << ans << endl;
}

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

int main ()
{
	int h, w, i;
		cin >> h >> w;
	
	vector<string> he(h);
	vector<string> wi(w);
	
	for (i = 0; i < h; i++)
	{
		cin >> he.at(i);
	}
	
	for (i = 0; i <= w + 1 ; i++)
	{
		cout << "#";
	}
	cout << endl;
	
	for (i = 0; i < h ; i++)
	{
		cout << "#";
		cout << he.at(i);
		cout << "#" << endl;
	}
	
	for (i = 0; i <= w + 1 ; i++)
	{
		cout << "#";
	}
	cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<n;++i)
#define rep2(i,a,b) for (ll i=a;i<b;++i)
const ll MOD=1000000007;
string alp="abcdefghijklmnopqrstuvwxyz";

int main(){
    int N;
    cin >> N;
    vector<Pii> p(N);
    rep(i,N){
        int a;
        cin >> a;
        p[i]=Pii(a,i+1);
    }
    sort(p.begin(),p.end());
    rep(i,N){
        cout << p[i].second;
        if (i!=N-1){
            cout << ' ';
        }
        else {
            cout << endl;
        }
    }
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(V) V.begin(),V.end()
const ll MOD = 1000000007;

ll X[24][24];

int main() {
	for (int i = 0;i < 24;i++) {
		for (int j = 0;j < 24;j++) {
			X[i][j] = 0;
		}
	}
	ll N, ss, x, y;
	int v2, v5;
	bool u;
	cin >> N;
	string S;
	for (int i = 0;i < N;i++) {
		cin >> S;
		ss = S.size();
		u = 0;
		v2 = v5 = 0;
		x = 0;
		y = 1;
		for (int j = 0;j < ss;j++) {
			if (S[j] == '.') {
				u = 1;
				continue;
			}
			x *= 10;
			x += (S[j] - '0');
			if (u)v2--, v5--;
		}
		while (x % 2 == 0) {
			x /= 2;
			v2++;
		}
		while (x % 5 == 0) {
			x /= 5;
			v5++;
		}
		X[min(v2 + 11, 23)][min(v5 + 11, 23)]++;
	}
	ll ans = 0;
	for (int i = 0;i < 24;i++) {
		for (int j = 0;j < 24;j++) {
			for (int k = 0;k < 24;k++) {
				for (int l = 0;l < 24;l++) {
					if (i + k >= 22 && j + l >= 22) {
						ans += X[i][j] * X[k][l];
					}
				}
			}
			if (i >= 11 && j >= 11) {
				ans -= X[i][j];
			}
		}
	}
	cout << ans / 2 << endl;
}

Measured memory_bytes: 3624
s = input()
opl = ['+', '-']

flag = [0,0,0]
for i in range(0, 0b111+1):
    for j in range(3):
        #print(i)
        flag[j] = (i>>(j) & 1)
        ans = s[0] + opl[flag[0]] + s[1] + opl[flag[1]] + s[2] + opl[flag[2]] + s[3]
        if(eval(ans) == 7):
            print(ans + '=7')
            break
    else:
        continue
    break
            
        


Measured memory_bytes: 3060
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) throws IOException {
		new Main().solve();
	}

	private void solve() throws IOException {
		try {
			//			solveA();
			solveB();
			//			 solveC();
			//			 solveD();
			//			 solveE();
			//			 solveF();
		} finally {
			if (in != null) {
				in.close();
			}
			if (out != null) {
				out.flush();
				out.close();
			}
		}

	}

	private void solveA() {
		int n = nextInt();

		out.println(180 * (n - 2));
	}

	private void solveB() {
		char[] n = next().toCharArray();
		int res = 8;
		for (int i = 0; i < n.length; i++) {
			if (n[i] == 'o') {
				res--;
			}
		}
		out.println((15 - n.length) - res >= 0 ? "YES" : "NO");
	}

	private void solveC() {
		int n = nextInt();

		out.println("");
	}

	private void solveD() {
		int n = nextInt();

		out.println("");
	}

	private void solveE() {
		int n = nextInt();

		out.println("");
	}

	private void solveF() {
		int n = nextInt();

		out.println("");
	}

	private final PrintWriter out = new PrintWriter(System.out);
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	private void skipUnprintable() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
	}

	public boolean hasNext() {
		skipUnprintable();
		return hasNextByte();
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}
}

Measured memory_bytes: 20948
n, k = map(int, input().split())
ans = 0
i = 0
if k == 0:
    ans = n ** 2
else:
    while i <= n:
        if i >= k:
            ans += n // (i + 1) * (i - k + 1)
        if k <= n % (i + 1) < n:
            ans += n % (i + 1) - (k - 1)
        i += 1
print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define all(v) v.begin(), v.end()
#define sz(v) v.size()
#define INF 100000000000000 //10^14
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
int main()
{
    ll X;
    cin >> X;
    ll a = (X-400) / 200;
    cout << 8-a << endl;
}

Measured memory_bytes: 3616