akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ; //何もしない文
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size()) //unsignedのサイズをint型に変換
#define pb push_back

typedef long long LL; 
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);	
    int N; cin >> N;
    vector<pair<LL,LL>> ab(N);
    REP(i,N)
    {
        LL ta,tb; cin >>ta>>tb;
        ab[i] = make_pair(ta,tb);
    }
    sort(ab.begin(), ab.end());
    reverse(ab.begin(), ab.end());
    LL xa = ab[0].first;
    LL xb = ab[0].second;

    cout << xa+xb << endl;


}


Measured memory_bytes: 1792
#include <iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<string>
#include<map>
#include<queue>
using namespace std;

int main() {
	int n;
	cin >> n;
	int ans = 0;
	for (int i = 0; i < 9; i++) {
		for (int j = 0; j < 9; j++) {
			if (n == (i + 1) * (j + 1)) {
				ans++;
			}
		}
	}
	if (ans == 0) {
		cout<<"No"<<endl;
	}
	else {
		cout<<"Yes"<<endl;
	}
}

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

const int NMAX = 110;
const int WMAX = 100010;
long long dp[NMAX][WMAX] = {0};

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

    int weight[NMAX], value[NMAX];
    for (int i = 0; i < N; ++i) cin >> weight[i] >> value[i];

    for (int i = 0; i < N; ++i) {
        for (int j = 0; j <= W; ++j) {
            dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
            if (j >= weight[i]) dp[i + 1][j] = max(dp[i + 1][j], dp[i][j - weight[i]] + value[i]);
        }
    }

    cout << dp[N][W] << endl;
    return 0;
}

Measured memory_bytes: 79360
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
#define int long long
#define ull unsigned long long
#define ld long double
#define rep(a) rep1(i,a)
#define rep1(i,a) rep2(i,0,a)
#define rep2(i,b,a) for(int i=(b); i<((int)(a)); i++)
#define rep3(i,b,a) for(int i=(b); i>=((int)(a)); i--)
#define all(a) a.begin(),a.end()
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define sz(a) ((int)a.size())
#define pow2(x) (1ll<<(x))
#define ceiling(a,b) (((a)+(b)-1)/(b))
#define print0(a) cout << (a) << ' '
#define print1(a) cout << (a) << '\n'
#define print2(a,b) cout << (a) << ' ',print1(b)
#define print3(a,b,c) cout << (a) << ' ',print2(b,c)
#define print4(a,b,c,d) cout << (a) << ' ',print3(b,c,d)
#ifdef i_am_noob
#define debug(a) print2(#a,a)
#else
#define debug(a) 
#endif
#define ordered_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
 
using namespace std;
using namespace __gnu_pbds;
 
const int Mod=1000000007,Mod2=998244353;
const int MOD=Mod2;
 
inline int add(int a, int b){return (a+b>=MOD?a+b-MOD:a+b);}
inline int sub(int a, int b){return (a+MOD-b>=MOD?a-b:a+MOD-b);}
int Pow(int a, int b){
	if(!b) return 1;
	int tmp=Pow(a*a%MOD,b>>1);
	return (b&1?tmp*a%MOD:tmp);
}
inline int inverse(int n){return Pow(n,MOD-2);}

const int maxn=100005;
//i_am_noob
int a,b;

signed main(){
	ios_base::sync_with_stdio(0),cin.tie(0);
	cin >> a >> b;
	print1(a+b/2);
	return 0;
}


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

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

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;


//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}


int main(){
  string s;
  string rmX = "";
  VI indexRmX;
  cin >> s;
  rep(i,s.size()) if( s[i] != 'x' ) {
    rmX += s[i];
    indexRmX.push_back(i);
  }
  if(rmX == ""){
    cout << 0 << endl;
    return 0;
  }
  rep(i,rmX.size()/2){
    if(rmX[i] == rmX[rmX.size()-1-i]) continue;
    else{
      cout << -1 << endl;
      return 0;
    }
  }
  int rm_n =  rmX.size();
  int s_n = s.size();
  ll ans = 0;

  rep(i,rm_n/2){
    ans += abs((indexRmX[i+1] - indexRmX[i]) - (indexRmX[rm_n-1 - i] - indexRmX[rm_n-1 - i-1]));
    // cout << "[" << i <<" , " << i+1 << "]" << " , [" << rm_n-1 - i << " , " << rm_n-1 - i-1 << "]" << endl;
  }
  // cout << indexRmX[rm_n - 1] - (s_n - 1) << " , "<< indexRmX[0]<< endl;
  ans += abs(((s_n - 1)-indexRmX[rm_n - 1]) - indexRmX[0] );

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


Measured memory_bytes: 1148
H, W = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(H)]
path = []
for i in range(H * W):
    h = i // W
    w = i % W if h % 2 == 0 else (W - i % W - 1)
    path.append((h, w))

ans = []
for i in range(H * W - 1):
    p, n = path[i], path[i + 1]
    if A[p[0]][p[1]] % 2 == 1:
        A[p[0]][p[1]] -= 1
        A[n[0]][n[1]] += 1
        ans.append("{} {} {} {}".format(
            p[0] + 1, p[1] + 1, n[0] + 1, n[1] + 1))

print(len(ans))
for a in ans:
    print(a)


Measured memory_bytes: 41920
#include <iostream>
#include <vector>

using namespace std;

int n;
vector<int> A;

bool solve(int i, int m) {
    if (m == 0) {
        return true;
    }
    if (i >= n) {
        return false;
    }
    bool res = solve(i + 1, m) || solve(i + 1, m - A[i]);
    return res;
}

int main() {
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        int d;
        scanf("%d", &d);
        A.push_back(d);
    }
    int q;
    scanf("%d", &q);
    int m;
    for (int i = 0; i < q; i++) {
        scanf("%d", &m);
        if (solve(0, m)) {
            printf("yes\n");
        } else {
            printf("no\n");
        }
    }

    return 0;
}

