akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
vector<int> E[101010];

int dfs(int cur,int pre,int T) {
	multiset<int> V;
	FORR(e,E[cur]) if(e!=pre) {
		int ret=dfs(e,cur,T);
		if(ret==-2) return -2;
		if(ret>=0) V.insert(ret+1);
	}
	if(E[cur].size()%2) V.insert(0);
	
	int cand=-1;
	while(V.size()) {
		int x=*V.rbegin();
		V.erase(V.find(x));
		
		auto it=V.lower_bound(T-x+1);
		if(it==V.begin()) {
			if(cand!=-1) return -2;
			cand=x;
		}
		else {
			it--;
			V.erase(it);
		}
	}
	return cand;
}

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	FOR(i,N-1) {
		cin>>x>>y;
		E[x-1].push_back(y-1);
		E[y-1].push_back(x-1);
	}
	int A=0;
	FOR(i,N) if(E[i].size()%2==1) A++;
	
	int B=1<<20;
	for(i=19;i>=0;i--) {
		if(dfs(0,-1,B-(1<<i))!=-2) B-=1<<i;
	}
	
	cout<<A/2<<" "<<B<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 16384
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define ALL(v) (v).begin(), (v).end()
#define LENGTHOF(x) (sizeof(x) / sizeof(*(x)))
#define AFILL(a, b) fill((int*)a, (int*)(a + LENGTHOF(a)), b)
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define INF 1 << 30
#define EPS 1e-10

typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;

int X, Y;
int dx[] = {-1,0,1,0}, dy[] = {0,-1,0,1};
int res;
int closed[16][16];

void filling(int s[16][16], int y, int x, int from, int to){
  s[y][x] = to;
  rep(d, 4){
    int ny = y + dy[d], nx = x + dx[d];
    if(ny < 0 || ny >= Y || nx < 0 || nx >= X || s[ny][nx] != from) continue;
    filling(s, ny, nx, from, to);
  }
  return;
}

int check(int s[16][16]){
  int p = s[0][0];
  rep(i, Y) rep(j, X){
    if(s[i][j] != p) return 0;
  }
  return 1;
}

void next(int from[16][16], int to1[16][16], int to2[16][16]){
  int c1, c2;
  c1 = c2 = from[0][0];
  c1 += 1; c2 += 2;
  c1 %= 3; c2 %= 3;

  rep(i, Y) rep(j, X){
    to1[i][j] = to2[i][j] = from[i][j];
  }

  queue<pi>open;
  open.push(pi(0, 0));
  memset(closed, 0, sizeof(closed));
  to1[0][0] = c1; to2[0][0] = c2;

  while(!open.empty()){
    pi p = open.front();
    open.pop();

    rep(d, 4){
      int ny = p.F + dy[d];
      int nx = p.S + dx[d];

      if(ny < 0 || nx < 0 || ny >= Y || nx >= X || closed[ny][nx] || from[0][0] != from[ny][nx]) continue;
      to1[ny][nx] = c1;
      to2[ny][nx] = c2;
      closed[ny][nx] = 1;
      open.push(pi(ny, nx));
    }
  }
}

void dfs(int s[16][16], int n){
  if(check(s)){
    res = n;
    return;
  }
  if(res <= n) return;

  int n1[16][16];
  int n2[16][16];

  next(s, n1, n2);
  dfs(n1, n+1);
  dfs(n2, n+1);
  
  return;
}

int main(){
  while(scanf("%d%d", &X, &Y) && X+Y){
    int s[16][16];
    getchar();
    rep(i, Y) rep(j, X){
      char c = getchar();
      switch(c){
      case 'R': s[i][j] = 0; break;
      case 'G': s[i][j] = 1; break;
      case 'B': s[i][j] = 2; break;
      }
      getchar();
    }
    
    res = 18;
    dfs(s, 0);
    printf("%d\n", res);
  }
  return 0;
}

Measured memory_bytes: 1228
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define N 100010
#define INF 10000000000
typedef long long ll;
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) int(x.size())
#define IN(a) cin>>(a)
#define OUT(a) cout<<(a)<<endl
typedef pair<int,int> P;
const int MAX = 1000000;
const int MOD = 1000000007;
int dp[N][13];
int main(){
    string s;
    IN(s);
    if(s[0]=='?'){
        REP(i,10){
            dp[0][i]=1;
        }
    }else{
        dp[0][s[0]-'0']=1;
    }
    for(int i=1;i<SZ(s);i++){
        REP(j,13){
            if(s[i]=='?'){
                REP(k,10){
                    dp[i][(10*j+k)%13]+=dp[i-1][j];
                    dp[i][(10*j+k)%13]%=MOD;
                }
            }else{
                dp[i][(10*j+s[i]-'0')%13]+=dp[i-1][j];
                dp[i][(10*j+s[i]-'0')%13]%=MOD;
            }
        }
    }
    OUT(dp[SZ(s)-1][5]);
	return 0;
}

Measured memory_bytes: 5504
#include<cstdio>
#include<string.h>
#include<algorithm>
using namespace std;

int n;
int mat[100][100];
int rs[100], ct[100];

int main() {
  while(scanf("%d", &n), n) {
    memset(mat, 0, sizeof(mat)); memset(rs, 0, sizeof(rs)); memset(ct, 0, sizeof(ct));
    for(int i=0; i<n; ++i) {
      int shortest = 10000000;
      for(int j=0; j<n; ++j) {
        scanf("%d", &mat[i][j]);
        shortest = min(shortest, mat[i][j]);
      }
      rs[i] = shortest;
    }

    for(int i=0; i<n; ++i) {
      int tallest = 0;
      for(int j=0; j<n; ++j)
        tallest = max(tallest, mat[j][i]);
      ct[i] = tallest;
    }

    for(int i=0; i<n; ++i)
      for(int j=0; j<n; ++j)
        if(ct[i] == rs[j]) {
          printf("%d\n", ct[i]);
          goto NEXT;
        }
    printf("0\n");
  NEXT:
    ;
  }
}

