akhauriyash/Code-Regression huggingface dataset:
/**
  * @brief atcoder
  * @author yao
  */
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <utility>
#include <algorithm>
#include <functional>
#include <climits>
#define ft first
#define sd second
#ifdef DBG
#   define dbg_pri(x...) fprintf(stderr,x)
#else
#   define dbg_pri(x...) 0
#   define NDEBUG
#endif //DBG
#include <cassert>

typedef unsigned int uint;
typedef long long int lli;
typedef unsigned long long int ulli;

#define N 524288
#define P 200003

constexpr ulli PRIME = 0xffffffff00000001;
constexpr ulli ntt_add(ulli a, ulli b)
{
    if(b>PRIME) b -= PRIME;
    ulli res = 0;
    bool f = __builtin_uaddll_overflow(a,b,&res);
    res -= -(ulli)f & PRIME;
    return res;
}
constexpr ulli ntt_sub(ulli a, ulli b)
{
    if(b>PRIME) b -= PRIME;
    ulli res = 0;
    bool f = __builtin_usubll_overflow(a,b,&res);
    res += -(ulli)f & PRIME;
    return res;
}
constexpr ulli ntt_mul(ulli a, ulli b)
{
    unsigned __int128 k = (unsigned __int128)a*b;
    ulli hh = k>>64>>32, hl = (uint)(k>>64), res = k;
    res = ntt_add(res,hl*-PRIME);
    res = ntt_sub(res,hh);
    return res;
}
constexpr ulli ntt_pow(ulli a, ulli b)
{
    ulli r = 1;
    while(b)
    {
        if(b&1) r = ntt_mul(r,a);
        a = ntt_mul(a,a);
        b >>= 1;
    }
    return r;
}
constexpr ulli ntt_find()
{
    ulli res = 2;
    while(ntt_pow(res,PRIME/2) != PRIME-1) ++res;
    return res;
}
constexpr ulli OMEGA = (ntt_pow(ntt_find(),PRIME/N));
static_assert(__builtin_popcount(N) == 1);
static_assert(PRIME%N == 1);
static_assert(ntt_pow(OMEGA,N/2) == PRIME-1);
uint ricr(uint k)
{
    k ^= (N-1);
    k ^= -1u >> 1 >> __builtin_clz(k);
    return k;
}
template <int n, ulli w>
void ntt_rec(ulli *a)
{
    constexpr int n2 = n/2;
    constexpr ulli w2 = ntt_pow(w,2);
    ntt_rec<n2, w2>(a);

    for(ulli *p=a; p!=a+N; p+=n)
    {
        ulli k = 1;
        for(int i=0,j=n2;i<n2;++i,++j)
        {
            ulli e = p[i], o = p[j];
            ulli ok = ntt_mul(o,k);
            p[i] = ntt_add(e,ok);
            p[j] = ntt_sub(e,ok);
            k = ntt_mul(k,w);
        }
    }
}
template <>
void ntt_rec<1, 1>(ulli *a)
{
}

template <ulli w=OMEGA>
void ntt(ulli *a)
{
    for(int i=0,ii=0;i<N;++i,ii=ricr(ii))
        if(i<ii) std::swap(a[i],a[ii]);
    ntt_rec<N,w>(a);
}
void ntt_inv(ulli *a)
{
    ntt<ntt_pow(OMEGA,PRIME-2)>(a);
    for(int i=0;i<N;++i) a[i] = ntt_mul(a[i],ntt_pow(N,PRIME-2));
}

int cnt[N];
ulli a[N];

