akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
using namespace std;


bool check(int x) {

    string S = to_string(x);
    auto first = S.begin();
    auto last = S.end();
    --last;

    while (first < last) {
        if(*first != *last) {
            return false;
        }
        ++first;
        --last;
    }
    return true;
}


int main() {
    int A, B;
    cin >> A >> B;
    int num = 0;

    for (int x=A; x<=B; ++x) {
        if (check(x)) {
            ++num;
        }
    }

    cout << num << endl;
}


Measured memory_bytes: 3652
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
const int INF=1e3+125;
const int dfx[]={0,0,1,-1},dfy[]={1,-1,0,0};
const int bfx[]={-2,-2,-2,-2,-2,-1,-1,-1,-1,0,0,1,1,1,1,2,2,2,2,2};
const int bfy[]={-2,-1,0,1,2,-2,-1,1,2,-2,2,-2,-1,1,2,-2,-1,0,1,2};
int h,w,cx,cy,dx,dy,qx[INF*INF*30+25],qy[INF*INF*30+25],l,r,dis_[INF][INF];
bool vis[INF][INF];
char Map[INF][INF];
void DFS(int x,int y) {
        for (int i=0; i<4; i++) {
                int gx=x+dfx[i],gy=y+dfy[i];
                if (gx<1 || gy<1 || gx>h || gy>w|| Map[gx][gy]!='.' || dis_[gx][gy]<=dis_[x][y] || vis[gx][gy]) continue;
                vis[gx][gy]=true;
                dis_[gx][gy]=dis_[x][y];
                qx[++r]=gx;
                qy[r]=gy;
                DFS(gx,gy);
        }
        return;
}
void BFS() {
        memset(dis_,63,sizeof dis_);
        vis[cx][cy]=true;
        dis_[cx][cy]=0;
        DFS(cx,cy);
        // bool flag=false;
        while (l<=r) {
                int x=qx[l],y=qy[l]; l++;
                // if (vis[dx][dy]) flag=true;
                // if (flag) break;
                for (int i=0; i<20; i++) {
                        int gx=x+bfx[i],gy=y+bfy[i];
                        if (gx<1 || gy<1 || gx>h || gy>w|| Map[gx][gy]!='.' || dis_[gx][gy]<dis_[x][y]+1 || vis[gx][gy]) continue;
                        dis_[gx][gy]=dis_[x][y]+1;
                        vis[gx][gy]=true;
                        DFS(gx,gy);
                        // if (vis[dx][dy]) flag=true;
                        // if (flag) break;
                        qx[++r]=gx;
                        qy[r]=gy;
                }
                // if (flag) break;

                // for (int i=1; i<=h; i++) {
                //         for (int j=1; j<=w; j++)
                //                 printf("%10d ",dis_[i][j]);
                //         putchar('\n');
                // }
                // putchar('\n');
        }
        return;
}
signed main()
{
        // freopen("test.out","w",stdout);
        scanf("%d %d",&h,&w); scanf("%d %d %d %d ",&cx,&cy,&dx,&dy);
        for (int i=1; i<=h; i++) {
                for (int j=1; j<=w; j++)
                        cin>>Map[i][j];
        }
        // cout<<"ok\n";
        l=1;
        qx[++r]=cx;
        qy[r]=cy;
        BFS();
        if (vis[dx][dy]) cout<<dis_[dx][dy]<<"\n";
        else cout<<"-1\n";
        return 0;
}


Measured memory_bytes: 14584
#include<bits/stdc++.h>
#define int long long
using namespace std;
void solve() {
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    cout<<max({a*c,a*d,b*c,b*d});
}
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int test = 1;
    while(test--) {
        solve();    
    }
}

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


void solve(long long N){
  int cnt=0;
  for(int i=1;i<=N;++i){
    if(to_string(i).length()%2) cnt++;
  }
  cout<<cnt<<endl;
}

// Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
  long long N;
  scanf("%lld",&N);
  solve(N);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <queue>
#include <map>


using namespace std;

#define int long long
#define rep(i, a, n) for (int i = a; i < n; i++)
#define pb push_back
#define eb emplace_back
#define dump(x) cout << #x << " = " << (x) << endl
#define chk() cout << "now" << endl;
#define ALL(x) (x).begin(), (x).end()
#define SORT(c) sort((c).begin(), (c).end())
#define SORTG(c) sort(ALL(c), greater<int>());
#define fi first
#define se second
int INF = 1e9 + 7;

typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector< vector<int> > mat;

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



void solve() {
  string s;
  cin>>s;
  int l = s.length();
  int count = 0;
  rep(i,0, l) {
    if (s[i] != s[l-1-i]) {
      ++count;
    }
  }
  cout<<count/2<<endl;
}

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

  // cout << fixed << setprecision(10);

  solve();

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
using P = pair<int,int>;
using ll = long long;
const int MOD = 1e9+7;
#define rep(i,N) for(int (i) = 0; (i) < (N);++(i))

int main(){
    ll Q,H,S,D,N;
    cin >> Q >> H >> S >> D >> N;
    Q *= 4;
    H *= 2;
    ll X = min({Q,H,S});
    if(2*X <= D) cout << N*X << endl;
    else cout << N/2*D + (N%2)*X << endl;

}

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::iter::*;
#[allow(unused_imports)]
use std::*;

macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
#[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

macro_rules! stdin {
    () => {{
        use std::io::Read;
        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }};
}

fn main() {
    println!("{}", solve(&stdin!()));
}
fn solve(src: &str) -> String {
    input! {
        source = src,
        n:usize,
        m:usize,
        h_s:[usize;n],
        ab_s:[(usize1,usize1);m],
    }

    let mut results = vec![true; n];
    for &(a, b) in ab_s.iter() {
        let ah = h_s[a];
        let bh = h_s[b];
        if ah < bh {
            results[a] = false;
        } else if bh < ah {
            results[b] = false;
        } else {
            results[a] = false;
            results[b] = false;
        }
    }
    results.iter().filter(|&&v| v).count().to_string()
}
test! {
    include_str!("c1_in.txt") => "2",
    include_str!("c2_in.txt") => "3",
}


Measured memory_bytes: 6656
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
 
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<stdlib.h>
#include<stdarg.h>
#include<malloc.h>


