akhauriyash/Code-Regression huggingface dataset:
#include<iostream>

using namespace std;

int main(void){
    int i,j,n,q,S[10000],T[500],ans=0;
    cin >> n;
    for(i=0;i<n;i++) cin >> S[i];
    cin >> q;
    for(i=0;i<q;i++) cin >> T[i];
    for(i=0;i<q;i++){
        for(j=0;j<n;j++){
            if(T[i]==S[j]){
                ans++;
                break;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

const int MOD = 1000000007;
const int INF = 1e9;

const int mod = 1000000007;
const int inf = 1e9;
#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
    ld n, m, d;
    cin >> n >> m >> d;
    ld ans;
    if(d == 0) {
        ans = (1.0/n)*(m-1);
    }else{
        ans = (2.0*(n-d))/(n*n)*(m-1);
    }
    cout << fixed << setprecision(20) << ans << endl;
}

Measured memory_bytes: 256
<?php
    fscanf(STDIN,"%s",$S);
    $N=strlen($S);
    $untile_sign = ($N-1)/2;
    $start_sign = ($N+3)/2;
    $miss_flag = false;
    
	
    $reverse = $untile_sign-1;
    for($i=0;$i<$untile_sign;$i++){
        // echo $S[$i]." ".$S[$reverse];
        if($S[$i] != $S[$reverse]){
            $miss_flag = true;
        }
        $reverse--;
    }

    $index = $start_sign-1;
    $indexN = $N-1;


    for($i=$index;$i<$N;$i++){
        // echo $S[$i]." ".$S[$indexN];
        if($S[$i] != $S[$indexN]){
            $miss_flag = true;
        }
        $indexN--;
    }

    $indexN = $N-1;


    for($i=0;$i<$N;$i++){
        // echo $S[$i]." ".$S[$indexN];
        if($S[$i] != $S[$indexN]){
            $miss_flag = true;
        }
        $indexN--;
    }

    

    if($miss_flag){
        echo "No\n";
    }else{
        echo "Yes\n";
    }


    

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

#define min(x,y) ((x)<(y)?(x):(y))

int main(int argc, char *argv[])
{
    long long n;
    long long a[5];
    long long min;
    int i;
    long long ans;

    scanf("%lld", &n);

    for (i = 0; i < 5; i++) {
        scanf("%lld", &a[i]);
    }

    min = min(a[0], min(a[1], min(a[2], min(a[3], a[4]))));

    ans = n / min + 4 + ((n % min)?(1):(0));

    printf("%lld\n", ans);

    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{

    ll n;
    cin>>n;
    ll arr[n+5]= {0};
    for(int i=0; i<n; i++)
    {
        cin>>arr[i];
    }
    ll cnt=0;
    ll ans=INT_MAX;
    for(int i=0; i<n; i++)
    {
        cnt=0;
        if(arr[i]%2==0)
        {
            while(arr[i]%2==0)
            {
                cnt++;
                arr[i]/=2;
            }
            ans=min(ans,cnt);
        }
        else
        {
            ans=min(ans,cnt);
        }



    }
    cout<<ans<<endl;



}



Measured memory_bytes: 3560
import sys


N,K=map(int,input().split())

v=list(map(int,input().split()))
ans=0

for i in range(1,min(K,N)+1):
    for j in range(i+1):
        x=[v[k] for k in range(j)]+[v[k] for k in range(N-i+j,N)]
        tmp=sum(x)
        x.sort()
        
        for k in range(min(i,K-i)):
            if x[k]<0: tmp-=x[k]

        if tmp>ans: ans=tmp

print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<iomanip>
#include <stdlib.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <vector>
#include <numeric>
#include <functional>
#include <cassert>
typedef long long int ll;
using namespace std;

int main(){
	ll N,M,a,b;
	cin>>N>>M;
	a=N%M;
	cout<<min(a,abs(a-M))<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(int i=(n);i<(k);i++)
#define ALL(a)  (a).begin(),(a).end()
ll ans=0;
const ll MOD = 1000000007;
void Main(){
    ll n;cin>>n;
    ll k;cin>>k;
    For(i,k,n+2){
        ans=(ans+(n-(i-1))*i+1)%MOD;
    }
    cout<<ans<<endl;
}
int main(){
    Main();
    /*
    東方風神録は神が出てくるので当然神ゲー
    */
    return 0;
}

Measured memory_bytes: 3632
a, b, c = map(int, input().split())

# if a % b == 0 and c != 0:
#     print('NO')
# else:
#     print('YES')

dic = {a%b:0}
now = a
while(1):
    now += a
    if now%b in dic:
        break
    else:
        dic[now%b]= 0

if c in dic:
    print('YES')
else:
    print('NO')


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long int n,c= 0,i;
  double z,x,y,d;
  cin>>n>>d;
  for(i = 0;i<n;i++)
  { cin>>x>>y;
   z =sqrt(1.0*(x*x+y*y));
   if(z<=d)
     c++;
  }
  cout<<c<<endl;
  return 0;
}
    

Measured memory_bytes: 3836
#include <bits/stdc++.h>
using namespace std;
#define el '\n'

int cost[] = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};
int ar[10], dp[10005];
int n, m;
int serc(int sisa) {
  if (sisa < 0) return -69;
  if (sisa == 0) return 0;
  if (dp[sisa] != -1) return dp[sisa];
  int ret = -1;
  for (int i = 0; i < m; i++) {
    ret = max(ret, 1+serc(sisa-cost[ar[i]]));
  }
  return dp[sisa] = ret;
}

string trace(int cur) {
  if (cur == 0) return "";
  for (int i = 0; i < m; i++) {
    if (dp[cur] == 1+serc(cur-cost[ar[i]])) {
      string ret = to_string(ar[i]) + trace(cur-cost[ar[i]]);
      return ret;
    }
  }
  return "";
}
int main() {
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    cin >> ar[i];
  }
  sort(ar, ar+m, greater<int>());
  memset(dp, -1, sizeof(dp));
  serc(n);
  string ans = trace(n);
  sort(ans.rbegin(), ans.rend());
  cout << ans << el;
  return 0;
}

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

int main(void){
    int m, f, r, p;
    char grade;

    cin >> m >> f >> r;
    while((m != -1) || (f != -1) || (r != -1)){
        p = m + f;
        if((m == -1) || (f == -1)) grade = 'F';
        else if(p >= 80) grade = 'A';
        else if((p >= 65) && (p < 80)) grade = 'B';
        else if((p >= 50) && (p < 65)) grade = 'C';
        else if((p >= 30) && (p < 50)){
            if(r >= 50) grade = 'C';
            else grade = 'D';
        }else grade = 'F';
        cout << grade << endl;
        cin >> m >> f >> r;
    }
    return 0;
}


Measured memory_bytes: 3096
#include<bits/stdc++.h>
using namespace std;
using ll = long long; 
using ull = unsigned long long;
using V = vector<int>;
using VV = vector<vector<int>>;
using VVV = vector<vector<vector<int>>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VVVL = vector<vector<vector<ll>>>;
template<class T> using pq = priority_queue<T>;
template<class T> using P = pair<T, T>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,k,n) for(int i=(k);i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define output(x,y) cout << fixed << setprecision(y) << x << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
ll upper = MOD + MOD;
ll under = -upper;
ll UPPER = MOD * MOD;
ll UNDER = -UPPER;
const long double pi = 3.141592653589793;
int main() { // 問題文はしっかり読め!!!
	int n;
	cin >> n;
	V a(n);
	rep(i, n) {
		cin >> a[i];
	}
	int maxi = *max_element(all(a));
	int cnt = 0;
	int pos = -1;
	rep(i, n) {
		if (a[i] == maxi) {
			pos = i;
			cnt++;
		}
	}
	if (cnt >= 2) {
		rep(i, n) {
			cout << maxi << endl;
		}
	}
	else {
		int maxi2 = -1;
		rep(i, n) {
			if (a[i] != maxi && maxi2 < a[i]) maxi2 = a[i];
		}
		rep(i, n) {
			cout << (i != pos ? maxi : maxi2) << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 2432
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...)name
#define _rep(i,n)repi(i,0,n)
#define repi(i,a,b)for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x)x
#define rep(...)MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c)c.begin(),c.end()
#define write(x)cout<<(x)<<'\n'
using namespace std; typedef long long ll; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T, class U>bool chmax(T& a, U&& b) { return a < b ? a = b, 1 : 0; }
template<class T, class U>bool chmin(T& a, U&& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

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

    ll ans = LINF;
    for (ll n = 1; n * n <= N; ++n) {
        if (N % n == 0) {
            ans = min(ans, n - 1 + N / n - 1);
        }
    }
    write(ans);
}

Measured memory_bytes: 384
#include<iostream>
#include<cmath>
#include<algorithm>
#include <cassert>
#include<string>
#include<vector>
#include <utility>
#include <math.h>
#define INF 1000000000;
using namespace std;
char mas[200500];
int main() {
	int menu[7],counto=0,Key=10;
	for (int i = 0; i < 5; i++) {
		cin >> menu[i];
		if (menu[i] % 10 == 0) {
			counto += menu[i];
		}
		else {
			counto += (((menu[i] / 10) + 1) * 10);
			Key = min(Key, (menu[i] - (menu[i] / 10 * 10)));
		}
	}
	cout << counto-10+Key << endl;
	return 0;
}

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

int main(void)
{
	ll n,i,k,j;
	cin>>n>>k;
	ll H[n];
	for(i=0;i<n;i++)
	cin>>H[i];
	
	vector <ll> dp(n);
	for(i=0;i<n;i++)
	dp[i]=LONG_MAX;
	dp[0]=0;
	dp[1]=abs(H[0]-H[1]);
	ll p=0;
	for(i=2;i<n;i++)
	{
		for(j=max(p,i-k);j<i;j++)
		{
			dp[i]=min(dp[j]+abs(H[i]-H[j]),dp[i]);
		}
	}
	cout<<dp[n-1];
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

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

    ll N, K;
    cin >> N >> K;
    vector<ll> A(N);
    REP(i, N) cin >> A[i];

    vector<ll> B(N+1, 0);
    REP(i, N) B[i+1] = B[i] + A[i];

    vector<ll> C;
    REP(i, N){
    	for(int j=i+1;j<N+1;j++){
    		C.push_back(B[j]-B[i]);
    	}
    }
    //cout << C << endl;
    ll res = 0;
    for(ll k=40;k>=0;k--){
    	ll tmp = (1ll << k);
    	ll kosu = 0;
    	REP(j, C.size()) if(C[j] >= tmp) kosu++;
    	if(kosu >= K){
    		res += tmp;
    		REP(j, C.size()){
    			C[j] -= tmp;
    		}
    	}else{
    		REP(j, C.size()){
    			if(C[j] >= tmp) C[j] -= tmp;
    		}
    	}
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 6384
#include<stdio.h>
#include<algorithm>
using namespace std;
int main(){
int a,b,c[3];
scanf("%d %d",&a,&b);
c[0]=a+b;
c[1]=a-b;
c[2]=a*b;
sort(c,c+3);
printf("%d",c[2]);
return 0;
}

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

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

	rep(i, s.size())
	{
		if (s[i] != t[i])
		{
			count++;
		}
	}

	cout << count << endl;

	return 0;
}

Measured memory_bytes: 3512
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <algorithm>
#define mem(i,a) memset(i,a,sizeof(i))
#define PI acos(-1.0)
#define DMAX 100005
#define MOD 20190823
#define eps 1e-8
#define bl bool
#define INF 1e+9
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
template<class T> inline void read(T &f){
	f=0;
    T x=1;
    char ch=getchar();
    while(ch<48 || ch>57) {
        if(ch=='-') {
            x=-1;
        }
        ch=getchar();
    }
    while(ch<=57 && ch>=48) {
        f=f*10+ch-'0';
        ch=getchar();
    }
    f*=x;
}
int main(){
	ll x,k;
	read(x),read(k);
	for(ll i=k-x+1;i<=k+x-1;i++){
		cout<<i<<" ";
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<deque>
#include<utility>
#include<queue>
#include<stack>
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,x,n) for(int i=(x);i<(n);i++)
#define EREP(i,n) for(int i=1;i<=n;i++)
using namespace std;
int main(){
	int n,d[200000],m,t[200000],some=0,count=0;
	cin>>n;
	REP(i,n)cin>>d[i];
	sort(d,d+n);
	cin>>m;
	REP(i,m)cin>>t[i];
	sort(t,t+m);
	for(int i=0;i<n;i++){
		if(d[i]==t[some]){
			some++;
			count++;
		}
	}
	cout<<((count==m)? "YES":"NO")<<endl;
}

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

typedef long long int ll;
typedef vector<int> vi;            typedef vector<ll> vl;
typedef vector<vi> vvi;         typedef vector<vl> vvl;
typedef pair<int, int>     pii;    typedef pair<ll, ll> pll;
typedef vector<pii> vii;         typedef vector<pll> vll;
typedef map<int,int> mii;
typedef vector<char> vc;
typedef vector<bool> vb;
#define endl '\n'
#define forn(i,n) for(int i=0;i<n;i++)
#define rforn(i,n) for(int i=n-1;i>=0;i--)
#define forne(i,n) for(int i=1;i<=n;i++)
#define rforne(i,n) for(int i=n;i>=1;i--)
#define forse(i,s,e) for(int i=s;i<e;i++)
#define rforse(i,s,e) for(int i=e-1;i>=s;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll)x.size()
#define MOD 1000000007
#define F first
#define S second
#define pb push_back
#define pf push_front
#define rb pop_back
#define rf pop_front
#define in insert
#define mp make_pair
#define fill(a,x) memset(a,x,sizeof a);
#define trav(a,x) for(auto &a:x)
#define min3(a, b, c) min(min(a, b), c)
#define min4(a, b, c, d) min(min(a, b), min(c, d))
#define max3(a, b, c) max(max(a, b), c)
#define max4(a, b, c, d) max(max(a, b), max(c, d))
const ll INFL = 1e18;
const int INFI = 1e9;
#ifdef KARAN
    #include "../../trace.h"
#else
    #define trace(args...)
#endif

ll div_floor(const ll &a,const ll &b) { return a / b - (((a ^ b) < 0) and a % b);}
ll div_ceil(const ll &a,const ll &b) { return a / b + (((a ^ b) >= 0) and a % b);}
ll modpow(ll a, ll b, ll m = MOD){a %= m; ll res = 1; 
    while (b) {if (b & 1)res = (res * a) % m; a = (a * a) % m; b >>= 1;} return res;}
ll bpow(ll a, ll b){ll res = 1; while (b) {if (b & 1)res = res * a; a = a * a; b >>= 1;} return res;}
ll modinv(ll a, ll m = MOD) {return modpow(a, m - 2, m);}
void graph(vvi &adj, int m) {int x, y; forn(i, m){cin>>x>>y; adj[--x].pb(--y); adj[y].pb(x);}}

void solve(){
    int n; cin>>n;
    vl h(n); forn(i, n) cin>>h[i];
    vl dp(n, 0);
    dp[0] = 0;
    dp[1] = abs(h[1]-h[0]);
    for(int i = 2; i<n; i++)
        dp[i] = min(dp[i-2] + abs(h[i-2] - h[i]), dp[i-1] + abs(h[i-1] - h[i]));
    cout<<dp[n-1]<<endl;
    trace(dp);
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    #ifdef KARAN
        freopen("inp.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
        freopen("err.txt", "w", stderr);
    #endif
    int t=1;
    while(t--)
        solve();
}

Measured memory_bytes: 1792
#pragma region template
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD = 1e9+7, MAX = 1e18, larg = 1e5, INF = -1e9;
long long A,B,C,D,E,F,G,H,I,J,K,L,N,M,O,P,Q,S,T,U,V,W,x,y,z;
long long max_value = INF, max_index = -1;
typedef long long ll;
typedef pair<ll, ll> Pa;

template <std::int_fast64_t Modulus> class modint {
  using u64 = std::int_fast64_t;
public:
  u64 a;
  constexpr modint(const u64 x = 0) noexcept : a(x % Modulus) {}
  constexpr u64 &value() noexcept { return a; }
  constexpr const u64 &value() const noexcept { return a; }
  constexpr modint operator+(const modint rhs) const noexcept {
    return modint(*this) += rhs;
  }
  constexpr modint operator-(const modint rhs) const noexcept {
    return modint(*this) -= rhs;
  }
  constexpr modint operator*(const modint rhs) const noexcept {
    return modint(*this) *= rhs;
  }
  constexpr modint operator/(const modint rhs) const noexcept {
    return modint(*this) /= rhs;
  }
  constexpr modint &operator+=(const modint rhs) noexcept {
    a += rhs.a;
    if (a >= Modulus) {
      a -= Modulus;
    }
    return *this;
  }
  constexpr modint &operator-=(const modint rhs) noexcept {
    if (a < rhs.a) {
      a += Modulus;
    }
    a -= rhs.a;
    return *this;
  }
  constexpr modint &operator*=(const modint rhs) noexcept {
    a = a * rhs.a % Modulus;
    return *this;
  }
  constexpr modint &operator/=(modint rhs) noexcept {
    u64 exp = Modulus - 2;
    while (exp) {
      if (exp % 2) {
        *this *= rhs;
      }
      rhs *= rhs;
      exp /= 2;
    }
    return *this;
  }
};
#pragma endregion

int main() {
  cin >> K;
  queue<string> que;
  int count = 0;
  for(int i=1;i<10;i++) {
    que.push(to_string(i));
  }
  while(!que.empty()){
    string curr = que.front(); que.pop();
    count++;
    if(count == K){
      cout << curr;
      return 0;
    }
    char last = curr[curr.size() - 1];
    if(last == '0'){
      que.push(curr+'0');
      que.push(curr+'1');
    }else if(last == '9'){
      que.push(curr+'8');
      que.push(curr+'9');
    }else{
      que.push(curr+(char)(last - 1));
      que.push(curr+last);
      que.push(curr+(char)(last + 1));
    }
  }
} 



Measured memory_bytes: 13824
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
int main()
{
	int n;
	cin>>n;
	if(n%10==9)
	{
		cout<<"Yes"<<endl;
	}
	else if(n>=90)
	{
		cout<<"Yes"<<endl;
	}
	else
	{
		cout<<"No"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import qualified Data.ByteString.Char8 as BS
import Control.Monad
import Data.List
import Data.Char

main :: IO ()
main = do
    (x,y,a,b,c) <- (\vec -> (vec VU.! 0, vec VU.! 1, vec VU.! 2, vec VU.! 3, vec VU.! 4)) . VU.unfoldrN 5 readInt <$> BS.getLine
    ps <- unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
    qs <- unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
    rs <- unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
    let psU = take x $ sortBy (\j k -> compare k j) ps
    let qsU = take y $ sortBy (\j k -> compare k j) qs
    let rsU = sortBy (\j k -> compare k j) rs
    let psR = reverse psU
    let qsR = reverse qsU
    print $ fun psR qsR rsU

fun :: [Int] -> [Int] -> [Int] -> Int
fun ps qs [] = sum ps + sum qs
fun [] (q:qs) (r:rs) 
    | r > q     = r + fun [] qs rs
    | otherwise = sum (q:qs)
fun (p:ps) [] (r:rs) 
    | r > p     = r + fun ps [] rs
    | otherwise = sum (p:ps)
fun (p:ps) (q:qs) (r:rs) 
    | p <= q && r > p = r + fun ps (q:qs) rs
    | p > q  && r > q = r + fun (p:ps) qs rs
    | otherwise       = sum (p:ps) + sum (q:qs)


readInt :: BS.ByteString -> Maybe (Int,BS.ByteString)
readInt xs = do
    (x,ys) <- BS.readInt xs
    return (x,BS.tail ys)

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

#define name ""
#define ini freopen(name".inp","r",stdin); freopen(name".out","w",stdout)
#define long long long
#define db double
#define pii pair <int, int>
#define pll pair <long, long>
#define all(c) c.begin(), c.end()
#define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
template <class T> inline void chmin(T &a, const T& val) { if (a > val) a = val; }
template <class T> inline void chmax(T &a, const T& val) { if (a < val) a = val; }
template <class T> long sqr(T a) { return 1ll * a * a; }
template <class T> void compress(T &a){
  sort(all(a)); a.resize(unique(all(a)) - a.begin());  
}

const db pi = acos(-1.00);
const db eps = 1e-6;
const int INF = 1e9;
const int MOD = 1e9+7;
const int dx[4] = {0, 0, -1, 1};
const int dy[4] = {-1, 1, 0, 0};

int main()
{
  fastio;
  int n, k; cin >> n >> k;
  vector <int> a(n);
  for (int &x : a) cin >> x;
  sort(all(a));   
  int res = 0;
  for (int i = 0; i < k; i++) res += a[i];
  cout << res;
  return 0;
}

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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;

  if (A + B > C + D) {
    cout << "Left" << endl;
  }
  // ここにプログラムを追記
  else if (A + B == C + D) {
    cout << "Balanced" << endl;
  }
  else {
    cout << "Right" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define vi vector<int>
#define srt(a) sort(a.begin(), a.end());
#define se second
#define fi first
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cout.precision(10);
    cout << fixed;
    LL h,a; cin>>h>>a;
    cout<<((h/a)+(h%a==0?0:1))<<endl;
    return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        String s = sc.next();
        int K = Integer.parseInt(sc.next());
        System.out.println(s.replaceAll("[^" + String.valueOf(s.charAt(K - 1)) + "]", "*"));

    }
}


Measured memory_bytes: 21972
a,b=list(map(lambda x:int(x)-1,input().split()))
m=[[0]*50+[1]*50 for i in range(100)]
x,y=-2,0
for i in range(a):
  x+=2
  if x==50:
    x=0
    y+=2
  m[y][x]=1
x,y=49,0
for i in range(b):
  x+=2
  if x==101:
    x=51
    y+=2
  m[y][x]=0

print(100,100)
for i in range(100):
  for j in range(100):
    print("."*m[i][j]+"#"*(1-m[i][j]),end="")
  print()

Measured memory_bytes: 9356
#include <bits/stdc++.h>
  #pragma GCC target ("avx2")
  #pragma GCC optimization ("O3")
  #pragma GCC optimization ("unroll-loops")
  using ll = long long;
  using ld = long double;
  #define whatis(x) cout << "> "<<#x << " ==> " << x << endl;
  #define br cout<< "\n";
  #define endl "\n"
  #define vi vector<int>
  #define vii vector<ll>
  #define pll pair<ll,ll>
  #define vpll vector<pll>
  #define pii pair<int,int>
  #define pcl pair<char,ll>
  #define pb push_back
  #define eb emplace_back
  #define mp make_pair
  #define lb lower_bound
  #define ub upper_bound
  #define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
  #define all(v) begin(v),end(v)
  #define minv(a) *min_element(all(a))
  #define maxv(a) *max_element(all(a))
  #define outputv(a) for(auto i:a) cout<<i<<" ";br;
  #define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  #define outputvp(a) for(auto j:a) {cout<<j.first<<" " << j.second << ",",br;}
  #define T ll t;cin>>t;while(t--)
  using namespace std;

  const ll mod = 1000000007;
  const ll inf = 1000000000000000000;
  const ll rk = 256;
  const ld PI = 3.141592653589793;
  

  int dr[]={1,-1,0,0};
  int dc[]={0,0,1,-1};

  // ll isPrime[1000001];

  // void primeDivisors(map<ll,ll> &mapi, ll n){
  //   while(n > 1){
  //     if(isPrime[n] == -1){
  //       mapi[n]+=1;
  //       break;
  //     }
  //     else{
  //       mapi[isPrime[n]]+=1;
  //       n/=isPrime[n]; 
  //     }
  //   }
  // }


// void seive(){
//   ll maxn = 10000001;
//   isPrime[0] = 0; isPrime[1] = 0;
//   rep(i,2,maxn) isPrime[i] = -1;
//   for(int i=2; i*i < maxn; i++){
//     if(isPrime[i] == -1){
//       for(int j=i*i; j < maxn; j+=i){
//         if(isPrime[j] == -1){
//           isPrime[j] = i;
//         }
//       } 
//     }
//   }

// }

 ll power( ll base, ll power, ll mod){
    ll res = 1;
    while( power ){
      if(power%2) res= (res*base)%mod, power--;
      else base= (base * base)%mod, power/=2;
    }

    return res;
  }

    void inout(){
      // seive();
      #ifndef ONLINE_JUDGE
          // for getting input from input.txt
          freopen("/home/logan/contest/ongoing/input.txt", "r", stdin);
          // for writing output to output.txt
          freopen("/home/logan/contest/ongoing/output.txt", "w", stdout);
      #endif
  }

  

  int main(){
     FastIO
     // seive();
    //inout();

      map<string, ll> mapi;
    T{
      string s; cin >> s;
      mapi[s]+=1;
    }

    cout << "AC x " << mapi["AC"] << endl;
    cout << "WA x " << mapi["WA"] << endl;
    cout << "TLE x " << mapi["TLE"] << endl;
    cout << "RE x " << mapi["RE"] << endl;
    





  return 0;
  }

 

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

int main(){
    int n; cin>>n;
    vector<int> a(n),b(n);
    rep(i,n) cin>>a[i];

    int ct = 0;
    for(int i=0; i<n; i++){
        if(ct==0){
            b[i/2] = a[n-1 - i];
            ct=1;
        }else{
            b[n-1 - i/2] = a[n-1 -i];
            ct=0;
        }
    }

    for(int i=0; i<n; i++){
        cout << b[i];
        if(i==n-1){
            cout << endl;
        }else{
            cout << " ";
        }
    }
}


Measured memory_bytes: 4836
n = int(input())

l = [int(i) for i in input().split()]

total = sum(l)

for i in range(1,n,2):
    total -= l[i] * 2

ans = [total]

for i in range(1,n):
    ans.append(2*l[i-1]-ans[i-1])
ans = [str(i) for i in ans]
    
print(' '.join(ans))
    


Measured memory_bytes: 20576
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc=new Scanner(System.in);
        int N=sc.nextInt();
        int MAX=-1;
        int MIN=1000000007;
        for(int i=0;i<N;i++){
            int S=sc.nextInt();
            if(S>MAX) MAX=S;
            if(S<MIN) MIN=S;
        }
        
        System.out.println(MAX-MIN);
    }
}


Measured memory_bytes: 22612
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
using namespace std;

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

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;

const int INF = 1e9;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
int a, b, c;

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

  cin >> a >> b >> c;
  cout << ((b / a) < c ? (b / a) : c) << endl;
}


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

using namespace std;

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

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

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

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



i64 a,b;
void solve(){
	cin >> a >> b;
	
	if(b-a >= 2018){
		cout << 0 << endl;
		return;
	}
	i64 mi = INF;
	for(i64 i = a; i < b; i++){
		for(i64 j = i+1; j <= b; j++){
			chmin(mi, i*j%2019);
		}
	}
	cout << mi << endl;
}

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

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

#define rep(i, n) for(long long i=0;i<(long long)(n);i++)
#define rep2(i, s, n) for(long long i=(s);i<(long long)(n);i++)
#define repi(i, n) for(int i=0;i<(int)(n);i++)
#define rep2i(i, s, n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(), v.end()

using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;

const ll INF = (1LL<<60);
const int INFi = (1<<29);

int main(){

    ll n, k; cin >> n >> k;
    vll p(n);
    rep(i, n) cin >> p[i];

    sort(all(p));

    ll sum = 0;
    rep(i, k) sum += p[i];

    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define ll long long
#define INF (ll)(4e18)
#define REP(i,n) for(int i=0;i<(n);i++)
#define mod 1000000007
using namespace std;
int n,f[100010],s[100010];
ll a,b,x[100010];
int get(int l,int r)
{
	if(l>r)
	{
		return 0;
	}
	if(!l)
	{
		return s[r];
	}
	else
	{
		return (s[r]-s[l-1]+mod)%mod;
	}
}
int main()
{
	cin>>n>>a>>b;
	if(a<b)
	{
		swap(a,b);
	}
	for(int i=1;i<=n;i++)
	{
		cin>>x[i];
	}
	x[0]=-INF,x[n+1]=INF;
	f[0]=s[0]=1;
	int l=0,r=0;
	for(int i=1;i<=n+1;i++)
	{
		while(r+1<i&&x[i]-x[r+1]>=a)
		{
			r++;
		}
		if(i>=2&&x[i-1]-x[i-2]<b)
		{
			l=i-2;
		}
		if(x[i]-x[i-1]>=a)
		{
			f[i]=f[i-1];
		}
		f[i]=(f[i]+get(l,min(i-2,r)))%mod;
		s[i]=s[i-1];
		if(x[i+1]-x[i-1]>=b)
		{
			s[i]=(s[i]+f[i])%mod;
		}
	}
	cout<<f[n+1]<<endl;
	return 0;
}

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

void North(int *nums){
    nums[6]=nums[0];
    nums[0]=nums[1];
    nums[1]=nums[5];
    nums[5]=nums[4];
    nums[4]=nums[6];
}
void East(int *nums){
    nums[6]=nums[0];
    nums[0]=nums[3];
    nums[3]=nums[5];
    nums[5]=nums[2];
    nums[2]=nums[6];
}
void South(int *nums){
    nums[6]=nums[0];
    nums[0]=nums[4];
    nums[4]=nums[5];
    nums[5]=nums[1];
    nums[1]=nums[6];
}
void West(int *nums){
    nums[6]=nums[0];
    nums[0]=nums[2];
    nums[2]=nums[5];
    nums[5]=nums[3];
    nums[3]=nums[6];
}
int main(void){
    int nums[7];
    int num;
    int a,b;
    
    for(int i=0;i<6;i++){
        cin>>nums[i];
    }
    nums[6]=0;
    cin>>num;
    for(int i=0;i<num;i++){
        cin>>a>>b;
        for(int i=0;i<4;i++){
            if(nums[0]==b)break;
            North(nums);
        }
        if(nums[0]!=b){
            West(nums);
            if(nums[0]!=b){
                East(nums);
                East(nums);
            }
        }
        South(nums);
        while(nums[0]!=a){
            West(nums);
        }
        cout<<nums[2]<<endl;
    }

    return 0;
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
#define rep(i, n) for(int i= 0; i < (n); i++)
using ll= long long int;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll mod= 1e9 + 7;


int main(){
  int l,r,d;
  cin >> l >>r >>d;
  int ans=0;
  for(int i=l;i<=r;i++){
    if(i%d==0)ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3648
import std.stdio, std.string, std.conv, std.algorithm, std.array, std.math;
void main(){
	auto s = readln.split.map!(to!real);
	auto a = s[0]*s[1]*sin(s[2]*PI/180)/2;
	auto b = s[0]+s[1]+sqrt(s[0]^^2+s[1]^^2-2*s[0]*s[1]*cos(s[2]*PI/180));
	auto c = a*2/s[0];
	writefln("%.5f",a);
	writefln("%.5f",b);
	writefln("%.5f",c);
}

Measured memory_bytes: 2580
#include "bits/stdc++.h"
#pragma GCC optimize "03"
using namespace std;

#define int long long int
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
#define rep(i,a,b) for (int i = a; i < b; ++i)
#define dbg(x) { cerr<<"> "<<#x<<": "<<x<< endl; }
#define dbg2(x,y) { cerr<<"> "<<#x<<": "<<x<<" , "<<#y<<": "<<y<<endl; }
#define dbg3(x,y,z) { cerr<<"> "<<#x<<": "<<x<<" , "<<#y<<": "<<y<<" , "<<#z<<": "<<z<<endl; }
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#ifndef LOCAL
#define endl '\n'
#endif

const int inf = INT_MAX;
const int MOD = 1e9 + 7;
const int N = 2e5 + 5;



signed main(){
    IOS;
    int n, m, k;
    cin >> n >> m >> k;
    int arr[n];
    for (int i = 0; i < n; i++)
    	arr[i] = m;
    for (int i = 0; i < k; i++) {
    	int a;
    	cin >> a;
    	a--;
    	arr[a]++;
    }
    for (int i = 0; i < n; i++) {
    	if (arr[i] > k) cout << "Yes\n";
    	else cout << "No\n";
    }
    return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define M 1000000007
typedef long long ll;
int main() { 
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    ll t,a[1000000],n,i;
    cin>>n;
    cout<<n*n;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 4000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

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

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};

class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% MOD + MOD) % MOD) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint& a) {
		if ((x += a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator-=(const mint& a) {
		if ((x += MOD - a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator*=(const  mint& a) {
		(x *= a.x) %= MOD;
		return *this;
	}
	mint operator+(const mint& a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint& a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint& a) const {
		mint res(*this);
		return res *= a;
	}

	mint operator^(const ll& t)const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}
	// for prime MOD
	mint inv() const {
		return pow(MOD - 2);
	}
	mint& operator/=(const mint& a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint& a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream& os, const mint& m) {
		os << m.x;
		return os;
	}
};

///////////////////////////

int main() {
	
	ll H, W;
	cin >> H >> W;

	vector<vector<char>> c(H + 1, vector<char>(W + 1));
	repn(i, H)repn(j, W) cin >> c[i][j];

	ll ans = 0;

	repn(j, W - 1) {
		vector<vector<ll>> cost(H + 1, vector<ll>(H + 1, 0));

		repn(k, H)repn(l, H) {
			cost[k][l] = cost[k - 1][l - 1];
			if (c[k][j] == c[l][j+1]) { cost[k][l]++; }
			//cout << k << l << cost[k][l] << endl;
		}

		vector<vector<ll>> dp(H + 1,vector<ll>(H + 1, 0));

		for (ll k = H; k >= 0; k--) {
			for (ll l = H; l >= 0; l--) {
				if (k == H && l == H) { dp[k][l] = 0; }
				else if (k == H) {
					dp[k][l] = dp[k][l + 1] + cost[k][l + 1];
				}
				else if (l == H) {
					dp[k][l] = dp[k + 1][l] + cost[k + 1][l];
				}
				else {
					dp[k][l] = min(dp[k][l + 1] + cost[k][l + 1], dp[k + 1][l] + cost[k + 1][l]);
				}

			}
			
		}

		ans += dp[0][0];

	}

	cout << ans << endl;

	system("PAUSE");
}


Measured memory_bytes: 1840
# 平文
PLAIN = input()

# 秘密鍵
KEY = 1

# 以下に、記述してください。
enc = ""

for char in list(PLAIN):
    ASCII = ord(char)
    num = ASCII - 97
    num = (num + KEY) % 26
    ASCII = num + 97
    enc += chr(ASCII)

print(enc)

Measured memory_bytes: 38384
#include<iostream> 
#include<algorithm> 
using namespace std;
 int main(){ 
int a[3],i;
cin>>a[0]>>a[1]>>a[2];
if(a[0]==a[1]&&a[1]==a[2]){
  printf("%d",0);
return 0;}
for(i=1;;i++){
 sort(a,a+3);
a[0]++;
if(a[0]==a[1]&&a[1]==a[2])break;
}
if(i%2==1){
cout<<(i+3)/2<<endl;
}
else{cout<<i/2<<endl;}
 return 0; } 

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import itertools
import random
from collections import deque
from decimal import *
import queue

input = sys.stdin.readline

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
def inputStr(): return input()[:-1]


def main():
	L,R,d = inputMap()

	ans = 0
	for i in range(L,R+1):
		if i % d == 0:
			ans += 1

	print(ans)

if __name__ == "__main__":
	main()


Measured memory_bytes: 76904
#include <bits/stdc++.h>
    
using namespace std;
typedef long long ll;
    
int main()
{
    int N;
    cin >> N;
    string S;
    cin >> S;

    int answer = 0;

    for (int i = 0; i < S.length(); i++) {
        string before = "";
        string after = "";

        before = S.substr(0, i);
        after = S.substr(i);

        int count = 0;

        for (char c='a'; c <='z'; c++) {
            bool left = false, right = false;

            for (int j = 0; j < before.length(); j++) {
                if (before[j] == c) { left = true; }
            }
            for (int j = 0; j < after.length(); j++) {
                if (after[j] == c) { right = true; }
            }

            if (left == true && right == true) {
                count++;
            }
        }

        if (answer < count) { answer = count; }
    }
    cout << answer;
    
    return 0;
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/abc080/tasks/abc080_b

#include <bits/stdc++.h>
#define REP(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define REPR(i, n) for (int(i) = (n); (i) >= 0; (i)--)
#define FOR(i, m, n) for (int(i) = (m); (i) < (n); i++)
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;

int main()
{
  /* Magic word */
  // cin.tie(0);
  // ios::sync_with_stdio(false);
  /* ---------- */

  ll n, t;

  cin >> n;
  t = n;

  int sum = 0;
  while (0 < t)
  {
    sum += t % 10;
    t /= 10;
  }

  string r = n % sum == 0 ? "Yes" : "No";

  cout << r << '\n';

  return 0;
}


Measured memory_bytes: 384
n, x = map(int, input().split())
a = list(map(int, input().split()))
sum_a = sum(a)
cnt = 0
a.sort()
if x > sum_a:
    cnt = n - 1
elif x == sum_a:
    cnt = n
else:
    for i in a:
        if i <= x:
            x -= i
            cnt += 1
        else:
            break
print(cnt)

Measured memory_bytes: 9056
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * y / gcd(x, y); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto s = RD!string;

	writeln(s.replace(",", " "));
	stdout.flush();
	debug readln();
}

Measured memory_bytes: 256
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> P;
const ll MOD=1000000007;
const ll MAX_N=500010;
const ll INF=999999999999;

ll gcd(ll a,ll b){
    ll M=max(a,b);
    ll m=min(a,b);
    if(m==0){
        return M;
    }
    return gcd(m,M%m);
}

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

int main(){
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    ll ans=b-a+1;
    ll cd=lcm(c,d);
    ans-=b/c-a/c;
    if(a%c==0) ans--;
    ans-=b/d-a/d;
    if(a%d==0) ans--;
    ans+=b/cd-a/cd;
    if(a%cd==0) ans++;
    cout<<ans<<endl;
    
}

Measured memory_bytes: 3588
use std::io::{stdout, Write, BufWriter};
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 $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")
    };
}

fn main() {
    input!{
        n: usize,
    }

    let out = stdout();
    let mut out = BufWriter::new(out.lock());

    match n {
        3 | 5 | 7 => writeln!(out, "YES").unwrap(),
        _ => writeln!(out, "NO").unwrap(),
    }
}

Measured memory_bytes: 4352
a = int(input())
b = int(input())
c = int(input())
x = int(input())
ans = 0
for i in range(a+1):
  for j in range(b+1):
    for k in range(c+1):
      if 500*i + 100*j + 50*k == x:
        ans += 1
        
print(ans)
      

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

using namespace std;

#define rep(i,m,n) for(int i=m;i<n;i++)


typedef long long ll;
typedef vector<string> vs;
typedef vector<ll> vll;


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

 ll h,w;
  cin >> h >> w;
  vll c(26,0);
  rep(i,0,h) {
    rep(j,0,w){
      char a;
    cin >> a;
    c[a-'a']++;
  }
  }
  vll num(4,0);
  rep(i,0,26) num[(c[i]%4)]++;
  
 
   string res="No";
  if(h%2&&w%2){
   if(num[1]+num[3]==1&&num[2]<=h/2+w/2) res="Yes";
  }
  else if(h%2){
   if(num[1]+num[3]==0&&num[2]<=w/2) res="Yes";
  }
  else if(w%2){
   if(num[1]+num[3]==0&&num[2]<=h/2) res="Yes";
  }
  else {
   if(num[1]+num[3]==0&&num[2]==0) res="Yes";
  }
 
 cout << res << endl; 
}

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

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t,n,m,i,a;
	t = 1;
	while(t--) {
     a = 0;
	 cin >> n >> m;
	 a = a + (n * (2 * m + n - 1)) / 2;
     if(m >= 0)
      cout << a - m << endl;
     else {
      if(m + n - 1 >= 0)
	   cout << a << endl;
	  else
	   cout << a - m - n + 1 << endl;
     }
	}
	return 0;
}



Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt(),
			b = sc.nextInt(),
			c = sc.nextInt(),
			k = sc.nextInt(),
			ans = 0;
		if(a >= b && a >= c) {
			ans = b + c + a * (int)Math.pow(2, k);
		} else if(b >= a && b >= c) {
			ans = a + c + b * (int)Math.pow(2, k);
		} else {
			ans = a + b + c * (int)Math.pow(2, k);
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 24020
/* ex4_2
   kento_titech*/
#include<stdio.h>
#include<math.h>
#define PI 3.14159265358979//円周率
int main(void){
    int a,b,hour,minute;
    double angle,angle_h,angle_m,l;//求める長さはlとする
    scanf("%d %d %d %d",&a,&b,&hour,&minute);
    angle_m=6*minute;//一分ごとに6度進む
    angle_h=30*hour+0.5*minute;//一分ごとに短針は0.5度進む
    angle=angle_m-angle_h;//角度の差を出す、cosに入れるので負の値でもよい
    l=sqrt(a*a+b*b-2*a*b*cos(PI*angle/180));//余弦定理
    printf("%.10f\n",l);
    
    return 0;
}

Measured memory_bytes: 2624
import java.util.Scanner;

public class Main {
    static String X;
    static String Y;

    private static void init() {
        Scanner scanner = new Scanner(System.in);
        X = scanner.next();
        Y = scanner.next();
        scanner.close();
    }


    public static void main(String args[]) {
        init();
        if(0 < X.compareTo(Y)) {
            System.out.println(">");
        } else if(0 > X.compareTo(Y)) {
            System.out.println("<");
        } else {
            System.out.println("=");
        }
    }
}

Measured memory_bytes: 21716
a = [0]*3
for i in range(3):
  a[i] = list(map(int, input().split()))
n = int(input())
b = [0]*n
for i in range(n):
  b[i] = int(input())

  
  

  
  
for i in range(n):
  for j in range(3):
    for k in range(3):
      if a[j][k] == b[i]:
        a[j][k] = 0


for i in range(3):
  if sum(a[i]) == 0:
    print("Yes")
    exit()
    
for i in range(3):
  if a[0][i] + a[1][i] + a[2][i] == 0:
    print("Yes")
    exit()
if a[0][0] + a[1][1] + a[2][2] == 0:
  print("Yes")
  exit()
if a[0][2] + a[1][1] + a[2][0] == 0:
  print("Yes")
  exit()
print("No")


Measured memory_bytes: 62136
using System;
using System.Linq;
using System.Security.Cryptography.X509Certificates;

namespace _0815
{
    class Program
    {
        private static string s;
        static void Main(string[] args)
        {
            s = Console.ReadLine();

            long result = Solution();
            Console.WriteLine(result);
        }

        static long Solution()
        {
            long res=0;
            if (s[0] == 'R')
            {
                if (s[1] == 'R')
                {
                    if (s[2] == 'R')
                    {
                        res = 3;
                    }
                    else
                    {
                        res = 2;
                    }
                }
                else
                {
                    res = 1;
                }
            }
            else
            {
                if (s[1] == 'R')
                {
                    if (s[2] == 'R')
                    {
                        res = 2;
                    }
                    else
                    {
                        res = 1;
                    }
                }
                else if(s[2] == 'R')
                {
                    res = 1;
                }
            }


            return res;
        }
    }
}


Measured memory_bytes: 25960