int main()
{
    int n;
    lli ans = 0;
    scanf("%d", &n);
    for(int i=0;i<n;++i)
    {
        int k;
        scanf("%d", &k);
        ++cnt[k];
    }
    for(int i=0, k=1; i<P-1; ++i, k=k*2<P?k*2:k*2-P) a[i] = cnt[k];
    for(int i=0; i<P-1; ++i) cnt[i] = a[i];
    ntt(a);
    for(int i=0;i<N;++i) a[i] = ntt_mul(a[i],a[i]);
    ntt_inv(a);
    for(int i=0; i<P-1; ++i) a[i*2] = ntt_sub(a[i*2], cnt[i]);
    for(int i=0,k=1; i<N; ++i, k=k*2<P?k*2:k*2-P)
    {
        if(a[i] >= PRIME) a[i] -= PRIME;
        ans += k * a[i];
    }
    assert(ans%2==0);
    ans /= 2;
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 6628
#include<bits/stdc++.h>
using namespace std;
struct edge{int go,next;} e[1000000];
int n,m,gg,vis[1000],f[1000][1000],ljb[1000],cnt,nn,c[1000],ma[1000][1000],num[1000][3];
void dfs(int x){
	vis[x]=1;
	num[nn][c[x]]++;
	for (int i=ljb[x];i;i=e[i].next){
		if (!vis[e[i].go]){
			c[e[i].go]=c[x]^1;
			dfs(e[i].go);
		}
		else{
			if (c[x]==c[e[i].go]) gg=1;
		}
	}
}
int ff(int x){
	return x*(x-1)/2;
}
int main(){
	scanf("%d%d",&n,&m);
	gg=0;
	for (int i=1;i<=m;i++){
		int x,y;scanf("%d%d",&x,&y);
		ma[x][y]=ma[y][x]=1;
	}
	for (int i=1;i<=n;i++) for (int j=i+1;j<=n;j++) if (ma[i][j]==0){
		e[++cnt].go=j;e[cnt].next=ljb[i];ljb[i]=cnt;
		e[++cnt].go=i;e[cnt].next=ljb[j];ljb[j]=cnt;
	}
	int td=0;
	for (int i=1;i<=n;i++) if (!vis[i]){
		nn++;
		dfs(i);
	}
	if (gg){puts("-1");return 0;}
	f[0][0]=1;
	for (int i=0;i<nn;i++){
		for (int j=0;j<=n;j++){
			f[i+1][j+num[i+1][0]]|=f[i][j];
			f[i+1][j+num[i+1][1]]|=f[i][j];
		}
	}
	for (int i=n/2;i;i--) if (f[nn][i]){
		printf("%d",ff(i)+ff(n-i));
		return 0;
	}
}

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

int x[5];
int ans;

main(){

    for (int i = 0;i < 5;i++) cin >> x[i];

    for (int j = 0;j < 5;j++){
        if (x[j] == 0){
            ans = j+1;
            break;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3632
import sys
from numpy import*
from scipy.sparse import*
def main():
  f=csgraph.floyd_warshall
  t=int32(sys.stdin.buffer.read().split())
  n,m,l=t[:3]
  t=t[3:]
  m*=3
  print('\n'.join(map(str,map(int,f(f(csr_matrix((t[2:m:3],(t[:m:3],t[1:m:3])),[n+1]*2),0)<=l)[t[m+1::2],t[m+2::2]].clip(0,n)%n-1))))
main()

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

namespace A
{
    class Program
    {
        public static void Main(string[] args)
        {
            var n = ReadLineStringSplit();
            var re = "NO";

            if(n[0][n[0].Length-1] == n[1][0] && n[1][n[1].Length-1] == n[2][0]) {
                re = "YES";
            }

            Console.WriteLine(re);
            ReadLine();
        }

        /// <summary>
        /// stringを一文字ずつintにキャストして配列に変換します。
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public static int[] StringCharArrayIntArray(string str)
        {
            List<int> b = new List<int>();
            for (int i = 0; i < str.Length; i++) {
                b.Add( int.Parse(str[i].ToString()));
            }
            return b.ToArray();
        }

        public static string ReadLine()
        {
            return Console.ReadLine();
        }

        public static int ReadLineInt()
        {
            return int.Parse(Console.ReadLine());
        }

        public static string[] ReadLineStringSplit(char a = ' ')
        {
            return ReadLine().Split(a).ToArray();
        }

        public static int[] ReadLineIntSpilit(char a = ' ')
        {
            return ReadLine().Split(a).Select(x => int.Parse(x)).ToArray();
        }
    }
}

Measured memory_bytes: 13268
#include <bits/stdc++.h>
#define exrep(i, a, b) for(long long i = a; i <= b; i++)
#define rep(i,n)for(long long i=0;i<(long long)(n);i++)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vector<ll> > vvl;
typedef vector<vector<P> > vvp;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const int MAX=510000;
const double pi=acos(-1);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

const int MAX_N=200050;
int n;
vector<int>a,ans;
vector<int>G[MAX_N];
int dp[MAX_N];

void dfs(int v,int p=-1){
  int i=lower_bound(dp,dp+MAX_N,a[v])-dp;
  int old=dp[i];
  dp[i]=a[v];
  ans[v]=i;
  if(p!=-1)ans[v]=max(ans[v],ans[p]);
  for(int nv:G[v]){
    if(nv==p) continue ;
    dfs(nv,v);
  }
  dp[i]=old;
}
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  
  cin >> n;
  a=ans=vector<int>(n);
  rep(i,n) cin >> a[i];
  rep(i,n-1){
    int u,v;
    cin >> u >> v;
    u--;
    v--;
    G[u].push_back(v);
    G[v].push_back(u);
  }
  rep(i,MAX_N)dp[i]=2e9;
  dp[0]=-2e9;
  dfs(0);
  
  rep(i,n)cout << ans[i] << endl;
  return 0;     
}


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

using namespace std;

typedef long long ll;

mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    vector <int> a, b;
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        if (x <= 0) {
            a.push_back(-x);
        } else {
            b.push_back(x);
        }
    }
    reverse(a.begin(), a.end());
    int m = (int) b.size();
    ll ans = 1e18;
    ll sum = 0;
    if (m >= k) {
        ans = min(ans, b[k - 1] + 0ll);
    }
    if ((int) a.size() >= k) {
        ans = min(ans, a[k - 1] + 0ll);
    }
    for (int i = 0; i < (int) a.size(); i++) {
        sum = a[i];
        int need = k - i - 1;
        if (need < 0) {
            continue;
        }
        if (need == 0) {
            ans = min(ans, sum);
            continue;
        }
        if (m >= need) {
            ans = min(ans, 2 * sum + b[need - 1]);
        }
    }
    for (int i = 0; i < (int) b.size(); i++) {
        sum = b[i];
        int need = k - i - 1;
        if (need < 0) {
            continue;
        }
        if (need == 0) {
            ans = min(ans, sum);
            continue;
        }
        if ((int) a.size() >= need) {
            ans = min(ans, 2 * sum + a[need - 1]);
        }
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 1020
#include <bits/stdc++.h>
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
#define all(x) (x).begin(),(x).end()

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);std::cout<<std::fixed<<std::setprecision(10);
    string S;
    cin >> S;
    bool ok = 0;
    REP(i,S.size()){
        if(i%2 == 0){
            if(S[i]=='L')ok = 1;
        }else{
            if(S[i]=='R')ok = 1;
        }
    }
    if(ok){
        cout <<"No"<< "\n";
    }else{
        cout <<"Yes"<< "\n";
    }
}

Measured memory_bytes: 256
#include <vector>
#include <algorithm>
#include <cstdio>
using namespace std;
int main(){
	int N,M;
	scanf("%d%d",&N,&M);
	vector<int>dist(N);
	for(int i=0;i<N;i++)scanf("%d",&dist[i]);
	vector<int>climate(M);
	for(int i=0;i<M;i++)scanf("%d",&climate[i]);
	vector<vector<int> >m(N+1);
	for(int i=0;i<=N;i++){
		m[i].resize(M+1);
		for(int j=0;j<=M;j++)m[i][j]=999999999;
	}
	for(int i=0;i<=M;i++)m[0][i]=0;
	for(int i=1;i<=N;i++){
		for(int j=1;j<=M;j++)m[i][j]=min(m[i][j-1],m[i-1][j-1]+dist[i-1]*climate[j-1]);
	}
	int result=m[N][0];
	for(int i=0;i<=M;i++)result=min(result,m[N][i]);
	printf("%d\n",result);
}

Measured memory_bytes: 4172
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <math.h>
using namespace std;

int main(void){
    int n;
    cin >> n;
    vector<int> a(n);

    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    
    sort(a.begin(), a.end());

    double sum = a[0];
    for(int i = 1; i < n; i++){
        sum = (sum + a[i]) / 2.0;
    }
    cout << sum << endl;
    
    return 0;
}

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

int v[100];

int main() {
    int n;
    while (cin >> n, n) {
        for (int i=0; i<n; ++i) {
            cin >> v[i];
        }
        int search;
        cin >> search;
        int l = 0, h = n-1, res = 0;
        while (l <= h) {
            int mid = (l + h) / 2;
            ++ res;
            if (v[mid] == search) {
                break;
            } else if (search < v[mid]) {
                h = mid-1;
            } else {
                l = mid+1;
            }
        }
        cout << res << endl;
    }
    return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define all(n) begin(n), end(n)
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
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;
}
template <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts)
{
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v)
{
    for (auto &e : t)
        fill_v(e, v);
}
int main()
{
    ll D,T,S;
    cin>>D>>T>>S;
    cout<<(S*T>=D?"Yes":"No");
    return 0;
}