Measured memory_bytes: 0
#include<iostream>
#include<string>
#include<set>
using namespace std;

int main(){
    int n;
    cin>>n;
    set<string> s;
    string v,w;
    for(int i=0;i<n;i++){
        cin>>v>>w;
        if(v=="insert"){
            s.insert(w);
        }
        else{
            if(s.count(w)){cout<<"yes"<<endl;}
            else{cout<<"no"<<endl;}
        }
    }
}


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

typedef pair<int,int> P;
#define ll long long
#define ld long double
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define sz(x) ((int)(x).size())
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n)
    {
        cin >> a[i];
    }
    deque<int> d;
    rep(i,n)
    {
        auto p = lower_bound(d.begin(), d.end(), a[i])-d.begin();
        if (p==0)
        {
            d.push_front(a[i]);
        }else
        {
            d[p-1] = a[i];
        }        
    }
    int ans = d.size();
    cout << ans << endl;
}

Measured memory_bytes: 1024
//https://atcoder.jp/contests/aising2019/tasks/aising2019_c
//C - Alternating Path
#include <bits/stdc++.h>
#if LOCAL
#include "dump.hpp"
#else
#define dump(...)
#endif
using namespace std;
using ll=long long;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
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;}

struct uf_tree {
    std::vector<int> parent;
    int __size;
    uf_tree(int size_) : parent(size_, -1), __size(size_) {}
    void unite(int x, int y) {
        if ((x = find(x)) != (y = find(y))) {
            if (parent[y] < parent[x]) std::swap(x, y);
            parent[x] += parent[y];
            parent[y] = x;
            __size--;
        }
    }
    bool is_same(int x, int y) { return find(x) == find(y); }
    int find(int x) { return parent[x] < 0 ? x : parent[x] = find(parent[x]); }
    int size(int x) { return -parent[find(x)]; }
    int size() { return __size; }
};

int main() {
#if LOCAL&01
    std::ifstream in("./test/sample-3.in"); //input.txt
    std::cin.rdbuf(in.rdbuf());
#else
    cin.tie(0);
    ios::sync_with_stdio(false);
#endif
    ll H,W; cin>>H>>W;
    vector<string> sh(H);
    for(auto&& s:sh){
        cin>>s;
    }
    ll n=H*W;

    uf_tree uft(n);
    auto idx = [&](ll x,ll y){
        return y*W+x;
    };
    auto getch = [&](ll x,ll y){
        return sh.at(y).at(x);
    };
    auto check_same = [&](ll x0,ll y0,ll x1,ll y1){
         return getch(x0,y0)==getch(x1,y1);
    };
    FOR(y,0,H){
        FOR(x,0,W){
            if (x+1<W && !check_same(x,y,x+1,y)) {
                uft.unite(idx(x,y), idx(x+1,y));
            }
            if (y+1<H && !check_same(x,y,x,y+1)) {
                uft.unite(idx(x,y),idx(x,y+1));
            }
        }
    }
    ll ans=0;
    ll b[n]={};
    ll w[n]={};
    FOR(y,0,H){
        FOR(x,0,W){
            auto p = uft.find(idx(x,y));
            if(getch(x,y)=='#'){
                ++b[p];
            }else{
                ++w[p];
            }
        }
    }
    REP(i,n){
        ans += b[i]*w[i];
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3584
import sys
import bisect
readline = sys.stdin.readline
N = int(readline())
L = list(map(int, readline().split()))
L.sort()

ans = 0
for i in range(N):
    for j in range(i, N):
        if i == j: continue
        ab = L[i] + L[j]
        to = bisect.bisect_left(L, ab, j, N)
        ans += to - 1 - j
print(ans)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define P pair<ll, ll>
#define PP pair<P,P>
using namespace std;
vector<vector<int> > ki;
vector<int> pat;
vector<int> visited;
vector<int> p;

int pt(int now){
    visited[now]++;
    if(!ki[now].size()){
        pat[now]=0;
        return 0;
    }
    int tmp=0;
    rep(i,ki[now].size()){
        if(visited[ki[now][i]]) continue;
        p[ki[now][i]]=now;
        tmp=max(pt(ki[now][i])+1,tmp);
    }
    pat[now]=tmp;
    return pat[now];
}

int main(){
  	int n,u,v; cin >> n >> u >> v;
    u--; v--;
    ki.resize(n);
    pat.resize(n);
    visited.resize(n);
    p.resize(n);
    rep(i,n-1){
        int a,b; cin >> a >> b;
        a--; b--;
        ki[a].push_back(b);
        ki[b].push_back(a);
        visited[i]=0;
    }
    int d=pt(v);
    int dis=0;
    int tmpu=u;
    while(tmpu!=v){
        tmpu=p[tmpu];
        dis++;
    }
    int md=0;
    tmpu=u;
    int nowdis=dis;
    rep(i,((dis-1)/2)+1){
        if(md<=pat[tmpu]+nowdis-1+i){
            md=pat[tmpu]+nowdis-1+i;
        }
        tmpu=p[tmpu];
        nowdis-=2;
    }
    cout << md << endl;



return 0;
}




Measured memory_bytes: 10752
n = int(input())
h = list(map(int, input().split()))
max = 0
pre = h[0]
c = 0
for i in range(1, n):
    if pre >= h[i]:
        c += 1
    else:
        if max < c:
            max = c
        c = 0
    pre = h[i]
if max < c:
    max = c
print(max)

Measured memory_bytes: 14252
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using V = vector<int>;
using VV = vector<V>;
using VVV = vector<VV>;
using VL = vector<ll>;
using VVL = vector<VL>;
using VVVL = vector<VVL>;
template<class T> using VE = vector<T>;
template<class T> using P = pair<T, T>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,k,n) for(int i=(k);i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define output(x,y) cout << fixed << setprecision(y) << x << endl;
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; }
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; }
// const ll MOD = 1e9 + 7;
const ll MOD = 998244353;
ll upper = MOD + MOD;
ll under = -upper;
ll UPPER = MOD * MOD;
ll UNDER = -UPPER;
const long double pi = 3.141592653589793;
int main(){
	int n;
	cin >> n;
	set<int> st;
	rep(i, n) {
		int x;
		cin >> x;
		st.insert(x);
	}
	cout << st.size() << endl;
	return 0;
}