Measured memory_bytes: 3192
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 2e5 + 5, mod = 1e9 + 7;


int a[N];

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n, k;
    cin >> n >> k;
    for(int i = 0; i < n; i++) cin >> a[i];
    sort(a, a + n);
    int ans = 0;
    for(int i = 0; i < k; i++) ans += a[i];
    cout << ans;

    return 0;
}



Measured memory_bytes: 3620
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from sys import stdin
import math

# 標準入力をスペースで区切って、intに変換 listに収納
int_list  = [int(x) for x in stdin.readline().rstrip().split()]

A = int_list[0]
B = int_list[1]

print(max(A+B,A-B,A*B))



Measured memory_bytes: 2940
N=int(input())
S=input()
R=[]
G=[]
B=[]

for n in range(N):
    if S[n]=="R":
        R.append(n)
    elif S[n]=="G":
        G.append(n)
    else:
        B.append(n)

ANS=len(R)*len(G)*len(B)

for i in range(N-2):
    for j in range(i+1,N-1):
        k=2*j-i
        if k<N and S[i]!=S[j] and S[j]!=S[k] and S[k]!=S[i]:
            ANS-=1


print(ANS)

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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007

typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;



int main() {
    li n;
    cin >> n;
    vector<li> p(n);
    vector<li> q(n);
    rin{
        cin >> p[i];
    }
    rin{
        cin >> q[i];
    }
    vector<li> perm(n);
    rin{
        perm[i] = i + 1;
    }
    li pp = -1;
    li qq = -1;
    li cnt = 0;
    do {
        if (perm == p) {
            pp = cnt;
        }
        if (perm == q) {
            qq = cnt;
        }
        cnt++;
    } while (next_permutation(allof(perm)));
    cout << abs(pp - qq) << endl;

    return 0;
}


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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long a,b;
    char op;

    while(1){
    cin >> a >> op >> b;
    if(op == '+')cout << a+b << endl;
    else if(op == '-')cout << a-b << endl;
    else if(op == '*')cout << a*b << endl;
    else if (op == '/')cout << a/b << endl;
    else break;
    }
}


Measured memory_bytes: 3152
#include <iostream>
#include <queue>

using namespace std;

int main() {
    int N;
    cin >> N;
    
    queue<int> que;
    for(int n=0; n<N; n++) {
        int p;
        cin >> p;
        if(p==n+1) {
            que.push(p);
        }
    }
    
    int ans=que.size();
    while(que.size()>=2) {
        int f=que.front(); que.pop();
        int s=que.front();
        
        if(s-f==1) {
            ans--;
            que.pop();
        }
    }
    
    cout << ans << endl;

    return 0;
    
}

Measured memory_bytes: 640
#include <iostream>
using namespace std;
int ans,a[20],b[20],n;
int main(void){
    cin>>n;
    for(int i=0;i<n;i++)cin>>a[i];
    for(int i=0;i<n;i++)cin>>b[i];
    for(int i=0;i<n;i++){
        ans+=max(0,a[i]-b[i]);
    }
    cout<<ans<<endl;
}


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

int main()
{
    int n;
    cin >> n;
    int p[n];
    int max = 0;
    int sum = 0;
    for(int i=0;i<n;i++){
        cin >> p[i];
        if(max < p[i]){max = p[i];}
        sum = sum + p[i];
    }
    cout << sum - max/2 << endl;
    return 0;
}

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

const int MN = 200010;

int N;
multiset<int> st;
int chk[MN];

int main() {
    scanf("%d", &N);

    for(int i = 0; i < N; i++) {
        int t; scanf("%d", &t);
        st.insert(t);
    }

    int ans = 0;
    while(st.size() > 1) {
        int t = *st.rbegin(); st.erase(st.find(t));

        int p = 1;
        while(p <= t) p <<= 1;
        int d = *st.lower_bound(p - t);
        if(d == p - t) {
            ans++;
            st.erase(st.find(d));
        }
    }
    printf("%d", ans);
}


Measured memory_bytes: 9600
while 1:
    s = raw_input()
    if s == "#": break
    l = len(s)
    ps = [(int(c)-1) % 3 for c in s]
    dpl = [1e9]*l; dpr = [1e9]*l
    dpl[0] = dpr[0] = 0
    for i in xrange(1, l):
        if ps[i-1] <= ps[i]:
            dpl[i] = dpr[i-1]
        if ps[i] <= ps[i-1]:
            dpr[i] = dpl[i-1]
        dpl[i] = min(dpl[i], dpl[i-1]+1)
        dpr[i] = min(dpr[i], dpr[i-1]+1)
    print min(dpl[l-1], dpr[l-1])

Measured memory_bytes: 12056
#include<stdio.h>

int search(int A[],int n,int key){
    int i=0;
    A[n]=key;
    while (A[i]!=key)i++;
    return i !=n;
}

int main (void){
    int i,n,A[10000+1],q,key,sum=0;
    scanf("%d",&n);
    for(i=0;i<n;i++)scanf("%d",&A[i]);
    scanf("%d",&q);
    for(i=0;i<q;i++){
        scanf("%d",&key);
        if(search(A,n,key))sum++;
    }
    printf("%d\n",sum);
    return 0;
}


