akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>
#include <random>
#include <iomanip>

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define fillInt(xs, x)        \
  for (int i = 0; i < (x); i++) \
    scanf("%d", &xs[i]);
#define fillLong(xs, x)       \
  for (int i = 0; i < (x); i++) \
    scanf("%ld", &xs[i]);
#define fillString(xs, x)       \
  for (int i = 0; i < (x); i++) \
    cin >> xs[i];
#define sortv(xs) sort(xs.begin(), xs.end())
#define sortvdi(xs) sort(xs.begin(), xs.end(), std::greater<int>())
#define lbv(xs, x) lower_bound(xs.begin(), xs.end(), x) - xs.begin()
#define ubv(xs, x) upper_bound(xs.begin(), xs.end(), x) - xs.begin()
#define bs(xs, x) binary_search(xs.begin(), xs.end(), x)

#define rep(i,n) for(auto i=0; i<(n); i++)
#define isValidPoint(x, y, mx, my) x >= 0 && x  < mx && y >= 0 && y < my

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

const int MOD =   1000003;

long exp_mod(long long a, long long b, long m) {
	long long res = 1;
	while (b > 0) {
		if (b&1)
			res = (res * a)%m;
		a = (a * a)%m;
		b >>= 1;
	}
	return (long)res;
}

long fact_mod(long n, long m) {
	long long res = 1;
	for (long i=n; i>0; --i)
		res = (res * i)%m;
	return (long)res;
}