Measured memory_bytes: 3636
N=int(input())
V=list(map(int,input().split()))

V.sort()
#print(V)
tmp = 0.0
for i,v in enumerate(V):
    if i == 0:
        tmp = v
    else:
        tmp = (v + tmp) / 2.0
#    print(str(i)+','+str(v)+','+str(tmp))

print(tmp)

Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int i=(int)(m);i<(int)(n);++i)
#define rREP(i,m,n) for(int (i)=(n)-1; (i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;

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;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int main() {
	init();
	
	int N, K; cin >> N >> K;
	vector<ll>west, east;
	rep(i, 0, N) {
		int a; cin >> a;
		if (a < 0)west.push_back(abs(a));
		else east.push_back(a);
	}
	sort(all(west));
	ll ans = (ll)1e18;
	if (west.size() == 0) {
		ans = east[K - 1];
	}
	else if (east.size() == 0) {
		ans = west[K - 1];
	}
	else {
		rep(i, 0, min(K, (int)west.size()) + 1) {
			if (i == 0) {
				int j = K - 1;
				if (j > east.size() - 1)continue;
				else chmin(ans, east[j]);
			}
			else {
				int j = K - i - 1;
				if (j > east.size()-1)continue;
				else {
					ll w = west[i - 1], e = east[j];
					ll cnt = min(w * 2 + e, e * 2 + w);
					chmin(ans, cnt);
				}
			}
		}
	}
	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 1656
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <limits.h>
#include <math.h>

void search(int b[1000][1000], char c[1000][1000], int h, int w, int x, int y)
{

    int orig = b[y][x];
    int dx, dy;

    // down
    for (dy = 1; y + dy < h; dy++) {
        if (b[y + dy][x] > orig + dy) {
            b[y + dy][x] = orig + dy;
            c[y + dy][x] = 1;
        } else {
            break;
        }
    }
    // up
    for (dy = -1; y + dy >= 0; dy--) {
        if (b[y + dy][x] > orig - dy) {
            b[y + dy][x] = orig - dy;
            c[y + dy][x] = 1;
        } else {
            break;
        }
    }
    // right
    for (dx = 1; x + dx < w; dx++) {
        if (b[y][x + dx] > orig + dx) {
            b[y][x + dx] = orig + dx;
            c[y][x + dx] = 1;
        } else {
            break;
        }
    }
    // left
    for (dx = -1; x + dx >= 0; dx--) {
        if (b[y][x + dx] > orig - dx) {
            b[y][x + dx] = orig - dx;
            c[y][x + dx] = 1;
        } else {
            break;
        }
    }
    


    return;
}

int main(int argc, char *argv[])
{
    int h, w;
    char a[1000][1001];
    int b[1000][1000];
    char c[1000][1000]; // need search
    int i, j;
    int x, y;
    int cnt;
    int max;

    scanf("%d %d", &h, &w);

    for (i = 0; i < h; i++) {
        scanf("%s", a[i]);
    }

    for (y = 0; y < h; y++) {
        for (x = 0; x < w; x++) {
            if (a[y][x] == '#') {
                b[y][x] = 0;
                c[y][x] = 1;
            } else {
                b[y][x] = INT_MAX;
                c[y][x] = 0;
            }
        }
    }

    do
    {
        cnt = 0;

        for (y = 0; y < h; y++) {
            for (x = 0; x < w; x++) {
                if (c[y][x] == 1) {
                    c[y][x] = 0;
                    search(b, c, h, w, x, y);
                    cnt++;
                }
            }
        }
    } while (cnt);

    max = 0;
    for (y = 0; y < h; y++) {
        for (x = 0; x < w; x++) {
            if (max < b[y][x]) {
                max = b[y][x];
            }
        }
    }

    printf("%d\n", max);


    return 0;
}


Measured memory_bytes: 6016
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		int Y = sc.nextInt();
		int Z = sc.nextInt();
		sc.close();

		System.out.println(Z + " " + X + " " + Y);
	}
}


Measured memory_bytes: 22100
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    int a,b,c,k;
    cin>>a>>b>>c>>k;
    rep(i,k){
        if(a>=b) b=b*2;
        else if(b>=c)c=c*2;
    }
        if(a<b&&b<c) cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
}

Measured memory_bytes: 3644
#include <stdio.h>

int main(void){
  int S,h,m,s;
  scanf("%d",&S);
  h=S/3600;
  m=(S-3600*h)/60;
  s=S-(h*3600+m*60);
  printf("%d:%d:%d\n",h,m,s);
  
  return 0;
}

