akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int func2(vector<vector<int> > &a, string x, string y)
{
    int m = x.size(), n = y.size();
    x = ' ' + x, y = ' ' + y;
    for (int i = 0; i <= m; ++i)
        a[i][0] = 0;
    for (int j = 1; j <= n; ++j)
        a[0][j] = 0;
    for (int i = 1; i <= m; ++i)
    {
        for (int j = 1; j <= n; ++j)
        {
            if (x[i] == y[j])
                a[i][j] = a[i - 1][j - 1] + 1;
            else
                a[i][j] = max(a[i - 1][j], a[i][j - 1]);
        }
    }
    return a[m][n];
}

int main()
{
    int q;
    cin >> q;
    int ans[q + 1] = {};
    for (int i = 0; i < q; ++i)
    {
        string x, y;
        cin >> x >> y;
        vector<vector<int> > a(1001, vector<int>(1001));
        ans[i] = func2(a, x, y);
    }
    for (int i = 0; i < q; ++i)
    {
        printf("%d\n", ans[i]);
    }
}


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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 60)
#define PI 3.14159265358979

typedef long long i64;
typedef pair<i64,i64> P;

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

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



string s;
void solve(){
	cin >> s;
	
	if(s[2]==s[3] && s[4]==s[5]) cout << "Yes" << endl;
	else cout << "No" << endl;
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long 
using namespace std;
int main() {
	
	string s,t;
	cin>>s>>t;
	int n=s.size(),m=t.size();
	
	vector<vector<int>> dp(n+1,vector<int>(m+1));
	
	for(int i=0;i<=n;i++)
	{
	    for(int j=0;j<=m;j++)
	    {
	        if(i==0||j==0)
	        {
	            dp[i][j]=0;
	        }
	        else if(s[i-1]==t[j-1])
	        {
	            dp[i][j]=dp[i-1][j-1]+1;
	        }
	        else
	        {
	            dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
	        }
	    }
	}
	string res="";
	int i= n,j=m;
	while(i>0&&j>0)
	{
	   if(s[i-1]==t[j-1])
	   {
	       res=s[i-1]+res;
	       i--;j--;
	   }
	    else if(dp[i-1][j]>dp[i][j-1]){
            i--;
            
        }
        else{
            j--;
        }
	}
//	reverse(res.begin(),res.end());
	cout<<res<<endl;
   return 0;
}


Measured memory_bytes: 35584
N, M = map(int, input().split(' '))
H_ls = list(map(int, input().split(' ')))
edge = [ [] for i in range(N)]
cnt = 0
for i in range(M):
    a, b = map(int, input().split(' '))
    a -= 1
    b -= 1
    edge[a].append(b)
    edge[b].append(a)
for i in range(N):
    is_peak = True
    for neighbor in edge[i]:
        if H_ls[i] <= H_ls[neighbor]:
            is_peak = False
            break
    if is_peak:
        cnt += 1
print(cnt)

Measured memory_bytes: 29400
#include <bits/stdc++.h>
#define PI 3.14159265358979323846
using namespace std;

double a, b, h, m;
 
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);

	cin >> a >> b >> h >> m;
	double k = PI * (60*h - 11*m) / 360;
	cout << fixed << setprecision(12) << sqrt(a*a + b*b - 2*a*b*cos(k));
}

Measured memory_bytes: 4228
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define endl "\n"
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);

    ll n;
    cin >> n;
    ll b[n-1];
    for (ll i=0;i<=n-2;i++)
    {
        cin >> b[i];
    }

    ll ans=b[0];
    for (ll i=0;i<=n-3;i++)
    {
        ans=ans+min(b[i],b[i+1]);
    }
    ans=ans+b[n-2];
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 3624
#include <iostream>

struct shuumai{
    unsigned int a, b, c, d;
    shuumai(void):a(), b(), c(), d(){}
    unsigned int eval(unsigned int* A) const {
        return (A[b] == A[a] + c) * d;
    }
};

std::istream& operator >> (std::istream& is, shuumai& karashi){
    is >> karashi.a >> karashi.b >> karashi.c >> karashi.d;
    --karashi.a; --karashi.b; return is;
}

unsigned int n, m, q;
shuumai S[50];

unsigned int dfs(unsigned int idx, unsigned int val, unsigned int* A){
    if(idx == n){
        unsigned int res = 0;
        for(unsigned int i = 0; i < q; ++i) res += S[i].eval(A);
        return res;
    }
    unsigned int mx = 0;
    for(unsigned int i = val; i <= m; ++i){
        A[idx] = i; const unsigned int&& res = dfs(idx + 1, i, A); if(mx < res) mx = res;
    }
    return mx;
}


int main(void){
    std::cin.tie(nullptr); std::cin.sync_with_stdio(false);
    std::cin >> n >> m >> q;
    for(unsigned int i = 0; i < q; ++i) std::cin >> S[i];
    unsigned int* A = new unsigned int[n];
    std::cout << dfs(0, 1, A) << std::endl;
    delete A;
    return 0;
}

Measured memory_bytes: 3596
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

n = onem()


k = 0
kk = 0

for i in range(1,n+1):
    if i % 2 != 0:
        k += 1
    kk += 1
print(k/kk)







Measured memory_bytes: 3444
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
#define endl '\n'
#define deb(x) cout << #x << " = " << x << endl;
const int inf = 1e9;
vector<vector<int>>h, dp;

int recc(int n, int x) {
  if(dp[n][x] != -1)
    return dp[n][x];
  dp[n][0] = h[n][0], dp[n][1] = h[n][1], dp[n][2] = h[n][2];
  dp[n][0] += max(recc(n-1, 1), recc(n-1, 2));
  dp[n][1] += max(recc(n-1, 0), recc(n-1, 2));
  dp[n][2] += max(recc(n-1, 0), recc(n-1, 1));
  return dp[n][x];
}

void solve(){
  int n;
  cin >> n;
  h.resize(n, vector<int>(3, 0));
  dp.resize(n, vector<int>(3, -1));
  for(int i = 0; i < n; i++) 
    cin >> h[i][0] >> h[i][1] >> h[i][2];
  dp[0][0] = h[0][0], dp[0][1] = h[0][1], dp[0][2] = h[0][2];
  ll ans = recc(n-1, 0);
  cout << max({dp[n-1][0], dp[n-1][1], dp[n-1][2]});
}