long comb_mod(long n, long r) {
	long long res = 1;
	for (long i=0; i<r; ++i)
		res = (res * (n - i) )%MOD;
	return ( res * exp_mod(fact_mod(r, MOD), MOD-2, MOD) ) % MOD;
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

struct Pony
{
    long s, t, x;

    Pony(long s_, long t_, long x_)
    {
        s = s_;
        t = t_;
        x = x_;
    }

    bool operator<(const Pony &another) const
    {
        return x < another.x;
    };
};

long modinv(long a, long m) {
    long b = m, u = 1, v = 0;
    while (b) {
        long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

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

  long n;
  cin >> n;

  vector<long> w(n);

  fillLong(w, n);

  long sm = 0;

  rep(i, n) {
    sm += w[i];
  }

  long res = sm;
  long left = 0;
  long right = sm;
  rep(i, n) {
    left += w[i];
    right -= w[i];

    res = min(res, abs(right-left));
  }

  cout << res << endl;
}


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

int main(){
	string sa,sb,sc;
    cin>>sa>>sb>>sc;
    int a=0;int b=0;int c=0;
    string te="a";
    a++;
  for (int i=0;i<(sa.size()+sb.size()+sc.size());i++){
    
    if(te=="a"){
      
      if(sa.size()<=a){
      	cout<<"A"<<endl;
        return 0;
      }else{
        te=sa.at(a);
        a++;
        continue;
      }
      
    }else if(te=="b"){
      
      if(sb.size()<=b){
      	cout<<"B"<<endl;
        return 0;
      }else{
        te=sb.at(b);
        b++;
        continue;
      }
      
    }else if(te=="c"){
      
      if(sc.size()<=c){
      	cout<<"C"<<endl;
        return 0;
      }else{
        te=sc.at(c);
       	c++;
        continue;
      }
      
 	}
    
  }
}    

Measured memory_bytes: 256
#include<iostream>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip>//setprecision
#include<math.h>
#include <functional>
#include<climits>
using namespace std;
#define ll  long long 
#define rep(i, n)        for(ll i=0; i<(ll)(n); ++i)
#define mod 1000000007
  vector<ll>to[1000005];
   ll dp[2000000];
 int gcd(int a, int b)
{
  if (a%b == 0)
{
return(b);
}
else
{
return(gcd(b,a%b));
}
}
int main(){
  ll a,b;cin>>a>>b;
  char c[1000][1000];
  rep(i,a)rep(o,b)cin>>c[i][o];
  rep(i,a){
    rep(o,b)cout<<c[i][o];
    cout<<endl;
    rep(o,b)cout<<c[i][o];
    cout<<endl;
  }
}



Measured memory_bytes: 27168
N = int(input())
H = list(map(int, input().split()))
H.append(0)
H.append(0)

#dp[足場i]=足場iにたどり着く最小コスト
dp = [10**10 for _ in range(N+10)]

dp[0] = 0
for i in range(N):
    dp[i+1] = min(dp[i+1], dp[i] + abs(H[i]-H[i+1]))
    dp[i+2] = min(dp[i+2], dp[i] + abs(H[i]-H[i+2]))

print(dp[N-1])


Measured memory_bytes: 13924
import sys

for in_str in sys.stdin:
#    comp_list = list(map(int, in_str.split(" ")))
    a, b = map(int, in_str.split())
    #a = comp_list[0]
    #b = comp_list[1]
    if (a == 0) & (b == 0) : break
    elif a < b :
        print(a, b)
    else :
        print(b, a)

Measured memory_bytes: 7848
<?php
ini_set('error_reporting', E_ALL & ~E_NOTICE);

define('MOD', pow(10, 9) + 7);

fscanf(STDIN, "%s", $s);
$n = strlen($s);

$dp[0][0] = 1;
for ($i = 0; $i < $n; $i++) {
    if ($s[$i] == '?') {
        $c = -1;
    } else {
        $c = $s[$i] - '0';
    }
    
    for ($j = 0; $j < 10; $j++) {
        if ($c != -1 && $c != $j) continue;
        for ($ki = 0; $ki < 13; $ki++) {
            $dp[$i + 1][($ki * 10 + $j) % 13] += $dp[$i][$ki];
        }
    }
    for ($j = 0; $j < 13; $j++) $dp[$i + 1][$j] %= MOD;
}
$res = $dp[$n][5];

printf("%d", $res);


Measured memory_bytes: 76276
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
typedef long long int ll;
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int> 

int main(){
  int N; cin >> N;
  int a;
  vector<pii> A(N); 
  rep(i,N) {
    cin >> a;
    A[i] = {a,i};
  }
  sort(all(A));
  rep(i,N) {
    cout << A[i].second+1;
    if (i!=N-1) cout << " ";
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
#define RI register int
int read() {
	int q=0;char ch=' ';
	while(ch<'0'||ch>'9') ch=getchar();
	while(ch>='0'&&ch<='9') q=q*10+ch-'0',ch=getchar();
	return q;
}
const int N=100005;
int n,a[N];
int cmp(int x,int y) {return x>y;}
int main()
{
	n=read();
	for(RI i=1;i<=n;++i) a[i]=read();
	sort(a+1,a+1+n,cmp);
	for(RI i=1;i<=n;++i)
		if(i+1>a[i+1]) {
			int j=i+1;while(a[j]==i) ++j;
			int ans=(j-i-1)&1;
			ans|=(a[i]-i)&1;
			if(ans) puts("First");
			else puts("Second");
			return 0;
		}
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph= vector<vector<int>>; 
#define rep(i,n) for (ll i=0; i < (n); ++i)
#define rep2(i,n,m) for(ll i=n;i<=m;i++)
#define rep3(i,n,m) for(ll i=n;i>=m;i--)
#define pb push_back
#define eb emplace_back
#define ppb pop_back
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}
// ミント
const int mod = 1e9+7 ;
//998244353;

struct mint {
  ll x; // typedef long long ll;
  mint(ll 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 { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= 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 { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
//昆布
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
}   ;
 

int main(){
   ll n ,k ;cin>>n >>k ;
   combination c(n+5) ;
   rep2(i,1,k){
     mint a= c(k-1,i-1) ;
     mint b= c(n-k+2-1,i+1-1) ;
     mint ans= a*b ;
     cout<<ans<<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);
		
		String s = sc.next();
		int answer = 0;
		
		if(s.charAt(0) == '1') answer++;
		if(s.charAt(1) == '1') answer++;
		if(s.charAt(2) == '1') answer++;
		
		System.out.println(answer);
	}
}


Measured memory_bytes: 22612
S = gets.to_i
puts "#{S / 60 / 60}:#{(S - S / 60 / 60 * 60 * 60) / 60}:#{(S - S / 60 / 60 * 60 * 60) - (S - S / 60 / 60 * 60 * 60) / 60 * 60}"

Measured memory_bytes: 8684
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
ll a[200005],b[200005];
ll two[30];
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;cin>>N;
  FOR(i,0,N)cin>>a[i];
  FOR(i,0,N)cin>>b[i];
  // 2^kの位が1となる個数を数える
  two[0]=1;
  FOR(i,1,30)two[i]=two[i-1]*2;
  ll ans = 0;
  FOR(k,0,29){
    // aiと足して1になるbjの個数を一気に求める
    // 2^(k+1)以上のくらいは意味ないので2^(k+1)で割っておく
    vector<ll> bb(N);
    FOR(i,0,N)bb[i]=b[i]%two[k+1];
    sort(bb.begin(),bb.end());
    ll cnt=0;
    FOR(i,0,N){
      int aa=a[i]%two[k+1];
      cnt+=lower_bound(bb.begin(),bb.end(),2*two[k]-aa)-lower_bound(bb.begin(),bb.end(),two[k]-aa);
      cnt+=lower_bound(bb.begin(),bb.end(),4*two[k]-1-aa)-lower_bound(bb.begin(),bb.end(),3*two[k]-aa);
    }
    if(cnt%2)ans+=two[k];
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 4992
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <string>
#include <math.h>
#include <cmath>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <algorithm>
#include <stdio.h>
#include <cstring>                    
#include <sstream>
#include <numeric>
#include <assert.h>

using namespace std;

#define lop(i,n) for(int i=0 ;i<n ;i++)
#define VI    vector<int>
#define VLL    vector<ll>
#define VPI    vector<pair<int,int>>
#define VII    vector<VI>
#define all(v)    v.begin() , v.end()
#define SORT(v)    sort(all(v))
#define ll    long long
#define ull unsigned long long
#define scni(x)    scanf("%d",&x)           
#define scnll(x)    scanf("%lld",&x)        
#define scnd(x)    scanf("%lf",&x)          
#define prnti(x)    printf("%d\n",x)        
#define prntll(x)    printf("%lld",x)       
#define prntd(x)    printf("%.9lf",x)        
#define sz(x)  x.size()
#define pp push_back
#define P pair<int , int>
#define mp make_pair

const double EPS = 1e-9;
const double PI = 3.14159265359;

//  O( n * log(log(n)) )
vector<ll> primes;
void GeneratingPrimes(int top){
    vector<bool> p (top+1 , 1);
//    vector<ll> primes;
    p[0] = p[1] = 0;

    for(int i = 2; i <= sqrt(top) ; i++){
        if(p[i]){
            for(int j = i*i ; j <= top ; j+=i){
                p[j]=0;
            }
        }
    }
    lop(i , top+1)
        if(p[i])primes.push_back(i);
//    return primes;
}

ll gcd(ll a ,ll b){return (b==0)?a : gcd(b , a%b);}
ll lcm(ll a, ll b){return (a * b) / gcd(a , b);}
void EXTgcd(ll a , ll b , ll & x0 , ll & y0){
    if(b==0){ x0 =1 , y0 = 0; return; }
    EXTgcd( b , a%b , x0 , y0 );
    ll x1 = y0;
    ll y1 = x0 - (a/b) * (y0);

	y1 = y1;
    x0 = x1;
    y0 = y1;
}

long long power(long long n, long long p , ll mod) {
    if (!p)
        return 1;
    long long ans = 1;
    while (p > 1) {
        if (p & 1)
            ans = (ans * n) % mod;
        n = (n * n) % mod;
        p /= 2;
    }
    return (ans * n) % mod;
}

double dist(double a , double b , double x, double y){ return sqrt( pow( a-x ,2) + pow( b-y ,2) ); }
double dist3(double a , double b , double c , double x , double y ,double z ){ return sqrt( pow( a-x ,2) + pow( b-y ,2) + pow( c-z ,2)); }

int xadd[9]= { 1 , -1 , 0 , 1 , -1 , 0 , 1 , -1 , 0 };
int yadd[9]= { 1 , -1 , 0 ,-1 ,  0 , 1 , 0 ,  1, -1 };

int xx[4]={0 , 1 , 0 , -1};
int yy[4]={1 , 0 , -1 , 0};

// string digits[]= {"1110111", "0010010", "1011101", "1011011", "0111010", "1101011", "1101111", "1010010", "1111111", "1111011"};

#define no  { cout<<"NO\n";  }
#define yes { cout<<"YES\n"; }
#define _1  { cout<<"-1\n";  }

ll const N = 1e5 + 10;
ll const INF = 1e18;
ll const mod = 1000000007;

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

int n,m,vis[N],from[N];
VI e[N];

int dfs(int idx){
	if(vis[idx])return from[idx];

	vis[idx]=1;
	int &ret= from[idx];
	for(int to: e[idx])ret= max(ret, dfs(to)+1);
	return ret;
}

int main(){
	cin >>n>>m;
	while(m--){
		int x,y;
		scni(x),scni(y);
		e[x].pp(y);
	}
	int ans=0;
	for(int i=1; i<=n; i++)if(!vis[i])ans = max(ans, dfs(i));
	cout << ans;
return 0;}

Measured memory_bytes: 7808
#include<bits/stdc++.h>
using namespace std;
int main()
{
	cin.tie(0);
	cout.tie(0); 
	ios::sync_with_stdio(false);	
	
	long long N,h,n,w,t1,t2;
	cin >> N;
    bool flag=false;
    for(h=1;h<=3500;h++)
    {
        for(n=1;n<=3500;n++)
        {
            t1=N*h*n;
            t2=4*h*n-n*N-h*N;
            if(t1>0&&t2>0&&t1%t2==0)
        	{
        		cout << h << " " << n << " " << t1/t2;
        		flag=true;
                break;
            }
        }
        if(flag) break;
    }   
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
#define REP(i, N) for(ll i = 0; i < N; ++i)
#define FOR(i, a, b) for(ll i = a; i < b; ++i)
#define ALL(a) (a).begin(),(a).end()
#define pb push_back
#define INF (long long)1000000000
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main(void) {
	while(true) {
		int n, k;
		cin>>n>>k;
		if(n == 0 && k == 0) break;
		vector<vector<P> > l(n);
		REP(i, k) {
			int hoge;
			cin>>hoge;
			if(hoge == 0) {
				ll a, b;
				cin>>a>>b;
				--a;
				--b;
				vector<ll> d(n, INF * INF);
				priority_queue<P, vector<P>, greater<P> > que;
				que.push(P(0, a));
				d[a] = 0;
				while(!que.empty()) {
					P np = que.top();
					que.pop();
					if(d[np.second] != np.first) continue;
					REP(j, l[np.second].size()) {
						if(d[l[np.second][j].first] > d[np.second] + l[np.second][j].second) {
							d[l[np.second][j].first] = d[np.second] + l[np.second][j].second;
							que.push(P(d[l[np.second][j].first], l[np.second][j].first));
						}
					}
				}
				if(d[b] == INF * INF) cout<<-1<<endl;
				else cout<<d[b]<<endl;
			} else {
				ll c, d, e;
				cin>>c>>d>>e;
				--c;
				--d;
				l[c].pb(P(d, e));
				l[d].pb(P(c, e));
			}
		}
	}
}

Measured memory_bytes: 3032
from math import inf

A=26

D=int(input())

C=[0]+list(map(int,input().split())) #減る満足度のベース
S=[0]*(D+1) #S[d][i] :(d+1)日目にコンテストiを開催した時の満足度

for i in range(1,D+1):
    S[i]=[0]+list(map(int,input().split()))

L=[0]*(A+1)
for d in range(1,D+1):
    Y=-inf
    E=0
    for a in range(1,A+1):
        X=S[d][a]
        for s in range(1,A+1):
            if a!=s:
                X-=C[s]*(d-L[s])

        if X>Y:
            Y=X
            E=a
    L[E]=d
    print(E)
            


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

int main() {
  string S;
  string T;
  cin >> S;
  cin >> T;
  int ans=1;
  int a=S.size();
  if (a>10 || a<1) ans=0;
  for (int i=0; i<a ; i++) {
    if (S.at(i) != T.at(i)) ans=0; 
  }
  if (ans==1) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3632
#include <iostream>

using namespace std;

int main()
{
	long long n, m;
	cin >> n >> m;
	
	if(m > 2*n)
	{
		m -= 2*n;
		cout << n + (m / 4) << endl;
	}
	else
	{
		cout << m / 2 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
using System;
using static System.Console;
using static System.Math;

public class Hello{
    public static void Main(){
        string[] input = ReadLine().Split(' ');
        int aa = int.Parse(input[0]);
        int ab = int.Parse(input[1]);
        int ba = int.Parse(input[2]);
        int bb = int.Parse(input[3]);
        WriteLine(Max(aa*ab,ba*bb));
    }
}


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

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repn(i, n) for(int (i) = 1; (i) <= (n); (i)++)
#define repr(i, n) for(int (i) = (n-1); (i) >= 0; (i)--)
#define all(x) (x).begin(), (x).end()
#define lint long long
#define ulint unsigned long long
#define fi first
#define se second
#define setpre(x) cout << fixed << setprecision(x)
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define out(x) cout << (x) << endl
#define outs(x) cout << (x) << " "
#define yn(x) cout << ((x)?("Yes"):("No")) << endl
#define YN(x) cout << ((x)?("YES"):("NO")) << endl
#define bit_c(x) __builtin_popcountll(x)

inline void logger(){ cout << " [LOGGER] " << endl; }
template<typename A, typename... B>
void logger(const A& a, const B&... b){
    cout << a << " , ";
    logger(b...);
}

typedef pair<lint, lint> P;
const lint MOD = 1000000007;
const lint MOD9 = 998244353;
const lint INF = MOD * MOD;
const int MAX = 200005;

/* ...o(^-^)o... */

int main(){
    int n; cin >> n;
    vector<int> v(n);
    map<int, lint> mp;
    rep(i, n){
        int a; cin >> a; mp[a]++; v[i] = a;
    }

    lint res = 0;
    for(auto &p : mp){
        res += p.se * (p.se - 1) / 2;
    }

    rep(i, n){
        lint k = mp[v[i]];
        out(res - (k - 1));
    }
}

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

#define filein freopen ("in.txt", "r", stdin)
#define fileout freopen ("out.txt", "w", stdout)
#define dbg(x) cerr << #x << ": " << x << endl

using namespace std;
typedef long long ll;

const int maxn = 100005;

ll a[maxn];
ll dp[maxn];

int main(){
	ll n;
	scanf ("%lld", &n);
	for (ll i = 1; i <= n; i++)
		scanf ("%lld", &a[i]);
	dp[1] = 0;
	dp[2] = llabs (a[1] - a[2]);
	for (ll i = 3; i <= n; i++){
		dp[i] = min (dp[i - 1] + llabs (a[i] - a[i - 1]), dp[i - 2] + llabs (a[i] - a[i - 2]));
	}
	cout << dp[n] << '\n';
	return 0;
}

Measured memory_bytes: 1792
def main():
    import sys

    def input(): return sys.stdin.readline().rstrip()

    n = int(input())
    a = list(map(int, input().split()))
    x = [0]*n
    x[0] = (sum(a[::2])-sum(a[1::2]))
    for i in range(1, n):
        x[i] = 2*a[i-1]-x[i-1]
    print(*x)

if __name__ == '__main__':
    main()

Measured memory_bytes: 20528
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pi 3.141592653589793238
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MOD 1000000007
int main(){
	fast;
	string s;
	cin>>s;
	int n=s.length(),a=0,z=0;
	for(int i=0;i<n;i++)
		if(s[i]=='A')
		{
			a=i;
			break;
		}
	for(int i=n-1;i>=0;i--)
		if(s[i]=='Z')
		{
			z=i;
			break;
		}
	cout<<z-a+1;
	return 0;
}



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

using namespace std;

typedef long long ll;

// Scan and Debug
void scan(){}
template<typename F, typename... R> void scan(F &f,R&... r){cin>>f;scan(r...);}
int di_; string dnms_, co_ = ",";
void debug_(){cout<<endl;}
template<typename F, typename... R> void debug_(F f, R... r){while(dnms_[di_] != ',')cout<<dnms_[di_++];di_++;cout<<": "<<f<<",";debug_(r...);}
#define debug(...) dnms_=#__VA_ARGS__+co_,di_=0,debug_(__VA_ARGS__)

const int MAX = 100001;
int a, b, t, tot = 0;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	scan(a, b, t);

	for (int ct = a; ct <= t; ct += a)
		tot += b;

	cout << tot << "\n";

	return 0;
}


Measured memory_bytes: 256
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<pii> vpii;
typedef vector<vi> vvi;
typedef vector<vb> vvb;
typedef vector<vpii> vvpii;
const int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
const int MOD = 1000000007;
const double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
bool odd(const int &n) { return n & 1; }
bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

void solve() {
  int n, m, t;
  cin >> n >> m >> t;
  vi cannotStudy(t + 1);
  while (n--) {
    int a;
    cin >> a;
    // (imos method would be good for this process)
    for (int i = a - m; i <= a + m; i++) {
      if (i < cannotStudy.size()) cannotStudy[i] = 11235813213455LL;
    }
  }
  int c = 0;
  loop(i, 1, cannotStudy.size()) c += !(cannotStudy[i - 1] && cannotStudy[i]);
  cout << c << endl;
}

Measured memory_bytes: 3180
// Created by sz
#include <bits/stdc++.h>
using namespace std;

const int N = 1e3 + 5, mod = 1e9 +7;
int n, e[N];

void unique_factorization(int n){
    int m = sqrt(n + 0.5);
    for (int i = 2; i <= m; i++){
        while (n%i == 0) {
            n/= i;
            e[i] ++;
        }
        if(n==1) break;
    }
    if(n>1)e[n]++;
}

int main(){
#ifdef LOCAL
    freopen("./input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    cin>>n;
    
    for (int i = 2; i <= n; i++){
        unique_factorization(i);
    }
    
    long long ans = 1;
    for (int i = 2; i <= n; i++){
        if(e[i])ans *= ((1+e[i])%mod);
        ans %= mod;
        
    }
    cout<<ans<<endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#define ll long long
inline int Min(int a,int b){
    return a<b?a:b;
}
ll ans=0;int a[100005];
int main() {
	int n;scanf ("%d",&n);
    for (int i=1;i<=n;i++) scanf ("%d",&a[i]);
    for (int i=1;i<=n;i++){
        if (a[i]&&a[i-1]) a[i]--,a[i-1]--,ans++;
        ans+=(a[i]>>1),a[i]&=1;
    }
    printf ("%lld",ans);
	return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<math.h>

using namespace std;

int main(int argc, char **argv) {
    int n, ans;
    int sum = 0;
    double ave, mini;
    vector<double> a;

    cin >> n;
    a.resize(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        sum += a[i];
    }
    ave = (double)sum / (double)n;
    mini = ave;

    for (int j = 0; j < n; j++) {
        a[j] = fabs(a[j] - ave);
        if (a[j] < mini) {
            ans = j;
            mini = a[j];
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
/// Bismillahir Rahmanir Rahim
/* Author: Mohammad Morsalin
    Dept of ICE, NSTU
*/
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define endl "\n"
#define f0(n) for(int i=0;i<n;i++)
#define ms(x) memset(x,0,sizeof(x))
#define ins insert
#define ALL(v) v.begin(),v.end()
#define highest(x) numeric_limits<x>::max()
#define lowest(x) numeric_limits<x>::min()
#define Inf INFINITY
#define minv(v) *min_element(v.begin(),v.end())
#define maxv(v) *max_element(v.begin(),v.end())
#define PI acos(-1)
#define IOS ios::sync_with_stdio(false);
using namespace std;
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};
const long long MOD = 1000000007;
template<typename T>inline T Bigmod(T base, T power, T MOD){
    T ret=1;
    while(power)
    {
        if(power & 1)ret=(ret*base)%MOD;
        base=(base*base)%MOD;
        power>>=1;
    }
    return ret;
}

bool sortinrev(const pair<int,int> &a,
               const pair<int,int> &b)
{
       return (a.first > b.first);
}
int main()
{
    IOS
    long double a,b;
    cin>>a>>b;
    ll x = a*b ;
    cout << x << endl;
    return 0;
}
///Alhamdulillah


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

const int mul[2] = {233, 19260817};
const int mod[2] = {998244353, 1000000007};

#define pb push_back

int n;
vector <int> a, b, na, nb, pw[2], hsh[2];
int get(int l, int r, int k) {return (hsh[k][r] + mod[k] - 1LL * pw[k][r - l] * hsh[k][l] % mod[k]) % mod[k];}

int main() {
	ios :: sync_with_stdio(0);
	cin >> n;
	for (int i = 0; i < n; ++ i) {int x; cin >> x; a.pb(x);}
	for (int i = 0; i < n; ++ i) {int x; cin >> x; b.pb(x);}
	for (int i = 0; i < n; ++ i) na.pb(a[i] ^ a[(i + 1) % n]);
	for (int i = 0; i < n; ++ i) na.pb(na[i]);
	for (int i = 0; i < n; ++ i) nb.pb(b[i] ^ b[(i + 1) % n]);
	int hb[2];
	for (int k = 0; k < 2; ++ k) {
		pw[k].pb(1); for (int i = 1; i <= n * 2; ++ i) pw[k].pb(1LL * mul[k] * pw[k].back() % mod[k]);
		hsh[k].pb(0); for (int i = 0; i < n * 2; ++ i) hsh[k].pb((1LL * mul[k] * hsh[k].back() + na[i]) % mod[k]);
		hb[k] = 0; for (int i = 0; i < n - 1; ++ i) hb[k] = (1LL * mul[k] * hb[k] + nb[i]) % mod[k];
	}
	for (int i = 0; i < n; ++ i)
		if (get(i, i + n - 1, 0) == hb[0] && get(i, i + n - 1, 1) == hb[1] && na[i + n - 1] == nb[n - 1])
			cout << i << " " << (a[i] ^ b[0]) << "\n";
	return 0;
}

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

bool check(vector<vector<ll>> &x, ll sum){
    rep(i, 0, 3){
        ll tsum = 0;
        rep(j, 0, 3) tsum += x[i][j];
        if(tsum != sum) return false;
    }
    rep(i, 0, 3){
        ll tsum = 0;
        rep(j, 0, 3) tsum += x[j][i];
        if(tsum != sum) return false;
    }
    ll tsum = x[0][0] + x[1][1] + x[2][2];
    if(tsum != sum) return false;
    tsum = x[0][2] + x[1][1] + x[2][0];
    if(tsum != sum) return false;
    return true;
}

int main(){
    ll a, b, c;
    cin >> a >> b >> c;
    vector<vector<ll>> x(3, vector<ll>(3));
    x[0][0] = a;
    x[0][1] = b;
    x[1][1] = c;
    for(ll sum = a + b; sum <= 10000; sum++){
        x[0][2] = sum - x[0][0] - x[0][1];
        x[2][1] = sum - x[0][1] - x[1][1];
        x[2][0] = sum - x[0][2] - x[1][1];
        x[2][2] = sum - x[2][0] - x[2][1];
        x[1][2] = sum - x[0][2] - x[2][2];
        x[1][0] = sum - x[0][0] - x[2][0];
        if(check(x, sum)){
            rep(i, 0, 3){
                rep(j, 0, 3){
                    cout << x[i][j];
                    if(j == 2) cout << endl;
                    else cout << " "; 
                }
            }
        }
    }
    return 0;
}

Measured memory_bytes: 256
N = int(input())
answer = 'Yes'
place_now = [0,0,0]
for i in range(N):
  place_next = list(map(int, input().split()))
  if place_next[0]-place_now[0] < place_next[1]+place_next[2]-place_now[1]-place_now[2]:
    answer = 'No'
    break
  elif (place_next[0]-place_now[0])%2 != (place_next[1]+place_next[2]-place_now[1]-place_now[2])%2:
    answer = 'No'
    break

print(answer)

Measured memory_bytes: 3064
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include <ctype.h>
#include <stdint.h>
#include <string.h>
#include <wchar.h>
#include <math.h>

#define N_MAX (100)
#define P_MAX (100)
#define DP_ARRAY_SIZE (N_MAX * P_MAX / 32 + 1)

#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define ABS(a) ((a) < 0 ? -(a) : (a))
#define ABSS(a, b) ((a) > (b) ? (a) - (b) : (b) - (a))

int compare_sz_desc(const void* a, const void* b) {
    return *((size_t*)a) > * ((size_t*)b) ? -1 : 1;
}

int compare_f(const void* a, const void* b) {
    return *((int64_t*)a) < *((int64_t*)b) ? -1 : 1;
}

int compare_f2(const void* a, const void* b) {
    return *((uint64_t*)a) > * ((uint64_t*)b) ? -1 : 1;
}

static size_t comb(const size_t n, const size_t r) {
    size_t result = 1;

    for (size_t i = 0; i < r; i++) {
        result *= n - i;
        result /= i + 1;
    }

    return result;
}

static uint64_t combU64(const uint64_t n, const uint64_t r) {
    uint64_t result = 1;

    for (uint64_t i = 0; i < r; i++) {
        result *= n - i;
        result /= i + 1;
    }

    return result;
}

static uint64_t gcdU64(uint64_t m, uint64_t n)
{
    uint64_t temp;

    while (m % n != 0) {
        temp = n;
        n = m % n;
        m = temp;
    }

    return n;
}

static size_t gcdZu(size_t m, size_t n) {
    size_t temp;

    while (m % n != 0) {
        temp = n;
        n = m % n;
        m = temp;
    }

    return n;
}

int main(void) {
    size_t W, H, x, y;

    scanf("%zu %zu %zu %zu", &W, &H, &x, &y);

    printf("%lf %d", (double)W * (double)H / 2, (2 * x == W && 2 * y == H ? 1 : 0));

    return 0;
}


Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //[summary]B - Kagami Mochi
            int n = int.Parse(Console.ReadLine());
            var mochi = ReadLines(n);

            Console.WriteLine(mochi.Distinct().Count());
        }

        static List<int> ReadLines(int count = 0)
        {
            //[summary]コンソールの値を読み込む
            var numbers = new List<int>();

            //読み込む行数が未指定のときは、1行目の値を"count"とみなす
            if (count == 0)
            {
                string s = Console.ReadLine().TrimEnd();
                count = int.Parse(s);
            }

            for (int i = 0; i < count; i++)
            {
                string s = Console.ReadLine().TrimEnd();
                numbers.Add(int.Parse(s));
            }

            return numbers;
        }
    }
}

Measured memory_bytes: 11348
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
using namespace std;
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF 1145141919364364
#define int long long
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first

int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}

int h, w, k;
char a[810][810];
int mi = INF;
int dx[4] = { 0,0,1,-1 }, dy[4] = { 1,-1,0,0 };

void bfs(int x, int y, int z) {
	queue<P> que;
	que.push({ x, y });
	int d[810][810];
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			d[i][j] = INF;
		}
	}
	d[x][y] = 0;
	while (!que.empty()) {
		P p = que.front(); que.pop();
		int u = p.first, v = p.second;
		mi = min({ mi,u,v,h - u - 1,w - v - 1 });
        if (d[p.first][p.second] == z)continue;
		for (int i = 0; i < 4; i++) {
			int tx = u + dx[i], ty = v + dy[i];
			if (tx < 0 || h <= tx || ty < 0 || w <= ty || a[tx][ty] == '#' || d[tx][ty] != INF)continue;
			d[tx][ty] = d[u][v] + 1;
			que.push({ tx,ty });
		}
	}
	return;
}

signed main() {
	cin >> h >> w >> k;
	int s = 0, t = 0;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			cin >> a[i][j];
			if (a[i][j] == 'S')s = i, t = j;
		}
	}
	bfs(s, t, k);
	int ans = 1 + mi / k;
	if (mi%k)ans++;
	cout << ans << endl;
}

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

ll solve(const std::vector<std::pair<int, int>>& TA)
{
    ll T = 1, A = 1;
    for (auto itr = TA.begin(); itr != TA.end(); ++itr)
    {
        ll t = (T + itr->first - 1) / itr->first;
        ll a = (A + itr->second - 1) / itr->second;
        ll n = std::max(t, a);
        T = n * itr->first;
        A = n * itr->second;
    }
    return T + A;
}

int main(void)
{
    int N;
    std::cin >> N;

    std::vector<std::pair<int, int>> TA(N);
    for (int i = 0; i < N; i++)
    {
        std::cin >> TA[i].first >> TA[i].second;
    }
    std::cout << solve(TA) << std::endl;

    return 0;
}

Measured memory_bytes: 256
/**
*   @Author : MeGA
*   @InitTime :01/24/20 13:03:35
*   @Idea : 
*
*
*
*
*
*
*
**/
#include <bits/stdc++.h>
using namespace std;
int main(){
#ifndef ONLINE_JUDGE
  // freopen("in","r",stdin);
  // freopen("out","w",stdout);
#endif
     int n,m;
     scanf("%d %d",&n,&m);
     vector<int>v(n+1);
     priority_queue<int>q;
     for(int i=0;i<n;i++){
         int a;
         scanf("%d",&a);
         q.push(a);
     }
     while(m){
        int f=q.top();
        q.pop();
        f=floor(1.0*f/2);
        m--;
        q.push(f);
     }
     long long ans=0;
     while(!q.empty()){
         ans+=q.top();
         q.pop();
     }
     printf("%lld",ans);
     


}

Measured memory_bytes: 1276
#include <bits/stdc++.h> //JuniorMonster a.k.a Sho10
#define ll long long
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define all(a) (a).begin(), (a).end()
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define sz size
#define f first
#define s second
#define pb push_back
#define er erase
#define in insert
#define mp make_pair
#define pi pair
#define rc(s) return cout<<s,0
#define mod 1000000007
#define PI 3.14159265359
#define CODE_START  ios_base::sync_with_stdio();cin.tie();cout.tie();
using namespace std;
ll n,a,b;
int32_t main(){
CODE_START;
cin>>n;
cin>>a;
cin>>b;
cout<<min(n*a,b);
}


Measured memory_bytes: 256
# include <stdio.h>
# include <bits/stdc++.h>
using namespace std;
const pair < int , int > DD[] = {{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};
# define fi cin
# define fo cout
# define x first
# define y second
# define ll long long
# define IOS ios_base :: sync_with_stdio(0);cin.tie(0)
# define p(v) cerr << #v << " = " << v << '\n'
# define p2(v) cerr << #v << " = " << (complex < __typeof(v.x) > (v.x,v.y)) << '\n'
# define vi vector < int >
# define vl vector < ll >
# define pll pair < ll , ll >
# define pii pair < int , int >
# define mp make_pair
# define db long double
# define fail puts("-1")
# define yes puts("YES")
# define no puts("NO")
# define PP puts("Possible")
# define II puts("Impossible")
# define vii vector < pii >
# define vll vector < ll >
# define pb push_back
# define pdd pair < db , db >
template < class T > T smin(T &a,T b) {if (a > b) a = b;return a;}
template < class T > T smax(T &a,T b) {if (a < b) a = b;return a;}
int main(void)
{
    #ifdef CF
    freopen("input","r",stdin);
    #endif // CF
    srand(time(0));
    fo << fixed << setprecision(7);
    cerr << fixed << setprecision(7);
    int n;
    IOS;
    fi>>n;
    static int s[1 << 20];
    for (int i = 1;i <= n;++i)
        fi>>s[i];
    ll sum = accumulate(s + 1,s + 1 + n,0ll);
    ll cur = 1ll * n * (n + 1) / 2;
    if (sum % cur)
        return no * 0;
    sum /= cur;
    int ok = 1;
    for (int i = 1;i <= n;++i)
        ok &= s[i] <= sum * n && (s[i] >= sum);
    int cnt = 0;
    s[n + 1] = s[1];
    ll ss = 0;
    for (int i = 1;i <= n;++i)
        ok &= ((s[i] + sum) % n) == ((s[i + 1]) % n);
    for (int i = 1;i <= n;++i)
        ok &= s[i + 1] - s[i] <= sum,ss += (s[i] - s[i + 1] + sum) / n;
    ok &= ss == sum;
    if (ok)
        yes;
    else
        no;
    cerr << "Time elapsed :" << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
    return 0;
}


Measured memory_bytes: 768
#include<cstdio>
#include<iostream>
#include<cstdlib>
#define ll long long
using namespace std;
int a,b,c,d,m;
bool check(int x)
{
	ll res1=a-x/(m+1)*m-x%(m+1),res2=b-x/(m+1);
	return res2-res1*m<=0;
}
int main()
{
	int t;
    scanf("%d",&t);
    while(t --> 0)
	{
        scanf("%d%d%d%d",&a,&b,&c,&d);
        int l=0,r=a+b+1;
		m=(max(a,b)-1)/(min(a,b)+1)+1;
        while(l<r)
		{
            int mid=(l+r)>>1;
            if(check(mid))l=mid+1;
			else r=mid;
        }
        for(int i=c;i<=min(d,l);i++)
		if(i%(m+1)==0)putchar('B');
		else putchar('A');
		ll res1=a-l/(m+1)*m-l%(m+1),res2=b-l/(m+1);
        for(int i=max(c,l+1);i<=d;i++)
		if((i-(l+res2-res1*m+1))%(m+1)==0)putchar('A');
		else putchar('B');
        puts("");
    }
    return 0;
}

Measured memory_bytes: 384
import sys
n,k,c=map(int, input().split())
s=str(input())

l=[0]*n
r=[0]*n
i=0
j=n-1
cnt=0
while i<n:
    if s[i]=='x':
        i+=1
    if s[i]=='o':
        l[i]=1
        i+=c+1
        cnt+=1
#前から働いていって、必要以上の数働ける形の場合、必須となる日はありません。
if cnt>k:
    sys.exit()
    
while j>=0:
    if s[j]=='x':
        j-=1
    if s[j]=='o':
        r[j]=1
        j-=c+1
"""
ここまでで、lには「最速でその日に仕事ができる」
rには「遅くともその日までには仕事しないといけない」
というリストができます。

print(l)
print(r)
"""
for _ in range(len(l)):
    if l[_] and r[_]:
        print(_+1)

Measured memory_bytes: 7876
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

func main() {
	stdin := bufio.NewScanner(os.Stdin)
	stdin.Scan()
	text := stdin.Text()

	var a float64
	a, _ = strconv.ParseFloat(text, 64)

	fmt.Printf("%6f %6f", a*a*math.Pi, a*2*math.Pi)
}



Measured memory_bytes: 1108
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <map>
typedef long long LL;

int main() {
	int x;
	LL hoge = 1;
	int ans = 0;
	LL num = 0;
	std::string str;

	std::cin >> str;

	for (int i = 0; i < str.size()-1; ++i) {
		hoge *= 10;
	}

	for (int i = 0; i < str.size(); ++i) {
		ans += str[i] - 48;
		num += (str[i] - 48) * hoge;
		hoge /= 10;
	}

	if (num%ans == 0) {
		std::cout << "Yes" << std::endl;
	}
	else {
		std::cout << "No" << std::endl;
	}

}

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

#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
#define FORA(i,I) for(const auto& i:I)
#define ALL(x) x.begin(),x.end() 
#define SIZE(x) ll(x.size()) 

int main(void)
{
    string S;
    cin >> S;

    string T = "";
    string dream   = "dream"; 
    string erase   = "erase"; 
    string eraser  = "eraser";
    string dreamer = "dreamer"; 

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

    //逆順に
    reverse(ALL(S));
    REP(i,4){
        reverse(ALL(X[i]));
    }

//    REP(i,SIZE(S)){
    for (int i = 0; i < S.size();) {
        bool flag = false;
        REP(j,SIZE(X)){
            if(S.substr(i,SIZE(X[j])) == X[j]){
                i += SIZE(X[j]);
                flag = true;
            }
        }
        if(flag == false){
            cout << "NO" << endl;
            return 0;
        }
    }

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


Measured memory_bytes: 3740
#include <vector>
#include <list>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <cstdio>
#include <climits>
#include <complex>
#include <cstdint>
#include <tuple>

#define M_PI       3.14159265358979323846

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(); }
inline int readInt() { int x; scanf("%d", &x); return x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//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 SQ(a) ((a)*(a))
#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,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()


struct Edge {
    int to, cost, nm;
    Edge(int to, int cost, int nm): to(to), cost(cost), nm(nm) {}
};

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<Edge>> AdjList;
AdjList graph;
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
const int INF = 100000000;

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

bool cmp(const pii& a, const pii& b){
    if(a.first == b.first){
        return a.second < b.second;
    }
    return a.first < b.first;
}


int N, M;
double r;
int n;
int arr[45][45][45][45];


int main() {


    cout << fixed << setprecision(10);


    ll L, R; cin >> L >> R;

    if(R-L>=2019){
        cout << 0 << endl;
        return 0;
    }
    L %=2019; R %= 2019;

    ll ans = 2019;

    for(int i=L; i<=R; ++i){
        for(int j=i+1; j<=R; ++j){
            ans = min(ans, (ll)i*j%2019);
        }
    }
    cout << ans << endl;
    return 0;
}

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

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

    ll m=1000;

    for(i=0; i<n-1; i++)
    {
        if(a[i+1]>a[i])
        {
            ll d=m/a[i];
            ll r=m%a[i];

            m=d*a[i+1];
            m+=r;
        }
    }
    cout<<m;

    return 0;
}


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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define MP make_pair
ll MOD = 1e9+7;
//ll MOD = 998244353;
ll INF = 1e18;
void chmin(ll &a,ll b){if(a>b)a=b;}
void chmax(ll &a,ll b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
void ans(bool x,ll y,ll z){if(x)cout<<y<<endl;else cout<<z<<endl;}
void anss(bool x,string y,string z){if(x)cout<<y<<endl;else cout<<z<<endl;}   
ll gcd(ll x,ll y){ll r;while((r=x%y)!=0){x=y;y=r;}return y;}

int main(){
  ll i,j,o;
  ll res=0,res1=0,res2=INF,buf=0,buf1=0,buf2=0,buf3=0,buf4=0;
  bool judge = true;
  ll n;cin>>n;
  vector<ll> a(n);
  ll sum=0;
  for(i=0;i<n;i++){
    cin>>a[i];
    sum+=a[i];
  }
  buf=a[0];
  res=abs(sum-2*buf);
  for(i=1;i<n-1;i++){
    buf+=a[i];
    chmin(res,abs(sum-2*buf));
  }
  cout<<res<<endl;

  return 0;
}

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

#define MAX 100

int N;
string A;
string B;
string C;

int main() {
	cin >> N;
	cin >> A;
	cin >> B;
	cin >> C;

	int ans = 0;
	for( int i = 0; i < N; i++ ) {
		if( A[i] == B[i] && B[i] == C[i] ) {
		}
		else if( A[i] != B[i] && B[i] != C[i] && C[i] != A[i] ) {
			ans += 2;
		}
		else if( A[i] != B[i] || B[i] != C[i] || C[i] != A[i] ) {
			ans++;
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
using System;

public class Program
{
    static void Main(string[] args)
    {
        string[] input = Console.ReadLine().Split(' ');
        int a = int.Parse(input[0]);
        int b = int.Parse(input[1]);
        Console.WriteLine(a * b % 2 == 1 ? "Odd" : "Even");
    }
}

Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;
const int MOD=1e9+7,inv2=5e8+4;
inline int poww(long long x,int y)
{
	long long ret=1;
	while(y)
	{
		if(y&1)ret*=x,ret%=MOD;
		x*=x,x%=MOD;
		y>>=1;
	}
	return ret;
}
int n,k;
long long dp[2333][2333];
long long fac[4555555],invfac[4555555];
inline long long c(int a,int b)
{
	return fac[a]*invfac[b]%MOD*invfac[a-b]%MOD;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin>>n>>k;
	if(k==1)return cout<<1<<endl,0;
	fac[0]=1;
	for(int i=1;i<=4000000;i++)fac[i]=fac[i-1]*i%MOD;
	invfac[4000000]=poww(fac[4000000],MOD-2);
	for(int i=4000000;i>=1;i--)invfac[i-1]=invfac[i]*i%MOD;
	dp[n+1][n]=1;
	for(int i=n;i>=1;i--)
	{
		long long sum=0;
		for(int j=n;j>=i;j--)
		{
			sum+=dp[i+1][j];sum%=MOD;
			dp[i][j]=c(n-j+(n-i)*(k-1)+k-2,k-2)*sum%MOD;
//			cerr<<"dp "<<i<<','<<j<<'='<<dp[i][j]<<endl;
		}
	}
	long long sum=0;
	for(int i=1;i<=n;i++)sum+=dp[1][i];
	cout<<sum%MOD*fac[n]%MOD<<endl;
	return 0;
}

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

#define INF 1e9
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;

int gcd(int a, int b) {
    if(a % b == 0) {
        return b;
    }
    else {
        return(gcd(b, a % b));
    }
}


int main() {
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a.at(i);
    ll ans = 1;
    sort(a.begin(), a.end());
    if (a.at(0) == 0) {
        cout << 0 << endl;
        return 0;
    }
    rep(i, n) {
        if (1000000000000000000 / ans < a.at(i)) {
            cout << -1 << endl;
            return 0;
        }
        ans *= a.at(i);
        if (ans > 1000000000000000000)  {
            cout << -1 << endl;
            return 0;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 4048