Measured memory_bytes: 592
#include <iostream>

using namespace std;

int main()

  {

  string s;

  cin>>s;

  if(s=="SUN") 

    {cout<<7;

  }

  else if(s=="MON") 

    {cout<<6;

  }

  else if(s=="TUE") 

    {cout<<5;

  }

  else if(s=="WED") 

    {cout<<4;

  }

  else if(s=="THU") 

    {cout<<3;

  }

  else if(s=="FRI") 

    {cout<<2;

  }

  else if(s=="SAT") 

    {cout<<1;

  }

return 0;

}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;
ll k,sum;
vector<vector<ll> > mul(vector<vector<ll> > v1, vector<vector<ll> > v2){
    vector<vector<ll> > res(k,vector<ll> (k));
    for(int i=0;i<k;i++){
        for(int j=0;j<k;j++){
            sum=0;
            for(int n=0;n<k;n++){
                sum+=(v1[i][n]*v2[n][j])%mod;
            }
            res[i][j]=sum%mod;
        }
    }
    return res;
}

vector<vector<ll> > matpow(vector<vector<ll> > a,ll n) {
    vector<vector<ll> > res(k,vector<ll> (k,0));
    for(int i=0;i<k;i++){
        res[i][i]=1;
    }
    while(n>0) {
        if (n&1)res=mul(res,a);
        a=mul(a,a);
        n>>=1;
    }
    return res;
}
int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>k>>n;
    vector<vector<ll> > v(k,vector<ll> (k));
    for(int i=0;i<k;i++){
    	for(int j=0;j<k;j++){
    		cin>>v[i][j];
    	}
    }
    v=matpow(v,n);
    ll ans=0;
    for(int i=0;i<k;i++){
    	for(int j=0;j<k;j++){
    		ans+=v[i][j];
    		ans%=mod;
    	}
    }
    cout << ans<<endl;
    return 0;
}


Measured memory_bytes: 384
n=int(input())
dic={"M":0,"A":0,"R":0,"C":0,"H":0}
check=["M","A","R","C","H"]

for i in range(n):
  s=input()
  if s[0] in check:
    dic[s[0]]+=1

ans=0
for i in range(3):
  for j in range(i+1,4):
    for k in range(j+1,5):
      ans+=dic[check[i]]*dic[check[j]]*dic[check[k]]
      
print(ans)



Measured memory_bytes: 74176
import java.util.Scanner;

class Main{
        public static void main(String[] args){
                Scanner scanner=new Scanner(System.in);
                String s=scanner.next();
                String l="";
                for(int i=0;i<s.length();i+=2){
                        System.out.print(s.charAt(i));
                }
                System.out.println();
        }
}

Measured memory_bytes: 29276
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n) ; ++i)
#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define emb emplace_back

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

template<typename T> void pv(vector<T> vec) {
  cout << "[";
  for(auto& v : vec) { cout << v << ","; }
  cout << "]" << endl;
}

template<>
void pv(vector<P> vec) {
  cout << "[";
  for(auto& v : vec) {
    cout << "<" << v.fi << ","<< v.se << ">" << ",";
  }
  cout << "]" << endl;
}

int main() {
  string s,r;
  cin >> s;
  int n = s.length();
  r = s;
  reverse(all(r));
  if(r != s) {
    cout << "No" << endl;
    return 0;
  }
    string f,b;
    f = s.substr(0,(n-1)/2);
    b = s.substr((n+1)/2,(n-1)/2);
    string fr = f;
    reverse(all(fr));
    string br = b;
    reverse(all(br));
    if(fr != f) {
      cout << "No" << endl;
      return 0;
    }
    if(br != br)
    {
      cout << "No" << endl;
      return 0;
}

cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
function bomb(x,y,z){
   max=Math.max(max,z);
   if(max==n)return;
   var dx=[-1,0,1,-2,2,-2,2,-2,2,-1,0,1];
   var dy=[-2,-2,-2,-1,-1,0,0,1,1,2,2,2];
   var Safe={};
   for(var i=-1;i<=1;i++){
      for(var j=-1;j<=1;j++){
         Safe[(water[z*2]+i)+" "+(water[z*2+1]+j)]=true;
      }
   }
   for(var i=0;i<12;i++){
      var xx=x+dx[i];
      var yy=y+dy[i];
      if(xx<0 || yy<0 || xx>=10 || yy>=10)continue;
      if(Safe.hasOwnProperty(xx+" "+yy))bomb(xx,yy,z+1);
   }
}
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.trim()).split("\n");
while(true){
   var xy=(Arr.shift()).split(" ").map(Number);
   if(xy[0]==0 && xy[1]==0)break;
   var n=Arr.shift()-0;
   var water=(Arr.shift()).split(" ").map(Number);
   var max=0;
   bomb(xy[0],xy[1],0);
   console.log((max==n)?"OK":"NA");
}

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

int main() {
    int n,q;
    cin >> n >> q;
    vector<priority_queue<int>> Q(n);
    while (q--) {
        int code;
        cin >> code;
        switch (code) {
            case 0: {
                int t,x;
                cin >> t >> x;
                Q[t].push(x);
            } break;
            case 1: {
                int t;
                cin >> t;
                if (Q[t].size()) cout << Q[t].top() << endl;
            } break;
            case 2: {
                int t;
                cin >> t;
                if (Q[t].size()) Q[t].pop();
            } break;
            default : break;
        }
    }
    
}