Measured memory_bytes: 2108
#include "bits/stdc++.h"
using namespace std;
int main(){
	cout << fixed << setprecision(10);
	int N;
	cin >> N;
	if (N % 2 == 0){
		cout << (double)N / 2 / N << endl;
	}
	else{
		int B = N / 2 + 1;
		cout << (double)B / N << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
using ll = long long;
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using pll = pair<long long,long long>;
#define cY cout<<"Yes"<<endl
#define cN cout<<"No"<<endl
const long long INF = 1LL << 60;
const long long MOD = 1000000007;

//最大最小の入れ替え
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;
}

//約数列挙
vector<long long> divisor(long long n) {
    vector<long long> ret;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    sort(ret.begin(), ret.end()); // 昇順に並べる
    return ret;
}
//コンビネーション
ll nCr(ll n, ll r) {
    ll ans = 1;
    for (int i = n; i > n - r; --i) {
        ans = ans*i;
    }
    for (int i = 1 ; i < r + 1; ++i) {
        ans = ans / i;
    }
    return ans;
}
//素因数分解
map< ll, ll > prime_factor(ll n) {
  map< ll, ll > ret;
  for(ll i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}

//切り上げの割り算は(a + b - 1) / bでできる
//時間を意識しろ
//コードテストちゃんとして
//画面とにらめっこするな書け
//WA出すたびにABCは五億円払え
//わからない問題はとばせ
//躊躇なくぐぐれ

//ここから
int main(){
    ll N,A,B;
    cin>>N>>A>>B;
    ll C=B-A;
    ll Ans=(N-2)*C+1;
    if(Ans>0){
        cout<<Ans<<endl;
    }else{
        cout<<0<<endl;
    }
    }



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

int main(void){
    int N, K, xi, yi, s;
    char C;
    cin >> N >> K;
    int XY[4005][4005];
    int ans=0;
    for(int i = 0 ;i < N ; i++){
        cin >> xi >> yi >> C;
        if(C == 'B') xi += K;
        XY[xi % (2*K)+1][yi % (2*K)+1]++;
        XY[xi % (2*K)+1+2*K][yi % (2*K)+1+2*K]++;
        XY[xi % (2*K)+1][yi % (2*K)+1+2*K]++;
        XY[xi % (2*K)+1+2*K][yi % (2*K)+1]++;
    }

    for(int i=1;i<=4*K;i++){
		for(int j=1;j<=4*K;j++){
			XY[i][j] += -XY[i-1][j-1] +XY[i-1][j]+XY[i][j-1];
		}
	}
	for(int i=1;i<=K;i++){
		for(int j=1;j<=K;j++){
			s=XY[i+K][j+K]-XY[i][j+K]-XY[i+K][j]+XY[i][j];
            s+=XY[i+K +K][j+K +K]-XY[i +K][j+K +K]-XY[i+K +K][j +K]+XY[i +K][j +K];
            ans = max(ans, s);
            ans = max(ans, N-s);
		}
	}
	cout << ans << endl;
    return 0;
}


Measured memory_bytes: 62848
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {
    public static void main(String[] args) throws IOException {
    	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        
      	while(true) {
          String str[] = br.readLine().split(" ");
          int a = Integer.parseInt(str[0]);
          int b = Integer.parseInt(str[2]);

          if (str[1].equals("+")) {
    	  	System.out.println(a + b);
          } else if (str[1].equals("-")) {
			System.out.println(a - b);          	
          } else if (str[1].equals("*")) {
			System.out.println(a * b);          	
          } else if (str[1].equals("/")) {
			System.out.println(a / b);         	
          } else {
              break;
          }
        }    
    }
}



Measured memory_bytes: 24444
#include "bits/stdc++.h"
using namespace std;

int main()
{
	string s, t;
	cin >> s >> t;

	int l = s.size();
	string ans = "Yes";
	
	for (int i = 0; i < l; i++) {
		if (s[i] != t[i]) {
			ans = "No";
			break;
		}
	}

	cout << ans << endl;
}


Measured memory_bytes: 3628
#include "bits/stdc++.h"

using namespace std;

int main() {
	int sx, sy, tx, ty;
	cin >> sx >> sy >> tx >> ty;
	for (int j = 0;j < 2;j++) {
		if (j) cout << "D";
		for (int i = 0;i < (tx - sx)+j;i++) cout << "R";
		for (int i = 0;i < (ty - sy)+j;i++) cout << "U";
		if (j) cout << "LU";
		for (int i = 0;i < (tx - sx)+j;i++) cout << "L";
		for (int i = 0;i < (ty - sy)+j;i++) cout << "D";
		if (j) cout << "R"<<endl;
	}
}


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

int main()
{
  string s;
  cin >> s;
  int ans = 0;
  int n = s.length();
  for (int i = 0; i < n / 2; i++)
  {
    if (s[i] != s[n - 1 - i])
    {
      ans++;
    }
  }
  cout << ans << endl;
}


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

#define vi std::vector<int>
#define vvi std::vector<std::vector<int> >
#define vpi std::vector<pi >
#define pi std::pair<int,int>
#define fi first
#define se second
#define all(n) n.begin(), n.end()

#define FROMTO(var, from, to) for (int var = (from), var##down = ((int)(to)) < ((int)(from));var##down ? (var >= (int)(to)) : (var <= (int)(to));var##down ? var-- : var++)
#define UPTO(var, from, to)   for (int var = (from); var <= ((int)(to)); var++)
#define DOWNTO(var, from, to) for (int var = (from); var >= ((int)(to)); var--)
#define FOR(var, to)		  UPTO(var, 0, (to)-1)
#define DOWN(var, from)	   DOWNTO(var, (from)-1, 0)

#define INIT(var, val) FOR(i,countof(var)) var[i] = val
#define INPUT(var) FOR(i,countof(var)) cin >> var[i]
#define INPUT1(var) FOR(i,countof(var)) cin >> var[i], var[i]--

#define SORT(v) qsort(v,countof(v),sizeof(*v),int_less)
#define SORTT(v) qsort(v,countof(v),sizeof(*v),int_greater)
#define QSORT(v,b) qsort(v,countof(v),sizeof(*v),b)

typedef uint8_t u8;
typedef uint16_t u16;
typedef uint32_t u32;
typedef uint64_t u64;
typedef int8_t s8;
typedef int16_t s16;
typedef int32_t s32;
typedef int64_t s64;

static const int MOD = 1000000007;
static const int INF = ((1<<30)-1);
static const s64 LINF = ((1LL << 62)-1);

struct Comb {
	std::vector<std::vector<s64> > a;
	Comb(int n) { // O(n^2)
		a.resize(n+1);
		FOR(i,n+1) {
			a[i].resize(i+1, 1);
			UPTO(j,1,i-1) a[i][j] = a[i-1][j] + a[i-1][j];
		}
	}
	s64 ncr(int n, int r) {
		assert(n >= 0);
		assert(n <= (int)a.size());
		assert(r >= 0);
		assert(r <= n);
		return a[n][r];
	}
};

#define gc(c) (c)=getchar()
int ri() {
	int c,s=0,r=0;
	for(;;){gc(c);if(c=='-'){s=1;break;}if(c>='0'&&c<='9'){r=c-'0';break;}}
	for(;;){gc(c);if(c<'0'||c>'9')break;r*=10;r+=c-'0';}
	if(s)r=-r;
	return r;
}
s64 rs64() {
	s64 r;
	int c,s;
	for(;;){gc(c);if(c=='-'){s=1;break;}if(c>='0'&&c<='9'){r=c-'0';break;}}
	for(;;){gc(c);if(c<'0'||c>'9')break;r*=10;r+=c-'0';}
	if(s)r=-r;
	return r;
}

int int_less(const void *a, const void *b) {
	return (*(const int*)a - *(const int*)b);
}
int int_greater(const void *a, const void *b) {
	return (*(const int*)b - *(const int*)a);
}
std::string operator*(const std::string &s, int n){ std::string res; FOR(i,n) res += s; return res; }

template<class T> std::ostream& operator<<(std::ostream& os, std::vector<T> a) { for (auto i : a) os << i << " "; return os; }
template<class T> std::ostream& operator<<(std::ostream& os, std::set<T> a) { for (auto i : a) os << i << " "; return os; }
template<class A, class B> std::ostream& operator<<(std::ostream&os, std::pair<A,B> a) { os << a.fi << "," << a.se; return os; }


int main() {
	int a = ri();
	int b= ri();
	int c = ri();
	std::cout << (a==b && b == c ? "Yes":"No") << std::endl; 
	return 0;
}


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

using namespace std;

typedef long long ll;

int N;
vector<int> h;
vector<ll> a, t;

void put(int i, int L, int R, int pos, ll x) {
    if (L == R)
        t[i] = x;
    else {
        int M = (L + R) / 2;
        if (pos <= M)
            put(2 * i + 1, L, M, pos, x);
        else
            put(2 * i + 2, M + 1, R, pos, x);
        t[i] = max(t[2 * i + 1], t[2 * i + 2]);
    }
}

ll rmq(int i, int L, int R, int l, int r) {
    if (l <= L && R <= r)
        return t[i];
    int M = (L + R) / 2;
    ll result = 0;
    if (l <= M)
        result = max(result, rmq(2 * i + 1, L, M, l, r));
    if (r > M)
        result = max(result, rmq(2 * i + 2, M + 1, R, l, r));
    return result;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> N;
    h.resize(N);
    for (int i = 0; i < N; i++)
        cin >> h[i], h[i]--;
    a.resize(N);
    for (int i = 0; i < N; i++)
        cin >> a[i];
    t.resize(4 * N);
    for (int i = N - 1; i >= 0; i--)
        put(0, 0, N - 1, h[i], a[i] + rmq(0, 0, N - 1, h[i], N - 1));
    cout << rmq(0, 0, N - 1, 0, N - 1) << endl;
}


Measured memory_bytes: 8832
#include<bits/stdc++.h>
#define rep(i, n) for (int i =0; i < (int64_t)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
 
int main() {
    int64_t n;cin>>n;
    cout<<n/500*1000+n%500/5*5;
  
  
 
}

Measured memory_bytes: 256
import java.util.*;

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

        int a = scan.nextInt();
        int ans=0;
        boolean flg=true;
        for(int i=0;i<a;i++){
            int c=scan.nextInt();
            if(i+1!=c){
                ans+=1;
                if(ans==3){flg=false;break;}
            }
        }
        String b = flg?"YES":"NO";
        System.out.println(b);
    }
}