int main()
{
	int i, n;
	double x1,y1,x2,y2,x3,y3,x4,y4;

	scanf("%d", &n);

	for(i=0; i<n; i++){
		scanf("%lf%lf%lf%lf%lf%lf%lf%lf",&x1,&y1,&x2,&y2,&x3,&y3,&x4,&y4);

		if(fabs((x1-x2)*(y3-y4) - (y1-y2)*(x3-x4)) < 1e-10)
			printf("YES\n");
		else
			printf("NO\n");
	}

	return 0;

}

Measured memory_bytes: 620
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define endl '\n'
#define mod 1000000007
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	string s, s1;
	cin >> s >> s1;
	ll x = s.length();
	ll count = 0;
	for (ll i = 0; i < x; i++) {
		if (s[i] != s1[i]) {
			count++;
		}
	}
	cout << count << endl;
}

Measured memory_bytes: 3840
#include<bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define vvi vector<vi>
#define vs vector<string>
#define pb push_back
#define P pair<int,int>
#define vp vector<P>
#define PP pair<P,int>
#define vpp vector<PP>
#define fi first
#define se second
#define INF 1e9
#define MOD 1000000007
#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 all(x) (x).begin(),(x).end()
int main(){
    int n,m;
    cin>>n>>m;
    vvi g(n,vi(n,INF));
    REP(i,m){
        int a,b,c;
        cin>>a>>b>>c;
        a--;b--;
        g[a][b]=g[b][a]=c;
    }
    REP(i,n){
        cerr<<endl;
        REP(j,n){
            cerr<<g[i][j]<<" ";
        }
    }cerr<<endl;
    vvi d=g;
    REP(i,n)d[i][i]=0;
    REP(k,n)REP(i,n)REP(j,n){
        d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
    }
    int ans=0;
    REP(i,n){
        FOR(j,i+1,n){
            if(g[i][j]!=INF&&d[i][j]<g[i][j]){
                ans++;
            }
        }
    }
    REP(i,n){
        cerr<<endl;
        REP(j,n){
            cerr<<d[i][j]<<" ";
        }
    }cerr<<endl;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 384
H, W, K = map(int, input().split())
data = []
for y in range(H):
	data.append(list(input()))

total = 0

for i in range(2 ** (H + W)):
	tmp_data = tuple(list(col) for col in data)
	for y in range(H):
		if i % 2 == 0:
			for x in range(W):
				tmp_data[y][x] = "r"
		i //= 2
	for x in range(W):
		if i % 2 == 0:
			for y in range(H):
				tmp_data[y][x] = "r"
		i //= 2
	count = 0
	for y in range(H):
		for x in range(W):
			if tmp_data[y][x] == "#":
				count += 1
	if count == K:
		total += 1
print(total)


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

int main() {
    int N;
    cin >> N;
    int fn = N;
    int sum = 0;
    while(fn > 0){
        sum += fn % 10,
        fn /= 10;
    }
    if(N % sum == 0) puts("Yes");
    else puts("No");
}

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

int N, K;
vector<int> height;

int main(){
  cin >> N >> K;

  for(int i = 0; i < N; i++){
    int h;   cin >> h;
    height.push_back(h);
  }

  sort(height.begin(), height.end());    

  int min_h = 1e9;
  for(int i = 0; i < N-K+1; i++)
    min_h = min(height[i+K-1] - height[i], min_h);

  cout << min_h << endl;
  return 0;
}

Measured memory_bytes: 892
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#define N_MAX 100005
using namespace std;
typedef long long ll;
ll num[6];

int main()
{
	ll N, A, B, C, D, E;
  	ll ans = 0;
    cin >> N >> A >> B >> C >> D >> E;
	num[0] = N;
  	num[1] = A;
    num[2] = B;
    num[3] = C;
    num[4] = D;
    num[5] = E;
  	ll min = 1000000000000007;
  	int min_num = 0;
  	for(int i = 0; i < 6; i++){
    	if(num[i] < min){
        	min = num[i];
          	min_num = i;
        }
    }
  	if(min_num == 0) ans = 5;
  	else{
    	ans = 4 + N/min;
      	if(N%min > 0) ans++;
    }
  	cout << ans << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    string ss;
    cin>>ss;
    int q;
    cin>>q;
    bool dir=false;
    string front="",back="";
    while(q--)
    {
        int t;
        cin>>t;
        if(t==1) dir=(!dir);
        else if(t==2)
        {
            int f;
            char c;
            cin>>f>>c;
            if((f==1&&dir==false)||(f==2&&dir==true))
                front+=c;
            else
                back+=c;
        }
    }
    reverse(front.begin(),front.end());
    ss=front+ss+back;
    if(dir) reverse(ss.begin(),ss.end());
    cout<<ss<<endl;
    return 0;
}

Measured memory_bytes: 1200
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b)  for(int i=(a),i##formax=(b);i< i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formin=(b);i>=i##formin;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max((x),(y))
#define mins(x,y) x=min((x),(y))
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define all(a) ((a).begin()),((a).end())
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define bit(n) (1LL<<(n))
typedef long long ll;
typedef __int128_t lll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>using P=pair<T,Y>;
template<class T,class Y>ostream& operator<<(ostream&o,P<T,Y>&p){return o<<"("<<p.fi<<","<<p.se<<")";}
template<class T>ostream& operator<<(ostream&o,V<T>&v){for(T&t:v)o<<t<<",";return o<<endl;}
template<class T>void uniq(V<T>&v){sort(all(v));v.erase(unique(all(v)), v.end());}

lll gcd(lll a,lll b,lll&x,lll&y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll modInv(ll a,ll m){lll x,y;gcd(a,m,x,y);return(x%m+m)%m;}
ll modPow(lll a,lll n,ll m){lll p=1;for(;n;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return p;}
V<ll>F,R;void setF(int n,int mod){F=R=V<ll>(++n);F[0]=1;FOR(i,1,n)F[i]=F[i-1]*i%mod;R[n-1]=modInv(F[n-1],mod);FORR(i,n-1,1)R[i-1]=R[i]*i%mod;}
ll comb(int a,int b,int m){return a<b||b<0?0:F[a]*R[b]%m*R[a-b]%m;}

const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 1e9+7; //998244353;
const int N = 1e6;
int x, y;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  setF(N, MOD);
  cin >> x >> y;
  y += x;
  if(y%3){
    cout << 0 << endl;
    return 0;
  }
  y /= 3;
  x -= y;
  cout << comb(y, x, MOD) << endl;
}

Measured memory_bytes: 16000
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  cout << fixed << setprecision(10);
  ll N,x;
  cin >> N >> x;
  vector<ll> a(N);
  rep(i,N) cin >> a[i];
  ll ans = 0;
  rep(i,N-1)
  {
    if(a[i]+a[i+1]>x)
    {
      ans += a[i] + a[i+1] - x;
      a[i+1] -= a[i] + a[i+1] - x;
      if(a[i+1]<0)
      {
        a[i+1] = 0;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


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

int a, b;

int main(void){
	while(cin >> a >> b){
		long int d=0, s; //d:digit s:sum
		s = a + b;
		while(s>=1){
			s = s/10;
			d++;
		}
		cout << d << endl;
	}
	return 0;
}

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

int main() {
	int Max = 0;
	
	string s;
	cin >> s;

	regex e("[ACGT]+");
	smatch sm;

	while (regex_search(s, sm, e)) {
		Max = max(Max, int(sm[0].length()));
		s = sm.suffix();
	}

	cout << Max;


	return 0;
}

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


bool isok(ll x) {
  bool b = true;
  for(ll i = 2; i<=floor(sqrt(x)); i++) {
    if(x%i == 0) {
      b = false;
    }
  }
  return b;
}

ll f(ll x) {
  ll res;
  ll i = x;
  bool flag = true;
  while(flag) {
    if(isok(i)) {
      res = i;
      break; 
    }
    i++;
  }
  return res;
}

int main() {
  ll x;
  cin >> x;
  cout << f(x) << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(ll i=0;i<n;i++)
const ll INF=1e15;
const int inf=1e9;
const ll MOD=1e9+7;

int par[100000],depth[100000];
vector<queue<int>> a(100000);
int count;
int findpar(int i){
    if(par[i]==-1) return ::count;
    else{
        ::count++;
        findpar(par[i]);
    }
    return ::count;
}

int main(){
    int N;cin>>N;
    rep(i,N)par[i]=-1;
    rep(i,N){
        int id,k;cin>>id>>k;
        rep(j,k){
            int c;cin>>c;
            a[id].emplace(c);
            par[c]=id;
        }
    }
    rep(i,N){
        ::count=0;
        depth[i]=findpar(i);
    }
    rep(i,N){
        if(par[i]==i)par[i]=-1;
        cout<<"node "<<i<<": parent = "<<par[i]<<", depth = "<<depth[i]<<", ";
        if(par[i]==-1)cout<<"root";
        else if(a[i].size())cout<<"internal node";
        else cout<<"leaf";
        cout<<", [";
        while(a[i].size()){
            cout<<a[i].front();
            if(a[i].size()!=1)cout<<", ";
            a[i].pop();
        }
        cout<<"]"<<endl;
    }
    return 0;
}


Measured memory_bytes: 71356
n, m  = map(int, input().split())
lst = [list(map(int, input().split())) for i in range(m)]
p = list(map(int, input().split()))
d = [0]*(n+1)
s = 0
for i in range(2**n):
  for j in range(n):
    if i & (1<<j):
      d[j+1] = 1
    else:
      d[j+1] = 0
  for k in range(m):
    a = 0
    for l in range(1, lst[k][0]+1):
      a = (a+d[lst[k][l]])%2
    if a!=p[k]:
      break
  else:
    s += 1

print(s)

Measured memory_bytes: 9196
#include <iostream>
#include <cstring>
#include <string>    
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
#define MAX_N 100008
ll n, a[MAX_N], b[MAX_N], c[MAX_N], ans1[MAX_N], ans2[MAX_N];

int cnt(ll x[], ll k){
	ll bimin = 0;
	ll bimax = n+1;
	while(bimin+1 != bimax){
		ll mid = (bimin+bimax)/2;
		if(x[mid] < k){
			bimin = mid;
		}
		else{
			bimax = mid;
		}
	}
	return bimin;
}

int main(){
	cin >> n;
	for(ll i = 1; i <= n; i++){cin >> a[i];}
	for(ll i = 1; i <= n; i++){cin >> b[i];}
	for(ll i = 1; i <= n; i++){cin >> c[i];}
	sort(a+1, a+n+1);
	sort(b+1, b+n+1);
	sort(c+1, c+n+1);
	
	for(ll i = 1; i <= n; i++){ans1[i] = cnt(a, b[i]);}
	for(ll i = 2; i <= n; i++){ans1[i] += ans1[i-1];}
	for(ll i = 1; i <= n; i++){ans2[i] = ans1[cnt(b, c[i])];}
	
	ll answer = 0;
	for(ll i = 1; i <= n; i++){answer += ans2[i];}
	cout << answer << endl;
	return 0;
}

Measured memory_bytes: 4096
n, m = map(int, input().split())
sc = [list(map(int, input().split())) for i in range(m)]

ans = ["x"] * n

for s, c in sc:
    if ans[s - 1] == "x":
        ans[s - 1] = str(c)
    else:
        if ans[s - 1] != str(c):
            print(-1)
            exit()

if n == 1:
    if ans[0] == "x":
        print(0)
    else:
        print(ans[0])
    exit()

for i in range(len(ans)):
    if ans[i] == "x":
        if i != 0:
            ans[i] = "0"
        else:
            ans[i] = "1"

if len(ans) > 1 and ans[0] == "0":
    print(-1)
    exit()

print("".join(ans))

Measured memory_bytes: 3064
#include<stdio.h>

int main() {
    int a, b, c, n;
    scanf("%d%d%d",&a,&b,&c);
    scanf("%d",&n);
    while (a >= b) {
        b = b * 2;
        if (n > 0) n--;
        else {
            printf("No");
            return 0;
        }
    }
    while (b >= c) {
        c = c * 2;
        if (n > 0) n--;
        else {
            printf("No");
            return 0;
        }
    }
    printf("Yes");
}

Measured memory_bytes: 1736
def p_(val):
    ret = 1
    for i in range(2, val+1):
        ret *= i
    return ret


def func(n, val):
    l = [j for j in range(1, n+1)]
    idx = 0
    for i, val_i in enumerate(val[:-1]):
        idx += (l.index(val_i)) * p_(n - 1 - i)
        l.pop(l.index(val_i))
    return idx


n = int(input())
p = [int(x) for x in input().split()]
q = [int(x) for x in input().split()]
print(abs(func(n, p) - func(n, q)))

Measured memory_bytes: 3064
#include <stdio.h>
#include <algorithm>
using namespace std;
using ll = long long;

int n, m, a[10100];
int main() {
	scanf("%d %d", &n, &m);
	for (int i = 0; i < m; i++)
		scanf("%d", a + i);
	for (int i = 0; i < m; i++)
		n -= a[i];
	printf("%d\n", max(-1, n));
}

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

int main() {
  int N;
  cin >> N;
  vector<int> A1(N);
  for (int i=0; i<N; i++) cin >> A1[i];
  vector<int> A2(N);
  for (int i=0; i<N; i++) cin >> A2[i];

  // 1行目の累積和
  vector<int> T1(N);
  T1[0] = A1[0];
  for (int i=1; i<N; i++) T1[i] = T1[i-1] + A1[i];

  // 2行目の累積和
  vector<int> T2(N);
  T2[0] = A1[0] + A2[0];
  for (int i=1; i<N; i++) T2[i] = max(T1[i], T2[i-1]) + A2[i];

  cout << T2[N-1] << endl;

  return 0;
}


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

int main(){
    int n, m;
    cin >> n >> m;

    vector<pair<long long int, long long int>> drink(n);
    for(int i=0; i<n; i++){
        long long int a, b;
        cin >> a >> b;
        drink[i] = make_pair(a, b);
    }

    sort(drink.begin(), drink.end());

    int count = m;
    long long int cost = 0;
    for(int i=0; i<n; i++){
        if(drink[i].second <= count){
            cost += drink[i].first * drink[i].second;
            count -= drink[i].second;
        }
        else if(drink[i].second > count){
            cost += drink[i].first * count;
            break;
        }
    }
    cout << cost << endl;
    return 0;
}

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

int main() {
  int N,W;
  cin >> N >> W;
  vector<int> w(N),v(N);
  for (int i=0;i<N;i++){
    cin >> w[i] >> v[i];
  }
  vector<vector<long long>> dp(N+1,vector<long long>(W+1));
  for (int i=0;i<W+1;i++){
    dp[0][i]=0;
  }
  for (int i=0;i<N;i++){
    for (int sum=0;sum<W+1;sum++){
      if (sum>=w[i]){
        dp[i+1][sum]=max(dp[i][sum],dp[i][sum-w[i]]+v[i]);
      }
      else {
        dp[i+1][sum]=dp[i][sum];
      }
    }
  }
  cout << dp[N][W] << endl;
}

Measured memory_bytes: 80256
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

# 文字列の読み込み
str = input()
a = list(set(str))
if len(a)==4:
    print("Yes")
elif len(a)%2==1:
    print("No")
else:
    if ('N' in a and 'S' in a ) or ('W' in a and 'E' in a ):
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define Fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define MOD 1000000007

ll a,b,k,i; 

int main()
{
    Fast;
    cin>>k;
    if(k==0)
        return 0;
    cin>>a>>b;
    for(i=a;i<=b;i++)
    {
        if(i%k==0)
        {
            cout<<"OK";
            return 0;
        }
    }
    cout<<"NG";
}

Measured memory_bytes: 3648
import java.io.BufferedReader;
import java.io.InputStreamReader;

class Main{
	static double before[][];
	static double after[][];
	static boolean souko[][];
	public static void main(String args[]){
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		try{
			while(true){
				int n = Integer.parseInt(br.readLine());
				if(n == 0) return;

				String strs[] = br.readLine().split(" ");
				char s = strs[0].charAt(0);
				char t = strs[1].charAt(0);
				char b = strs[2].charAt(0);

				before = new double[3][3];
				souko = new boolean[3][3];

				int bs[] = charToInts(b);
				souko[bs[0]][bs[1]] = true;
				//print(souko);

				int ss[] = charToInts(s);
				before[ss[0]][ss[1]] = 1.0;
				//print(before);

				for(int i = 0; i < n; i++){
					after = new double[3][3];
					calc();
					before = after;
					//print(before);
				}

				int ts[] = charToInts(t);
				System.out.println(before[ts[0]][ts[1]]);
			}
		}catch(Exception e){
		}
	}

	static void calc(){
		for(int i = 0; i < 3; i++){
			for(int j = 0; j < 3; j++){
				double p = before[i][j] * 0.25;
				// ←
				if(j == 0 || souko[i][j-1]){
					after[i][j] += p;
				}else{
					after[i][j-1] += p;
				}

				// ↑
				if(i == 0 || souko[i-1][j]){
					after[i][j] += p;
				}else{
					after[i-1][j] += p;
				}

				// →
				if(j == 2 || souko[i][j+1]){
					after[i][j] += p;
				}else{
					after[i][j+1] += p;
				}

				// ↓
				if(i == 2 || souko[i+1][j]){
					after[i][j] += p;
				}else{
					after[i+1][j] += p;
				}
			}
		}
	}

	static int[] charToInts(char c){
		int m = c - 'A';
		//System.out.println(m);
		int result[] = {m / 3, m % 3};
		//System.out.println("(" + result[0] + ", " + result[1] + ")");
		return result;
	}

	static void print(double m[][]){
		for(int i = 0; i < m.length; i++){
			for(int j = 0; j < m[i].length; j++){
				System.out.print(m[i][j] + "\t");
			}
			System.out.println();
		}
	}

	static void print(boolean m[][]){
		for(int i = 0; i < m.length; i++){
			for(int j = 0; j < m[i].length; j++){
				System.out.print(m[i][j] + "\t");
			}
			System.out.println();
		}
	}
}

Measured memory_bytes: 17096
#include <iostream>
#include <bits/stdc++.h>
#include<string>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <fstream>
#include <vector>

#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ll long long
#define SPACE " "
#define nLINE '\n'
#define ss second
#define ff first
//scanf("%d",&x) ,s.insert(x);
using namespace std;

ll GCD(ll a, ll b) {
	//Euclidian
	if (!b) return a;
	else return GCD(b, a % b);
}
const ll MAX = 51;
bool prime[MAX];
void sieve() {
	for (int p = 2; p * p <= MAX; p++)
		if (prime[p] == false)
			for (int i = p * 2; i <= MAX; i += p)
				prime[i] = true;
}

int comb(int a, int b)
{
	if (a < b) return 0;
	if (a == b) return 1;
	if (b == 0) return 1;
	return comb(a - 1, b) + comb(a - 1, b - 1);
}
int x[30];
long long int y[30];
long long int func(int s, int t)
{
	if (t == 0) return 1;
	if (s == 0) return 1;

	if (x[s] == 0) return func(s - 1, t);
	else
	{
		long long int sum = 0;
		for (int i = 0;i <= t;i++) sum += comb(s - 1, i) * y[i];

		long long int s1 = sum;

		sum = 0;
		for (int i = 0;i <= t - 1;i++) sum += comb(s - 1, i) * y[i];
		long long int s2 = (x[s] - 1) * sum;
		long long int s3 = func(s - 1, t - 1);
		return s1 + s2 + s3;
	}
}



int dp[13][1 << 13];
double arr[20][20];
int n;
int dvds[13],svs[13];
vector<double> sssp(int);
vector<double> minDis[20];
int Size;

double solve(int current, int mask) {
    if(mask == ((1 << Size) - 1)) return -arr[dvds[current]][0];

    if(dp[current][mask] != -1)
        return dp[current][mask];


    double Max = -arr[dvds[current]][0];
    for(int i= 0; i< Size; i++)
        if((mask & (1 << i)) == 0)
            Max = max(Max, svs[i] - arr[dvds[current]][dvds[i]]+ solve(i, mask | (1 << i)));

    return dp[current][mask]= Max;
}

int nextMin(int,int);
int lis[100001];
int main() {
	int N;
	cin >> N;
    for (int x=1;x<=100;x++){
        for (int y=1;y<=100;y++){
            for (int z=1;z<=100;z++){
                int n = x*x + y*y + z*z + x*y + y*z + z*x;
                    lis[n] ++;
            }
        }
    }
    for (int n=1;n<=N;n++)
        cout << lis[n] << nLINE;
}

bool used[20];
vector<double> sssp(int src) {
	vector<double> disSource(n);
	fill(disSource.begin(), disSource.end(), INT_MAX);
	disSource[src] = 0;
	int curr = src;
	memset(used, false, sizeof used);
	used[curr] = true;
	while (curr != -1) {
		for (int j = 0;j < n;j++) {
			if (arr[curr][j] != -1) {
				if (disSource[j] == INT_MAX) disSource[j] = arr[curr][j] + disSource[curr];
				else disSource[j] = std::min(disSource[j], disSource[curr] + arr[curr][j]);
			}
		}
		used[curr] = true;
		curr = nextMin(curr,src);
	}
	return disSource;
}

int nextMin(int curr,int src) {
	int indx = -1;
	double Min = 1e9;
	for (int i = 0;i < n;i++) {
		if (arr[curr][i]!=-1 && arr[curr][i] <= Min && used[i] == false) {
			Min = arr[curr][i];
			indx = i;
		}
	}
	if (indx == -1){
        for(int i=0;i<n;i++)
            if(arr[src][i]!=-1 && arr[curr][i] <= Min && used[i]== false)
                indx = i , Min = arr[curr][i];
	}
	if (indx == -1) return -1;
	return indx;
}


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

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

    static class XXOR {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            long k = in.nextLong();
            long[] a = new long[n];
            long max = k;
            for (int i = 0; i < n; i++) {
                a[i] = in.nextLong();
                max = Math.max(max, a[i]);
            }

            // 桁数 | 未満フラグ
            long[][] dp = new long[100][2];

            int dnum = 0;
            for (int i = 0; i <= 50; i++) {
                // ありえない遷移をさせない
                dp[i][0] = -1;
                dp[i][1] = -1;
                if ((max >> i) > 0) {
                    dnum++;
                }
            }
            if (k == 0) {
                long result = 0;
                for (long l : a) {
                    result ^= l;
                }
                out.println(result);
                return;
            }
            // 桁0で、k未満はあり得る
            dp[0][0] = 0;
            for (int i = 0; i < dnum; i++) {
                int shift = dnum - i - 1;
                long mask = 1L << shift;
                long one = 0;
                for (long l : a) {
                    if ((l & mask) > 0) {
                        one++;
                    }
                }
                long cost0 = one * mask;
                long cost1 = (n - one) * mask;

                // 未満フラグが立たない場合もあるのでチェックする
                if (dp[i][1] != -1) {
                    dp[i + 1][1] = Math.max(dp[i + 1][1], dp[i][1] + Math.max(cost1, cost0));
                }

                // 未満フラグ立ってない
                if (dp[i][0] != -1) {
                    // ぴったり->未満
                    if ((k & mask) > 0) {
                        // kのbitが立っていたときに未満にできる
                        dp[i + 1][1] = Math.max(dp[i + 1][1], dp[i][0] + cost0);
                    }

                    // ぴったり->ぴったり
                    if ((k & mask) > 0) {
                        dp[i + 1][0] = Math.max(dp[i + 1][0], dp[i][0] + cost1);
                    } else {
                        dp[i + 1][0] = Math.max(dp[i + 1][0], dp[i][0] + cost0);
                    }

                }
            }
            out.print(Math.max(dp[dnum][0], dp[dnum][1]));
        }

    }
}



Measured memory_bytes: 60392
#include <bits/stdc++.h>
#define rep(i, l, r) for (__typeof(l) i = (l); i <= (r); ++i)
#define per(i, r, l) for (__typeof(r) i = (r); i >= (l); --i)
using namespace std;
typedef long long ll;
const int mod = 998244353;
int read() {
	int f = 1, x = 0; char ch = getchar(); while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
	while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); } return f * x;
}
int qpow(int a, int b) { int res = 1; while (b) { if (b & 1) res = (ll)res * a % mod; a = (ll)a * a % mod; b >>= 1; } return res; }

ll X; 
int main() {
	cin >> X;
	ll mx = X / 500;
	ll ans = mx * 1000 + (X % 500) / 5 * 5;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<string, int> P;

bool pairCompare(const P &firstElof, const P &secondElof)
{
    if (firstElof.first != secondElof.first){
        return firstElof.first < secondElof.first;
    }else{
        return firstElof.second > secondElof.second;
    }
}

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

    int N;
    cin >> N;

    vector<pair<string, int>> p(N);
    vector<pair<string, int>> unsort_p(N);

    for (int n = 0; n < N; n++)
    {
        cin >> p[n].first >> p[n].second;
    }

    copy(p.begin(), p.end(), unsort_p.begin());

    sort(p.begin(), p.end(), pairCompare);

    for (int n = 0; n < N; n++)
    {
        //cout << p[n].first << p[n].second << '\n';
        for (int n_ = 0; n_ < N; n_++)
        {
            if (unsort_p[n_].second == p[n].second)
            {
                cout << n_ + 1 << '\n';
                break;
            }
        }
    }

    return 0;
}


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


int main()
{
	int H,W;
	cin>>H>>W;
	vector<string> S(H);
	rep(i,H) cin>>S[i];
	const int dir_x[8]={1,1,1,0,-1,-1,-1,0};
	const int dir_y[8]={1,0,-1,-1,-1,0,1,1};
	vector<vector<int>> ans(H,vector<int>(W,0));
	rep(i,H)
	{
		rep(j,W)
		{
			if(S[i][j]=='#')
			{
				rep(k,8)
				{
					int nx=j+dir_x[k];
					int ny=i+dir_y[k];
					if(0<=nx&&nx<W&&0<=ny&&ny<H&&S[ny][nx]=='.')
					{
						ans[ny][nx]++;
					}
				}
			}
		}
	}
	rep(i,H)
	{
		rep(j,W)
		{
			if(S[i][j]=='#') cout<<'#';
			else cout<<ans[i][j];
		}
		cout<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long int a, b, c, d;
    cin >> a >> b >> c >> d;
    long long int answer = -1e18;
    answer = max(answer, a*c);
    answer = max(answer, a*d);
    answer = max(answer, b*c);
    answer = max(answer, b*d);
    if(answer < 0){
        if((min(a, b) <= 0 && max(a, b) >= 0) || (min(c, d) <= 0 && max(c, d) >= 0)){
            answer = 0;
        }
    }
    cout << answer << "\n";
    return 0;
}

Measured memory_bytes: 3632
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>

int main(void) {
	int a, b;
	
	scanf("%d %d", &a, &b);
	printf(a * b % 2 == 0 ? "No" : "Yes");
	
	return 0;
}

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

using namespace std;

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

const int N = 110;

int w, h, n;
bool g[N][N];

int main()
{
    cin >> w >> h >> n;
    while(n--)
    {
        int x, y, a;
        cin >> x >> y >> a;
        if(a == 1)
        {
            for(int i = 1; i <= x; i++)
                for(int j = 1; j <= h; j++)
                    g[i][j] = true;
        }
        else if(a == 2)
        {
            for(int i = x + 1; i <= w; i++)
                for(int j = 1; j <= h; j++)
                    g[i][j] = true;
        }
        else if(a == 3)
        {
            for(int i = 1; i <= w; i++)
                for(int j = 1; j <= y; j++)
                    g[i][j] = true;
        }
        else
        {
            for(int i = 1; i <= w; i++)
                for(int j = y + 1; j <= h; j++)
                    g[i][j] = true;
        }
    }

    int res = 0;
    for(int i = 1; i <= w; i++)
        for(int j = 1; j <= h; j++)
            if(!g[i][j])
                res++;

    cout << res << endl;

    return 0;
}


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

int main() {
	int n, sum = 0;
	vector<int> a;
	cin >> n;
	a.push_back(0);
	rep(i, n) {
		int ai;
		cin >> ai;
		a.push_back(ai);
	}
	a.push_back(0);
	rep(i, n + 2) {
		if (i != 0) {
			sum += abs(a[i] - a[i - 1]);
		}
	}
	int tmp = sum;
	rep(i, n + 2) {
		sum = tmp;
		if (i != 0 && i != n + 1) {
			sum -= abs(a[i + 1] - a[i]) + abs(a[i] - a[i - 1]) - abs(a[i + 1] - a[i - 1]);
			cout << sum << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3904
#include<stdio.h>
#define INF 1000000
#define MIN(A,B) ((A) <= (B) ? (A) : (B))

int Ma,Mb,N,maxasum,maxbsum;
int a[41],b[41],c[41];
int DP[41][401][401];

int main(void){
    int i,j,k;


    scanf("%d %d %d",&N,&Ma,&Mb);

    for(i = 1;i <= N;i++)
        scanf("%d %d %d",&a[i],&b[i],&c[i]);

    j = 0;k = 0;
    for(i = 1;i <= N;i++){
            j += a[i];
            k += b[i];
    }
    maxasum = j;
    maxbsum = k;

    for(i = 0;i <= N;i++)
        for(j = 0;j <= 400;j++)
            for(k = 0;k <= 400;k++)
                DP[i][j][k] = INF;

    DP[0][0][0] = 0;
    for(i = 1;i <= N;i++){
        for(j = 0;j <= maxasum;j++ ){
            for(k = 0;k <= maxbsum;k++){
                if(a[i] <= j && b[i] <= k)
                    DP[i][j][k] = MIN(DP[i - 1][j - a[i]][k - b[i]] + c[i],DP[i - 1][j][k]);
                else
                    DP[i][j][k] = DP[i - 1][j][k];
            }
        }
    }

    i = Ma;j = Mb;k = INF;
    while(i <= maxasum && j <= maxbsum){
        if(k > DP[N][i][j])
            k = DP[N][i][j];
        i += Ma;j += Mb;
    }
    printf("%d\n",k < INF ? k : -1);
    return 0;

}

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

using namespace std;
using ll = long long;




int main() {
    int n,t,s;
    cin>>n>>t>>s;
    vector<ll> a(n);
    vector<ll> b(n);
    for(int i = 0;i < n;++i) {
        cin>>a[i];
        cin>>b[i];
    }

    vector<vector<ll>> dp(n,vector<ll>(t+1,0LL));

    ll tm=0LL;

    for(int i = b[0];i <= t;++i) {
        if(i-b[0]<s&&s<i)dp[0][i]=tm;
        else dp[0][i]=a[0],tm=a[0];
    }

    for(int i = 1;i < n;++i) {
        tm=0LL;
        for(int j = 0;j <= t;++j) {
            if(j-b[i]<s&&s<j)dp[i][j]=max(dp[i-1][j],tm);
            else if(j<b[i])dp[i][j]=dp[i-1][j],tm=max(dp[i][j],tm);
            else {
                dp[i][j]=max(dp[i-1][j],dp[i-1][j-b[i]]+a[i]);
                tm=max(dp[i][j],tm);
            }
        }
    }
    cout<<dp[n-1][t]<<endl;
    return 0;
}



Measured memory_bytes: 73392
a,b,c,d = gets.chomp.split('').map(&:to_i)
if a + b + c + d == 7
  puts a.to_s + "+" + b.to_s + "+" + c.to_s + "+" + d.to_s + "=7"
  a = 0.1
end
if a + b + c - d == 7
  puts a.to_s + "+" + b.to_s + "+" + c.to_s + "-" + d.to_s + "=7"
  a = 0.1
end
if a + b - c + d == 7
  puts a.to_s + "+" + b.to_s + "-" + c.to_s + "+" + d.to_s + "=7"
  a = 0.1
end
if a + b - c - d == 7
  puts a.to_s + "+" + b.to_s + "-" + c.to_s + "-" + d.to_s + "=7"
  a = 0.1
end
if a - b + c + d == 7
  puts a.to_s + "-" + b.to_s + "+" + c.to_s + "+" + d.to_s + "=7"
  a = 0.1
end
if a - b + c - d == 7
  puts a.to_s + "-" + b.to_s + "+" + c.to_s + "-" + d.to_s + "=7"
  a = 0.1
end
if a - b - c + d == 7
  puts a.to_s + "-" + b.to_s + "-" + c.to_s + "+" + d.to_s + "=7"
  a = 0.1
end
if a - b - c - d == 7
  puts a.to_s + "-" + b.to_s + "-" + c.to_s + "-" + d.to_s + "=7"
  a = 0.1
end

Measured memory_bytes: 14400
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <random>
#include <iterator>

using namespace std;

#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(v) reverse((v).begin(),(v).end())
#define ANS(ans) cout<<(ans)<<endl;
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
typedef vector<int> VI;
typedef pair<int, int> P;

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

struct MyStruct {
	int idx, pts;
	string name;
};

bool comp(const MyStruct& s, const MyStruct& t) {
	if (s.name != t.name)
		return s.name < t.name; 
	return s.pts > t.pts;
}
int main() {
	int n, m;
	cin >> n >> m;
	int s[10][10] = {};
	REP(i, m) {
		int k;
		cin >> k;
		REP(j, k) {
			cin >> s[i][j];
		}
	}
	VI p(m);
	REP(i, m) {
		cin >> p[i];
	}
	int sum;
	int ans = 0;
	bool flag = 1;
	REP(i, pow(2, n)) {
		bitset<10> b(i);
		flag = 1;
		REP(x, m) {
			if (flag == 0) {
				break;
			}
			sum = 0;
			REP(y, 10) {
				if (s[x][y] == 0) {
					break;
				}
				else {
					if (b[s[x][y] - 1]) {
						sum++;
					}
				}
			}
			if (sum % 2 != p[x]) {
				flag = 0;
			}
		}
		if (flag == 1) {
			ans++;
		}
		
	}
	ANS(ans)

	return 0;

}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <map>
#include <math.h>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <set>
#include <queue>
#include <sstream>
#include <stack>
#include <deque>
#include <memory.h>
#include <cassert>
#include <ctime>
#include <climits>
#include <list>
#include <time.h>
#include <unordered_map>
#include <bitset>
#include <exception>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned long long ull;
#define pb push_back
#define mp make_pair
#define FILE "file"
#define lc v << 1
#define rc (v << 1) + 1
#define inf 1e+9
#define linf ll(1e+18)
#define dinf 1e+14

typedef long long ll;
#define pb push_back
#define mp make_pair

int get(int x)
{
    int res = 0;
    while(x > 0)
    {
        res += (x % 10);
        x /= 10;
    }
    return res;
}

void solve()
{
    int n;
    cin >> n;
    if(n % get(n) == 0)
    {
        cout << "Yes";
    }
    else
    {
        cout << "No";
    }
}

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0), cout.tie(0);
    //freopen(FILE ".in", "r", stdin);freopen(FILE ".out", "w", stdout);
    //freopen("file.in", "r", stdin);freopen("file.out", "w", stdout);
    int t = 1;
    //cin >> t;
    
    while(t--)
    {
        solve();
    }
    
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <map>
#include <vector>

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> v(n);
  vector<pair<int, int>> odd;
  odd.reserve(n / 2);
  vector<pair<int, int>> even;
  even.reserve(n / 2);
  map<int, int> odd_map;
  map<int, int> even_map;
  for (int i = 0; i < n; i++) {
    cin >> v[i];
    if (i % 2 == 0) {
      even_map[v[i]]++;
    } else {
      odd_map[v[i]]++;
    }
  }
  for (auto p : odd_map) odd.push_back({p.second, p.first});
  for (auto p : even_map) even.push_back({p.second, p.first});
  sort(odd.begin(), odd.end(), greater<pair<int, int>>());
  sort(even.begin(), even.end(), greater<pair<int, int>>());

  int ans = 0;
  if (odd[0] == even[0]) {
    if (odd_map.size() == 1) {
      ans = n / 2;
    } else {
      ans = n - odd[0].first - max(odd[1].first, even[1].first);
    }
  } else {
    ans = n - odd[0].first - even[0].first;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 6144
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MAX = 2000000;
const ll MOD = 1000000007;
ll n;

int main() {
    cin >> n;
    ll d = 0;
    if(n%2 == 0){
        ll n1 = n/2;
        //cout << n1 << endl;
        do{
            n1 = n1/5;
            //cout << n1 << endl;
            d += n1;
        }while(n1 > 4);
    }
    cout << d << endl;
    return 0;
}

Measured memory_bytes: 256
# include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long 
ll dp[10005][105][2];
int n;string str;int k;
vector<int> v;
ll get(int pos,ll sum,bool  f)
{ ll& ans=dp[pos][sum][f];
  
  if(pos==n)
 { 
    if(sum%k==0) return (ans=1);
    else
      return (ans=0);
 }
 
 if(ans!=-1) return ans;
 ans=0;
  int lim=(f)? 9:v[pos];
  for(int i=0;i<=lim;i++)
  { 
    ans=(ans+get(pos+1,(sum+i)%k,f | (i<v[pos])))%mod;

  }
   return ans;
  
}

int main()
{  //ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  //string str;
 // cin.ignore();
  cin>>str;
  cin>>k;
  n=str.size();
 // cout<<str<<" ";
 //cout<<k<<" ";
 for(auto& i:str)
  v.push_back(i-'0');
   memset(dp, -1, sizeof (dp));
 cout<<(get(0,0,0)-1+mod)%mod;
  return 0;
  
}

Measured memory_bytes: 17536
L = int(input())

# ans = 0
# for i in range(1,L-1):
#     for j in range(1,L):
#         mm = L-i-j
#         ans = max(i*j*mm,ans)
#         # print(i,j,ans)
# print(ans)


mm = L/3
print(mm**3)






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

using namespace std;

int main(){
	int W,H,x,y,r;
	cin>>W>>H>>x>>y>>r;
	if(x-0>=r&&y-0>=r&&W-x>=r&&H-y>=r)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define fio     ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);
#define pi      3.14159265
#define ll      long long
#define repe    ll tc,cas=0;cin>>tc;while(tc--)
#define op      freopen("output.txt", "w", stdout);
using namespace std;


int main()
{
    fio;
    int n,a,ans=0;
    cin>>n;

    while(n--)
    {
        cin>>a;
        if(a==0) ans=a;
        else ans=__gcd(a,ans);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define ll long long
#define maxn 100005 /*rem*/
#define mod 998244353
#define db double
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define pi pair<int, int>
#define fi first
#define se second
using namespace std;
ll ksm(ll a, ll b) {
   if (!b) return 1;
   ll ns = ksm(a, b >> 1);
   ns = ns * ns % mod;
   if (b & 1) ns = ns * a % mod;
   return ns;
}
int st[maxn];
int l;
int n;
int ans[maxn];
ll a[maxn];
int main() {
	int top = 0;
	cin >> n >> l;
	int cnt = 0;
	for (int i = 1; i <= n; i++) {
		scanf("%lld", &a[i]);
		while (top && a[i] + a[st[top - 1]] >= l)
			a[i] += a[st[top - 1]], 
			ans[cnt++] = st[top - 1], 
			top--;
		st[top++] = i;
	}
	if (top == 1) {
		cout << "Possible" << endl;
		for (int i = cnt - 1; i >= 0; i--)
			cout << ans[i] << ' ';
		cout << endl;
 	}
 	else {
 		cout << "Impossible" << endl;
	 }
	return 0;
}


Measured memory_bytes: 2432
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int main(void)
{
	int n,i,j,jcnt,icnt,jj[100000],ii[100000];
	long long cnt1,cnt2,mx,x,m1;
	char buf[100001];
	scanf("%d",&n);
	scanf("%s",buf);
	icnt=0;	jcnt=0;
	for(i=0;i<n;i++)	{
		if(buf[i]=='I')	icnt++;
		if(buf[i]=='J')	jcnt++;
		ii[i]=icnt;	jj[i]=jcnt;
	}
	for(i=0;i<n;i++)	{
		ii[i]=icnt-ii[i];
		if(buf[i]=='I')	ii[i]++;
	}
//	for(i=0;i<n;i++)	printf("%d %d\n",ii[i],jj[i]);
	cnt1=0;
	for(i=0;i<n;i++)	{
		if(buf[i]=='O')	{
			x=(long long)(jj[i]+1)*ii[i];
			cnt1+=x;
		}
	}
	cnt2=0;
	for(i=0;i<n;i++)	{
		if(buf[i]=='O')	{
			x=(long long)(jj[i])*(ii[i]+1);
			cnt2+=x;
		}
	}
	mx=max(cnt1,cnt2);
	cnt1=0;
	m1=0;
	for(i=0;i<n;i++)	{
		if(buf[i]=='O')	{
			x=(long long)jj[i]*ii[i];
			cnt1+=x;
		}
		m1=max(m1,(long long)jj[i]*ii[i]);
	}
	cnt1+=m1;
	mx=max(cnt1,mx);
	printf("%lld\n",mx);
	return 0;
}


Measured memory_bytes: 3568
#include <bits/stdc++.h>
#include <cstdio>
#include <unordered_map>
#define ll long long
using namespace std;

unordered_map<string, int> userToWordCountMap;


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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define mset(arr,val) memset(arr,val,sizeof(arr))
#define loop(i,a,b) for(ll i=a;i<b;++i)
#define dloop(i,a,b) for(ll i=a;i>=b;--i)
#define all(a) a.begin(),a.end()
#define lar 1000000007
#define pq priority_queue 
#define pll pair<ll,ll>
#define ss second
#define ff first
#define pb push_back
#define ppb pop_back
#define umap unordered_map
#define ub upper_bound
#define lb lower_bound
#define br "\n"
#define sp " "
const int N=1e5;

void solve(){
	double d,t,s;
   cin>>d>>t>>s;
  double f = d/t;
  if(s<f) cout<<"No\n";
  else cout<<"Yes\n";
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
}


Measured memory_bytes: 3736
#include<bits/stdc++.h>
#define ll long long int

using namespace std;

int main(void)
{
//	int t;
//	cin>>t;
//	while(t--)
//	{
		char n[12],m[12];
		cin>>n>>m;
		int a = strlen(n);
		int b = strlen(m);
		if(a == b-1 || b == a -1)
		{
			for(int i=0;i<min(a,b);i++)
			{
				if(n[i] != m[i])
				{
					cout<<"No";
					return 0;
				}
			}
			cout<<"Yes";
		}
		else
		{
			cout<<"No";
		}
//			
//			cout<<ans<<endl;
//	}
	return 0;
}


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

int main() {
  int K, A, B;
  cin >> K >> A >> B;
  for (int i = A; i <= B; i++){
    if (i % K == 0) {
      cout << "OK" << endl;
      return 0;
    }
  }
  cout << "NG" << endl;
  return 0;
}

Measured memory_bytes: 3648