Measured memory_bytes: 4072
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
int N;
int minDif = INT_MAX;
int ans = N;
void gen(vector<int> like, int depth, int cur){
    if(depth==0){
       // cout << cur <<  " "<< N << "\n";
        if((cur-N)>=0 && (cur-N)<minDif){
            minDif = (cur-N);
            ans = cur;
        }
        return;
    }else{
        for(int i = 0; i < like.size(); i++){
            int val = cur+pow(10, depth-1)*like[i];
            gen(like, depth-1, val);
        }
    }
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int K;
    vector <int> like;
    int digits[10] = {0};
    cin >> N >> K;
    for(int i = 0; i < K; i++){
        int a;
        cin >> a;
        digits[a] = -1;
    }
    for(int i = 0; i < 10; i++){
        if(digits[i]!=-1){
            like.push_back(i);
        }
    }  
   for(int i = 1; i <= 5; i++){
       gen(like, i, 0);
   }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = m; i < (n); i++)
#define RFOR(i, m, n) for (int i = (m - 1); i >= 0; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;

int main() {
  int n;
  cin >> n;
  if (n == 1) {
    cout << 1 << endl;
    return 0;
  } else if (n % 2 == 0) {
    cout << 0.5 << endl;
  } else {
    cout << (double((n / 2) + 1) / n) << endl;
  }

  return 0;
}

Measured memory_bytes: 256
from collections import deque
H, W = [int(i) for i in input().split()]
Shw = [[0 if i =="." else 1 for i in input()] for _ in range(H)]

changes = [[-1 for _ in range(W)] for _ in range(H)]

for j in range(H):
  for i in range(W):
    current = Shw[j][i]
    if i == 0 and j ==0:
      changes[j][i] = current
    elif i == 0:
      changes[j][i] = changes[j-1][i] + (1 if current == 1 and Shw[j-1][i] == 0 else 0)
    elif j == 0:
      changes[j][i] = changes[j][i-1] + (1 if current == 1 and Shw[j][i-1] == 0 else 0)
    else:
      upper = changes[j-1][i] + (1 if current == 1 and Shw[j-1][i] == 0 else 0)
      lower = changes[j][i-1] + (1 if current == 1 and Shw[j][i-1] == 0 else 0)
      changes[j][i] = min(upper, lower)
      
print(changes[-1][-1])
    


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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

template<typename H> bool chmin(H& v1, const H v2) { if (v1 > v2) { v1 = v2; return true; } return false; }
template<typename H> bool chmax(H& v1, const H v2) { if (v1 < v2) { v1 = v2; return true; } return false; }
template<typename H> void read(H& head) { cin >> head; }
template<typename H, typename ...T> void read(H& head, T& ...tail) { cin >> head; read(tail...); }
template<typename H> void write(H head) { cout << head << '\n'; }
template<typename H, typename ...T> void write(H head, T ...tail) { cout << head << " "; write(tail...); }
template<typename ...T> void die(T ...tok) { write(tok...); exit(0); }

vector<ll> factors;
map<ll, ll> dp[40];

const ll mod = 1'000'000'007;
const ll bm(ll b, ll p, ll m) {
	ll r = 1;
	for (; p; p >>= 1, b = b * b % m) if (p & 1) r = r * b % m;
	return r;
}

const ll modinv(ll x) { return bm(x, mod - 2, mod); }

ll fact[200005];

const ll ncr(const ll n, const ll r) {
	return fact[n] * modinv(fact[n - r]) % mod * modinv(fact[r]) % mod;
}

int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(cin.failbit);

	fact[0] = 1;
	rep(i, 1, 200005)
		fact[i] = fact[i - 1] * i % mod;

	int n, m; read(n, m);

	if (m == 1) die(1);

	for (int i = 1; i * i <= m; i++) {
		if (m % i == 0) {
			if (i != 1) factors.push_back(i);
			if (i * i != m) factors.push_back(m / i);
		}
	}

	sort(all(factors));

	dp[0][1] = 1;
	rep(i, 0, 40) {
		for (auto p : dp[i]) {
			for (auto f : factors) {
				if (m % (p.first * f) == 0) {
					(dp[i + 1][p.first * f] += p.second) %= mod;
				}
			}
		}
	}

	ll ans = 0;
	rep(i, 1, min(40, n + 1)) {
		ans = (ans + dp[i][m] * ncr(n, i)) % mod;
	}
	die(ans);
}


Measured memory_bytes: 2304
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;

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; }
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};

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

struct Edge{int to,weight; Edge(int t, int w) : to(t), weight(w) {}};
using DirectedGraph = vector<vector<Edge>>;
using UndirectedGraph = vector<vector<int>>;

vector<int> color;