Measured memory_bytes: 22612
#include<bits/stdc++.h>
 
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb emplace_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
 
using namespace std;
 
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;
 
template<typename T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<typename T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }
template<typename T> T Min(T a, T b) { return a > b ? b : a; }
template<typename T> T Max(T a, T b) { return a < b ? b : a; }
template<typename T> void de(T a){ 
#ifdef LOCAL_DEFINE
	cout<< a << endl;
#endif
}	
const int INF = 2e5+1;
const int mod = 1e9+7;
         	
void solve(){
	i64 a,b;
	cin>>a>>b;
	cout<<Max(a*b,Max(a+b,a-b))<<endl;
}
 
 
int main(){
        ios::sync_with_stdio(false);
        cin.tie(nullptr);
    	cout.precision(10);
    	cout << fixed;
#ifdef LOCAL_DEFINE
    freopen("input.txt", "rt", stdin);
	freopen("output.txt","w",stdout);
#endif  
        int q=1;
#ifdef LOCAL_DEFINE
        cin>>q;
#endif
        while(q--){
         	solve();
        }
 
#ifdef LOCAL_DEFINE
         
             
        cerr << "Time elapsed: " << 1000.0 * clock() / CLOCKS_PER_SEC << " ms.\n";
#endif
 
	return 0;
}	

Measured memory_bytes: 256
//Sani buyuk Osman Pasa Plevneden cikmam diyor.
//FatihSultanMehmedHan
//Abdulhamid Han Elmuzaffer Daima
//Bismillahirrahmanirrahim