Measured memory_bytes: 3672
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define INSEG(l,x,r) ((l)<=(x)&&(x)<(r))
#define dump(...)
#define pb push_back
#define _ 0
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a,const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a,const U &b){return a>b?a=b,1:0;}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        cin.tie(0); ios::sync_with_stdio(false);
        cout << setprecision(15) << fixed;
        #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int H, W;
    cin >> H >> W;
    vector<vi> a(H, vi(W));
    cin >> a;
    
    vector<vi> ans;
    REP(i, H) {
        REP(j, W - 1) {
            if (a[i][j] % 2) {
                a[i][j + 1] += a[i][j];
                ans.pb({i+1, j+1, i+1, j+2});
            }
        }
    }
    REP(i, H - 1) {
        if (a[i][W - 1] % 2) {
            a[i + 1][W - 1] += a[i][W - 1];
            ans.pb({i+1, W, i+2, W});
        }
    }

    cout << SZ(ans) << endl;
    FORE(v, ans) cout << v << endl;
    return (0^_^0);
}



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

typedef long long ll;

#define p_ary(ary,a,b,i) do { cout << "["; for (int (i) = (a);(i) < (b);++(i)) cout << ary[(i)] << ((b)-1 == (i) ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

struct BinaryIndexedTree {
private:
	int n;
	vector<int> bit;
public:
	BinaryIndexedTree(int n_) {
		n = n_;
		bit = vector<int>(n+10,0);
	}

	void add(int a,int w) {
		for (int x = a;x <= n;x += x&-x) bit[x] += w;
	}

	int sum(int a) {
		int ret = 0;
		for (int x = a;x > 0;x -= x&-x) ret += bit[x];
		return ret;
	}
};

int main() {
    int n;
    cin >> n;
    vector<int> b(n),w(n);
    BinaryIndexedTree BITb(2*n),BITw(2*n);
    vector<vector<int>> invb(n+1,vector<int>(n+1,0)),invw(n+1,vector<int>(n+1,0)),dp(n+1,vector<int>(n+1,1<<29));
    for (int i = 0;i < 2*n;++i) {
        char c;
        int a;
        cin >> c >> a;
        if (c == 'W') w[a-1] = i+1;
        else b[a-1] = i+1;
    }
    for (int i = 0;i < n+1;++i) {
        BITb = BinaryIndexedTree(2*n);
        BITw = BinaryIndexedTree(2*n);
        for (int j = 0;j < i;++j) BITb.add(w[j],1);
        for (int j = 0;j < i;++j) BITw.add(b[j],1);
        for (int j = 0;j < n;++j) {
            invb[i][j+1] = i+j-BITb.sum(b[j]);
            invw[j+1][i] = i+j-BITw.sum(w[j]);
            BITb.add(b[j],1);
            BITw.add(w[j],1);
        }
    }
    dp[0][0] = 0;
    for (int i = 0;i < n+1;++i) {
        for (int j = 0;j < n+1;++j) {
            if (i > 0) dp[i][j] = dp[i-1][j]+invw[i][j];
            if (j > 0) dp[i][j] = min(dp[i][j],dp[i][j-1]+invb[i][j]);
        }
    }
    cout << dp[n][n] << endl;
    return 0;
}

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

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    if (a + b == c || a == b + c || b == a + c){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
        }
    return 0;
}


Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
using ll = int64_t;