bool dfs(const UndirectedGraph &G,int v,int cur=0){
    color[v]=cur;
    for(auto next:G[v]){
        if(color[next] != -1){
            if(color[next]==cur) return false;
            continue;
        }
        if(!dfs(G,next,1-cur)) return false;
    }
    return true;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N,M;
    cin>>N>>M;
    UndirectedGraph G(N);
    REP(i,M){
        int a,b;
        cin>>a>>b;
        --a,--b;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    color.assign(N,-1);
    bool is_bipartite=true;
    REP(v,N){
        if(color[v]!=-1) continue;
        if(!dfs(G,v)) is_bipartite = false;
    }
    if(is_bipartite){
        ll b=0,w=0;
        REP(i,N){
            if(color[i]==1) b++;
            else w++;
        }
        cout<<b*w - M<<endl;
    }
    else{
        cout<<N*(N-1)/2 - M<<endl;
    }
}


Measured memory_bytes: 6528
def solve(N):
    for h in range(1, 3501):
        for n in range(1, 3501):
            v1 = 4*h*n-N*(h+n)
            v2 = N*h*n
            if v1>0 and v2>0 and v2%v1==0:
                return h, n, v2//v1

N = int(input())
h, n, w = solve(N)
print(h, n, w)


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

int a[3][3];
int n, b;
bool f[3][3] = { {0, 0, 0}, {0, 0, 0}, {0, 0, 0} };
bool g = 0;

int main()
{
	for(int i = 0; i < 3; i++)
		for(int j = 0; j < 3; j++)
			cin >> a[i][j];

	cin >> n;

	for (int k = 0; k < n; k++) {
		cin >> b;

		for (int i = 0; i < 3; i++)
			for (int j = 0; j < 3; j++)
				if (a[i][j] == b)
					f[i][j] = 1;

		for (int i = 0; i < 3; i++) {
			if (f[i][0] && f[i][1] && f[i][2])
				g = 1;

			if (f[0][i] && f[1][i] && f[2][i])
				g = 1;
		}

		if (f[0][0] && f[1][1] && f[2][2])
			g = 1;

		if (f[2][0] && f[1][1] && f[0][2])
			g = 1;
	}

	if (g)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}


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

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true) {
			String cards = sc.nextLine();
			if (cards.equals("-")) {
				break;
			}
			String[] cds = cards.split("");
			int cdlength = cards.length();
			String[] cds2 = new String[cdlength];
			int repeat = Integer.parseInt(sc.nextLine());
			for (int i = 0; i < repeat; i++) {
				int shuffle = Integer.parseInt(sc.nextLine());
				if (i % 2 == 0) {
					for (int j = 0, k = shuffle; j < cdlength; j++, k++) {
						if (k == cdlength) {
							k  =0;
						}
						cds2[j] = cds[k];
					}
				} else {
					for (int j = 0, k = shuffle; j < cdlength; j++, k++) {
						if (k == cdlength) {
							k = 0;
						}
						cds[j] = cds2[k];
					}
				}
			}
			StringBuilder after = new StringBuilder();
			if (repeat % 2 == 0) {
				for (int i = 0; i < cdlength; i++) {
					after.append(cds[i]);
				}
			} else {
				for (int i = 0; i < cdlength; i++) {
					after.append(cds2[i]);
				}
			}
			System.out.println(after.toString());
		}
	}
}

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()

using namespace std;

typedef long long ll;

bool binarySearch(int A[], int n, int key) {
    int left = 0;
    int right = n;
    int mid = -1;

    while (left < right) {
        mid = (left+right) / 2;
        if (A[mid] == key) return true;
        else if (A[mid] > key) right = mid;
        else left = mid+1;
    }
    return false;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n; cin >> n;
    
    int A[n];
    REP(i, n) cin >> A[i];

    int q; cin >> q;
    int ans = 0;
    REP(i, q) {
        int key;
        cin >> key;
        if (binarySearch(A, n, key)) ++ans;
    }

    cout << ans << "\n";
} 


Measured memory_bytes: 3460
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)

int main(){
	string table[] = {"0111111","0000110","1011011","1001111","1100110","1101101","1111101","0100111","1111111","1101111"};
	int n;
	while(cin >> n , ~n){
		string cur = "0000000";
		rep(i,n){
			int number; cin >> number;
			rep(i,7)cout << (cur[i] != table[number][i]);
			cout << endl;
			cur = table[number];
		}
	}
}

Measured memory_bytes: 0
from itertools import groupby
S = list(input())
K = int(input())
newS = list([list(g) for k, g in groupby(S)])
change = 0
for i in range(len(newS)):
    change += len(newS[i])//2
chain = 0
if len(newS) == 1:
    print(K*len(S)//2)
else:
    if len(newS) > 2 and newS[0] == newS[len(newS)-1]:
        chain = 1
    print(change*K+chain*(K-1))

Measured memory_bytes: 38384
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7

a = LIST()
a.sort()
if a[0] + a[1] == a[2]:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 61676
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
const int MX = 200005;
 
 
 
int main() {
    int n;
    scanf("%d",&n);

    int a[1000] = {};

    rep(i,n){
        int aa;
        scanf("%d",&aa);
        a[i] = aa;
    }

    int ans = 0;

    int max = 0;

    rep(i,n){
        ans += a[i];
        if(max<a[i]){
            max=a[i];
        }
    }

    max = max /2;
    ans = ans - max;

    cout << ans << endl;
   
    return 0;
}
 
 

Measured memory_bytes: 256
import java.util.*;

// UVa 11504

public class Main {

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

		int x = in.nextInt();
		int sum = 0;
		int t = 0;
		
		while (sum < x) {
			sum += t;
			t++;
		}
		System.out.println(t - 1);
	}
}


Measured memory_bytes: 22868
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <map>
using namespace std;

typedef long long i64;
typedef pair <i64, i64> pi64;
const int MOD = 1e9 + 7;

i64 N;
map <i64, i64> dp;

i64 getDP(i64 x)
{
    if(dp[x])
        return dp[x];
    dp[x] = (getDP(x / 2) + getDP((x - 1) / 2) + getDP((x - 2) / 2)) % MOD ;
    return dp[x];
}