#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

typedef long long int lo;
typedef pair< int,int > PII;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR for(int i=1;i<=n;i++)
#define mid (start+end)/2
#define ort (bas+son)/2

const lo MAX = -1000000000000000000; 
const lo MIN = 1000000000000000000; 
const lo inf = 1000000000; 
const lo KOK = 100000; 
const lo LOG = 30; 
const lo li = 100005; 
const lo mod = 1000000007; 

int n,m,cev,b,a[li],k;
string s;
vector<string> v;

inline int solve(){
	scanf("%d %d",&n,&m);
	FOR{
		cin>>s;
		v.pb(s);
	}
	sort(v.begin(),v.end());
	for(int i=0;i<(int)v.size();i++) cout<<v[i];
	return 0;
}

int main(void){
	solve();
	
	return 0;
}


Measured memory_bytes: 256
#include<set>
#include<map>
#include<cmath>
#include<queue>
#include<bitset>
#include<string>
#include<cstdio>
#include<cctype>
#include<cassert>
#include<cstdlib>
#include<cstring>
#include<sstream>
#include<iostream>
#include<algorithm>

#define For(i,x,y) for (int i=x;i<y;i++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second

#define dprintf(...) fprintf(stderr,__VA_ARGS__)
using namespace std;

int IN(){
	int c,f,x;
	while (!isdigit(c=getchar())&&c!='-');c=='-'?(f=1,x=0):(f=0,x=c-'0');
	while (isdigit(c=getchar())) x=(x<<1)+(x<<3)+c-'0';return !f?x:-x;
}

typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> Vi;

const int N=400000+19;
const ll oo=1ll<<40;

struct Edge{
	int x,y;
	ll z;
	bool operator < (const Edge &B) const {return z<B.z;}
} E[N];
int fa[N];
ll val[N],tmp=oo;
int n,m,Qc,A,B,C;

int getf(int x){
	return fa[x]==x?x:fa[x]=getf(fa[x]);
}
ll Kruskal(){
	ll res=0;
	For(i,0,n) fa[i]=i;
	sort(E,E+m);
	For(i,0,m){
		int x=getf(E[i].x),y=getf(E[i].y);
		if (x!=y) fa[x]=y,res+=E[i].z;
	}
	return res;
}

int main(){
	n=IN();Qc=IN();
	For(i,0,n) val[i]=oo;
	while (Qc--){
		A=IN(),B=IN(),C=IN();
		E[m++]=(Edge){A,B,C};
		val[A]=min(val[A],C+1ll);
		val[B]=min(val[B],C+2ll);
	}
	for (int i=0,x=0;i<3*n;i++,x=(x+1)%n){
		val[x]=min(val[x],tmp);
		tmp=min(tmp,val[x])+2;
	}
	For(i,0,n) E[m++]=(Edge){i,(i+1)%n,val[i]};
	cout<<Kruskal()<<endl;
}

Measured memory_bytes: 11904
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <vector>
using namespace std;

int x[10], y[10];

double dist(int i, int j) {
    double dx = x[i] - x[j];
    double dy = y[i] - y[j];
    return pow(dx * dx + dy * dy, 0.5);
}

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

  int N;
  cin >> N;
  for(int i = 1; i <= N; ++i) {
    cin >> x[i] >> y[i];
  }

  double sum = 0.0;
  vector<int> v(N);

  for(int i = 0; i < N; i++) {
    v[i] = i + 1;
  }

  do {
      for(int i = 0; i < N - 1; i++) {
        sum += dist(v[i], v[i+1]);
      }
  } while(next_permutation(v.begin(), v.end()));

  int Factorial = 1;
  for(int i = 2; i <= N; i++) {
    Factorial *= i;
  }

  cout << fixed << setprecision(10) << sum / Factorial << endl;

  return 0;
}


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

#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define forn(i,n) for(ll i=0;i<n;i++)
#define fore(i,a,b) for(ll i=a;i<=b;i++)
#define ford(i,n) for(ll i=n-1;i>=0;i--)
#define fi first
#define se second
#define endl "\n"
#define all(a) a.begin(),a.end()
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define PI 3.14159265

/******************************************************************************************************/
void file(){
    #ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
    #endif
}
/******************************************************************************************************/

const ll nax=2e5+1,mod=1e9+7;



int main(){

    sync
   // file();
    

    int n;
    string s;
    cin>>n;
    cin>>s;
    n>=3200 ? cout<<s:cout<<"red";


    

  return 0;
}

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

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

#define m0(x) memset(x, 0, sizeof(x))
#define all(x) x.begin(), x.end()
#define rep(i, n) for(int i = 0; i < (n); i++)
#define asort(x) sort(all(x));
#define dsort(x, t) sort(x.begin(), x.end(), greater<t>());
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define MINS(m, s) m.insert(mp(s, 1));
#define MFIN(m, s) m.find(s) != m.end()
#define mp make_pair
#define pb push_back
#define INF (1 << 29)
const int mod = 1000000007;

int main() {
    int a, b, c, x;
    int cnt = 0;
    cin >> a >> b >> c >> x;

    for(int i = 0; i <= a; i++) {
        for(int j = 0; j <= b; j++) {
            for(int k = 0; k <= c; k++) {
                int ans = i * 500 + j * 100 + k * 50;
                if(ans == x) {
                    cnt++;
                }
            }
        }
    }

    cout << cnt << endl;

    return 0;
}

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

int main(int argc, char const *argv[])
{
    int a,b;
    char op;
    while(1) {
        cin >> a >> op >> b;
        if (op == '?') break;
        if (op == '+') cout << a+b << endl;
        if (op == '-') cout << a-b << endl;
        if (op == '*') cout << a*b << endl;
        if (op == '/') cout << a/b << endl;
    }
    return 0;
}