int main(){
		ios::sync_with_stdio(false);
		cin.tie(nullptr);
		int t = 1, tt = 0;
		//cin >> t;
		while(t--){
			//tt++;
			//cout << "Case #" << t << ": ";
			solve();
		}
	return 0;
}


Measured memory_bytes: 18760
#include<stdio.h>

int main()
{
	char a[3];
	int s=700;
	scanf("%c%c%c",&a[0],&a[1],&a[2]);
	int i;
	for(i=0;i<3;i++)
	{
		if(a[i]=='o')
			s+=100;
	}
	printf("%d\n",s);
	return 0;
}

Measured memory_bytes: 128
import sys
from collections import defaultdict, deque, Counter
import math

# import copy
from bisect import bisect_left, bisect_right
import heapq

# sys.setrecursionlimit(1000000)

# input aliases
input = sys.stdin.readline

getS = lambda: input().strip()
getN = lambda: int(input())
getList = lambda: list(map(int, input().split()))
getZList = lambda: [int(x) - 1 for x in input().split()]

INF = 10 ** 20
MOD = 10**9 + 7
divide = lambda x: pow(x, MOD-2, MOD)


def nck(n, k, kaijyo):
    return (npk(n, k, kaijyo) * divide(kaijyo[k])) % MOD


def npk(n, k, kaijyo):
    if k == 0 or k == n:
        return n % MOD
    return (kaijyo[n] * divide(kaijyo[n-k])) % MOD


def kaijyo(n):
    ret = [1]
    for i in range(1, n + 1):
        ret.append((ret[-1] * i)% MOD)
    return ret

def solve():
    a =getN()
    b=getN()
    c=getN()
    x=getN()
    ans = 0
    for i in range(a+1):
        for j in range(b+1):
            for k in range(c+1):
                if 500 * i + 100 * j + 50 * k == x:
                    ans += 1


    print(ans)


def main():
    n = getN()
    for _ in range(n):
        solve()


if __name__ == "__main__":
    # main()
    solve()

Measured memory_bytes: 68572
#include <bits/stdc++.h>
#include <assert.h>
using namespace std;
typedef __int128 ll;
typedef long double ld;
#define PB push_back
#define MP make_pair
#define MOD 1000000007LL
#define endl "\n"
#define fst first
#define snd second
const ll UNDEF = -1;
const ll INF=1e18;
template<typename T> inline bool chkmax(T &aa, T bb) { return aa < bb ? aa = bb, true : false; }
template<typename T> inline bool chkmin(T &aa, T bb) { return aa > bb ? aa = bb, true : false; }
typedef pair<ll,ll> pll;
typedef vector<ll> vll;

struct rational_t { __int128 nu, de;
  rational_t(const ll &n = 0, const ll &d = 1) {
    nu = n; de = d;
    if (de < 0) { nu = -nu; de = -de; } }
  rational_t operator+(const rational_t& b) const
  { return rational_t( nu*b.de+de*b.nu, de*b.de ); }
  rational_t operator-(const rational_t& b) const
  { return rational_t( nu*b.de-de*b.nu, de*b.de ); }
  rational_t operator-() { return rational_t(-nu, de); }
  rational_t operator*(const rational_t& b) const
  { return rational_t( nu*b.nu, de*b.de ); }
  rational_t operator/(const rational_t& b) const
  { return rational_t( nu*b.de, de*b.nu ); }
  bool operator== (const rational_t & b) const {return nu * b.de == b.nu * de;}
  bool operator== (const ll &k) const { return nu == k * de; }
  bool operator< (const rational_t& b) const { return nu * b.de < b.nu * de; }
  bool operator<= (const rational_t& b) const { return nu * b.de <= b.nu * de; }
  bool operator> (const rational_t& b) const { return nu * b.de > b.nu * de; }
  bool operator>= (const rational_t& b) const { return nu * b.de >= b.nu * de; }
};

typedef rational_t rat;
const ll lim=1e16+2;
void solve(){
	int K; cin>>K;
	vector<pair<rat,ll> > g;
	/*for (ll d=1;;d++) {
		ll lft=d;
		vector<ll> v;
		while(lft>0) {
			ll take=min(lft,(ll)9LL);
			v.PB(take);
			lft-=take;
		}
		sort(v.begin(),v.end());
		ll nu=0;
		for (auto &w:v) {
			nu*=10;
			nu+=w;
		}
		//printf("nu:%lld\n",nu);
		if (nu>lim) {
			break;
		}
		g.PB(MP(rat(nu,d),nu));
	}*/
	for (ll nu=1;nu<=100;nu++) {
			ll x=nu;
			ll den=0;
			while(x>0) {
				den+=x%10; x/=10;
			}
			g.PB(MP(rat(nu,den),nu));
	}
	ll pten=1;
	for (ll d=0;d<=16;d++) {
		for (ll p=1;p<1000;p++) {
			ll nu=pten*p-1;
			if (nu>lim) continue;
			ll x=nu;
			ll den=0;
			while(x>0) {
				den+=x%10; x/=10;
			}
			g.PB(MP(rat(nu,den),nu));
		}
		pten*=10;
	}
	sort(g.begin(),g.end());
	ll prev=0;
	for (auto &w:g) {
		//printf("wnu:%lld\n",w.nu);
		ll nu=w.snd;
		if (nu<=prev) continue;
		printf("%lld\n",(long long)nu);
		prev=nu;
		--K; if (K==0) break;
	}
}

int main(){	
	ios_base::sync_with_stdio(false); cin.tie(0);
	solve();
	return 0;
}



Measured memory_bytes: 1148
function main(input) {
  const formatted_input = input.split('\n');
 
  const N = parseInt(formatted_input[0], 10);
  const S = formatted_input[1];

  var count = 0;
  var result = N;


  var left_count = 0;
  var right_count=0;
  for(var i = 0 ; i < N ; i++){
      var current = S[i];
      if(current=='.'){right_count++;}
  }

  result = Math.min(result, right_count+left_count);

  for(var i = 0 ; i < N ; i++){
      var current = S[i];
      if(current=='#'){
        left_count++;
      }
      if(current=='.'){right_count--;}
      result = Math.min(result, right_count+left_count);

      //console.log('---');
      //console.log(`${result},${left_count},${right_count},${i}`);
  }

  console.log(result);
}
 