int main()
{
    dp[0] = 1;
    dp[1] = 2;
    //cin >> N ;
    //cout << getDP(N) << endl ;
    scanf("%lld", &N);
    printf("%lld\n", getDP(N));
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#include <math.h>
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
#define INF 999999999
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

using llong = long long;
using namespace std;

int main(){
    int h,w,k,ans=0;
    char c[10][10];
    cin >> h >> w >> k;
    rep(i,h) cin >> c[i];
    
    for(int bith=0;bith < (1<<h); bith++){
        for(int bitw=0;bitw < (1<<w);bitw++){
            int brack=0;
            rep(i,h) if(((bith>>i) & 1) == 0){
                rep(j,w) if(((bitw>>j) & 1) == 0){
                    if(c[i][j] == '#') brack++;
                }
            }
            if(brack == k) ans++;
        }
    }
    
    cout << ans << endl;
    
}

Measured memory_bytes: 3632
A1=list(map(int,input().split()))
A2=list(map(int,input().split()))
A3=list(map(int,input().split()))
N=int(input())
for i in range(N):
    B=int(input())
    for j in range(3):
        if B==A1[j]:
            A1[j] = 0
        if B==A2[j]:
            A2[j] = 0
        if B==A3[j]:
            A3[j] = 0
bingo = 0
if (sum(A1) == 0) | (sum(A2) == 0) | (sum(A3) == 0):
    bingo = 1
if (A1[0]+A2[0]+A3[0] == 0) | (A1[1]+A2[1]+A3[1] == 0) | (A1[2]+A2[2]+A3[2] == 0):
    bingo = 1
if (A1[0]+A2[1]+A3[2] == 0) | (A1[2] + A2[1] + A3[0] == 0):
    bingo = 1
if bingo == 1:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
from collections import defaultdict

H, W, N = map(int, input().split())

mem = defaultdict(int)
for _ in range(N) :
    a, b = map(int, input().split())
    for i in range(max(1, a-1), min(H, a+1)+1) :
        for j in range(max(1, b-1), min(W, b+1)+1) :
            mem[(i, j)] += 1
            
ret = [0] * 10
for k, v in mem.items() :
    if 2 <= k[0] <= H - 1 and 2 <= k[1] <= W - 1 :
        ret[v] += 1

ret[0] = (H - 2) * (W - 2) - sum(ret)
 
for r in ret :
    print(r)


Measured memory_bytes: 181592
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int dp[3005][3005];
int main(){
string s, t;
cin >> s >> t;
int n = s.length();
int m = t.length();

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][j-1], dp[i-1][j]);
            }
        }
    }
}
string ans = "";
int i=n, j = m;
//cout << s[i-1] << " " <<t[j-1] <<endl;
while(i>0 && j>0){
    if(s[i-1]==t[j-1]) { ans = ans + s[i-1]; i--, j--;}
    else{
        if(dp[i-1][j]>dp[i][j-1]){
            i--;
        }
        else {
            j--;
        }
    }
}
reverse(ans.begin(), ans.end());
cout << ans;
return 0;
}


Measured memory_bytes: 38744
N=list(map(str,input()))
ketasu=len(N)
def dfs(siki,sitei):
    if sitei == ketasu-1 :    
        if eval(siki)==7:
            print(siki+"=7")
            exit()
            return
    else:
        dfs(siki+"+"+N[sitei+1],sitei+1)
        dfs(siki+"-"+N[sitei+1],sitei+1)

dfs(N[0],0)

Measured memory_bytes: 61852
#include<stdio.h>

int main(void)
{
	int n, a[1000], i,sa, min, j;

	while(1){
		scanf("%d\n", &n);

		min = 10000000;
		if(n==0) break;

		for(i=0; i<n; i++){
			scanf("%d\n", &a[i]);
		}
		for(j=0; j<n; j++){
			for(i=j+1; i<n; i++){
				sa=a[i]-a[j];

				if(sa<0)
					sa=-sa;


				if(min>sa)
					min = sa;

			}
		}
		printf("%d\n", min);
	}
	return 0;
}

Measured memory_bytes: 608
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
//typedef pair<int,int> P;
//typedef pair<ll, ll> P;
//typedef pair<int, pair<int, int>> P;
//typedef pair<ll, pair<int, int>> P;
typedef pair<ll,pair<ll,ll>> T;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 2147483600;//10^9
int INFM =100000000;
ll MOD  = 1000000007;


int main(){
    ll N, M;
    cin >> N;
    M = N;
    ll digit = 0;
    while(N > 0){
        digit += N % 10;
        N /= 10;
    }
    if(M % digit){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }
    
}


Measured memory_bytes: 256
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto K = readln.split[3].to!int;
    auto as = readln.split.to!(long[]);
    auto bs = readln.split.to!(long[]);
    auto cs = readln.split.to!(long[]);

    long[] ss, ts;
    foreach (a; as) {
        foreach (b; bs) {
            ss ~= a + b;
        }
    }
    sort!"a > b"(ss);
    ss = ss[0..min($, K)];
    foreach (c; cs) {
        foreach (s; ss) {
            ts ~= c + s;
        }
    }
    sort!"a > b"(ts);
    foreach (t; ts[0..min($, K)]) writeln(t);
}

Measured memory_bytes: 59516
#define _USE_MATH_DEFINES
#include <iomanip>
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <tuple>
#include <climits>
#include <algorithm>
#include <cmath>
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<double> VD;
typedef vector<LL> VLL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef vector<vector<long long>> VVLL;
typedef vector<vector<bool>> VVB;
typedef vector<vector<double>> VVD;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(a) (a).begin(),(a).end()

const int MOD = 1000000007;

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

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

void debug(VI &arr){
	int n=arr.size();
	rep(i,n){
		cout<<arr.at(i)<<endl;
	}
}

void debug(VVI &board){
	int h = board.size();
	int w = board.at(0).size();
	rep(i,h){
		rep(j,w){
			cout << board.at(i).at(j) << " ";
		}
		cout<<endl;
	}
}