Measured memory_bytes: 1160
//From Naruto to Hokage
//#include <RJ>
#include<bits/stdc++.h>
using namespace std;

#define ll          long long
#define pb          push_back
#define eb          emplace_back
#define endl        '\n'
#define mii         map<ll,ll>
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll)x.size()
#define hell        1000000007
#define INF         (1ll<<60)
#define rep(i,a,b)  for(ll i=a;i<=b;i++)
#define rrep(i,a,b)  for(ll i=a;i>=b;i--)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
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)); }
const int N=100005;
void solve(){
    ll n,k;
    cin>>n>>k;
    vi v(n+1);
    rep(i,1,n) cin>>v[i];
    vi dp(n+1,INF);
    // memset(dp,1e9,sizeof(dp));
    dp[1]=0;
    rep(i,2,n){
        rep(j,1,k){
        // dp[i]=(abs(v[i]-v[i-1])+dp[i-1]);
        if((i-j)>=1) dp[i]=min(dp[i],abs(v[i]-v[i-j])+dp[i-j]);
    }
    }
    // rep(i,1,n) cout<<dp[i]<<" ";
    cout<<dp[n];
}
signed main()
{
    ios
    int TESTS=1;
    //cin>>TESTS;
    while(TESTS--){
        solve();
    }
    time
    return 0;
}

Measured memory_bytes: 1792
import java.util.Scanner;


public class Main {
	public static void main(String[] args) {
		new Main().run();
	}
	
	int n;
	int []a;
	boolean[] b;
	
	public void run() {
		Scanner scanner = new Scanner(System.in);
		n =scanner.nextInt();
		a = new int[n];
		for(int i=0;i<n;i++){
			a[i]=scanner.nextInt();
		}
		int p = scanner.nextInt();
		b = new boolean[p];
		
		for(int i=0;i<p;i++){
			int temp = scanner.nextInt();
			b[i]=isSum(0, temp);
		}
		for(int i=0;i<p;i++){
			if(b[i]){
				System.out.println("yes");
			}
			else{
				System.out.println("no");
			}
		}
		
	}
	
	public boolean isSum(int i,int m) {
		if(m==0){
			return true;
		}
		if(i==n){
			return false;
		}
		boolean res = isSum(i+1,m)||isSum(i+1, m-a[i]);
		
		return res;
	}
	
}

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

const int LIM = 100000;
int A, B, Q;
ll s[LIM], t[LIM], x;

int main(){
    cin >> A >> B >> Q;
    rep(i, A) cin >> s[i];
    rep(i, B) cin >> t[i];
    rep(i, Q){
    	cin >> x;
    	ll ans = 1e18;
    	rep(j, 2){
            int spos = max(0, min((int)(lower_bound(s, s + A, x) - s - j), A - 1));
    		rep(k, 2){
                int tpos = max(0, min((int)(lower_bound(t, t + B, x) - t - k), B - 1));
                ans = min(ans, min(abs(x - s[spos]), abs(x - t[tpos])) + abs(s[spos] - t[tpos]));
    		}
    	}
    	cout << ans << endl;
    }
    return 0;
}

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

int main(){
  int N;
  cin >> N;
  int a[N], b[N];
  for(int i = 0; i < N; i++) cin >> a[i];
  for(int i = int(N / 2); i < N; i++) b[i] = a[i];
  int b_sum;
  for(int i = int(N / 2) - 1; i >= 0; i--){
	b_sum = 0;
    for(int j = 2 * i + 1 ; j < N; j += (i + 1)) b_sum += b[j];
    if(b_sum % 2 == a[i]) b[i] = 0;
    else b[i] = 1;
  }
  cout << b_sum + b[0] << endl;
  int count = 0;
  if(b_sum + b[0] == 0) return 0;
  else {
    for(int i = 0; i < N; i++) {
      if(b[i] == 1){
        cout << i + 1;
        count += 1;
        if(count < b_sum + b[0]) cout << ' ';
      }
    }
    cout << endl;
    return 0;
  }
}

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

#define ll                   long long int
#define MOD                  1000000007
#define fast()               ios_base::sync_with_stdio(false);  cin.tie(NULL);
#define loop(i,a,b)          for(ll i=(ll)a;i<(ll)b;i++)
#define pool(i,a,b)          for(ll i=(ll)a;i>=(ll)b;i--)
#define pb                   push_back
#define vi                   vector<ll>
#define test()               ll t; cin>>t; while(t--)
#define endl                 "\n"
#define param                greater<ll>()
#define ff                   first
#define ss                   second
#define all(v)               v.begin(),v.end()
#define keep_unique(v) sort(v.begin(), v.end()); v.erase(unique(v.begin(), v.end()), v.end());
#define sor(vec) sort(vec.begin(),vec.end());

using namespace std;

// const int N = 105;
// const int W = 1e5+10;

const ll MAX = 10000000000000;
// const int MOD = 998244353;

ll fast_exp(ll x,ll n){ll ans=1;while(n){if(n&1)ans*=x;n=n>>1;x=x*x;}return ans;}
ll mod_exp(ll x, ll y,ll p){ll res = 1;x = x % p;while(y>0){if(y&1)res = (res*x) % p;y = y>>1;x=(x*x)%p;}return res;}


//  vector < ll > vec(N);

// ll fib[N];




