akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<string>
#include<queue>
#include<stack>
#include<map>
#include<vector>
#include<list>
#include<set>
#include<iomanip>
#include<cstring>
#include<cctype>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cassert>
#include<sstream>
#include<algorithm>
using namespace std;
#define MAXN 10005
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define PI acos(-1.0)
typedef long long ll;


int main()
{
	int a,b;
	cin>>a>>b;
	int c=(a+b)/2;
	if((a+b)&1)
	{
		
		c++;
	 } 
	 cout<<c<<endl;
	return 0;
}















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

int main() {
    ll n, m;
    cin >> n >> m;
    ll s = 0;
    rep(i, m) {
        ll tmp;
        cin >> tmp;
        s += tmp;
    }
    ll ans = (n - s >= 0) ? n - s : -1;
    cout << ans << endl;
    return 0;
}

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

int r, n;
int _h[40], h[20];

double calc()
{
	double res = 1e8;
	for (int i = 0; i < 20; i++){
		double height = i < r ? sqrt(r * r - i * i) - r : -1e8;
		res = min(res, h[i] - height);
	}
	return max(0.0, res);
}

int main()
{
	while (scanf("%d %d", &r, &n), r){
		memset(_h, 0, sizeof(_h));
		memset(h, 0, sizeof(h));
		
		for (int i = 0; i < n; i++){
			int a, b, c;
			scanf("%d %d %d", &a, &b, &c);
			for (int j = a + 20; j < b + 20; j++){
				_h[j] = max(_h[j], c);
			}
		}
		for (int i = 0; i < 20; i++){
			h[i] = min(_h[i + 20], _h[19 - i]);
		}
		
		printf("%.20f\n", calc());
	}
}

Measured memory_bytes: 1208
def c_cat_snuke_and_a_voyage(N, M, I):
    node1 = [False] * N  # 島1と島iに辺があるならTrue, なければFalse
    node2 = [False] * N  # 島iと島Nに辺があるならTrue, なければFalse
    for a, b in I:
        if a == 1:  # 出発地が島1なら
            node1[b] = True
        elif b == N:  # 目的地が島Nなら
            node2[a] = True
    return 'POSSIBLE' if any([p and q for p, q in zip(node1, node2)]) else 'IMPOSSIBLE'

N, M = [int(i) for i in input().split()]
I = [[int(i) for i in input().split()] for j in range(M)]
print(c_cat_snuke_and_a_voyage(N, M, I))

Measured memory_bytes: 44132
#include <bits/stdc++.h>
using namespace std;
#define modulo 998244353
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 100000000000000000