void debug(VVLL &board){
	int h = board.size();
	int w = board.size();
	rep(i,h){
		rep(j,w){
			cout<<board.at(i).at(j)<<" ";
		}
		cout<<endl;
	}
}

LL gcd(LL a,LL b){
	return b==0?a:gcd(b,a%b);
}

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

int main(){
	//cout<<fixed;
	//cout<<setprecision(9)<<...
	string s;cin>>s;
	int n = s.size();
	int ans=0;
	rep(i,n/2){
		if(s.at(i)!=s.at(n-1-i))ans++;
	}
	cout<<ans<<endl;
	return 0;
}


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

int main() {
  int n, ans = 1000000000;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a.at(i);
  }
  for (int i = -100; i <= 100; i++) {
    int s = 0;
    for (int j = 0; j < n; j++) {
      s += (a.at(j) - i) * (a.at(j) - i);
    }
    ans = min(ans, s);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
sp = [list(map(int, input().split())) for i in range(N)]
cp = [list(map(int, input().split())) for i in range(M)]

def mah(p1, p2):
    return abs(p1[0] - p2[0]) + abs(p1[1] - p2[1])

sci = []

for i in range(N):
    mindis = 0
    minind = 0
    for j in range(M):
        m = mah(sp[i], cp[j])
        if j == 0 or mindis > m:
            mindis = m
            minind = j
    sci.append(minind+1)

print('\n'.join(map(str, sci)))

Measured memory_bytes: 39664
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb(x) push_back(x)
#define PI pair<int,int>
#define PL pair<long int,long int>
#define PLL pair<ll,ll>
#define Tcase int t;cin>>t;while(t--)   
int main(){
	int s,w;
  cin>>s>>w;
  if(w>=s)
    cout<<"unsafe"<<"\n";
  else
    cout<<"safe"<<"\n";
return 0;
}

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

const int N = 2e4 + 5;

const int MAX = 3e4;

int n, m, x, y;

vector <int> ans;

main() {
  cin >> n;
  if(n == 3) {
	puts("2 5 63");
	return 0;
  }
  else {
	ans.clear();
	ans.push_back(2);
	ans.push_back(3);
	ans.push_back(4);
	ans.push_back(9);
	for(int i = 15; i <= MAX; i += 12) {
	  if(i + 6 <= MAX) {
		if(ans.size() < n - 1) ans.push_back(i), ans.push_back(i + 6);
	  }
	}
	for(int i = 8; i <= MAX; i += 6)  {
	  if(i + 2 <= MAX) {
		if(ans.size() < n - 1) ans.push_back(i), ans.push_back(i + 2);
	  }
	}
	for(int i = 6; i <= MAX; i += 6) {
	  if(ans.size() < n) ans.push_back(i);
	}
	sort(ans.begin(), ans.end());
	for(auto V : ans) printf("%d ", V);
  }
}


Measured memory_bytes: 512
// <------------- Template -----------------------> //


#include<bits/stdc++.h>
using namespace std;

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(2);
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';
#define N 1000000007 // prime modulo value 
 
typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll , ll> 			pll;
typedef pair<ld, ld> 			pld;
typedef unordered_map<ll, ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	1e+5 + 7;
const ll 	MAX7 	= 	1e+7 + 7;
const ll 	MAXN 	= 	2 * 1e18;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e+9 + 7;

vll adj[MAX5]; ll visit[] = {};

// <------------- Declare Variables Here ------------> //

ll T = 1;
ll n, x, y, q, m;
string s, t, d;
ll sum = 0;
ll cou = 0;


// <------------- Implement Functions Here ----------> //



// <------------- Start of main() -------------------> //

void MAIN() {
	cin >> n;
	vll ans(n);
	vpll a(n+1);
	a[0] = {0,0};
	for(ll i=1;i<=n;i++) cin>>x, a[i]={x,i};
	sort(all(a));
	for(ll i=1;i<=n;i++) {
		if(2*i<=n) {
			ans[a[i].s-1] = a[n/2+1].f;
		}		
		else {
			ans[a[i].s-1] = a[n/2].f;
		}
	}
	for(ll i=0;i<n;i++) {
		cout<<ans[i];newl;
	}
}

int main() {
	fastio; randomINT;
	//cin>>T;
	while (T--) {
		MAIN();
	}
	return 0;
}


Measured memory_bytes: 10356
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int n, p[100];
	int count = 0;
	cin >> n;
	for (int i = 0; i < n; i++){
		cin >> p[i];
	}

	for (int i = 1; i < n - 1; i++){
		if (p[i - 1]<p[i] && p[i + 1]>p[i]){
			count++;
		}
		else if (p[i - 1]>p[i] && p[i + 1] < p[i]){
			count++;
		}
	}


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

Measured memory_bytes: 256
L, R = map(int, input().split())

m = 2019
if R-L>=2018:
  for i in range(2019):
    for j in range(i+1,2019):
      m = min(m,i*j%2019)
else:
  for i in range(L,R+1):
    for j in range(i+1,R+1):
      m = min(m,i*j%2019)
  
print(m)

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

int main() {
  int n, flag;
  cin >> n;
  for (int i = n; i <= 100003; i++) {
    flag = 1;
    for (int j = 2; j * j <= i; j++) {
      if (i % j == 0) {
        flag = 0;
        break;
      }
    }
    if (flag) {
      cout << i << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
   string a;
   string b;
   cin>>a;
   cin>>b;
   int c = 0;
   for(int i = 0;i<a.size();i++)
   {
       if(a[i]!=b[i])
        c++;
   }
   cout<<c;

}


Measured memory_bytes: 3868