int main()
{

    fast()


    ll t;
    // cin>>t;
    t=1;

    while(t--)
    {
        ll a,b,c,i,n,k,p,j,d,m,r,w;

        string s;

        cin>>n>>w;

        vector<ll>wt(n+1),val(n+1);
        
        ll sum=0;
        
        for(i=1;i<=n;i++)
        {
            cin>>wt[i]>>val[i];
            
            sum+=val[i];
        }
        
        ll dp[110][100010];
        
          for(i=0;i<=n;i++)
        {
            for(j=0;j<=sum;j++)
            {
                
                dp[i][j]=MAX;


            }
        }
        
        // memset(dp, MAX ,sizeof(dp));
        
         for(i=0;i<=n;i++)
        {
            dp[i][0]=0;
        }

        for(i=1;i<=n;i++)
        {
            for(j=1;j<=sum;j++)
            {
                
                if(val[i]<=j)
                dp[i][j]=min(wt[i]+dp[i-1][j-val[i]] , dp[i-1][j]);
                else
                dp[i][j]=dp[i-1][j];


            }
        }
        
        ll ans=0;
        
        for(j=1;j<=sum;j++)
        {
            if(dp[n][j]<=w)ans=max(ans,j);
        }
        
        cout<<ans<<endl;

        // for(i=0;i<=n;i++)
        // {
        //     for(j=0;j<=sum;j++)
        //     {

        //         cout<<dp[i][j]<<" ";


        //     }
        //     cout<<endl;
        // }








        // string ans=vec[0];

    }




    return 0;
}


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

#define ll long long int
#define mp make_pair
#define ff first
#define ss second
#define fr(i,l,r) for (long long int i = l; i < r; ++i)
#define frr(i,l,r) for (long long int i = r; i >= l; --i) 
#define sortarr sort(arr,arr+n) //sorts array in asc order
#define sortarr_r sort(arr, arr+n, greater<long long int>()) //sorts array in desc order
#define make_set set<long long int>s //Set arranges in asc order
#define make_set_r set<long long int, greater <long long int>>s ////Set arranges in desc order
#define make_vector vector<long long int>v; 
#define pb push_back


// string size = str.size()

// stack <int> s; 
// queue <int> gquiz; 
// __gcd(m, n) 

// ll arr[10e5 + 5];
// char arr[10e5 + 5];

// printf ("%.9f\n",x);

bool compare(string &s1,string &s2) 
{ 
    return s1.size() < s2.size(); 
} 
void yes()
{
    cout << "YES" << endl;
}
void no()
{
    cout << "NO" << endl;
}


int main(void)
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    ll x,y,z;
    cin >> x >>y>>z;
    cout << z << " " << x << " " << y << endl;
    return 0;
}   

Measured memory_bytes: 256
N=int(input())
a=[int(i) for i in input().split()]
b=[int(i) for i in input().split()]

total_do=sum(b)-sum(a)
must_do_a=0
must_do_b=0

for i in range(N):
	dist=a[i]-b[i]
	if dist<0:
		dist=-dist
		must_do_a+=int((dist+1)/2)
		if dist%2!=0:
			must_do_b+=1
	elif dist>0:
		must_do_b+=dist
left_a=total_do-must_do_a
left_b=total_do-must_do_b

if total_do>=0 and must_do_a>=must_do_b and left_a*2==left_b:
	print("Yes")
else:
	print("No")



Measured memory_bytes: 4596
#include <iostream>
#include <bits/stdc++.h>
#include <math.h>

using namespace std;

int main(){
    string s;
    cin>>s;
    
    for(int i=2;i<s.size();i+=2){
        string left=s.substr(0,(s.size()-i)/2);
        string right=s.substr(((s.size()-i)/2),(s.size()-i)/2);
        
        if(left==right){
            cout<<s.size()-i<<endl;
            break;
        }
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++) 
#define FOR(i, a, b) for(int (i) = a; (i) < (int)b; i++)
#define RREP(i, n) for(int (i)=((int)(n)-1); (i)>=0; i--)
#define RFOR(i, a, b) for(int (i) =((int)(b)-1); (i)>=(int)a; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define FT first
#define SC second

using namespace std ;
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef pair<int, int> pint;
const int INF = 1e9;
const double EPS = 1e-9;



int main()
{
  string s ;
  cin >> s ;
  int y ;
  int n = s.size() ;
  int x = 0 ;
  
  REP(i,n){
    x += s.at(i) -'0' ;
  }
  
  y = stoi(s) ;
  
  if(y%x==0){
    cout <<"Yes"<<endl ;
  }
  else{
    cout <<"No"<<endl ;
  }

  return 0 ;
}




Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.FileReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;


public class Main {
    static Scanner scanner = new Scanner(System.in);
    static PrintWriter out = new PrintWriter(System.out);
    static int n,weight,w[],v[];
    static long memo[][];
    static final int inf=(int)1e9;
    public static void main(String[] args) throws Exception {
        //============================================//
        //answer here:
        n=scanner.nextInt(); weight=scanner.nextInt();
        w=new int[n];
        v=new int[n];
        memo=new long[n][weight+1];
        for (int i = 0; i <n ; i++) {
            w[i]=scanner.nextInt();
            v[i]=scanner.nextInt();
        }
        for (long[] arr:memo){
            Arrays.fill(arr,-1);
        }
        long ans=dp(0,weight);
        out.println(ans);
        //============================================//
        out.close();
    }
    //top down approach
    public static long dp(int i, int remw){
        if (remw<0) return -inf;
        if (i==n) return 0;
        if (memo[i][remw]!=-1) return memo[i][remw];
        long take=v[i]+dp(i+1,remw-w[i]);
        long leave=dp(i+1,remw);
        return memo[i][remw]=Math.max(take,leave);
    }
}
class Scanner {
    StringTokenizer st;
    BufferedReader br;

    public Scanner(InputStream system) {
        br = new BufferedReader(new InputStreamReader(system));
    }

    public Scanner(String file) throws Exception {
        br = new BufferedReader(new FileReader(file));
    }

    public String next() throws IOException {
        while (st == null || !st.hasMoreTokens()) st = new StringTokenizer(br.readLine());
        return st.nextToken();
    }

    public String nextLine() throws IOException {
        return br.readLine();
    }

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

    public double nextDouble() throws IOException {
        return Double.parseDouble(next());
    }

    public char nextChar() throws IOException {
        return next().charAt(0);
    }

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

    public boolean ready() throws IOException {
        return br.ready();
    }

    public void waitForInput() throws InterruptedException {
        Thread.sleep(3000);
    }

    int[] readArray(int n) throws IOException {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    long[] readLongArray(int n) throws IOException {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    }
}

class pair implements Comparable<pair> {
    int u;
    int v;

    public pair(int u, int v) {
        this.u= u;
        this.v = v;
    }

    @Override
    public String toString() {
        return v+""+u;
    }

    @Override
    public int compareTo(pair o) {
        return o.v-v;
    }
}


Measured memory_bytes: 127316
//ΔAGC032F
#include<iostream>
#include<cstdio>
#include<fstream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<bitset>
#include<cmath>
#include<cstring>
#include<cstdlib>
using namespace std;
typedef long long LL;
typedef double DB;
const int N = 1e6+16;
const int MO = 1e9+7;
inline int mul(int x,int y){
	return (LL)x*y%MO;
}
int fpow(int x,int y=MO-2){
	int z=1;
	while(y){
		if(y&1)
			z=mul(z,x);
		x=mul(x,x);
		y>>=1;
	}
	return z;
}
int n,i3,fac[N],ifac[N],p3[N],p2[N];
int cal(int i){
	int x=p2[i];
	if(i&1)
		x++;
	else
		x--;
	return mul(x,i3);
}
int main()
{
	int i;
	LL s=0;
	n=1e6+5;
	i3=fpow(3);
	fac[0]=1;
	for(i=1;i<=n;i=i+1)
		fac[i]=mul(fac[i-1],i);
	ifac[n]=fpow(fac[n]);
	for(i=n;i>=1;i=i-1)
		ifac[i-1]=mul(ifac[i],i);
	p3[0]=1;
	for(i=1;i<=n;i=i+1)
		p3[i]=mul(p3[i-1],3);
	p2[0]=1;
	for(i=1;i<=n;i=i+1)
		p2[i]=mul(p2[i-1],2);
	cin>>n;
	for(i=1;i<=n;i=i+1)
		s+=mul(mul(fac[n],mul(ifac[i],ifac[n-i])),mul(cal(i),mul(fac[i-1],ifac[i])));
	cout<<mul(mul(s%MO,fpow(n)),fpow(p3[n]));
	return 0;
}

Measured memory_bytes: 16000
import java.util.*;
import java.io.BufferedInputStream;

public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner (new BufferedInputStream(System.in));
    long n = sc.nextLong();
    System.out.println( n / 500 * 1000 + (n % 500) / 5 * 5);
  }
}