int main(){
	
	int N;
	cin>>N;
	
	vector<pair<int,int>> P(N);
	for(int i=0;i<N;i++){
		cin>>P[i].first;
	}
	for(int i=0;i<N;i++){
		cin>>P[i].second;
	}
	
	sort(P.begin(),P.end());
	
	vector<pair<int,int>> B(N);
	
	for(int i=0;i<N;i++){
		B[i].first = P[i].second;
		B[i].second = i;
	}
	
	sort(B.begin(),B.end());
	
	bool f = false;
	for(int i=0;i<N;i++){
		if(P[i].first>B[i].first){
			cout<<"No"<<endl;
			return 0;
		}
		if(i!=0){
			if(P[i].first<=B[i-1].first){
				f=true;
			}
		}
	}
	if(f){
		cout<<"Yes"<<endl;
		return 0;
	}
	
	int now = 0;
	for(int i=0;i<N;i++){
		now = B[now].second;
		if(now==0&&i!=N-1){
			cout<<"Yes"<<endl;
			return 0;
		}
		else if(now==0){
			cout<<"No"<<endl;
			return 0;
		}
	}
	
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <list>
#include <atcoder/convolution>
using namespace std;
using namespace atcoder;

long long powmod(long long a, long long b, long long m)
{
    long long r = 1;
    for (; b>0; b>>=1, a=a*a%m)
        if (b&1)
            r = r*a%m;
    return r;
}

int main()
{
    int N;
    cin>>N;
    vector<int> h(2*N);
    for (int &a: h)
    {
        cin>>a;
        a--;
    }

    vector<int> C(100000);
    for (int a: h)
        C[a]++;

    long long M = 998244353;
    vector<long long> F(2*N+1);
    F[0] = 1;
    for (int i=1; i<=2*N; i++)
        F[i] = F[i-1]*i%M;

    vector<long long> FF(2*N+1);
    FF[0] = FF[1] = 1;
    for (int i=2; i<=2*N; i++)
        FF[i] = FF[i-2]*i%M;

    list<vector<long long>> T;
    for (int c: C)
        if (c>0)
        {
            vector<long long> A(c/2+1);
            for (int i=0; i*2<=c; i++)
                A[i] = F[c]*powmod(F[i*2], M-2, M)%M*powmod(F[c-i*2], M-2, M)%M * (i==0 ? 1 : FF[2*i-1]) % M;
            T.push_back(A);
        }

    while (T.size()>1)
    {
        vector<long long> A = T.front();
        T.pop_front();
        vector<long long> B = T.front();
        T.pop_front();
        vector<long long> C = convolution(A, B);
        T.push_back(C);
    }

    vector<long long> A = T.front();
    for (int i=0; i<(int)A.size(); i++)
        A[i] = A[i]*(N*2-2*i-1 >= 0 ? FF[N*2-2*i-1] : 1)%M;

    long long ans = 0;
    for (int i=0; i<(int)A.size(); i++)
        ans = (ans + A[i]*(1-2*(i&1)) + M)%M;
    cout<<ans<<endl;
}


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

int main(){
    int flag=1;
    int cnt=0,nu[2],in[2];
    int ans=0,sum=0;
    int n,m;
    cin >> n;
    int data[n];

    for (int i = 0; i < n; i++){
        cin >>data[i];
        
        if(data[i]-1 != i){
            
            in[cnt]=i;
            nu[cnt]=data[i]-1;
            cnt++;
            
            if(cnt >= 2){
                flag=0;
                break;
            }
        }
    }
    
    if(cnt==0){
        flag=1;
    }else if(cnt==2){
        if(in[0] == nu[1] && in[1] == nu[0]){
            flag=1;
        }else{
            flag=0;
        }
    }else{
        flag=0;
    }



    //cout <<fixed<<setprecision(16)<< << endl;
    //cout << (n-1)*(m-1) << endl;

    if(flag==1)cout << "YES" <<endl;
    else cout << "NO" <<endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<vector>
#include<algorithm>
#include<map>
#include<iostream>
using namespace std;
bool end;
map<int, int> one, two;
int getline(){
    char res[1050];
    int p = 0;
    while(true){
	char c = getchar();
	if(c == EOF)end = true;
	if(c == '\n' || c == EOF){
	    if(p == 0)return -1;
	    sscanf(res, "%d,%*d", &p);
	    return p;
	}
	res[p++] = c;	
    }
}
int main(){
    while(!end){
	int p = getline();
	if(p == -1)swap(one, two);
	else{
	    two[p]++;
	}
    }    
    map<int, int>::iterator it = one.begin();
    while(it != one.end()){
	if(two[it->first]){
	    cout << it->first << " "<< (it->second) + two[it->first]<<endl;
	}
	it++;
    }
    return 0;
}

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

const int INF = 1000000;

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

  int sum = 0;
  int min_taste = INF;
  for (int i = 0; i < N; ++i) {
    sum += L + i;
    min_taste = min(min_taste, max(L + i, min(L + N - 1, 0)));
  }

  cout << sum - min_taste << endl;
  return 0;
}


Measured memory_bytes: 256
n, m, x = list(map(int, input().split()))
listA = [list(map(int, input().split())) for i in range(n)]
ans = -1
# n冊 mアルゴリズム x理解度

for i in range(2**n):  # 購入組み合わせ数
    price = 0
    point = [0]*m
    for j in range(n):
        if(i >> j) & 1 == 1: #bit全探索
            price += listA[j][0]
            for k in range(m):
                point[k] += listA[j][k+1]
    if min(point) >= x:
        ans = min(ans, price) if ans != -1 else price

print(ans)


Measured memory_bytes: 9108
#include<bits/stdc++.h>
using namespace std;
#define arep(i,x,n) for(int i=int(x);i<(int)(n);i++)
#define rep(i,n) for(long long i = 0;i < n;++i)
#define pi 3.141592653589793
#define eps 0.00000001
#define INF 1e9+7  
using ll = long long; 
using P=pair<int,int>;
using lP=pair<ll,ll>;
using fP=pair<double,double>;


int main(){
    int n;
    cin>>n;
    vector<int>w(n);
    int sum=0;
    rep(i,n){
        cin>>w[i];
        sum+=w[i];
    }
    
    int lsum=0;
    int ans=INF;
    for(int i=n-1;i>=0;--i){
        sum-=w[i];
        lsum+=w[i];
        ans=min(abs(sum-lsum),ans);
        
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
from bisect import bisect_left
class SEGTree:
    def __init__(self,n):
        self.Unit=0
        i=1
        while(i<n):
            i*=2
        self.SEG=[self.Unit]*(2*i-1)
        self.d=i
    def update(self,i,x):
        i+=self.d-1
        self.SEG[i]+=x
        while i>0:
            i=(i-1)//2
            self.SEG[i]=self.SEG[i*2+1]+self.SEG[i*2+2]
    def find(self,a,b,k,l,r):
        if r<=a or b<=l:
            return self.Unit
        if a<=l and r<=b:
            return self.SEG[k]
        else:
            c1=self.find(a,b,2*k+1,l,(l+r)//2)
            c2=self.find(a,b,2*k+2,(l+r)//2,r)
            return c1+c2
    def get(self,a,b):
        return self.find(a,b,0,0,self.d)
N,K=map(int,input().split())
a=[int(input()) for i in range(N)]
cum=[0]*(N+1)
for i in range(N):
    cum[i+1]=cum[i]+a[i]
B=[cum[i]-i*K for i in range(N+1)]

dic={}
li=sorted(B)
for i in range(N+1):
    dic[B[i]]=bisect_left(li,B[i])
seg=SEGTree(N+1)
ans=0
for i in range(N+1):
    ans+=seg.get(0,dic[B[i]]+1)
    seg.update(dic[B[i]],1)
print(ans)


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

int main(){
  int A,B;
  cin>>A>>B;
  std::vector<string> w(41),b(41);
  string s(51,'#');
  for(int i=0;i<41;i++)w[i]=s;
  for(int i=1;i<41;i+=2)for(int j=1;j<51;j+=2)w[i][j]='.';
  string sl(51,'.');
  for(int i=0;i<41;i++)b[i]=sl;
  for(int i=1;i<41;i+=2)for(int j=1;j<51;j+=2)b[i][j]='#';

  A=501-A;//I have to bury A*'.' in w[i]
  B=501-B;

  int k=A/25;int l=A%25;
  int j=1;
  for(int i=0;i<k;i++){
    w[j]=s;
    j+=2;
  }
  int m=1;
  for(int i=0;i<l;i++){
    w[j][m]='#';
    m+=2;
  }

  k=B/25;l=B%25;
  j=1;
  for(int i=0;i<k;i++){
    b[j]=sl;
    j+=2;
  }
  m=1;
  for(int i=0;i<l;i++){
    b[j][m]='.';
    m+=2;
  }

  cout<<82<<" "<<51<<endl;
  for(int i=0;i<41;i++)cout<<w[i]<<endl;
  for(int i=0;i<41;i++)cout<<b[i]<<endl;

}


Measured memory_bytes: 256
#include <algorithm>
#include <cctype>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <locale>
#include <map>
#include <numeric>
#include <queue>
#include <stack>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>

using namespace std;
vector<int> kisyutu;

auto makenum(int A, int L) {
    vector<int> num;
    int keep;
    for (int i = L - 1; i >= 0; i--) {
        keep = pow(10, i);
        num.push_back(A / keep);
        A = A - (A / keep) * keep;
        // cout << A << endl;
    }
    sort(num.begin(), num.end());

    // for (int i : num) cout << i << " ";
    // cout << endl;

    return num;
}

auto solve(int A, int L) {  //, vector<int> &num
    vector<int> ans;
    vector<int> num;
    num = makenum(A, L);

    int maxnum = 0;
    int minnum = 0;
    for (int i = 0; i < L; i++) {
        maxnum += num[i] * pow(10, i);
        minnum += num[i] * pow(10, L - i - 1);
    }
    int sa = maxnum - minnum;
    for (int i = 0; i < kisyutu.size(); i++) {
        if (kisyutu[i] == sa) {
            ans.push_back(i);
            ans.push_back(sa);
            ans.push_back(kisyutu.size() - i);
            return ans;
        }
    }
    kisyutu.push_back(sa);
    ans = solve(sa, L);
    return ans;
}

int main() {
    int A, L;
    vector<vector<int>> ans;
    // cout << kisyutu.size();
    while (1) {
        cin >> A >> L;
        if (!A && !L) break;
        // vector<int> num;
        kisyutu.push_back(A);
        ans.push_back(solve(A, L));  //, num
        kisyutu.clear();
    }
    for (int i = 0; i < ans.size(); i++) {
        cout << ans[i][0] << " " << ans[i][1] << " " << ans[i][2] << endl;
    }
}

/*
int型で入力をとる
aiとのさの分だけ０を足す
ソートして最大ー最小
再帰する
ai =＝ ai+1でretrun
*/


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

int main() {
  int N,M; cin >> N >> M;
  
  vector<int> c(M * 2);
  for(int i = 0; i < M * 2; i++){
    cin >> c.at(i);
  }
  
  for(int j = 0; j < N; j++){
  	int n = 0;
  	for(int i = 0; i < M * 2; i++){
  	  if(c.at(i) == j + 1) n++;
  	  else continue;
  	}
    cout << n << endl;
  }
}


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

namespace B_ABC111
{
    class Program
    {
        static void Main(string[] args)
        {
            string str = Console.ReadLine();
            int N = int.Parse(str);
            int Counter = 0;
            int min;
            
            for(int i = N; true; i++)
            {
                string s = i.ToString();
               
                string[] istr = new string[s.Length];
                for(int j = 0; j < s.Length; j++)
                {
                    istr[j] = s.Substring(j, 1);
                }

                Counter = 0;
                for(int j = 0; j < istr.Length-1; j++)
                {
                    if (istr[j] == istr[j + 1])
                    {
                        Counter++;
                    }
                }
                if (Counter == istr.Length - 1)
                {
                    min = i;
                    break;
                }
            }

            Console.Write(min);
            
        }
    }
}

Measured memory_bytes: 11092
import string

s = input()
K = int(input())

alp = string.ascii_lowercase
ans = ''

for i in range(len(s)-1):
    num = (len(alp) - alp.index(s[i])) % 26
    if num <= K:
        K -= num
        ans += 'a'
    else:
        ans += s[i]

if K > 0:
    num = (alp.index(s[-1]) + K) % 26
    ans += alp[num]
else:
    ans += s[-1]

print(ans)

Measured memory_bytes: 4088
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep2(i, m, n) for(int i=int(m); i<int(n); i++)
#define rep(i, n) rep2(i, 0, n)
#define ALL(a) a.begin(), a.end()
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
const int INF = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS = 1e-10;
const int MOD = int(1e9)+7;
template<typename T> inline bool chmin(T& a, T b) {if(a>b) {a=b; return true;} return false;}
template<typename T> inline bool chmax(T& a, T b) {if(a<b) {a=b; return true;} return false;}

template<typename T>
vector<int> compress(vector<T> &v) {
  vector<T> t = v;
  sort(t.begin(), t.end());
  t.erase(unique(t.begin(), t.end()), t.end());
	vector<int> r(v.size());
  for (int i = 0; i < v.size(); i++) {
    r[i] = lower_bound(t.begin(), t.end(), v[i]) - t.begin();
  }
	return r;
}

int main() {
  int n; cin >> n;
  V a(n);
  rep(i, n) cin >> a[i];
  V b = compress(a);

  deque<int> dq;
  rep(i, n) {
    int j = lower_bound(ALL(dq), b[i]) - dq.begin();
    if (j == 0) {
      dq.push_front(b[i]);
    }
    else {
      dq[j-1] = b[i];
    }
  }
  cout << dq.size() << endl;
  return 0;
}


Measured memory_bytes: 1416
// Have'nt AC
#include<iostream>
#include<string.h>
#include<stdlib.h>
#include<math.h>

using namespace std;

char X[100000100];

bool harshad(char* X){
  int len = strlen(X);
  long num = atoi(X);

  long modn = 1;
  for(int i=0;i<len-1;i++){
    modn *= 10;
  }
  int ans = 0;
  int com = num;
  for(int i = 0;i < len;i++){
    ans += num / modn;
    num %= modn;
    modn /= 10;
  }
  if(com % ans == 0){
    return true;
  }else{
    return false;
  }
}

int main(void){
  cin >> X;
  if(harshad(X)){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pii pair<int,int>
#define fi first
#define pb push_back
#define si second
#define int long long
#define mod 1000000007
#define debug(x) cout << #x << " " << x <<endl;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define double long double
#define all(o) o.begin(),o.end()
using namespace std;
int power(int x, int y)
{
    int res = 1;
    x = x % mod;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % mod;
        y = y>>1; // y = y/2
        x = (x*x) % mod;
    }
    return res%mod;
}
int inv(int  n)
{
    return power(n,mod-2)%mod;
}
int dp[105][100005],a[1005];
int32_t main(){
   //fast
   int n,q,i,j,k;
   cin>>n>>q;
   for(i=1;i<=n;i++)
       cin>>a[i];



   for(i=0;i<=q;i++)
       dp[0][i]=1;
    



    for(i=0;i<=n;i++)
        dp[i][0]=1;


   for(i=1;i<=n;i++)
   {
        for(j=1;j<=q;j++){
            int l=j-a[i]-1;
            dp[i][j]=dp[i-1][j];
            
            if(l>=0)
            {
                dp[i][j]-=dp[i-1][l];
                if(dp[i][j]<0)
                    dp[i][j]+=mod;
            }
            dp[i][j]+=dp[i][j-1];
            dp[i][j]%=mod;
        }
    }
    
    cout<<(dp[n][q]-dp[n][q-1]+mod)%mod<<"\n";
    

}

Measured memory_bytes: 82492
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#pragma GCC target ("avx2")
#pragma GCC optimization ("unroll-loops")
#define rep(i, n) for(int i=0;i<(int)(n);++i)
template <typename T> ll gcd(T a, T b) {return b?gcd(b, a%b):a;}
template <typename T> ll lcm(T a, T b) {return a * b / gcd(a, b);};
template <typename T> inline void chmin(T &a, const T& b){if(a>b)a=b;}
template <typename T> inline void chmax(T &a, const T& b){if(a<b)a=b;}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  int a = 0, b = 0;
  for (int i = 0; i < (int)s.size(); ++i) {
    if (s[i] == 'A') a++;
    else b++;
  }
  if (a==0 || b == 0) {
    cout << "No" << '\n';
  } else {
    cout << "Yes" << '\n';
  }
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int cnt = 0;
        String w, t;
        w = scanner.next();

        while (true) {
            t = scanner.next();
            if (t.equals("END_OF_TEXT")) break;

            if (t.toLowerCase().equals(w)) ++cnt;
        }
        System.out.println(cnt);
    }
}


Measured memory_bytes: 26184
/*                        ______
 _______   /\     |``\   |        |  /
    |     /  \    |__/   |____    |/
    |    / _ _\   |  \   |        |\
    |   /      \  |   \  |______  |  \

            Dept. of CSE
        Comilla  University

*/
#include<bits/stdc++.h>
#define pi 2*acos(0.0)
#define ll long long
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define Node struct node
#define spc " "
#define  E  2.71828182845904523536
#define pb push_back
#define pp pop_back
#define valid(nx,ny) nx>=0 && nx<n && ny>=0 && ny<m
#define ee endl
#define pii pair<int,int>
#define infinity 10000000000000000
#define mod 1000000007
int fx[]={0,0,+1,-1};
int fy[]={+1,-1,0,0};

using namespace std;
///check n=1;
///check corner case;
const int maX=1e5+1;
vector<ll>Graph[maX],cost[maX];
ll visit[maX];
ll x[10];
ll y[10];

int main()
{
    ll n,i,j,cc=0;
    cin>>n;
    ll ara[n];
    for(i=0;i<n;i++){
        cin>>ara[i];
        j=ara[0];
    }
    for(i=1;i<n;i++){
        if(ara[i]>=j){
            cc++;j=ara[i];
        }
    }
    cout<<cc+1<<endl;
return 0;
}


Measured memory_bytes: 4992
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { 
  INIT(){cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


signed main() {
  string s;
  cin >> s;

  int N = s.size();

  bool flag = true;
  FOR(i, 1, N){
    if(s[i] != '9') flag = false;
  }

  int ans = (s[0]-'0')+9*(N-1)+(flag? 0: -1);
  cout << ans << "\n";

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1000000007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define rep(i, n) for(ll i=0; i<(ll)(n); i++)
#define repd(i, n) for(ll i=n-1; 0<=i; i--)
#define FOR(i, a, b) for(ll i=a; i<(ll)(b); i++)
#define FORD(i, a, b) for(ll i=a-1; (ll)(b)<=i; i--)
#define ALL(x) x.begin(), x.end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};


int main(){
    ll n;   cin >> n;
    vector<double> p(n);
    rep(i, n)   cin >> p[i];
    vector<vector<double>> dp(n+1, vector<double>(n+1, 0.0));
    dp[0][0] = 1.0;
    rep(i, n){
        FOR(j, 0, i+1){
            dp[i+1][j+1] += dp[i][j]*p[i];
            dp[i+1][j] += dp[i][j]*(1.0-p[i]);
        }
    }
    double res=0.0;
    FOR(i, n/2, n) res += dp[n][i+1];
    cout << fixed << setprecision(20) << res << endl;
}


Measured memory_bytes: 73744
#include<stdio.h>

/* 値を入れ替える関数 */
void swap (int *x, int *y) {
  int temp;    // 値を一時保存する変数

  temp = *x;
  *x = *y;
  *y = temp;
}

/* pushdouwn操作 */
void pushdown (int array[], int first, int last) {
  int parent = first;   // 親
  int child = 2*parent;   // 左の子
  while (child <= last) {
    if ((child < last) && (array[child] < array[child+1])) {
       child++;   // 右の子の方が大きいとき、右の子を比較対象に設定
    }
    if (array[child] <= array[parent]) { break; }   // ヒープ済み
    swap(&array[child], &array[parent]);
    parent = child;
    child = 2* parent;
  }
}


int main (void) {
  int array[500001];
  int i,n;

  scanf("%d",&n);

  for(i=1;i<=n;i++){
    scanf("%d",&array[i]);
      }

  for (i = n/2; i >= 1; i--) {
    pushdown(array, i, n);   // 全体をヒープ化
  }

  for(i=1;i<=n;i++){
    printf(" %d",array[i]);
  }

  printf("\n");
    


  return 0;
}



Measured memory_bytes: 3652
s = input()
t = input()


s_len = len(s)
t_len = len(t)
ans = s_len
for i in range(0,s_len):
    if i+t_len > s_len:
        continue
    tmp = 0
    for j in range(0,t_len):
        if s[i+j] != t[j]:
            tmp = tmp + 1
    ans = min(tmp,ans)

print(ans)

Measured memory_bytes: 9112
n,m=map(int,input().split())
from collections import  Counter
MOD=10**9+7

def prime_decomposition(n):
  i = 2
  table = []
  while i * i <= n:
    while n % i == 0:
      n /= i
      table.append(int(i))
    i += 1
  if n > 1:
    table.append(int(n))
  return table

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = MOD #出力の制限
N = 10**6
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

tmp=prime_decomposition(m)
df=set(tmp)
df=list(df)
cnt=Counter(tmp)
ans=1

for i in range(len(df)):
    cv=cmb(cnt[df[i]]+n-1,cnt[df[i]],mod)
    ans*=cv%MOD

print(ans%MOD)

Measured memory_bytes: 122180
#include <bits/stdc++.h>
using namespace std;
using ll= long long;
using vi= vector<int>;
using vvi= vector<vi>;
using vd= vector<double>;
#define REP(i,x,n) for(int i=x; i<n; i++)
#define rep(i,n) REP(i,0,n)
#define all(x) x.begin(), x.end()

int main(){
  int n,ans=0,p=0;
  cin >>n;
  vi h(n);
  rep(i,n)  cin >> h[i];

  rep(i,n){
    if(h[i-1]>=h[i]){
      p++;
    }
    else{
      if(ans<p) ans=p;
      p=0;
    }
  }
  if(ans<p) ans=p;
  
  cout << ans << endl;
}

Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<algorithm>
int main(void){
    std::vector<std::string> a = {"SUN","MON","TUE","WED","THU","FRI","SAT"};
    std::reverse(a.begin(), a.end());
    std::string s;
    std::cin >> s;
    for(int i = 0; i < a.size(); i++){
	if(a[i] == s){
	    std::cout << ++i << std::endl;
	    break;
	}
    }
    return 0;
}



Measured memory_bytes: 3620
include Math

n = gets.to_i
points = (1..n).map { gets.split.map(&:to_i) }

if (2..n-1).all? {|i|
  (points[1][1] - points[0][1]) * (points[i][0] - points[0][0]) ==
  (points[i][1] - points[0][1]) * (points[1][0] - points[0][0])
}
  puts 'No'
  exit
end

center = [points.map(&:first).inject(:+) / n.to_f, points.map(&:last).inject(:+) / n.to_f]
points.map! {|x, y| [x - center[0], y - center[1]] }
points.reject! {|x, y| x.abs + y.abs < 1e-5 }
points.sort_by! {|x, y| atan2(y, x) }

a = []
points.each {|point| a << point }
points.each_cons(2) {|p1, p2| a << [(p1[0] + p2[0]) / 2.0, (p1[1] + p2[1]) / 2.0] }
a << [(points[-1][0] + points[0][0]) / 2.0, (points[-1][1] + points[0][1]) / 2.0]

ret = false
a.each do |x0, y0|
  t = atan2(y0, x0)

  rotated = points.map {|x, y| [cos(-t) * x - sin(-t) * y, sin(-t) * x + cos(-t) * y] }
  rotated.map! {|x, y| [x.round(5), y.round(5)] }
  rotated.reject! {|_, y| y.abs < 1e-5 }
  next if rotated.size < n - 2
  upper_points, lower_points = rotated.partition {|_, y| y > 0 }
  next if upper_points.empty? || lower_points.empty?
  next if upper_points.size != lower_points.size
  turned_lower_points = lower_points.map {|x, y| [x, -y] }
  upper_points.sort!
  turned_lower_points.sort!
  if upper_points.zip(turned_lower_points).all? {|p1, p2| (p1[0] - p2[0]).abs + (p1[1] - p2[1]).abs < 1e-5 }
    ret = true
    break
  end
end
puts ret ? 'Yes' : 'No'



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

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

    int ans = 0;
    for(int l=0; l<=N; l++) for(int r=0; l+r<=N; r++){
        int k = K - l - r;
        if(k < 0) continue;
        vector<int> vs;
        for(int i=0; i<l; i++) vs.push_back(V[i]);
        for(int i=0; i<r; i++) vs.push_back(V[N-1-i]);
        sort(vs.rbegin(), vs.rend());
        while(vs.size() && k && vs.back() < 0){
            vs.pop_back();
            k--;
        }
        int res = accumulate(vs.begin(), vs.end(), 0);
        ans = max(ans, res);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	ll n, m;
	cin>>n>>m;
	if(n == 1 && m == 1){
		cout<<1<<endl;
		return 0;
	}
	if(m == 1){
		cout<<n - 2<<endl;
		return 0;
	}
	if(n == 1){
		cout<<m - 2<<endl;
		return 0;
	}
	cout<<(long long)(n * m) - (long long)(((2 * m) + (2 * n) - 4))<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int a[100];
int main()
{
    int n,k,ans=0;
    cin>>n>>k;
    for(int i=0;i<k;i++)
    {
        int d,x;
        cin>>d;
        for(int j=0;j<d;j++)
        {
            cin>>x;
            a[x-1]++;
        }
    }
    for(int i=0;i<n;i++)
    {
        if(a[i]==0)
            ans++;
    }
    cout<<ans<<endl;
    return 0;
}

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

using namespace std;

#define LOG(...) fprintf(stderr, __VA_ARGS__)
//#define LOG(...)
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
#define RFOR(i, a, b) for (int i = (int)(b - 1); i >= (int)(a); --i)
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define RREP(i, n) for (int i = (int)(n - 1); i >= 0; --i)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define SZ(a) ((int)(a).size())
#define BIT(x, i) (((x) >> (i)) & 1)
#define SQ(x) ((x) * (x))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

int main() {
    int N;
    cin >> N;
    cout << ceil(log(N) / log(3)) << endl;
}

Measured memory_bytes: 3520
package main

import (
	"bufio"
	"fmt"
	"os"
)

var sc = bufio.NewScanner(os.Stdin)

func next() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	var res int
	s := next()

	for mask := 0; mask < 1<<uint(len(s)-1); mask++ {
		var cur int
		for i := 0; i < len(s); i++ {
			cur *= 10
			cur += int(s[i] - '0')
			if _bool := mask & (1 << uint(i)); _bool != 0 {
				res += cur
				cur = 0
			}
		}
		res += cur
	}
	fmt.Println(res)
}

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


using namespace std;
typedef long long ll;

#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VP vector<pair<int,int>>
#define VPP vector<pair<int,pair<int,int>>>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define fore(i,a) for(auto &i:a)
typedef pair <int, int> P;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

const int  INF = 1 << 29;
const ll INFL = 1LL << 60;
const ll mod = 1000000007;


int main() {

	ll n, a, b;
	cin >> n >> a >> b;

	ll k = n / (a + b);

	ll m = n - (k*(a + b));

	ll ans = 0;
	ans += a * k;

	ans += min(a, m);
	cout << ans << endl;



}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		final int a=sc.nextInt(),b=sc.nextInt();
		if(a>b){
			System.out.println(a-1);
		}else{
			System.out.println(a);
		}
	}
}


Measured memory_bytes: 21076
#include<iostream>
#include<algorithm>
#include<string>
#include<functional>
#include<utility>
#include<stack>
#include<queue>
#include<cmath>
#include<list>
#include<cstdint>
#include<vector>
#include<map>
#include<deque>
#define rep(i,rept)	for(ll i = 0; i<rept;i++)
typedef long long ll;
const ll MOD = 1e9 + 7;
using namespace std;

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

	ll n = 0, x = 0, ans = 0;
	cin >> n >> x;
	int town[100001] = {};
	int sa[100000] = {};
	ll gcd(ll a, ll b);
	rep(i, n) {
		cin >> town[i];
	}
	town[n] = x;
	sort(town, town + n + 1);
	for (int i = 1; i <= n + 1; i++) {
		sa[i - 1] = town[i] - town[i - 1];
	}
	ans = sa[0];
	for (int i = 1; i < n; i++) {
		ans = gcd(ans, sa[i]);
	}
	cout << ans << endl;

	return 0;
}
ll gcd(ll a, ll b) {
	ll tmp,r;
	if (a < b) {
		tmp = a;
		a = b;
		b = tmp;
	}
	r = a % b;
	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}
	return b;
}

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

int main()
{
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int r, c, n, sr, sc;
  cin >> r >> c >> n >> sr >> sc;
  string s, t;
  cin >> s >> t;
  int tl = sc, tr = sc, tu = sr, td = sr;
  for (int i = 0; i < n; ++i) {
    if (s[i] == 'L') {
      --tr;
    } else if (s[i] == 'R') {
      ++tl;
    } else if (s[i] == 'U') {
      --td;
    } else {
      ++tu;
    }
    if (tr < 1 || tl > c || td < 1 || tu > r) {
      cout << "NO" << endl;
      return 0;
    }
    if (t[i] == 'L') {
      tl = max(1, tl - 1);
    } else if (t[i] == 'R') {
      tr = min(c, tr + 1);
    } else if (t[i] == 'U') {
      tu = max(1, tu - 1);
    } else {
      td = min(r, td + 1);
    }
  }
  cout << "YES" << endl;
  return 0;
}



Measured memory_bytes: 920
#include <bits/stdc++.h>
using namespace std;
const int MX=1e5+5;
long long a[MX];
int n;
long long b[MX];
long long c[MX];
int main(){
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(0);
    int i,j;
    cin>>n;

    for(i=1 ; i<=n ; i++)cin>>a[i];
    int k=0;
    long long s=0;
    long long ss=0;

    for(i=1 ; i<=n ; i++)s+=a[i];
    for(i=1 ; i<=n-2 ; i+=2)ss+=a[i]*2;
    b[n]=s-ss;
    for(i=n-1 ; i>=1 ; i--)b[i]=2*a[i]-b[i+1];
    for(i=1 ; i<=n ; i++)cout<<b[i]<<" ";
    return 0;
}


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

public class Main
{
  	int n, max = -1000000;
 	int[] v, c;
  
    Main(Scanner in, PrintWriter out)
    {
    	n = in.nextInt();
      	v = new int[n];
      	c = new int[n];
      	for (int i = 0; i < n; i++)
        	v[i] = in.nextInt();
      	for (int i = 0; i < n; i++)
          	c[i] = in.nextInt();
      	for (int i = 0; i < (1 << n); i++)
        {
          	int V = 0, C = 0;
          	for (int j = 0; j < n; j++)
              	if ((i & (1 << j)) > 0)
                {
                  	V += v[j];
                  	C += c[j];
                }
          	max = Math.max(max, V-C);
        }
      	
      	out.println(max);
    }
	
	public static void main(String[] args)
	{
		Scanner in = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		new	Main(in, out);
		out.close();
	} 
}

Measured memory_bytes: 21844
// g++ -std=c++11 temp.cpp
#include <bits/stdc++.h>
using namespace std;

#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) FOR(i,0,n)
#define EACH(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;

#define INF INT_MAX/3

#define MAX_N 1000

int N;
int l[222];

int main(){
	int res  = 0;
	scanf("%d", &N);
	REP(i,N*2){
		scanf("%d", &l[i]);
	}
	sort(l,l+2*N);
	REP(i,N){
		res += l[i*2];
	}
	cout<<res<<endl;
	return 0;
}




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

#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define SIZE(array) (sizeof(array) / sizeof(array[0]))

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

#define MAX_V 100000

#define MOD 1000000007L
#define INF 2147483647

signed main() {
	int N;
	cin >> N;
	int a[N];
	for (int i = 0; i < N; ++i) {
		cin >> a[i];
	}
	ll m = 1000000000;
	int mi = 0;
	for (int i = -100; i <= 100; ++i) {
		ll k = 0;
		for (int j = 0; j < N; ++j) {
			k += (i - a[j]) * (i - a[j]);
		}
		if (k < m) {
			m = k;
			mi = i;
		}
		// cout << i << ": " << m << endl;
	}
	cout << m << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <deque>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <map>
#include <stack>
#include <set>
#include <sstream>
#define IOS ios_base::sync_with_stdio(0); cin.tie(0);
#define ll long long
#define INF 0x3f3f3f3f 
#define MEM(x,y) memset(x,y,sizeof(x))
#define int long long
#define rep(i , a , b) for(int i = a ; i <= b ; i ++)
#define P pair<int,int>
#define  sc(a) scanf("%lld",&a)
#define pf(a) printf("%lld ",a)
using namespace std;
string  s;
int n;
int v[10];
string t;
int q;
string t1[10000000];
void dfs(int x)
{
	if (x == n)
	{
		t1[q++] = t;
		return;
	}
	else
	{
		for (int i = 1; i <= n; i++)
		{
			if (!v[i])
			{
				string r = t;
				t += i + '0';
				v[i] = 1;
					dfs(x + 1);
				t = r;
				v[i] = 0;
			}
		}
	}
}
signed main()
{
	
	sc(n);
	string a;
	string b;
	getchar();
	for (int i = 0; i < n; i++)
	{
		char c = getchar();
		getchar();
		a += c;
	}
	
	for (int i = 0; i < n; i++)
	{
		char c = getchar();
		getchar();
		b += c;
	}
	dfs(0);
	int j, k;
	rep(i, 0, q - 1)
	{
		if (t1[i] == a)
			j = i;
		if (t1[i] == b)
			k = i;
	}
	cout << abs(j - k);
}










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

#define $(x) (int)((x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define endl '\n'
#define x first
#define y second
#define int long long
#define double long double
#define pii pair<int, int>
#define pb push_back
#define vec vector
#define beg begin
#define dbg(x) cerr << #x << " = " << x << endl;

template<class T> ostream& operator<<(ostream &str, vector<T> &a) {
    for (auto &i : a) {
        str << i << " ";
    }
    return str;
}

template<class T> istream& operator>>(istream &str, vector<T> &a) {
    for (auto &i : a) {
        str >> i;
    }
    return str;
}

template<class T> ostream& operator<<(ostream &str, pair<T, T> &a) {
    str << a.first << " " << a.second;
    return str;
}

template<class T> istream& operator>>(istream &str, pair<T, T> &a) {
    str >> a.first >> a.second;
    return str;
}

void solve(); signed main() {
#ifdef LOCAL
    freopen("C:\\Users\\artma\\CLionProjects\\problems\\input.txt", "r", stdin);
#endif
    srand(time(0));
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cout.setf(ios::fixed); cout.precision(6);
    solve();
    return 0;
}

const int MOD = 1e9 + 7, MAXN = 1e6 + 10, INF = 1e18 + 10, BASE = 37;

void solve() {
    int k;
    cin >> k;
    if (k % 7 == 0) k /= 7;
    if (k % 2 == 0 || k % 5 == 0) {
        cout << -1 << endl;
        return;
    }

    vec<int> r(k);
    int val = 1;
    int ans = INF;
    for (int i = 1; i < 2e6; ++i) {
        if (r[val] == 0) {
            r[val] = i;
            val = (val * 10 + 1) % k;
        }
        else {
            ans = min(ans, i - r[val]);
            r[val] = i;
            val = (val * 10 + 1) % k;
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 11012
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main()
{
    int          input;
    vector<int>  array;
    for (int i=0; i<5; ++i) {
        cin >> input;
        array.push_back(input);
    }
    sort(array.begin(), array.end(), greater<int>());
    for (vector<int>::size_type i=0; i<array.size(); ++i) {
        cout << array[i];
        cout << (i==4 ? '\n' : ' ');
    }
}

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

const int INF = 1e18;
const int MAX_V = 2510;
const int MAX_E = 5010;

int V, E, P;

struct edge {
    int from;
    int to;
    int cost;
};

edge es[MAX_E];

int d[MAX_V];
bool negative[MAX_V];

void bellman_ford(int s) {
  for (int i = 1; i <= V; i++) d[i] = INF;
  d[s] = 0;

  for (int i = 0; i < V - 1; i++) {
    for (int j = 0; j < E; j++) {
      edge e = es[j];
      if(d[e.from] != INF && d[e.from] + e.cost < d[e.to]) {
        d[e.to] = d[e.from] + e.cost;
      }
    }
  }
}

void find_negative_loop() {
  for (int i = 1; i <= V; i++) negative[i] = false;
  for (int i = 1; i <= V; i++) {
    for (int j = 0; j < E; j++) {
      edge e = es[j];
      if(d[e.to] != INF && d[e.from] + e.cost < d[e.to]) {
        d[e.to] = d[e.from] + e.cost;
        negative[e.from] = true;
      }
      if(negative[e.from]) negative[e.to] = true;
    }
  }
}

signed main() {
  cin >> V >> E >> P;

  for (int i = 0; i < E; i++) {
    int a,b,c;
    cin >> a >> b >> c;

    edge e = {a, b, P - c};
    es[i] = e;
  }

  bellman_ford(1);
  int answer = max(0LL, -d[V]);
  find_negative_loop();
  if(negative[V]) answer = -1;
  cout << answer << "\n";
}


Measured memory_bytes: 3768
import java.io.BufferedReader; 
import java.io.IOException; 
import java.io.InputStreamReader; 
import java.util.StringTokenizer; 
import java.util.*;
  
public class Main {  
	static Map<List<Integer>, Integer> dp;
	static int n;
	static int min = Integer.MAX_VALUE;
    public static void main(String[] args) throws IOException { 
    	BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); 
		StringTokenizer st = new StringTokenizer(br.readLine()); 
		//int k = Integer.parseInt(st.nextToken());
		int n = Integer.parseInt(st.nextToken());
		int s = 0;
		int x = n;
		while (x > 0) {
			s += x % 10;
			x /= 10;
		}
		if (n % s == 0) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 21332
#include <bits/stdc++.h>
using namespace std;
//#define ll long long 
#define all(v) v.begin(),v.end()
#define boost ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
/*
#define bigint __int128
__int128 abss(__int128 x){if(x>0)return x;
    return -x;
    }
*/
void solve() {
  string s,t,S;cin>>s>>t;bool ok =1;
  int l = s.length(),ll = t.length();
  int mx =  0;
  if(s==t){cout<<"0\n";}
  else{
    for(int i =0;i<=l-ll;i++){
    string tmp = s.substr(i,ll);
      int cnt = 0;
      
      for(int j = 0;j<ll;j++){
      if(tmp[j]==t[j]){++cnt;}
      }
      if(cnt>mx){
        mx = cnt;
        S = tmp;
      }
      
      cnt = 0;
    }
  if(ok)
  cout<<(ll-mx)<<"\n";
  else{cout<<"0\n";}
  }
}
int main()
{boost;
int t;t = 1;//cin>>t;
while(t--){solve();}
}


Measured memory_bytes: 3648
#include<iostream>

typedef unsigned long long ULL;
using namespace std;

int main(){
    int N;
    bool *a;
    int i,j;
    bool *box;
    bool temp;
    int count;
    
    cin >> N;
    a = new bool[N];
    box = new bool[N];
    for(i=0;i<N;i++){
        cin >> a[i];
    }
    for(i=N/2;i<N;i++){
        box[i] = a[i];
    }
    
    for(i=N/2;i>0;i--){
        temp = 0;
        for(j=i*2;j<=N;j+=i){
            temp = temp ^ box[j-1];
        }
        if(temp != a[i-1] ){
            box[i-1] = true;
        }
        
    }
    count = 0;
    for(i=0;i<N;i++){
        count += box[i];
    }
    cout << count << endl;
    for(i=0;i<N;i++){
        if( box[i] == true){
            cout << i+1 << " ";
        }
    }
    if( count != 0){
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 1408
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
#include<boost/dynamic_bitset.hpp>
namespace adaptor = boost::adaptors;
auto udlr(int i, int j)
{
	return std::array<std::pair<int, int>, 4>
	{
		std::make_pair(i + 1, j),
			std::make_pair(i - 1, j),
			std::make_pair(i, j + 1),
			std::make_pair(i, j - 1)
	};
}

int run(int H, int W, boost::multi_array<int, 2>& map, int rest, std::set<std::pair<int, int>> black)
{
	int count = 0;
	for (; rest != 0; ++count)
	{
		std::set<std::pair<int, int>> target;
		for (auto p : black)
		{
			for (auto q : udlr(p.first, p.second))
			{
				int i, j;
				std::tie(i, j) = q;
				if (map[i][j])
				{
					target.emplace(i, j);
				}
			}
		}
		for (auto p : target)
		{
			int i, j;
			std::tie(i, j) = p;
			map[i][j] = 0;
			--rest;
		}
		std::swap(target, black);
	}
	return count;
}

void Main()
{
	int H, W;
	std::cin >> H >> W;
	boost::multi_array<int, 2> map(boost::extents[H + 2][W + 2]);
	std::set<std::pair<int, int>> black;
	int rest = 0;
	for (int i : boost::irange(1, H + 1))
	{
		for (int j : boost::irange(1, W + 1))
		{
			char c;
			std::cin >> c;
			if (c == '.')
			{
				map[i][j] = 1;
				++rest;
			}
			else
			{
				black.emplace(i, j);
			}
		}
	}
	std::cout << run(H, W, map, rest, std::move(black)) << std::endl;
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}


Measured memory_bytes: 51072
#include <bits/stdc++.h>
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)

                    
using ll = long long;
using ull = unsigned long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const ll mod = 1e9+7;
void chmod(ll &M){
  if(M >= mod) M %= mod;
  else if(M < 0){
     M += (abs(M)/mod + 1)*mod;
    M %= mod;
}
}
ll modpow(ll x, ll n){
   if(n==0) return 1;
  ll res=modpow(x, n/2);
 if(n%2==0) return res*res%mod;
else return res*res%mod*x%mod;
}
int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };
long long GCD(long long a, long long b) {
  if (b == 0) return a;
  else return GCD(b, a % b);
}

using namespace std;
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
int main() 
{
    int A, B;
    cin >> A >> B;
    cout << A * B << endl;
}


Measured memory_bytes: 3556
N = int(input())
grid = []
for i in range(N):
    array = list(sorted(input()))
    grid.append(array)
sss = []
for i in range(N):
  sss.append(','.join(grid[i]))
import collections
aaa = collections.Counter(sss).most_common()
var = 0
for i in range(len(aaa)):
  y = aaa[i][1]
  var = var + y*(y-1)/2
print(int(var))

Measured memory_bytes: 46532
[n,m]=list(map(int,input().split()))
roads=[]
for i in range(m):
    road=list(map(int,input().split()))
    roads.append(road)
ans=[]
for i in range(n):
    kaisu=0
    for j in range(m):
        if roads[j][0]==i+1 or roads[j][1]==i+1:
            kaisu+=1
    ans.append(kaisu)

for i in range(n):
    print(ans[i])

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> // Common file  
#include <ext/pb_ds/tree_policy.hpp>  
#include <functional> // for less
using namespace __gnu_pbds;

typedef tree<int,null_type,less<int>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#define rep(i,a,n)    for(int i=a; i<=n; ++i)
#define rep1(i,a,n)   for(int i=a; i>=n; --i)
#define pb            push_back
#define mp            make_pair
#define int           long long
#define fr            first
#define sc            second
#define vc            vector
#define sz(v)         (int)v.size()
#define all(x)        (x).begin(),(x).end()
#define rall(x)       (x).rbegin(),(x).rend()
#define N             (int)(1e6+5)
#define M             1000000007
#define MM            998244353
#define PI            3.14159265358979
#define INF           1000000000000000

typedef vector<int> vi;
typedef pair<int,int> pii;
typedef map<int,int> mii;

int n,m,ans; string str;

int solve(){
    cin>>n>>m; ans=INF;
    int a[n+1]; a[0]=0; rep(i,1,n) cin>>a[i];
    sort(a,a+n+1);
    // rep(i,1,n) a[i]+=a[i-1];
    rep(i,m,n) ans=min(ans,a[i]-a[i-m+1]);
    cout<<ans;
    return 0;
}

signed main() {
    ios::sync_with_stdio(0);
    //std::mt19937_64 rng(std::chrono::steady_clock::now().time_since_epoch().count());
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t=1;
    //cin>>t;
    while(t--) solve();
    return 0;
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
int xl[20], xr[20], h[20];
const double EPS = 1e-6;
int main() {
	int R, n;
	while (cin >> R >> n,R) {
		for (int i = 0; i < n; i++) {
			cin >> xl[i] >> xr[i] >> h[i];
		}
		double l = 0, r = 60;
		for (int i = 0; i < 20; i++) {
			double m = (l + r) / 2;
			bool OK = 1;
			for (int j = 0; j <= 1<<17; j++) {
				double x = -R + (2 * R) / (double)(1<<17) * j;
				int Max = 0;
				for (int k = 0; k < n; k++) {
					if (xl[k] <= x+EPS&&x <= xr[k]+EPS) {
						Max = max(Max, h[k]);
					}
				}
				double H = sqrt(R*R - x*x) + m - R;
				if (Max < H+EPS) {
					OK = 0;
					break;
				}
			}
			if (OK) l = m; else r = m;
		}
		cout << l << endl;
	}
}

Measured memory_bytes: 3172
#include <bits/stdc++.h>
using namespace std;
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) {
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

int main() {
    int N;
    cin >> N;
    if(N == 10 || N==100 || N == 1000 || N == 10000 || N == 100000)
      cout << 10 << endl; 
    else cout << findSumOfDigits(N) << endl; 
}

Measured memory_bytes: 256