main(require('fs').readFileSync('/dev/stdin', 'utf8'));



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

int main(void){
    int a,b,result;
    char c;

    while(true){
        cin >> a >> c >> b;
        if(c == '?') break;
        else if(c == '+') result = a + b;
        else if(c == '-') result = a - b;
        else if(c == '*') result = a * b;
        else if(c == '/') result = a / b;
        else if(c == '%') result = a % b;
        else break;
        cout << result << endl;
    }
    return 0;
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};


int main(){
    int a, b;
    cin >> a >> b;
    int ans = max(a, b)*2-1;
    if (a==b) ans = a*2;    
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using std::cerr;using std::cin;using std::cout;using std::abs;using std::min;using std::max;using std::swap;using std::map;using std::unordered_map;using std::unordered_set;using std::bitset;using std::pair;using std::set;using std::string;using std::vector;using ll=long long;using uint=unsigned int;using pii=pair<int,int>;using pll=pair<ll,ll>;using ull = unsigned long long;using ld=long double;using vci=vector<int>;using vcl=vector<ll>;template<typename T>void _dbg(const char*_s,T _h){cerr<<_s<<" = "<<_h<<"\n";}template<typename T,typename...Ts>void _dbg(const char*_s,T _h,Ts..._t){int _b=0;while(((_b+=*_s=='(')-=*_s==')')!=0||*_s!=',')cerr<<*_s++;cerr<<" = "<<_h<<",";_dbg(_s+1,_t...);}
#define f first
#define s second
#define pb emplace_back
struct init{init(){cin.tie(0);std::iostream::sync_with_stdio(0);cout<<std::fixed<<std::setprecision(10);cerr<<std::fixed<<std::setprecision(5);}~init(){
#ifdef LOCAL
#define dbg(...) _dbg(#__VA_ARGS__,__VA_ARGS__)
cerr<<"Time elapsed: "<<(double)clock()/CLOCKS_PER_SEC<<"s.\n";
#else
#define dbg(...) 
#endif
}}init;
ll p[11],c[11];
int32_t main() {
    
    ll n,g;
    cin>>n>>g;
    for(int i=1;i<=n;++i)
        cin>>p[i]>>c[i];
    vector<int> v(n);
    iota(v.begin(), v.end(), 1);
    int ans=123456789;
    do{
        ll cur=g;
        int pot=0;
        for (int i : v){
            int w=p[i];
            while(w&&cur>0){
                pot++;
                w--;
                cur-=i*100;
            }
            if(!w)
                cur -= c[i];
            if(cur<0){
                break;
            }
        }
        ans=min(ans,pot);
    }while(next_permutation(v.begin(), v.end()));
    cout<<ans<<'\n';

    

    return 0;
}


Measured memory_bytes: 256
S = input()
n = len(S)

MOD = 10 ** 9 + 7

# dp[i][j] i桁までで、あまりjの個数
dp = [[0] * 13 for _ in range(n + 1)]
dp[0][0] = 1

for i, s in enumerate(S):
  if s == "?":
    c = -1
  else:
    c = int(s)
  for j in range(10):
    if c != -1 and c != j:
      continue
    for k in range(13):
      dp[i + 1][(k * 10 + j) % 13] += dp[i][k]
  for k in range(13):
    dp[i + 1][k] %= MOD
print(dp[n][5])

Measured memory_bytes: 62172
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
int vector_finder(std::vector<ll> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

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

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

int main(){
    int n, m;
    cin >> n >> m;
    int cnt = 0;
    for(int i = 0; i < m; i++){
        int x;
        cin >> x;
        cnt += x;
    }
    if(cnt > n){
        cout << -1 << endl;
    }
    else{
        cout << n-cnt << endl;
    }
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,Max;
    cin>>a>>b;
    Max=a+b;
    if(Max<a-b)
       Max=a-b;
    if(Max<a*b)
       Max=a*b;
    cout<<Max;
    return 0;
}

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

typedef long long ll;
typedef pair<ll,ll> P;

const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;

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

ll gcd(ll x, ll y)
{
  if (x % y == 0)
  {
    return y;
  }
  return gcd(y, x % y);
}

int main()
{
  string s;
  cin >> s;
  s[5] = ' ';
  s[13] = ' ';
  cout << s << endl;
  return 0;
}

Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
even=odd=0

for i in a:
    if i % 2 == 0:
        even += 1
    else:
        odd += 1

odd_ans = odd % 2
# even_ans = even//2 + even % 2 + odd//2

if odd_ans==0:
    print('YES')
else:
    print('NO')


Measured memory_bytes: 14108
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using st=string;
using ch=char;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<ch> vc;
typedef vector<vc> vvc;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
#define ROF(i,a,b) for(ll i=a;i>=b;i--)
#define per(i,a) ROF(i,a,0)
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld PI=acos(-1);
const ll INF=1e18;
st abc="abcdefghijklmnopqrstuvwxyz";
st ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
struct edge{ll to,cost;};

vl G[50];
vl B;
vP p;

void dfs(ll x,ll j){
  ll k=G[x].size();
  B[x]=1;
  rep(i,k){
    if((x==p[j].first&&G[x][i]==p[j].second)||(G[x][i]==p[j].first&&x==p[j].second)){
      continue;
    }
    if(B[G[x][i]]==0){
      dfs(G[x][i],j);
    }
  }
}

int main() {
  ll n,m;
  cin >> n >> m;
  ll ans=0;
  p.resize(m);
  rep(i,m){
    cin >> p[i].first >> p[i].second;
    p[i].first--;
    p[i].second--;
    G[p[i].first].push_back(p[i].second);
    G[p[i].second].push_back(p[i].first);
  }
  rep(i,m){
    B.assign(n,0);
    dfs(0,i);
    rep(i,n){
      if(B[i]==0){
        ans++;
        break;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define ll long long
#define pii pair<int,int>


void test_case()
{
    int k,ans=0;
    cin>>k;
    for(int a=1;a<=k;a++)
        for(int b=1;b<=k;b++)
            for(int c=1;c<=k;c++)
               ans+=__gcd(a,__gcd(b,c));
    cout<<ans;

}

int main()
{
    fastio
//    int t;
//    cin>>t;
//    while(t--)
    test_case();
}


Measured memory_bytes: 3624
s = input()
n = len(s)
a = []
 
p = 1
for i in range(n-1):
    if s[i] != s[i+1]:
        a.append(p)
        p = 1
    else:
        p += 1
a.append(p)

ans = 0
if s[0] == ">":
    ans += a[0]*(a[0]+1)//2
    a = a[1:]
if s[-1] == "<":
    ans += a[-1]*(a[-1]+1)//2
    a = a[:-1]

for i in range(len(a)//2):
    p, q = a[2*i], a[2*i+1]
    x, y = max(p,q), min(p,q) - 1
    ans += x*(x+1)//2 + y*(y+1)//2

print(ans)


Measured memory_bytes: 63304
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;

/*Atcoder用
 * 		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] tmp = br.readLine().split(" ");
		int a = Integer.parseInt(tmp[0]);
		int b = Integer.parseInt(tmp[1]);
		int c = Integer.parseInt(tmp[2]);


		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String get = br.readLine();
		char[] s = get.toCharArray();
		for(char c:s)System.out.println(c);

		List<Integer> ls = new ArrayList<Integer>();
		String[] tmp = br.readLine().split(" ");
		for (int n = 0; n < N; n++) {
			ls.add(Integer.parseInt(tmp[n]));
		}
 */

public class Main {

	public static void main(String[] args) throws IOException {
 		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String num = br.readLine();
 		String[] tmp = num.split("");

 		int N = Integer.parseInt(num);
		ArrayList<String> nls = new ArrayList<String>(Arrays.asList(tmp));

		int sum = 0;
		for(int i = 0;i<nls.size();i++){
			sum += Integer.parseInt(nls.get(i));
		}

		if(N%sum == 0)System.out.println("Yes");
		else System.out.println("No");

	}

}


Measured memory_bytes: 23124
#include<bits/stdc++.h>
#define for_int(i,a,b) for(int i=(a);i<=(b);++i)
#define rep_int(i,a,b) for(int i=(a);i>=(b);--i)
#define for_ll(i,a,b) for(ll i=(a);i<=(b);++i)
#define rep_ll(i,a,b) for(ll i=(a);i>=(b);--i)
#define ull unsigned long long
#define ll long long
#define db double
#define HPMAX 1005
#define KMP_MAX 1005
#define prime_MAX 1e6+5
#define quick_pow_mod 1e9+7
#define PII pair<int,int>
const int factor_N = 1e7 + 5;
const int tree_arr_N = 1e6 + 5;
using namespace std;
//快读
int read() {
	char c = getchar();
	int x = 0, f = 1;
	for (; !isdigit(c); c = getchar())
		if (c == '-') f = -1;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - 48;
	return x * f;
}
ll n, k;
int main() {
	n = read(); k = read();
	vector<int>a(n + 1, 0);
	for_int(i, 1, n) a[i] = read();
	int p1 = 1, p2 = k+1;
	for (int i = k + 1; i <= n; ++i, ++p1) {
		if (a[i] > a[p1]) cout << "Yes" << endl;
		else cout << "No" << endl;
	}
	return 0;
}

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

///******************************** C o n t a i n e r ********************************///

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;

///*********************************** C o n s t ***********************************///

const int       N=1e6+3;
const double    PI = acos(-1);
const ll        MOD=1000000007;                 ///1e9+7
ll dx[] = {+1, 0, -1, 0, +1, +1, -1, -1};
ll dy[] = {0, +1, 0, -1, +1, -1, +1, -1};

///********************************** M a r c o ***********************************///

#define pb push_back
#define F first
#define S second
#define test int tc; cin>>tc; while(tc--)
#define forn(i,n) for(i=0;i<n;i++)
#define rforn(i,n) for(i=n-1;i>=0;i--)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define sz(x) x.size()
#define el <<'\n'
#define sp <<' '
#define print(a) {for(auto x:a)cout<<x<<" ";cout<<endl;}
#define mem(a,b) memset(a, b, sizeof(a))
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*(b/gcd(a,b)))
#define sqr(a) (a)*(a)

#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);

///*********************************** F u n c t i o n ***********************************///

ll powmod(ll a,ll b){ll p=MOD;a%=p;if(!a) return 0;ll pr=1;while(b>0){if(b&1){pr*=a;pr%=p;--b;}a*=a;a%=p;b/=2;}return pr;}
bool isPrime(ll n){ if(n<=1)return false;if(n<=3)return true;if(n%2==0 or n%3==0)return false;for(ll i=5;i*i<=n;i+=6){if(n%i==0 or n%(i+2)==0)return false;}return true;}
void seive(bool a[]){ll mx=sqrt(N),ii,jj;for(ii=3;ii<=mx;ii+=2)if(!a[ii])for(jj=ii*ii;jj<=N;jj+=2*ii)a[jj]=true;}
void numofdiv(ll a[]){ll mx=sqrt(N),ii,jj;for(ii=1;ii<=mx;ii++){for(jj=ii*ii;jj<=N;jj+=ii){if(jj==ii*ii) a[jj]++; else a[jj]+=2;}}}
void sumofdiv(ll a[]){ll mx=sqrt(N),ii,jj;for(ii=1;ii<=mx;ii++){for(jj=ii*ii;jj<=N;jj+=ii){if(jj==ii*ii) a[jj]+=ii; else a[jj]+=ii+jj/ii;}}}

///**************************************************** C o d e ****************************************************///
///-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=///



void _case()
{
    ll n,i;
    cin>>n;
    ll a[n],b[n];
    forn(i,n) cin>>a[i],b[i]=a[i];
    if(n==1){cout<<0 el; return;}
    sort(b,b+n);
    for(i=0;i<n;i++){
        if(a[i]==b[n-1]) cout<<b[n-2] el;
        else cout<<b[n-1] el;
    }
}

main()
{
//      fastio();
        _case();

}


///Thank you.


///Brainless_Loco Terminates Here!


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

#define vint vector<int> 
#define vbool vector<bool>
#define vvint vector<vector<int>>

#define rep(a, b, c) for(int (a)=(b); (a)<(c); (a)++)
#define all(a) (a).begin(), (a).end()

int main(){
    int n, a, b; cin>>n>>a>>b;
    cout<< min( a*n, b );
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main(){
    
    int m;
    cin >>m;
    int a[m];
    for (int i=0;i<m;i++){
        cin >> a[i];}
    vector<int> vec(m,0);
    
    if(m%2==0){
        for(int i=0;m-1>=2*i;i++){
            vec[i]=m-1-(2*i);}
        for (int i=0;m-2>=2*i;i++){
            vec[m-1-i]=m-2-(2*i);}
    }
    
    else{
        for(int i=0;m-1>=2*i;i++){
            vec[i]=m-1-(2*i);}
        for (int i=0;m-2>=2*i;i++){
            vec[m-1-i]=m-2-(2*i);}
    }
    
    for (int i=0;i<m;i++){
        cout << a[vec[i]]<< ' ';}
    
}



Measured memory_bytes: 3712
def PrimeFactorization(m):
    pf = {}
    for i in range(2, int(m ** 0.5) + 1):
        while m % i == 0:
            pf[i] = pf.get(i, 0) + 1
            m //= i
    if m > 1:
        pf[m] = 1
    return pf
n, p = map(int, input().split())
f = PrimeFactorization(p)
ans = 1
for k, v in f.items():
    if v >= n:
        ans *= k ** (v // n)
print(ans)

Measured memory_bytes: 3064
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include<stdbool.h>
typedef long long ll;
typedef long double ld;
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define rrep(i,l,r)for(ll i=(l);i>=(r);i--)
#define rrepp(i,l,r,k)for(ll i=(l);i>=(r);i-=(k))
#define INF (1LL<<60)
#define MOD1 1000000007
#define MAX_N (1 << 17)
#define YES printf("Yes\n")
#define NO printf("No\n")


void swap(ll *a, ll *b){ll c;c=*b;*b=*a;*a=c;}
ll max2(ll a,ll b){return a>=b?a:b;}
ll min2(ll a,ll b){return a>=b?b:a;}
ll minn(ll n, ll a[n]){ll b=INF;rep(i,0,n) b=min2(b,a[i]);return b;}
ll maxn(ll n, ll a[n]){ll b=-INF;rep(i,0,n) b=max2(b,a[i]);return b;}
ll ABS(ll a){return a>=0?a:(-a);}
ll POW(ll a, ll b){ll c=1;rep(i,0,b) c*=a;return c;}
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;}
ll mod(ll n){return n%=MOD1;}
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}

typedef struct{
    ll aa;
    ll bb;
}frequent;

ll divi[1000005]={};
void makedivi(ll n){
    ll c=0;
    while(n%2==0){
        n/=2;
        c++;
    }
    divi[2]=c;
    // printf("%lld ",n);
    repp(i,3,1000001,2){
        // printf("%lld ",n);
        if(n<i) break;
        c=0;
        while(n%i==0){
            n/=i;
            c++;
        }
        // printf("%lld ",c);
        divi[i]=c;
    }
}

int main(void){
    // char ;
    ll n,p,ans=1;
    scanf("%lld%lld",&n,&p);
    if(n==1){
        printf("%lld\n",p);
        return 0;
    }
    makedivi(p);
    rrepp(i,1000001,3,2){
        // printf("%lld ",divi[i]);
        // if(divi[i]>=n){
            ans*=POW(i,divi[i]/n);
        // }
    }
    if(divi[2]>=n){
        ans*=POW(2,divi[2]/n);
    }
    printf("%lld\n",ans);
    return 0;
}

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

int n, dp[32];

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

	while (cin >> n, n) {
		memset(dp, 0, sizeof(dp));

		dp[1] = dp[2] = dp[3] = 1;

		for (int i = 1; i < n + 1; ++i) {
			if (i + 3 < n + 1) {
				dp[i + 3] += dp[i];
			}
			if (i + 2 < n + 1) {
				dp[i + 2] += dp[i];
			}
			if (i + 1 < n + 1) {
				dp[i + 1] += dp[i];
			}
		}
		cout << dp[n] / 10 / 365 + 1<< endl;
	}

	return 0;
}

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

#define foreach(i, v) for(__typeof((v).begin()) i = (v).begin(); i != (v).end(); ++ i)
#define BETWEEN(a, x, b) (a<=x&&x<b)

using namespace std;
typedef long long ll;

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

  int n,k;cin>>n;string s;cin>>s;cin>>k;k--;
  for(int i=0;i<n;i++){
    if(s[i]==s[k])cout<<s[k];
    else cout<<'*';
  }
  cout<<endl;

  return 0;
}


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

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T>
vector<vector<T> > make_v(size_t a,size_t b){
  return vector<vector<T> >(a,make_v<T>(b));
}
template<typename T>
vector<vector<vector<T> > > make_v(size_t a,size_t b,size_t c){
  return vector<vector<vector<T> > > (a,make_v<T>(b,c));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}


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

//INSERT ABOVE HERE
signed main(){
  Int n,t,s;
  cin>>n>>t>>s;
  vector<Int> a(n),b(n);
  for(Int i=0;i<n;i++) cin>>a[i]>>b[i];
  auto dp=make_v<Int>(t+3333);
  const Int INF = 1e12;
  fill_v(dp,-INF);
  dp[0]=0;
  for(Int i=0;i<n;i++){
    for(Int j=t;j>=0;j--){
      if(dp[j]==-INF) continue;
      if(j+b[i]>t) continue;
      if(j<s&&j+b[i]>s) chmax(dp[s+b[i]],dp[j]+a[i]);
      else chmax(dp[j+b[i]],dp[j]+a[i]);
    }
  }
  cout<<*max_element(dp.begin(),dp.begin()+t+1)<<endl;
  return 0;
}



Measured memory_bytes: 3136
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include <cmath>
#include <limits>
#include<set>
#include <iomanip>
#include <queue>
#include <string>
#pragma GCC optimize("Ofast")
using namespace std;
const long long INF=20000000000;
//setprecision(2) <<

const int MOD = 1000000007;

long long max(long long a,long long b){
	if(a<b)return b;
	else return a;	
}
long long min(long long a,long long b){
	if(a>b)return b;
	else return a;	
}
long long gcd(long long a,long long b){
	if(a<b)swap(a,b);
	if(a%b==0)return b;
	else return gcd(a%b,b);
}

long long lcm(long long a,long long b){
	return a*b/gcd(a,b);
}

long long com(long long n,long long k){
	
}
long long getDigit(long long n){
	if(n==1)return 1;
	else return log10(n)+1;
}
class G{
	long long node;
	long long w;
	
};
int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	string S[3];
	cin>>S[0]>>S[1]>>S[2];
	for(int i=0;i<3;i++){
		reverse(S[i].begin(),S[i].end());
	}
	int turn =0;
	//1 B 2 C
	while(1){
		//cout<<turn <<endl;
		if(S[turn].length()==0){
			break;
		}
		int d=S[turn].length()-1;
		char data=S[turn][d];
		
		S[turn].erase(S[turn].end()-1);
		if(data=='a')turn =0;
		if(data=='b')turn =1;
		if(data=='c')turn =2;
	}
	char d='A'+turn;
	cout<<d<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define ll long long
#define dd double
#define MOD 1000000007
#define nl cout<<endl
#define rt ll Q[100005]={0}
#define mp make_pair
#define test() ull t;cin>>t;while(t--)
#define pb push_back
#define ff first    
#define ss second
#define all(v) v.begin(),v.end()
#define s(ar,n) sort(ar,ar+n)
#define rs(ar,n) sort(ar, ar+n, greater<ll>()) 
#define oa(a,n) for(ll i=0;i<n;i++)cout<<a[i]<<" ";nl
#define cn(a,n) for(ll i=0;i<n;i++)cin>>a[i];
#define ov(a,n) for(ll i=n-1;i>=0;i--)cout<<a[i]<<" ";nl
#define ovp(a,n) for(ll i=0;i<n;i++)cout<<a[i].ff<<" "<<a[i].ss<<endl;
#define maxa(ar,N) *max_element(ar,ar+N)
#define mina(ar,N) *min_element(ar,ar+N)
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
typedef pair<int,int> pii;
ll powe(ll n,ll m){if(m==0)return 1;ll t=powe(n,m/2);if(m%2==0)return (t*t);return (((t*t))*n);}
ll mpowe(ll n,ll m){if(m==0)return 1;ll t=mpowe(n,m/2);t%=MOD;if(m%2==0)return (t*t)%MOD;return (((t*t)%MOD)*n)%MOD;}
ll logtwo(ll n){if(n==1)return 0;return logtwo(n/2)+1;}
int main()
{
    fastio();
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif*/
    int n,m;
    cin>>n>>m;
    int a[n+1]={0};
    int b[n+1]={0};
    int ac=0,wa=0;
    for(int i=0;i<m;i++)
    {
        int x;
        string s;
        cin>>x>>s;
        if(s=="WA")
        {
            a[x]++;
        }
        else
        {
            if(b[x]==0)
            {
                ac++;
                b[x]=1;
                wa+=a[x];
                a[x]=0;
            }
        }
    }
    cout<<ac<<" "<<wa<<endl;

}

Measured memory_bytes: 1024
import java.io.*;
import java.util.*;
import java.util.function.*;
import java.util.regex.*;

final class Solver {
	static final Solver INSTANCE = new Solver();

	void solve(Supplier<String> sc) {
		String S = sc.get();
		Pattern cont = Pattern.compile("(.).?\\1");
		Matcher matcher = cont.matcher(S);
		if (!matcher.find()) {
			System.out.println("-1 -1");
			return;
		}
		MatchResult result = matcher.toMatchResult();
		System.out.printf("%d %d%n", result.start() + 1, result.end());
	}
}

class Main {
	public static void main(String... args) {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		Solver.INSTANCE.solve(new Supplier<String>() {
			StringTokenizer line;

			public String get() {
				try {
					return (line = line != null && line.hasMoreTokens() ? line : new StringTokenizer(reader.readLine())).nextToken();
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
			}
		});
	}
}


Measured memory_bytes: 24512
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
vector<int>Tashi(vector<int>f1, vector<int>f2) {
	vector<int>f3; for (int i = 0; i < f1.size(); i++) { for (int j = 0; j < f2.size(); j++)f3.push_back(f1[i] + f2[j]); }
	return f3;
}
vector<int>Hiki(vector<int>f1, vector<int>f2) {
	vector<int>f3; for (int i = 0; i < f1.size(); i++) { for (int j = 0; j < f2.size(); j++)f3.push_back(f1[i] - f2[j]); }
	return f3;
}
vector<int>Kake(vector<int>f1, vector<int>f2) {
	vector<int>f3; for (int i = 0; i < f1.size(); i++) { for (int j = 0; j < f2.size(); j++)f3.push_back(f1[i] * f2[j]); }
	return f3;
}
vector<int>Wari(vector<int>f1, vector<int>f2) {
	vector<int>f3;
	for (int i = 0; i < f1.size(); i++) {
		for (int j = 0; j < f2.size(); j++) { if (f2[j] != 0)f3.push_back(f1[i] / f2[j]); }
	}
	return f3;
}
vector<int> solve(string S) {
	while (true) {
		if (S[0] != '(' || S[S.size() - 1] != ')')break;
		int depth = 0; string S2 = S.substr(1, S.size() - 2); bool OK = true;
		for (int i = 0; i < S2.size(); i++) {
			if (S2[i] == '(')depth++;
			if (S2[i] == ')')depth--;
			if (depth == -1)OK = false;
		}
		if (OK == false)break;
		S = S.substr(1, S.size() - 2);
		if (S.size() <= 1)break;
	}
	bool OK = false;
	for (int i = 0; i < S.size(); i++) {
		if (S[i] < '0' || S[i] > '9')OK = true;
	}
	if (S.size() == 0) { return{}; }
	if (OK == false) { return{ stoi(S) }; }

	int depth = 0; vector<int>K;
	for (int i = 0; i < S.size(); i++) {
		if (S[i] == '(')depth++; if (S[i] == ')')depth--;
		if (depth == 0) {
			if (S[i] == '+') {
				vector<int>J = Tashi(solve(S.substr(0, i)), solve(S.substr(i + 1, S.size() - i - 1)));
				for (int j = 0; j < J.size(); j++)K.push_back(J[j]);
			}
			if (S[i] == '-') {
				vector<int>J = Hiki(solve(S.substr(0, i)), solve(S.substr(i + 1, S.size() - i - 1)));
				for (int j = 0; j < J.size(); j++)K.push_back(J[j]);
			}
			if (S[i] == '*') {
				vector<int>J = Kake(solve(S.substr(0, i)), solve(S.substr(i + 1, S.size() - i - 1)));
				for (int j = 0; j < J.size(); j++)K.push_back(J[j]);
			}
			if (S[i] == '/') {
				vector<int>J = Wari(solve(S.substr(0, i)), solve(S.substr(i + 1, S.size() - i - 1)));
				for (int j = 0; j < J.size(); j++)K.push_back(J[j]);
			}
		}
	}
	return K;
}
int main() {
	while (true) {
		string U; cin >> U; if (U == "#")break;
		vector<int>ans = solve(U);
		sort(ans.begin(), ans.end()); ans.erase(unique(ans.begin(), ans.end()), ans.end());
		cout << ans.size() << endl;
	}
	return 0;
}

Measured memory_bytes: 3112
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <iostream>
#include <vector>
#include <queue>
#include <unordered_map>
#include <random>
#include <stack>
#include <set>
#include <unordered_set>

#define bug(x) cout<<"zdongdebug1: "<<x<<endl;
#define bug2(x, y) cout<<"zdongdebug2: "<<x<<" "<<y<<endl;
#define bug3(x, y, z) cout<<"zdongdebug3: "<<x<<" "<<y<<" "<<z<<endl;
using namespace std;
typedef long long ll;
const int maxn = 2000005;
const int mod = 1000000007;

ll p5[maxn],p6[maxn];
ll p[maxn];

void gcd(ll a,ll b, ll& d,ll& x,ll& y){  //      已经测试 FZU 1402
  if(!b) {d=a;x=1;y=0;}
  else   {	gcd(b,a%b,d,y,x);	y-=a/b*x;}
}

ll inv(ll a,ll n)  { //无逆元返回-1
  ll d,x,y;	gcd(a,n,d,x,y);
  return d==1?(x%n+n)%(n/d):-1;
}

int main() {
#ifdef suiyuan2009
  freopen("/Users/suiyuan2009/CLionProjects/icpc/input.txt", "r", stdin);
  //freopen("/Users/suiyuan2009/CLionProjects/icpc/output.txt", "w", stdout);
#endif
  p5[0] = p6[0] = p[0] = 1;
  for(int i=1;i<maxn;i++){
    p5[i] = p5[i-1] * 25 %mod;
    p6[i] = p6[i-1] * 26 %mod;
    p[i] = p[i-1] * i %mod;
  }
  ll ret = 0;
  string s;
  int m;
  cin>>m>>s;
  int n = s.size();
  for(int i=n;i<=n + m;i++){
    ll tt = 1;
    if(i>n){
      tt = p5[i-n] * p[i-1]%mod*inv(p[i-n]*p[n-1]%mod, mod)%mod;
    }
    ret = (ret + tt * p6[n+m-i]%mod)%mod;
  }
  cout<<ret<<endl;
  return 0;
}

Measured memory_bytes: 52208
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ll          long long
#define pb          push_back
#define INF         9223372036854775807
#define    endl        '\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)    for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define lower(u)    transform(u.begin(), u.end(), u.begin(), ::tolower);//convert string u to lowercase;
#define upper(u)    transform(u.begin(), u.end(), u.begin(), ::toupper);
using namespace std;

using namespace __gnu_pbds; 
  
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define N  100005

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int TESTS=1;
//    cin>>TESTS;
    while(TESTS--)
    {
        ll n,a[3];
        cin>>n;
        rep(i,0,3)cin>>a[i];
        vector<string>s(n);
        rep(i,0,n)cin>>s[i];
        bool f=1;
        vi ans;
        rep(i,0,n)
        {
            if(a[s[i][0]-'A']<a[s[i][1]-'A'])
            {
                a[s[i][0]-'A']++;
                a[s[i][1]-'A']--;
                ans.pb(s[i][0]-'A');
            }
            else if(a[s[i][0]-'A']>a[s[i][1]-'A'])
            {
                a[s[i][0]-'A']--;
                a[s[i][1]-'A']++;
                ans.pb(s[i][1]-'A');
            }
            else
            {
                a[s[i][0]-'A']++;
                a[s[i][1]-'A']--;
                if(i!=n-1)
                {
                    if(a[s[i+1][0]-'A']==0&&a[s[i+1][1]-'A']==0)
                    {
                        a[s[i][0]-'A']-=2;
                        a[s[i][1]-'A']+=2;
                        ans.pb(s[i][1]-'A');
                    }
                    else
                    {
                        ans.pb(s[i][0]-'A');
                    }
                    
                }
                else
                {
                    ans.pb(s[i][0]-'A');
                }
            }
            rep(i,0,3)
            if(a[i]<0)
            {
                f=0;
                break;
            }
        }
        if(!f)
        {
            cout<<"No"<<endl;
        }
        else
        {
            cout<<"Yes"<<endl;
            for(auto u:ans)
                cout<<char(u+'A')<<endl;
        }

    }
    return 0;
}

Measured memory_bytes: 7412
def dfs(s, t):
    if int(s) > t:
        return 0
    ret = 1 if all(s.count(c) > 0 for c in '753') else 0
    for c in '753':
        ret += dfs(s+c, t)
    return ret

n = int(input())
print(dfs('0', n))

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

#define ll long long
#define ld long double
#define mp(p,q,r) make_pair(p,make_pair(q,r))
#define pb push_back
#define F first
#define S second
#define mod	%1000000007
#define FOR(I,N) for(I=0;I<N;++I)
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
ld pi = 3.141592653;
ll dp[402][402];
ll solve(ll s[],ll l,ll r)
{
	ll x=1e15;
	if(dp[l][r]!=-1)
		return dp[l][r];
	for(ll i=l;i<r;++i)
		x = min(x, solve(s,l,i) + solve(s,i+1,r));
	dp[l][r]=x+ s[r] - s[l-1];
	return dp[l][r];
}

int main()
{
	//IOS;
	ll n,i;
	cin>>n;
	ll a[n+1],s[n+1]={0};
	for(i=1;i<=n;++i)
		cin>>a[i];
	memset(dp,-1,sizeof(ll)*(402)*(402));
	for(i=1;i<=n;++i)
	{
		dp[i][i] = a[i];
		s[i]=a[i]+s[i-1];
	}

	cout<<(solve(s,1,n)-s[n]);

}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  int n, t;
  cin >> n >> t;
  vector<int> v(n);
  rep(i, 0, n) cin >> v[i];

  int maxv = v[v.size()-1], diffv = 0, ans = 0;
  repr(i, 0, n - 1) {
    if (diffv < maxv - v[i]) {
      diffv = maxv - v[i];
      ans = 1;
    } else if (diffv == maxv - v[i]) {
      ans++;
    }
    chmax(maxv, v[i]);
  }
  cout << ans << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i, n) for (lli i = 0; i < (n); i++)
#define rrep(i, n) for (lli i = (n)-1; i >= 0; i--)
using namespace std;
using lli = long long int;
void YESNO(bool), YesNo(bool);
template <class T1, class T2>
bool chmin(T1 &l, const T2 &r);
template <class T1, class T2>
bool chmax(T1 &l, const T2 &r);
template <class T1, class T2>
void vadd(vector<T1> &v, T2 x);

#define int long long int

void solve(long long N, long long K)
{
  map<lli, bool> used;
  N = N % K;

  lli ans = N;
  used[N] = true;
  while (true)
  {
    N = abs(N - K);
    if (used[N])
      break;
    used[N] = true;
    chmin(ans, N);
  }
  cout << ans << endl;
}

signed main()
{
  long long N;
  scanf("%lld", &N);
  long long K;
  scanf("%lld", &K);
  solve(N, K);
  return 0;
}

// -- lib
void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }
void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }

template <class T1, class T2>
bool chmin(T1 &l, const T2 &r)
{
  return (l > r) ? (l = r, true) : false;
}

template <class T1, class T2>
bool chmax(T1 &l, const T2 &r)
{
  return (l < r) ? (l = r, true) : false;
}

template <class T1, class T2>
void vadd(vector<T1> &v, T2 x)
{
  for (auto &s : v)
    s += T2(x);
}


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

int main(){
    int N ;
    cin >> N ;
    for(int i = N ;; i++ ){
        if(i%10 == (i%100)/10 && (i%100)/10 == i/100 ){
            cout << i << endl;
            return 0 ;
        }
    }
}

Measured memory_bytes: 3516
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define repeat(i,a,b) for(int i=(a),i##__end=(b);i<i##__end;i++)
#define repeat_back(i,a,b) for(int i=(b)-1,i##__end=(a);i>=i##__end;i--)
#define mst(a,x) memset((a),(x),sizeof(a))
#define pii pair<int,int>
#define N 100010
#define mod 1000000007
#define int ll
deque<int> q;
int sum=0,n;
signed main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin>>n;
	repeat(i,0,n){
		int x;
		cin>>x;
		q.push_back(x);
		sum+=x;
	}
	while(q.size()>=3){
		if(q[0]+q[1]<q.back()+q[q.size()-2]){
			q[1]+=q[0];
			q.pop_front();
		}
		else{
			q[q.size()-2]+=q.back();
			q.pop_back();
		}
	}
	cout<<abs(q[0]-q[1])<<endl;
	return 0;
}

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

int main(){
  string s;
  cin >> s;
  int i = s.size();
  if(s[i-1]=='s'){
    s+="es";
  }
  else{
    s+='s';
  }
  cout << s << endl;
  return 0;
}


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

string s;
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin>>s;
	int cnt=15-s.size();
	for(int i=0;i<s.size();i++)
		if(s[i]=='o')
			cnt++;
	if(cnt>=8)
		cout<<"YES"<<endl;
	else
		cout<<"NO"<<endl;

}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define repk(i,k,n) for (ll i = k; i < (ll)(n); ++i)
#define MAt 500000001000000000
#define MOD 1000000007
typedef long long  ll;