Measured memory_bytes: 22996
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int h = scanner.nextInt(),w = scanner.nextInt();
		String[] str = new String[h];
		for(int i=0;i<h;i++){
			str[i] = scanner.next();
		}
		for(int i=0;i<w+2;i++){
			System.out.print("#");
		}
		System.out.println();
		for(int i=0;i<h;i++){
			System.out.print("#");
			System.out.print(str[i]);
			System.out.println("#");
		}
		for(int i=0;i<w+2;i++){
			System.out.print("#");
		}
	}
}


Measured memory_bytes: 23156
#include <iostream>
#include <string>
#include <vector>

typedef long long ll;

using namespace std;

int main () {
  int n;
  cin >> n;
  vector <ll> a(n);
  ll sum = 0;
  for (int i = 0; i < n; i++)
    cin >> a[i];
  for (int i = 1; i < n; i++)
    if (a[i] < a[i - 1]) {
      sum += a[i - 1] - a[i];
      a[i] = a[i - 1];
    }
  cout << sum;
  return 0;
}


Measured memory_bytes: 4780
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int tHP = sc.nextInt();
        int tAtack = sc.nextInt();
        int aHP = sc.nextInt();
        int aAtack = sc.nextInt();
        boolean isTkhsWin = false;

        while(true) {
            // 高橋の攻撃
            aHP -= tAtack;
            if (aHP <= 0) {
                isTkhsWin = true;
                break;
            }
            // 青木の攻撃
            tHP -= aAtack;
            if (tHP <= 0) {
                isTkhsWin = false;
                break;
            }
        }
        String result = isTkhsWin ? "Yes" : "No";
        System.out.println(result);
    }
}

Measured memory_bytes: 35656
import sys
import numpy as np
import numba
from numba import njit, b1, i4, i8, f8

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

MOD = 200_003
R = 2  # primitive root

@njit((i8[:], ), cache=True)
def precompute(A):
    exp = np.zeros(MOD - 1, np.int64)
    log = np.zeros(MOD, np.int64)
    exp[0] = 1
    for k in range(1, MOD - 1):
        exp[k] = exp[k - 1] * R % MOD
        log[exp[k]] = k
    # r^k の個数を B[k] に入れる
    B = np.zeros(MOD - 1, np.int64)
    for x in A:
        if x != 0:
            B[log[x]] += 1
    return exp, log, B

@njit((i8[:], i8[:], i8[:], i8[:]), cache=True)
def get_ans(A, C, exp, log):
    # 順序対について集計
    ans = 0
    for i in range(len(C)):
        x = exp[i % (MOD - 1)]
        ans += x * C[i]
    for a in A:
        x = a * a % MOD
        ans -= x
    return ans // 2

A = np.array(read().split(), np.int64)[1:]

exp, log, B = precompute(A)
fft, ifft = np.fft.fft, np.fft.ifft
fft_len = 1 << 20
FB = fft(B, fft_len)
C = np.rint(ifft(FB * FB, fft_len)).astype(np.int64)

print(get_ans(A, C, exp, log))

Measured memory_bytes: 194988