int main() {
    ll N;
    cin >> N;
    vector<ll> A(N);
    for (ll i = 0; i < N; i++) {
        cin >> A[i];
    }

    vector<vector<ll>> dp(2, vector<ll>(N + 1, 0));
    dp[1][0] = INT_MIN;

    for (ll i = 0; i < N; i++) {
        //操作する
        dp[1][i + 1] = max(dp[0][i] - A[i], dp[1][i] + A[i]);

        //操作しない
        dp[0][i + 1] = max(dp[0][i] + A[i], dp[1][i] - A[i]);
    }

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

Measured memory_bytes: 3328
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>

#define ll long long

using namespace std;

int N;
ll add1 = 0;
ll buff2 = 0;

int main()
{
    cin >> N;
    ll a[N], b[N];
    for (int i=0; i<N; i++) {
        cin >> a[i];
    }
    for (int i=0; i<N; i++) {
        cin >> b[i];
        if (a[i] < b[i]) {
            buff2 += (b[i] - a[i]) / 2;
        } else {
            add1 += a[i] - b[i];
        }
    }

    if (add1 <= buff2) {
        cout << "Yes";
    } else {
        cout << "No";
    }

    return 0;
}

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


int main(){
    ll n,k,sum=0;
    cin>>n>>k;
    vector<ll> h(200001);
    rep(i,n)cin>>h[i];
    sort(h.begin(),h.end(),greater<ll>());
    rep(i,n){
        if(i>=k)sum+=h[i];
    }
    cout<<sum<<endl;

    return 0;
}

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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
using ll = long long;


int main() {
    int n, m; cin >> n >> m;
    V<V<int> > v(m);
    for(int i = 0; i < m; i++){
        int k; cin >> k;
        for(int j = 0; j < k; j++){
            int s; cin >> s;
            s--;
            v[i].push_back(s);
        }
    }
    V<int> w(m);
    for(int i = 0; i < m; i++) cin >> w[i];

    int ans = 0;
    for(int bit = 0; bit < (1 << n); bit++){
        bool flag = true;
        for(int j = 0; j < m; j++){
            int cnt = 0;
            for(int k = 0; k < (int)v[j].size(); k++){
                if(bit & (1 << v[j][k])) cnt++;
            }
            if(cnt % 2 != w[j]){
                flag = false;
            }
        }
        if(flag) ans++;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define endl "\n"
#define fr first
#define sc second
#define f(i, L, R) for (int i = L; i < R; i++)
#define F(i, t) for (typeof(t.begin()) i = t.begin(); i != t.end(); i++)
void solve()
{
    ll n;
    cin >> n;
    vector<ll> Data(n + 2, 0);
    f(i, 0, n) cin >> Data[i];
    vector<ll> dp(n, 0);
    dp[n - 1] = 0;
    dp[n - 2] = abs(Data[n - 1] - Data[n - 2]);
    for (ll i = n - 3; i >= 0; i--)
    {
        dp[i] = min(dp[i + 1] + abs(Data[i] - Data[i + 1]), dp[i + 2] + abs(Data[i] - Data[i + 2]));
    }
    cout << dp[0] << endl;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll T = 1;
    while (T--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 4700
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(){
	int n, k;
	string s;
	cin >> n >> k;
	cin >> s;
	int p[100000];
	p[0] = 0;
	int count = 1;
	for(int i = 1;i < n;i++){
		if(s[i] != s[i - 1]){
			p[count] = i;
			count++;
		}
	}
	int amax = 0;
	if(s[0] == '0'){
		if(count <= (2 * k)){
			cout << n << endl;
			return 0;
		}
		amax = p[2 * k];
		for(int i = 0;(2 * i + 1) < count;i++){
			if((2 * (i + k + 1)) >= count){
				amax = max(amax, n - p[2 * i + 1]);
			}else{
				amax = max(amax, p[2 * (i + k + 1)] - p[2 * i + 1]);
			}
		}
		cout << amax << endl;
		return 0;
	}else{
		for(int i = 0;(2 * i) < count;i++){
			if((2 * (i + k) + 1) >= count){
				amax = max(amax, n - p[2 * i]);
			}else{
				amax = max(amax, p[2 * (i + k) + 1] - p[2 * i]);
			}
		}
		cout << amax << endl;
	}
	return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
#define ll long long
using namespace std;
inline int D()
{
	int t;
	scanf("%d",&t);
	return t;
}
inline ll llD(){
	ll t;
	scanf("%lld",&t);
	return t;
}
const int N=2e5+9;

int arr[N],in[N];
int main(){

    ll n =llD();
    char ch;
    cin>>ch;
    
    ll b=llD();
    if(ch=='+')
        printf("%lld",n+b);
    else  printf("%lld",n-b);
   /** for(int i=1; i<=n;i++)
    {
      
    }*/
   

    }
 
/**
bool ok(int val){
  int cntm=0,cntp=0;
  for(int i=0;i<n-val;i++)
  {
      cntm=0;cntp=0;
      for(int j=i;j<val;j++)
      {
      (arr[j]==1)?cntp++:cntm++;
      }
      if(cntp==cntm)
        break;
  }
  return cntp==cntm;
}
int binarySearch(){
  int low = 0, med, hi =n;
  while(low<hi){
    med = (low+hi+1)>>1;
    cout<<med<<" "<<hi<<" "<<low<<endl;
    if(ok(med))  low = med;
    else  hi = med-1;
  }
  return low;
}*/



/**
  int power1(int b, int p){               //O(p)
    if(!p)  return 1;
    return b*power1(b, p-1);
  }
  int power2(int b, int p){               //O(Log(p))
    if(!p)  return 1;
    int ret = power2(b, p/2);
    return (p&1 ? ret*ret*b : ret*ret);
  }
   int mul(int a, int b, int m){
      return (a%m * b%m) % m;
  }

*/


/**
void seive()
{
    bitset<N>iscomp;
    iscomp[0]=iscomp[1]=1;
    for(long long i=2; i<=N; ++i)
    {
        if(!iscomp[i])
        {
            a.push_back(i);
            for(long long j=i*i; j<=N; j+=i)
                iscomp[j]=1;
        }
    }
}
3
abc
abc
*/

    /**


    */


Measured memory_bytes: 256
n, m = map(int, input().split())
mod = 1_000_000_007
A = [1] * (n+1)
for i in range(m):
    A[int(input())] = 0

for i in range(2, n+1):
    if A[i]!=0:
        A[i] = (A[i-1] + A[i-2])%mod

print(A[-1])

Measured memory_bytes: 12616
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cctype>
#include <ctime>
#include <climits>
#include <cfloat>
#include <cassert>
#include <memory>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <bitset>
#include <queue>
#include <complex>
#include <utility>
#include <functional>
#include <algorithm>
#include <numeric>

using namespace std;

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

const double EPS = 0.0000000001;
const long long int INF = 1000000000;

const int MAX_L = 100000;

char S[MAX_L + 1];
int len;

bool checked[MAX_L];
bool ok[MAX_L];

vector<string> text = {"dream", "dreamer", "erase", "eraser"};

bool check(int i)
{
	if (checked[i]) return ok[i];

	checked[i] = true;
	if (i == len) return ok[i] = true;

	for (auto s : text) {
		if (strncmp(s.c_str(), S + i, s.size()) == 0) {
			ok[i] = check(i + s.size());
		}

		if (ok[i]) break;
	}
	return ok[i];
}

void solve()
{
	memset(checked, false, sizeof(checked));
	memset(ok, false, sizeof(ok));
	len = strlen(S);
	printf("%s\n", check(0) ? "YES" : "NO");
}

int main()
{
	scanf("%s", S);
	solve();

	return 0;
}



Measured memory_bytes: 2432
#include <iomanip>
#include <iostream>

using namespace std;

double solver(int i, int j, int k, double ***dp, int n) {
  if (dp[i][j][k] >= 0)
    return dp[i][j][k];
  if (i == 0 and j == 0 and k == 0)
    return 0;

  double ret = 0.0;
  if (i > 0)
    ret += solver(i - 1, j, k, dp, n) * i;
  if (j > 0 and i < n)
    ret += solver(i + 1, j - 1, k, dp, n) * j;
  if (k > 0 and j < n)
    ret += solver(i, j + 1, k - 1, dp, n) * k;

  ret += static_cast<double>(n);
  ret *= 1.0 / (i + j + k);
  return dp[i][j][k] = ret;
}

int main(int argc, char const *argv[]) {

  int n;
  cin >> n;
  int a[3] = {0};
  for (int i = 0; i < n; i++) {
    int temp;
    cin >> temp;
    a[(temp - 1) % 3]++;
  }

  double ***dp = new double **[n + 1];
  for (int i = 0; i <= n; i++)
    dp[i] = new double *[n + 1];

  for (int i = 0; i <= n; i++)
    for (int j = 0; j <= n; j++)
      dp[i][j] = new double[n + 1];

  for (int i = 0; i <= n; i++)
    for (int j = 0; j <= n; j++)
      for (int k = 0; k <= n; k++)
        dp[i][j][k] = -1.0;

  dp[0][0][0] = 0.0;

  double ans = solver(a[0], a[1], a[2], dp, n);
  cout << setprecision(10) << ans << endl;

  for (int i = 0; i <= n; i++)
    for (int j = 0; j <= n; j++)
      delete[] dp[i][j];

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

  delete[] dp;

  return 0;
}


Measured memory_bytes: 214784
#include<iostream>
using namespace std;
int main(){
    int W,H,x,y,r;
    cin>>W>>H>>x>>y>>r;

    if (x-r<0 || x+r>W || y+r>H || y-r<0){
        cout<<"No"<<endl;
        
    }else{
        cout<<"Yes"<<endl;
    }

    return 0;
}


Measured memory_bytes: 3108
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
int a[105];
int b[105];
int n;

int main() {
	while(~scanf("%d", &n)) {
		for(int i = 1; i <= n; i++) scanf("%d", &a[i]);
		for(int i = 1; i <= n; i++) scanf("%d", &b[i]);
		int sum = 0;
		for(int i = 1; i <= n; i++) sum += a[i];
		int max = sum + b[n];
		int p = n;
		while(p--) {
			sum = 0;
			for(int i = 1; i <= p; i++) sum += a[i];
			for(int j = n; j >= p; j--) sum += b[j];
			if(sum > max) max = sum;
		}
		printf("%d\n", max);
	}
}

Measured memory_bytes: 128
time_seconds = int(input())
h = 0
m = 0
s = 0

while time_seconds != 0:
  if time_seconds >= 3600:
    time_seconds -= 3600
    h += 1
  elif 3600 > time_seconds >= 60:
    time_seconds -= 60
    m += 1
  else:
    s = time_seconds
    time_seconds = 0

print(h, m, s, sep=":")



Measured memory_bytes: 5588
//https://beta.atcoder.jp/contests/abc113/tasks/abc113_b
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
#ifdef BTK
#define DEBUG if(1)
#else
#define CIN_ONLY if(1)
struct cww {cww() {CIN_ONLY{ios::sync_with_stdio(false); cin.tie(0);}}}star;
#define DEBUG if(0)
#endif
#define ALL(v) (v).begin(),(v).end()
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline bool chmin(T &l, T r){bool a = l>r; if (a)l = r; return a;}
template <typename T>inline bool chmax(T &l, T r){bool a = l<r; if (a)l = r; return a;}
template <typename T>istream& operator>>(istream &is, vector<T> &v){for (auto &it : v)is >> it;return is;}
class range {private: struct I { int x; int operator*() { return x; }bool operator!=(I& lhs) { return x<lhs.x; }void operator++() { ++x; } }; I i, n;public:range(int n) :i({ 0 }), n({ n }) {}range(int i, int n) :i({ i }), n({ n }) {}I& begin() { return i; }I& end() { return n; }};

int h[11234];
int main(){
    int n,t,a;
    cin>>n>>t>>a;
    a*=1000;
    t*=1000;
    int ret = 0;
    for(int i:range(n)){
        cin>>h[i];
    }
    for(int i:range(n)){
        int x = t-h[ret]*6;
        int y = t-h[i]*6;
        if(abs(x-a)>abs(y-a)){
            ret=i;
        }
    }
    cout<<ret+1<<endl;
    return 0;
}

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

int main() {
	ios_base :: sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin >> n;
	int a[n], b[n], c[n];
	unsigned long long dp[n][3];
	for(int i = 0; i < n; i++)
		cin >> a[i] >> b[i] >> c[i];
	dp[0][0] = a[0], dp[0][1] = b[0], dp[0][2] = c[0];
	for(int i = 1; i < n; i++){
		dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + a[i];
		dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + b[i];
		dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + c[i];
	}
	cout << max(dp[n - 1][0], max(dp[n - 1][1], dp[n - 1][2]));
	return 0;
}

Measured memory_bytes: 3840
#define _USE_NATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <random>
#include <tuple>


using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
#define EPS 1e-9
const int INF = 1050000000;
const long long LINF = 1LL << 60;
const ll MOD = 1e9 + 7;
const int MINF = -1050000000;

int main() {
	ll n, m;
	cin >> n >> m;
	ll max_num = max(n, m);
	ll min_num = min(m, n);
	if (n == 1 && m == 1) {
		cout << 1 << endl;
		return 0;
	}
	else if(n == 1 || m == 1){
		cout << (max_num - 2) * min_num << endl;
	}
	else {
		cout << (n - 2)*(m - 2) << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

typedef long long ll;

#define rep(i, a, b) for (ll i = a; i < (ll)b; ++i)
#define INF 10e12
#define MAX 51000
#define all(x) (x).begin(), (x).end()
#define MX(x) *max_element(all(x))
#define MN(x) *min_element(all(x))

using namespace std;

const long long MOD = 1e9 + 7;

int main(void)
{
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    int a, b;
    cin >> a >> b;
    cout << max(a + b, max(2 * a - 1, 2 * b - 1)) << endl;
}


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

typedef long long ll;
typedef pair<int,int> P;
typedef map<int,int> M;
typedef vector<int> V;
typedef queue<int> Q;
typedef pair<long,long> PLL;
typedef map<long,long> MLL;
typedef vector<long> VLL;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define MOD (1e9+7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n-1);i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
/*--------------------------------------------*/

int main(){
    int n;cin>>n;
    V p(n);rep(i,n)cin>>p[i];
    sort(RALL(p));
    int ans=p[0]/2;
    REP(i,n-1){
        ans+=p[i];
    }
    cout<<ans<<endl;
}




Measured memory_bytes: 256
def solve(n,ma,mb,list)
  list.sort! {|a,b| a[2] <=> b[2]}
  all_a = 0
  all_b = 0
  list.each do |a,b,c|
    all_a += a
    all_b += b
  end
  f = 0
  ans = -1
  loop do
    f += 1
    ta = ma * f
    tb = mb * f
    return ans if ta > all_a || tb > all_b
    r = rec(list,0,0,0,0,ta,tb,n,ans)
    # puts "ta#{ta} tb#{tb} r#{r} ans#{ans}"
    next if r == -1
    ans = r if ans == -1
    ans = r if r < ans
    # return ans if ans != -1
  end
end

def rec(list,idx,ca,cb,cc,ta,tb,n,ans)
  return -1 if idx == n
  r = rec(list,idx+1,ca,cb,cc,ta,tb,n,ans)

  a,b,c = list[idx]
  if (ca + a) == ta && (cb + b) == tb
    # find
    return (cc + c) if r == -1
    if (cc + c) < r
      return (cc + c)
    else
      return r
    end
  else
    r2 = -1
    if (ca + a) < ta && (cb + b) < tb && (ans == -1 || (cc + c) < ans)
      r2 = rec(list,idx+1,ca + a,cb + b,cc + c,ta,tb,n,ans)
    end
    return r2 if r == -1
    return r if r2 == -1
    if r < r2
      return r
    else
      return r2
    end
  end
end

def main
  n,ma,mb = gets.split.map(&:to_i)
  list = []
  n.times do
    list << gets.split.map(&:to_i)
  end
  puts solve(n,ma,mb,list)
end

main


Measured memory_bytes: 1788
#include <iostream>
#include <math.h>
using namespace std;
typedef long long ll;
ll n, x, ans, y;
int main(void){
    // Your code here!
    cin >> n >> x;
    y = x;
    n++;
    while(n > 1 && x > 0){
        if (x == 1){
            x = 0, ans++;
        } else if (x == pow(2, n) - 1){
            x = 0, ans += pow(2, n - 1) - 1;
        } else if (x == pow(2, n + 1) - 3){
            x = 0, ans += pow(2, n) - 2;
        } else if (x > 1 && x < pow(2, n) - 1){
            x--, ans++;
        } else {
            x -= pow(2, n) - 1, ans += pow(2, n - 1) - 1;
        }
        n--;
    }
    cout << y - ans << endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
using namespace std;
typedef long long ll;
int N;
long double money[10];
string kind;
long double total=0;



int main(void) {
    // insert code here...
    cin >> N;
    for(int i = 0; i < N; i++){
        long double coin;
        cin >> coin >> kind;
//        cout << coin << kind << endl;
        if(kind == "JPY"){
            money[i] = coin;
        }else{
            money[i] = coin * 380000.0;
        }
//        cout << money[i] << endl;
        total+=money[i];
    }
    cout << total << endl;
    
    return 0;
}


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

int N;
int table[128];

void doA() {
  for(int i = 0; i < N; i++) if( table[i] == '#' ) {
      table[i] = 'A';
      return;
    }
}

void doB() {
  for(int i = N - 1; i >= 0; i--) {

    if( table[i] == '#' ) {
      
      bool a = false;
      if( i - 1 >= 0 && table[i - 1] == 'A' ) a = true;
      if( i + 1 < N && table[i + 1] == 'A' ) a = true;
      
      if( ! a ) {
        table[i] = 'B';
        return;
      }
    }    
  }

  for(int i = 0; i < N; i++) if( table[i] == '#' ) {
      table[i] = 'B';
      return;
    }

}

void doC() {
  for(int i = 0; i < N; i++) {
    if( table[i] != '#' ) {
      if( i + 1 < N && table[i + 1] == '#' ) {
        table[i + 1] = 'C'; return;
      }

      if( i - 1 < N && table[i - 1] == '#' ) {
        table[i - 1] = 'C'; return;
      }

    }
  }

  if( N & 1 ) table[(N + 1) / 2 - 1] = 'C';
  else table[N / 2] = 'C';
}

void doD() {
  static int temp[128];
  for(int i = 0; i < 128; i++) temp[i] = 987654321;
  
  for(int i = 0; i < N; i++) {
    if( table[i] != '#' ) 
      temp[i] = -1;
    else 
      for(int j = 0; j < N; j++) 
        if( table[j] != '#' ) {
          temp[i] = min( temp[i], abs(i - j));
        }
  }
  
  int best = 0;
  for(int i = 0; i < N; i++) 
    if( temp[best] < temp[i] )
      best = i;
  
  table[best] = 'D';
}

int main() {
  for(int M; cin >> N >> M, (N || M); ) {

    for(int i = 0; i < N; i++) table[i] = '#';

    for(int m = 0; m < M; m++) {
      char ch; cin >> ch;
      if( ch == 'A' ) doA();
      if( ch == 'B' ) doB();
      if( ch == 'C' ) doC();
      if( ch == 'D' ) doD();
    }
    for(int i = 0; i < N; i++) cout << (char)(table[i]); cout << endl;
  }
}

Measured memory_bytes: 0
#!/usr/bin/env python3
import sys
from math import *
from itertools import *
from collections import *
from functools import *
import operator
try:
    from math import gcd
except Exception:
    from fractions import gcd


def solve(N: int, a: "List[int]"):
    m = reduce(operator.mul, a) - 1
    return sum([m % x for x in a])


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    a = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    result = solve(N, a)
    print(result)

if __name__ == '__main__':
    main()


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

int main()
{
    int x = 0, i = 0;

    while(1)
    {
        cin >> x;
        if((x == 0) && (i >= 10000))
        {
            break;
        }
        else
        {
            i++;
            cout << "Case " << i << ": " << x << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 3096
// "include" {{{
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cstring>
#include <iomanip>
#include <tuple>
// }}}

using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define pii pair<int,int> 
#define int long long
#define setout(n,x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10)
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const long long mod = 1e9+7;

int gcd(int a,int b){ return b ? gcd(b,a % b) : a;}
int lcm(int a,int b){ return a / gcd(a,b) * b;}

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,m;
	cin >> n >> m;
	priority_queue<int,vector<int>,greater<int> > que;
	vector<pii> chvec;
	int sum = 0;
	rep(i,n){
		int a;
		cin >> a;
		que.emplace(a);
		sum += a;
	}
	rep(i,m){
		int b,c;
		cin >> b >> c;
		chvec.emplace_back(c,b);
	}
	sort(all(chvec),greater<pii>());
	rep(i,m){
		rep(j,chvec[i].second){
			int x = que.top();
			que.pop();
			if(x < chvec[i].first){
				sum += chvec[i].first - x;
				x = chvec[i].first;
				que.emplace(x);
			}
			else{
				cout << sum << '\n';
				return 0;
			}
		}
	}
	cout << sum << '\n';
				
	return 0;	
}


Measured memory_bytes: 3188
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#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>

using namespace std;

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

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

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

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

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

int main() {
    /*
    int N, K;
    cin >> N >> K;

    if((N - 1) % (K - 1) == 0) cout << (N -1) / (K-1);
    else cout << (N - 1) / (K - 1) + 1;
    */
    int N;
    cin >> N;
    int t_N;
    int sum = 0;
    t_N = N;
    while( t_N > 0) {
        sum += t_N % 10;
        t_N /= 10;
    }
    if(N % sum == 0) cout << "Yes";
    else cout << "No";
    return 0;
}


Measured memory_bytes: 256
mod_number=1000000007
n,m=map(int,input().split())
x=list(map(int,input().split()))
y=list(map(int,input().split()))

ans_x=0
ans_y=0

for i in range(n-1):
    ans_x += (x[i+1]-x[i])*(i+1)*(n-i-1) % mod_number


for i in range(m-1):
    ans_y += (y[i+1]-y[i])*(i+1)*(m-i-1) % mod_number

print(ans_x * ans_y % mod_number)


Measured memory_bytes: 18556
// AtCoder template
// 最近sabaがかまってくれないからキレて暴れてる
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i = 0; i < n; ++i)

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll a,b,c,k; cin >> a >> b >> c >> k;
    if(a >= k) cout << k << endl;
    else if(a + b >= k) cout << a << endl;
    else if(a + b + c >= k) cout << a - (k-(a+b)) << endl;
}

Measured memory_bytes: 3652
#include <iostream>

using namespace std;

int cmp(const void *a, const void *b) {
    if(*(int*)a > *(int*)b) {
        return 1;
    }
    if(*(int*)a < *(int*)b) {
        return -1;
    }
    cout << "NO" << endl;
    exit(0);
}

int main() {
    int N;
    int A[200000];
    cin >> N;
    for(int i=0;i<N;i++){
        cin >> A[i];
    }
    qsort(A, N, sizeof(int), cmp);
    cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 1788
#include <cstdio>
#include <cstring>
long long dp[2][21];
int main() {
	int n,m;
	scanf("%d",&n);
	scanf("%d",&m);
	dp[0][m]=1;
	for(int i=1;i<n-1;i++) {
		scanf("%d",&m);
		for(int j=0;j<=20;j++) {
			if((j+m)<=20) {
				dp[i%2][j+m]+=dp[(i-1)%2][j];
			}
			if((j-m)>=0) {
				dp[i%2][j-m]+=dp[(i-1)%2][j];
			}
		}
		memset(dp+(i-1)%2,0,sizeof(long long)*21);
	}
	scanf("%d",&m);
	printf("%lld\n",dp[(n-2)%2][m]);
}

Measured memory_bytes: 1028
def gcd(a,b):
  while b:a,b=b,a%b
  return a
def lcm(a,b):return a*b//gcd(a,b)
n=int(input())
a=list(map(int,input().split()))
ans=0
mod=10**9+7
l=a[0]
for i in range(1,n):l=lcm(l,a[i])
l%=mod
for i in a:
  ans+=l*pow(i,mod-2,mod)%mod
  ans%=mod
print(ans)

Measured memory_bytes: 4084
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	long long a, b, c;
	cin >> a >> b >> c;
	if (a % 2 == 0 || b % 2 == 0 || c % 2 == 0)cout << 0 << endl;
	else
	{
		int d = max(a, max(b, c));
		if (d == a)
			cout << b * c << endl;
		else if (d == b)
			cout << a * c << endl;
		else 
			cout << b * a << endl;
	}
}

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

int main(){
  int N, a[100];
  cin >> N;
  for(int i=0; i<N; i++) cin >> a[i];

  sort(a, a+N);
  int b=0, c=0;
  for(int i=N-1; i>=0; i--){
    if(i%2==0) b+=a[i];
    else c+=a[i];
  }
  cout << abs(b-c) << endl;

  return 0;
}

Measured memory_bytes: 256
N = gets.to_i
as = gets.split

counts = Hash.new(0)

as.each do |a|
  counts[a] += 1
end

counts = counts.select { |k, v| v >= 2 }.sort { |a, b| b[0].to_i <=> a[0].to_i }

x = 0
y = 0
if counts.empty?
elsif counts[0][1] >= 4
  x = counts[0][0].to_i
  y = counts[0][0].to_i
else
  x = counts[0][0].to_i
  y = counts[1][0].to_i
end

puts x * y


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

using namespace std;

vector<ll> divisor(ll n) {
  vector<ll> ret;
  for(ll i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(ret.begin(), ret.end());
  return (ret);
}

int main() {
  ll n;
  scanf("%lld", &n);
  vector<ll> v = divisor(n - 1), r = divisor(n);
  set<ll> o;
  for(int i = 1; i < v.size(); i++) o.insert(v[i]);
  for(auto x : r) {
    if(x == 1) continue;
    ll t = n;
    while(t >= x) {
      if(t % x)
        t %= x;
      else
        t /= x;
    }
    t %= x;
    if(t == 1) o.insert(x);
  }
  printf("%d\n", o.size());
}

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

using namespace std;
typedef long long ll;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    ll n;
    cin>> n;
    ll c=0,x;
    ll ans=0;
    vector<ll>v;
    for(ll i = 1 ; i*(i+1) <= n*2 ; i++ )
    {
        v.push_back((i*(i+1))/2);
    }
    while(n%2==0)
    {
        c++;
        n/=2;
    }
    if(c>0)
    {
        x=upper_bound(v.begin(),v.end(),c)-v.begin();
        ans+=x;
    }
    for(ll i = 3 ; i*i <= n ;i+=2)
    {
        c=0;
        while(n%i==0)
        {
            c++;
            n/=i;
        }
        if(c>0)
        {
            x=upper_bound(v.begin(),v.end(),c)-v.begin();
            ans+=x;
        }
    }
    if(n>2)
    {
        ans++;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 19716
#include<bits/stdc++.h>
using namespace std;
int a,b,c;
int main(){
    cin>>a>>b>>c;
    if(a+b<c){
        cout<<a+2*b+1<<endl;
    }
    else if(a+b==c){
        cout<<a+b*2<<endl;
    }
    else if(a+b>c){
        cout<<b+c<<endl;
    }
}


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

int main(void)
{
	int r, d, x;
	scanf("%d %d %d", &r, &d, &x);
	int i = 0;
	while (i < 10)
	{
		x = r*x - d;
		printf("%d\n",x);
		i++;
	}

	return(0);
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
    int a, b, c;
    cin>>a>>b>>c;
    int d1=a+b, d2=a+c, d3=b+c;
    cout<<min(d3, min(d1, d2))<<endl;
    return 0;

}

Measured memory_bytes: 256
def string(s,i):
  l = 0
  while i < len(s) and s[i].isalpha():
    l += 1
    i += 1
  return i,l

def number(s,i):
  n = 0
  while i < len(s) and s[i].isdigit():
    n = n*10 + (ord(s[i])-ord('0'))
    i += 1
  return i,n

def block(s,i):
  if i < len(s) and s[i].isalpha():
    return string(s,i)
  else:
    i,n = number(s,i)
    if i < len(s) and s[i] == '(':
      i += 1
      sum = 0
      while i < len(s) and s[i] != ')':
        i,tmp = block(s,i)
        sum += tmp
      sum *= n
      i += 1
      return i,sum
    else:
      i,tmp = block(s,i)
      sum = tmp*n
      return i,sum

def find(s,i,j,p):
  if i == j:
    return 0
  k,l = block(s,i)
  if p < l:
    if i < j and s[i].isalpha():
      return s[i+p]
    else:
      i,n = number(s,i)
      if i < j and s[i] == '(':
        return find(s,i+1,k-1,p%(l//n))
      else:
        return find(s,i,k,p%(l//n))
  else:
    return find(s,k,j,p-l)

if __name__ == '__main__':
  while True:
    [s,p] = input().split()
    p = int(p)
    if s == "0" and p == 0:
      break
    print(find(s,0,len(s),p))



Measured memory_bytes: 5644
#include<bits/stdc++.h>
using namespace std;
typedef	 long long int lli;
typedef long long ll;
typedef long double ld;
const int mod=1e9+7;
const int MAX=200005;
#define ALL(x) x.begin(),x.end()
#define all(x,k) x.begin(),x.begin()+k


void solve();

string getString(char x) 
{ 
    // string class has a constructor 
    // that allows us to specify size of 
    // string as first parameter and character 
    // to be filled in given size as second 
    // parameter. 
    string s(1, x); 
  
    return s;    
} 
bool sz(ll a, ll b)
{
	return a>b;
}
int main()
{


		solve();
		
		
	
	
	

return 0;
}

void solve()
{
	
int t,n;
string s;
	cin>>n;
	pair<pair<string ,int>,int >m[n+1];

for(int i=1;i<n+1;i++)
{
	cin>>s>>t;
	m[i]={{s,-t},i};
	
}
sort(m+1,m+(n+1));
	
	for(int i=1;i<=n;i++)
	{
		cout<<m[i].second<<"\n";
	}
}



Measured memory_bytes: 3636
import java.io.BufferedReader
import java.io.BufferedWriter
import java.io.StringWriter
import kotlin.math.pow

fun solve(c: Case) {
    val (d, n) = c.intList()
    c.println((100.toDouble().pow(d).toInt() * (if (n == 100) 101 else n)).toString())
}

open class Case(
    private val input: BufferedReader = System.`in`.bufferedReader(),
    private val out: BufferedWriter = System.out.bufferedWriter()
) {
    fun exec(fn: (Case) -> Unit) = input.use { out.use { fn(this) } }
    fun println(c: CharSequence?) = out.appendln(c)
    fun intList(): List<Int> = input.readLine().split(" ").map { it.toInt() }
}

fun main() = Case().exec(::solve)

Measured memory_bytes: 36532