using namespace std;

// 最大公約数のll版
ll gcd(ll a, ll b) {
	if (a < b) swap(a, b);
	return b == 0 ? a : gcd(b, a%b);
}

// 最小公倍数のll版
ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}

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

	int N;
	cin >> N;

	ll ans = 1;

	rep(i,N){
		ll t;
		cin >> t;

		ans = lcm(max(ans,t),min(ans,t));
	}

	cout << ans << endl;

	return 0;
}

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

int main() {
	string s; cin >> s;
  	int c = 0;
  	rep(i, s.size()) if (s[i]=='x') c++;
  	cout << (c < 8 ? "YES" : "NO") << endl;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var str string
	fmt.Scan(&str)
	mp := make(map[string]int)
	for _, i := range str {
		s := string(i)
		mp[s] = 0
	}
	if len(str) == len(mp) {
		fmt.Println("yes")
	} else {
		fmt.Println("no")
	}
}

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

int main()
{
    long long int w,a,b,c;
    scanf("%lld %lld %lld",&w,&a,&b);
    if(a>b && b+w<a)
        c=a-b-w;
    if(a>b && b+w>a)
        c=0;
    if(a<b && a+w<b)
        c=b-w-a;
    if(a<b && a+w>b)
        c=0;
    if(a==b)
        c=0;
    printf("%lld\n",c);
}


Measured memory_bytes: 128
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=int(a);i<int(b);i++)
#define INF 1200000000
int L[210010],R[210010];
long long cnt=0;

void merge(int A[],int left,int mid,int right){
    int n1=mid-left;
    int n2=right-mid;
    for(int i=0;i<n1;i++)L[i]=A[left+i];
    for(int i=0;i<n2;i++)R[i]=A[mid+i];
    L[n1]=INF;R[n2]=INF;
    int i=0,j=0;
    for(int k=left;k<right;k++){
        if(L[i]<=R[j]){
            A[k]=L[i];
            i++;
        }
        else{
            A[k]=R[j];
            j++;
            
            cnt+=n1-(k-left);
            n1++;
        }
    }
}
    

void mergesort(int A[],int left,int right){
    if(left+1<right){
        int mid=(left+right)/2;
        mergesort(A,left,mid);
        mergesort(A,mid,right);
        merge(A,left,mid,right);
    }
}

int main(){
    int n,A[200010];
    cin>>n;
    rep(i,0,n)cin>>A[i];
    mergesort(A,0,n);
    cout<<cnt<<endl;
}





Measured memory_bytes: 4648