akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define all(x) x.begin(),x.end()
#define let auto const

int main() {
  i64 n;
  cin >> n;
  vector<i64> v(n);
  rep(i,0,n) {
    cin >> v[i];
  }
  sort(all(v));
  double a = v[0];
  rep(i,1,n) {
    a = (a + v[i]) / 2;
  }
  cout << fixed << setprecision(10);
  cout << a << endl;

}


Measured memory_bytes: 256
#include<stdio.h>
#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;

//pair sort
bool compare_by_b(pair<LL, LL> a, pair<LL, LL> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

const string YES = "Yes";
const string NO = "No";

void solve(long long N, std::vector<long long> a, std::vector<long long> b){
    LL sum=0;
    REP(i, N){
        if(a[i]<b[i]){
            sum+=floor((b[i]-a[i])/2.0);
        }
        else{
            sum -= a[i]-b[i];
        }
    }
    if(sum>=0)cout<<YES<<endl;
    else cout<<NO<<endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> a(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&a[i]);
    }
    std::vector<long long> b(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&b[i]);
    }
    solve(N, std::move(a), std::move(b));
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

struct mint {
    const int mod = 1e9 + 7;
    long long x;
    
    mint (long long x = 0) : x((x % mod + mod) % mod) {
        
    }
    
    mint& operator=(const long long a) {
        x = a % mod;
        return *this;
    }
    
    mint& operator=(const mint a) {
        x = a.x % mod;
        return *this;
    }
    
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    
    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }
    
    mint& operator-=(const mint a) {
        if ((x += (mod - a.x)) >= mod) x -= mod;
        return *this;
    }
    
    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }
    
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    
    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }
    
    mint pow(long long t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }
    
    mint inv() const {
        return pow(mod - 2);
    }
    
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    
    mint operator/(const mint a) const {
        mint res(*this);
        return res /= a;
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    string s;
    cin >> s;
    reverse(all(s));
    ll n = len(s);
    vector<vector<mint>> dp(n + 1, vector<mint>(13, 0));
    dp[0][0] = 1;
    ll m = 1;
    rep(i, n) {
        char c = s[i];
        set<ll> kh;
        if (c == '?') rep(j, 10) kh.insert(j);
        else kh.insert(c - '0');
        for (auto x : kh) {
            rep(j, 13) {
                ll next = (j + x * m) % 13;
                dp[i + 1][next] += dp[i][j];
            }
        }
        m = (m * 10) % 13;
    }
    cout << dp[n][5].x << endl;
    return 0;
}


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

#define rep(i,n)  for(int i=0;i<n;++i)
#define sc1(a)  scanf("%d",&a)
#define sc2(a,b)  scanf("%d %d",&a,&b)


int main(){
    int mod=1000000007;
    int n,k;
    sc2(n,k);
    double ans=0.0;
    for (int i=1;i<=n;i++) {
        int x=i,f=1;
        for(;;) {
            if (x>=k) break;
            x*=2;
            f*=2;
        }
        ans+=1.0/(n*f);
    }
    printf("%.15lf\n",ans);
    return 0;
}


Measured memory_bytes: 3744
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>
//#include <tuple>

//#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back

int main() {
  int a, b;
  cin >> a >> b;

  if (a <= 9 && b <= 9){
    cout << a * b << endl;
  } else {
    cout << -1 << endl;
  }

}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.io.InputStream;

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

    static class TaskA {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            String s = in.next();
            for (int i = 0; i + 1 < s.length(); ++i) {
                if (s.charAt(i) == 'A' && s.charAt(i + 1) == 'C') {
                    out.println("Yes");
                    return;
                }
            }
            out.println("No");
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1)
                throw new UnknownError();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new UnknownError();
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public String next() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            StringBuffer res = new StringBuffer();
            do {
                res.appendCodePoint(c);
                c = read();
            } while (!isSpaceChar(c));

            return res.toString();
        }

        private boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

    }
}



Measured memory_bytes: 21460
#include <iostream>
#include <cstdio>
#include <vector>

using namespace std;

const int inf = 1e9;

int main(void){
    int n;
    while (cin>>n && n) {
        vector<vector<int> > g(n, vector<int>(n+1));
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n+1; j++) {
                cin >> g[i][j];
            }
        }
        
        vector<int> dp(1<<n, inf);
        dp[0] = 0;
        for (int bit = 0; bit < (1<<n); bit++) {
            for (int i = 0; i < n; i++) {
                if (bit & (1<<i)) continue;
                int cost = g[i][0];
                for (int j = 0; j < n; j++) {
                    if (bit&(1<<j)) cost = min(cost, g[i][j+1]);
                }
                dp[bit|(1<<i)] = min(dp[bit|(1<<i)], dp[bit]+cost);
            }
        }
        cout << dp[(1<<n)-1] << endl;
    }
}

Measured memory_bytes: 3408
package main

import (
	"fmt"
)

func main() {
	var a, b, c, counter, i int
	counter = 0
	fmt.Scan(&a, &b, &c)

	for i = a; i < b+1; i++ {
		if c%i == 0 {
			counter++
		}
	}
	fmt.Println(counter)
}



Measured memory_bytes: 1156
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <unordered_map>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
#include <unordered_map>
#include <fstream>
#include <ctime>
#include <complex>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef pair<int,int> pii;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(int i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 2020000;
ll dy[8] = {1,-1,0,0,1,-1,1,-1};
ll dx[8] = {0,0,1,-1,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T> inline void print(T &a){
    for(auto itr = a.begin(); itr != a.end(); itr++){
		cout << *itr << " ";
	}
    cout << "\n";
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){
	cout << "debug: " << a << " " << b << "\n";
}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << "debug: " << a << " " << b << " " << c << "\n";
}
void mark() {cout << "#" << "\n";}
ll pcount(ll x) {return __builtin_popcountll(x);}
const int mod = 1e9 + 7;
//const int mod = 998244353;

int main(){
	string s; cin >> s;
	if(s.back() == 's') s += "es";
	else s.push_back('s');
	cout << s << "\n";
}

Measured memory_bytes: 3624
#include<cstdio>
int h[100005];
int main(void)
{
    int n;
    scanf("%d" ,&n);
    for(int i=0;i<n;i++)
        scanf("%d" ,&h[i]);
    for(int i=n-1;i>0;i--)
    {
        int t=h[i]-h[i-1];
        if(t==-1) h[i-1]--;
        else if(t<-1)
        {
            printf("No");
            return 0;
        }
    }
    printf("Yes");
    return 0;
}


Measured memory_bytes: 512
//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> P;
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, D_t;
    cin >> N >> K;
    VI D;
    REP(i, K) {
        cin >> D_t;
        D.push_back(D_t);
    }

    for(;;) {
        bool is_ans = true;
        int t_N = N;
        while(t_N > 0) {
            if(find(D.begin(), D.end(), t_N % 10) != D.end()){
                is_ans = false;
                break;
            }
            t_N /= 10;
        }
        if(is_ans) break;
        N++;
    }
    cout << N << endl;
    return 0;
}


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

int main() {
  int N, M; cin >> N >> M;
  int D[N]; for (int i = 0; i < N; i++) D[i] = -1;
  int s, c; bool exists = true;
  for (int i = 0; i < M; i++) {
    cin >> s >> c; s--;
    if (D[s] != -1 && c != D[s]) {
      exists = false; break;
    }
    else D[s] = c;
  }
  if (N > 1 && D[0] == 0) exists = false;
  if (!exists) cout << -1 << endl;
  else {
    for (int i = 0; i < N; i++) {
      if (D[i] == -1) {
        if (i > 0 || N == 1) D[i] = 0;
        else D[i] = 1;
      }
      cout << D[i];
    }
    cout << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD (long long int)(1e9 + 7)
#define ll long long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n) for (int i = 1; i <= (int)(n); i++)
#define REP(i, n) for (int i = n - 1; i >= 0; i--)
#define REPS(i, n) for (int i = n; i > 0; i--)
#define FOR(i, a, b) for (int i = a; i < (int)(b); i++)
#define ALL(x) (x).begin(), (x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define CLR(a) memset((a), 0, sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const long double PI = acos(-1.0L);
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a, b) a = (((a) < (b)) ? (b) : (a))
#define chmin(a, b) a = (((a) > (b)) ? (b) : (a))

__attribute__((constructor)) void initial() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

signed main() {
  int h, w;
  cin >> h >> w;
  int a[h][w], b[h][w];
  int max_k = (h + w) * 80 + 5;
  rep(i, h) rep(j, w) cin >> a[i][j];
  rep(i, h) rep(j, w) cin >> b[i][j];
  vector<vector<vector<bool>>> dp(h,
                                  vector<vector<bool>>(w, vector<bool>(max_k)));

  // bool dp[h][w][max_k];
  // memset(dp, false, sizeof(dp));
  const int dh[2] = {1, 0}, dw[2] = {0, 1};
  dp[0][0][abs(a[0][0] - b[0][0])] = true;
  rep(now_h, h) rep(now_w, w) {
    rep(i, 2) {
      int next_h = now_h + dh[i], next_w = now_w + dw[i];
      if (next_h >= h || next_w >= w)
        continue;
      int d = abs(a[next_h][next_w] - b[next_h][next_w]);
      rep(k, max_k) {
        if (!dp[now_h][now_w][k])
          continue;
        if (k + d < max_k)
          dp[next_h][next_w][k + d] = true;
        if (abs(k - d) < max_k)
          dp[next_h][next_w][abs(k - d)] = true;
      }
    }
  }
  int ans = max_k;
  rep(k, max_k) {
    if (dp[h - 1][w - 1][k])
      return cout << k << endl, 0;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 10752
//
//  main.cpp
//  HelloWorld
//
//  Created by purple on 2020/04/13.
//  Copyright © 2020 Purple. All rights reserved.
//

#include <iostream>
#include <algorithm>
#include <string>
#include <fstream>
#include <cmath>

using namespace std;

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

    string s;
    
    cin >> s;
    string s2;
    
    s2 = s+s;
    string chk;
    cin >> chk;
    
    if(s2.find(chk)!=string::npos)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    
    return 0;
}



Measured memory_bytes: 3224
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,x,n) for(int i=x;i<n;i++)
#define mod 1000000007 //10^9+7
#define INF 1000000000000 //10^12
#define F first
#define S second
#define P pair<int,int>
#define all(vec) vec.begin(),vec.end()
signed main(){
    int n,m;
    cin>>n>>m;
    int ans=(n*(n-1)/2)+(m*(m-1)/2);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
using System;

class Program
    {
        static void Main(string[] args)
        {
            string val = Console.ReadLine();

            int topprice = 700;

            if (val.Substring (0,1)== "o")
            {   
                topprice += 100;
            }

            if (val.Substring(1,1) == "o")
            {
                topprice += 100;
            }

            if (val.Substring(2,1) == "o") 
            {
                topprice += 100;
            }

            Console.WriteLine(topprice.ToString());
            
        }
    }

Measured memory_bytes: 11092
#define _USE_MATH_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>
using namespace std;

const int MOD = 1000000007;

int main()
{
    int n, m;
    cin >> n >> m;
    ++ n;
    vector<vector<pair<int, int> > > v(n);
    for(int i=0; i<m; ++i){
        int l, r, x;
        cin >> l >> r >> x;
        v[r].push_back(make_pair(l, x));
    }

    vector<vector<int> > dp(n, vector<int>(n, 0));
    dp[0][0] = 1;
    for(int i=1; i<n; ++i){
        vector<vector<int> > nextDp(n, vector<int>(n, 0));
        for(int a=0; a<n; ++a){
            for(int b=0; b<=a; ++b){
                for(int j=0; j<3; ++j){
                    vector<int> color = {a, b, i-1};
                    color[j] = i;
                    sort(color.begin(), color.end());
                    nextDp[color[1]][color[0]] += dp[a][b];
                    nextDp[color[1]][color[0]] %= MOD;
                }
            }
        }
        
        for(int a=0; a<n; ++a){
            for(int b=0; b<=a; ++b){
                bool ok = true;
                for(const auto& p : v[i]){
                    int cnt = 1;
                    if(p.first <= a)
                        ++ cnt;
                    if(p.first <= b)
                        ++ cnt;
                    if(cnt != p.second)
                        ok = false;
                }
                if(!ok)
                    nextDp[a][b] = 0;
            }
        }
        dp.swap(nextDp);
    }

    long long ans = 0;
    for(int a=0; a<n; ++a){
        for(int b=0; b<=a; ++b){
            ans += dp[a][b];
            ans %= MOD;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1048
#include <iostream>
#include <vector>
#include <stack>
#include <string>
#include <cmath>
#include <sstream>
#include <queue>
#include <map>
#include <cstring>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
using namespace std;

int main() {
    int K, T;
    int types[100];
    cin >> K >> T;
    for (int i = 0; i < T; i++) {
        cin >> types[i];
    }
    sort(types, types + T);
    for (int i = T - 2; i >= 0; i--) {
        types[T - 1] -= types[i];
    }
    cout << (types[T - 1] > 0 ? types[T - 1] - 1 : 0) << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] a = new int[4];
		int[] b = new int[4];
		int[][] c = new int[4][4];
		for(int i=1;i<=3;i++) {
			for(int j=1; j<=3; j++) {
				c[i][j] = sc.nextInt();
			}
		}
		a[1] = c[1][1];
		a[2] = c[2][1];
		a[3] = c[3][1];
		b[1] = 0;
		b[2] = c[1][2] - c[1][1];
		b[3] = c[1][3] - c[1][1];

		boolean ans = true;
		int numbers[] = {2,3};//[1]
		 for (int i : numbers) {
			 for(int j: numbers) {
				 if(a[i] + b[j] == c[i][j]);
				 else ans = false;
			 }
        }

		if(ans) System.out.println("Yes");
		else System.out.println("No");

	}
}


Measured memory_bytes: 21972
#include <iostream> // cout, endl, cin
#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

using namespace std;



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

	s.at(3) = '8';
	cout << s << endl;
}

Measured memory_bytes: 3596
///Bismillahir Rahmanir Rahim
#include<bits/stdc++.h>
using namespace std;
#define     FAST        ios_base::sync_with_stdio(false);cin.tie(NULL)
#define     int 	    long long
#define 	pb 	        push_back
#define     pop         pop_back
#define 	mp 	        make_pair
#define 	pi 	        2*acos(0.0)
#define     scan(i)     scanf("%lld",&i)
#define     scann(i,j)  scanf("%lld%lld",&i,&j)
#define     print(i)    printf("%lld\n",i)
#define     printt(i,j) printf("%lld %lld\n",i,j)
#define     loop(i,n) 	for(int i = 0 ; i <n ; i++)
#define     loopp(i,n) 	for(int i = 1 ; i <n ; i++)
#define     rep(i,n)    for(int i=n-1;i>=0;i--)
#define 	vect 	    vector<int>
#define 	vec_it 	    vector<int>::reverse_iterator vi
#define     sorta(v)    sort(v.begin(),v.end())
#define     sortd(v)    sort(v.begin(),v.end(),greater<>())
#define     sorted      is_sorted(v.begin(),v.end())
#define 	mapp 	    map<int,int>
#define 	pairr 	    pair<int,int>
#define 	sett	    set<int>
#define 	set_it 	    set<int>::reverse_iterator si
#define     map_it      map<int,int> :: reverse_iterator mi
#define     digit(n)    floor(log10(n)+1)
#define 	yes 	    cout<<"YES"<<endl
#define 	no 	        cout<<"NO"<<endl
#define 	ff 	        first
#define 	ss 	        second
#define     mx          INT_MAX
#define     lmx         LLONG_MAX
#define     mn          INT_MIN
#define     lmn         LLONG_MIN
#define     GCD         __gcd(a,b)
#define     LCM         (a/GCD)*b
template <typename T> T gcd(T a,T b){return (b==0)?a:gcd(b,a%b);}
template <typename T> T lcm(T a,T b) {return a*(b/gcd(a,b));}
int modulo (int a, int b) { return a >= 0 ? a % b : ( b - abs ( a%b ) ) % b; }

void solve()
{
   // freopen ("(input).txt" , "r",  stdin) ;
    string st,stt ;
    int low=0,high=0;
    int l=0,r=0; char ch;
    int n,k,t,b,c,x,y,z,d=0,temp=0,cnt=0,sum=0,f=0;
    cin>>st ; vect v ,a  ; sett s; mapp m,mm ; pairr p;
    loop(i,3)
    {
        if(st[i]=='R')
            cnt++;
        else
            cnt=0;
        temp=max(temp,cnt);
    }
    cout<<temp<<endl;


}

main()
{
    int t;
  //  cin>>t;
  //  while(t--)
        solve();
}


Measured memory_bytes: 3620
// reference: https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

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

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

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

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

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

use std::cmp::Ordering;
#[derive(Eq, PartialEq, Clone, Debug)]
pub struct Rev<T>(pub T);

impl<T: PartialOrd> PartialOrd for Rev<T> {
    fn partial_cmp(&self, other: &Rev<T>) -> Option<Ordering> {
        other.0.partial_cmp(&self.0)
    }
}

impl<T: Ord> Ord for Rev<T> {
    fn cmp(&self, other: &Rev<T>) -> Ordering {
        other.0.cmp(&self.0)
    }
}

impl<T: Copy> Copy for Rev<T> {}

fn main() {
    input! {
        n: usize,
        b: [i64; n-1],
    }
    let m = n - 1;
    let mut a = vec![0; n];
    a[0] = b[0];
    a[n - 1] = b[m - 1];

    for i in 0..m - 1 {
        a[i + 1] = std::cmp::min(b[i], b[i + 1]);
    }

    let ans = a.into_iter().sum::<i64>();

    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<iostream>
#include<map>
#include<string.h>
#include<queue>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<cstdlib>
#include<math.h>
#include<set>
#include<array>
using namespace std;

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



#define rep(n) for(int i=0;i<n;i++)
typedef pair<int, int> pii;

typedef long long ll;
typedef pair<ll, ll>pll;
const int MOD = 1000000007;
const int INF = 1 << 29;


int main() {
	
	long long n,b[101],cnt=0;
	cin >> n;
	for(int i=0;i<n-1;i++) {
		cin >> b[i];
	}
	for (int i = 0; i < n - 2; i++) {
		if (b[i] > b[i + 1]) {
			cnt += b[i + 1];
		}
		else {
			cnt += b[i];
		}
	}
	
		cout << cnt + b[n - 2] + b[0] << endl;
	
	return 0;
}


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

int main() {
	int n, m;
	cin >> n >> m;
	map<int, int> mp;
	map<int, int> check;
	int flag = 1;
	rep(i, m) {
		int s;
		int c;
		cin >> s;
		cin >> c;
		if (s == 1 && c == 0 && n!= 1) flag = 0;
		mp[s] = c;
		check[s]++;
		if (check[s] == 1) check[s + 3] = c;
		if (check[s] > 1 && c != check[s + 3]) flag = 0;
	}



	if (flag == 1) {
		if (n == 1) cout << mp[1];
		else {
			if (mp[1] != 0) cout << mp[1];
			else cout << 1;
			for (int i = 2; i <= n; ++i) {
				cout << mp[i];
			}
		}
	}
	else {
		cout << "-1";
	}

	return 0;
}


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

int fizzbuzz(int a)
{
  if(a % 3 == 0 && a % 5 == 0)
    return 0;
  else if(a % 3 == 0)
    return 0;
  else if(a % 5 == 0)
    return 0;
  else
    return a;
}

int main()
{
  int n;
  long long ans = 0;
  cin >> n;
  for(int i = 1; i <= n; i++)
    ans += fizzbuzz(i);
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3596
n, m = map(int, input().split())
a = [int(input()) for _ in range(m)]

dp = [0] * (n + 10)
dp[0] = 1
mod = 10**9 + 7

ok = [1] * (n + 10)
for i in a:
    ok[i] = 0

for i in range(n):
    if ok[i + 1]:
        dp[i + 1] += dp[i]
        dp[i + 1] %= mod
    if ok[i + 2]:
        dp[i + 2] += dp[i]
        dp[i + 2] %= mod
print(dp[n])


Measured memory_bytes: 8592
// Problem : C - Dubious Document
// Contest : AtCoder - AtCoder Beginner Contest 058
// URL : https://atcoder.jp/contests/abc058/tasks/arc071_a
// Memory Limit : 256 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#define eb emplace_back
#define pb push_back
#define size(s) (int)s.size()
#define int long long
#define vi vector<int>
#define vs vector<string>
#define vv vector<vector<int>>
#define pii pair<int,int>
#define m_p(x,y) make_pair(x,y)
#define vp vector<pair<int,int>>
#define setbits(x) __builtin_popcountll(x)
#define f first
#define se second
#define inc(v,n,x) v.assign(n,x)
#define incd(v,n) v.resize(n)
#define iniz(n) memset(n,0,sizeof(n))
#define inin(n) memset(n,-1,sizeof(n))
#define inimi(n) memset(n,0xc0,sizeof(n))
#define inima(n) memset(n,0x3f,sizeof(n))
#define all(v) (v).begin(),(v).end()

using namespace std;

template<typename T1,typename T2>istream &operator>>(istream &is, vector<pair<T1,T2>> &v) { for (pair<T1,T2> &t : v) is >> t.f>>t.se; return is; }
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }

double pi=acos(-1.0);
const int md=1e9+7;
const int INF=1e15;
int dx1[]={0,0,-1,1};
int dy1[]={1,-1,0,0};

template<class T>
T abst(T a)
{return a<0?-a:a;}

template<class T>
T max2(T a,T b){return a>b?a:b;}
template<class T>
T min2(T a,T b){return a<b?a:b;}

void solve()
{
int n;cin>>n;
vs v(n);cin>>v;
vector<int> ans(26,INT_MAX);
for(string &s:v)
{
	int arr[26]={0};
	for(char c:s)
	{
		arr[c-'a']++;
	}
	for(int i=0;i<26;i++)
	ans[i]=min2(ans[i],arr[i]);
}
string fans;
for(int i=0;i<26;i++)
{
	while(ans[i]--)
	fans+=(char)(i+'a');
}
cout<<fans;
}

int32_t main(){
ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
int t=1;
//cin>>t;
for(int i=1;i<=t;i++)
{
    solve();
}
return 0;
}


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

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

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

Measured memory_bytes: 4796
#include <bits/stdc++.h>
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define REP(i,n) for(int i=0;i<n;i++)
#define FORq(i, m, n) for(int i = m;i <= n;i++)
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define PRINTD(n) printf("%d\n",n)
#define DEBUG printf("%s\n","debug")
using namespace std;
//////////////////////////////////////////////////////
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_12_B&lang=jp
struct Vertex {
	// edge information
	vector<int> edges_to; //to vertex number
	vector<int> edges_cost; // edge cost
	
	//for dijkstra
	bool done; //conform or not
	int cost; // now cost
	
	bool operator<(const Vertex& another) const { // priority --> min
        return another.cost < cost; // order(cost)
    }
	
	bool operator==(const Vertex& another) const {
        return another.cost == cost; // order(cost)
    }
};

const int V_MAX = 10003;
struct Vertex v[V_MAX];


int main(){
	priority_queue<Vertex>Q;
	int n; // vertex 0-indexed
	SCD(n);
	REP(i,n){ // 0-indexed
		int u,k;
		SCD2(u,k);
		REP(j,k){
			int nv,c; // to edge , its cost
			SCD2(nv,c);
			v[u].edges_to.push_back(nv);
			v[u].edges_cost.push_back(c);
		}
	}
	
	REP(i,n){
		v[i].done = false;
		v[i].cost = -1;
	}
	
	v[0].cost = 0; //start
	Q.push(v[0]);
	
	while (!Q.empty()){
		Vertex nowV = Q.top(); Q.pop();
		nowV.done = true;
		
		REP(i,nowV.edges_to.size()){
			int nto = nowV.edges_to[i];
			int ncost = nowV.cost + nowV.edges_cost[i];
			if (((v[nto].cost) < 0) or (ncost < v[nto].cost)){  //not visited or required refresh
				v[nto].cost = ncost;
				Q.push(v[nto]);
			
			}
			
		}
	}
	
	REP(i,n){ // output
		printf("%d %d\n",i,v[i].cost);
	}
	
	
}







Measured memory_bytes: 28332
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

int main()
{
    int N; cin >> N;
    bool exist = false;
    int k = 2;
    for (; k <= 1000; ++k)
    {
        if (N == k * (k - 1) / 2)
        {
            exist = true;
            break;
        }
    }
    if (exist)
    {
        cout << "Yes" << endl << k << endl;
        int start = 1;
        int val;
        for (int i = 0; i < k - 1; ++i)
        {
            cout << k - 1 << ' ';
            start += i;
            for (int j = 0; j < i + 1; ++j)
            {
                val = start + j;
                cout << val << ' ';
            }
            for (int j = i + 1; j < k - 1; ++j)
            {
                val += j;
                cout << val << ' ';
            }
            cout << endl;
        }
        cout << k - 1 << ' ';
        val = 1;
        for (int i = 2; i <= k; ++i)
        {
            cout << val << ' ';
            val += i;
        }
        cout << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 1408
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    var rd = mutableListOf<List<Int>>()
    var bd = mutableListOf<List<Int>>()
    for(i in 0 until n){
        val (x, y) = readLine()!!.split(" ").map { it.toInt() }
        rd.add(listOf(x, y))
    }
    for(i in 0 until n){
        val (x, y) = readLine()!!.split(" ").map { it.toInt() }
        bd.add(listOf(x, y))
    }

    rd.sortBy {it[1] * -1}
    var xbd = bd.sortedBy { it[0] }.toList()
    var a = 0
    xbd.forEach{
        var tmpl = rd.filter{that -> that[0] < it[0] && that[1] < it[1]}
        if(tmpl.count() > 0){
            rd.remove(tmpl.first())
            a += 1
        }
    }
    println(a)
}

Measured memory_bytes: 38252
// And in the end, the love you take is equal to the love you make.
//                      Paul McCartney (the Beatles). The End. Abbey Road.

#include <bits/stdc++.h>
using namespace std;

using ll = long long;

namespace _buff {

const size_t BUFF = 1e5;
char buff[BUFF], *begin = buff, *end = buff;
char getc() {
    if (begin == end) {
        begin = buff;
        end = buff + fread(buff, 1, BUFF, stdin);
    }
    return begin == end ? -1 : *begin++;
}

}

ll read() {
    using namespace _buff;
    ll ret = 0; bool pos = true; char c = getc();
    for (; (c < '0' || c > '9') && c != '-'; c = getc()) {
        assert(~c);
    }
    if (c == '-') {
        pos = false;
        c = getc();
    }
    for (; c >= '0' && c <= '9'; c = getc()) {
        ret = (ret << 3) + (ret << 1) + (c ^ 48);
    }
    return pos ? ret : -ret;
}

const size_t N = 2000 + 5;
const size_t M = N * N;
const ll MOD = 1e9 + 7;

void add(ll &dp, ll val) {
    dp += val;
    if (dp >= MOD) {
        dp -= MOD;
    }
}

ll fac[M], inv[M], finv[M];

void prep() {
    fac[0] = inv[0] = finv[0] =
    fac[1] = inv[1] = finv[1] = 1;
    for (int i = 2; i < M; ++i) {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - MOD / i * inv[MOD % i] % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

ll C(int n, int m) {
    return fac[n] * finv[m] % MOD * finv[n - m] % MOD;
}

ll dp[N][N];

int main() {
    prep();
    int n = read(), k = read() - 1;
    if (!k) {
        return puts("1"), 0;
    }
    dp[0][0] = 1;
    for (int i = 1; i <= n; ++i) {
        for (int j = 0; j <= i; ++j) {
            if (j) dp[i][j] = dp[i][j - 1];
            add(dp[i][j], dp[i - 1][j] * C(i * k + j - 1, k - 1) % MOD);
        }
    }
    cout << dp[n][n] * fac[n] % MOD << '\n';
    return 0;
}


Measured memory_bytes: 124416
/**
 *    viet the nay ko phai bat chuoc tourist
 *    ma la muon noi rang
 *	 doc code ban khac la suc vat khong phai con nguoi
**/


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ldb;
typedef unsigned long long ull;
typedef pair<ll,ll> ii;
typedef pair<ll, pair<ll,ll> > iii;
typedef vector<ll> vi;

const int kn = 2e5 + 1;
const int N = 21;
const ll mod = 1e9 + 7;

//#define x first
//#define y second
#define _it iterator
#define pb push_back
#define f(i,a,b) for(int i=a;i<=b;i++)
#define ff(i,n) for(int i=1;i<=n;i++)
#define ms(val,a) memset(a,val,sizeof(a))
#define _ff(i,n) for(int i=n;i>=1;i--)
#define _f(i,a,b) for(int i=b;i>=a;i--)
#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

int n, a[N], b[N];

int main() {
	cin >> n;
	ff(i,n) cin >> a[i];
	ff(i,n) cin >> b[i];
	int ans = 0;
	ff(i,n)
	{
		if(a[i] > b[i]) ans+=(a[i]-b[i]);
	}
	cout << ans;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <cmath>

using namespace std;
typedef long long ll;

int N;
int field[6][6];
int ss[6];

ll calc(){
  ll sum=0;
  int nowField[6][6]={};
  for(int i=0;i<5;i++)
    for(int j=0;j<5;j++)
      nowField[i][j]=field[i][j];
  int bonus=1;
  while(1){
    bool isDel=false;
    int nxtField[5][5]={};
    // テァツ渉セテ・ツ慊ィテ」ツ?ョfieldテ」ツ?ォテ」ツ?ェテ」ツつ嘉」ツつ禿」ツ?ァテ」ツ??」ツつ凝」ツつづ」ツ?ョテ」ツつ津」ツ?凖」ツ?ケテ」ツ?ヲテヲツカツ暗」ツ??
    for(int i=0;i<5;i++){
      for(int j=0;j<5;j++){
        if(nowField[i][j]==-1)continue;
        // テヲツィツェ
        {
          int now=nowField[i][j];
          int cnt=0;
          for(int k=j;k<5;k++){
            if(now==nowField[i][k])cnt++;
            else break;
          }
          if(cnt>=3){
            isDel=true;
            for(int k=j;k<5;k++){
              if(now==nowField[i][k])nxtField[i][k]=-1;
              else break;
            }
          }
        }
        // テァツクツヲ
        {
          int now=nowField[i][j];
          int cnt=0;
          for(int k=i;k<5;k++){
            if(now==nowField[k][j])cnt++;
            else break;
          }
          if(cnt>=3){
            isDel=true;
            for(int k=i;k<5;k++){
              if(now==nowField[k][j])nxtField[k][j]=-1;
              else break;
            }
          }
        }
      }
    }
    for(int i=0;i<5;i++)
      for(int j=0;j<5;j++)
        if(nxtField[i][j]==-1)
          sum+=ss[nowField[i][j]]*bonus;
    for(int i=0;i<5;i++)
      for(int j=0;j<5;j++)
        if(nxtField[i][j]==-1)
          nowField[i][j]=-1;
    memset(nxtField,-1,sizeof(nxtField));
    // テヲツカツ暗」ツ?療」ツ?淌・ツセツ古」ツ??ィツ青ステ」ツ?ィテ」ツ?凖・ツ仰陛、ツスツ愿」ツつ津ィツ。ツ古」ツ??
    for(int j=0;j<5;j++){
      int lis[5];
      memset(lis,-1,sizeof(lis));
      int cnt=0;
      for(int i=4;i>=0;i--)
        if(nowField[i][j]!=-1)
          lis[cnt++]=nowField[i][j];
      for(int i=0;i<cnt;i++)
        nxtField[4-i][j]=lis[i];
    }
    for(int i=0;i<5;i++)
      for(int j=0;j<5;j++)
        nowField[i][j]=nxtField[i][j];
    if(!isDel)break;
    bonus++;
  }
  return sum;
}

void dfs(int depth,int cy,int cx,ll &res){
  res=max(res,calc());
  if(depth!=N){
    const int dy[]={-1,0,0,1};
    const int dx[]={0,-1,1,0};
    for(int i=0;i<4;i++){
      int ny=dy[i]+cy;
      int nx=dx[i]+cx;
      if(ny>=0&&nx>=0&&ny<5&&nx<5){
        swap(field[ny][nx],field[cy][cx]);
        dfs(depth+1,ny,nx,res);
        swap(field[ny][nx],field[cy][cx]);
      }
    }
  }
}

int main(){

  while(cin>>N&&N!=-1){
    for(int i=0;i<5;i++)
      for(int j=0;j<5;j++)
        cin>>field[i][j],field[i][j]--;
    for(int i=0;i<5;i++)
      cin>>ss[i];
    ll res=0;
    for(int i=0;i<5;i++)
      for(int j=0;j<5;j++)
        dfs(0,i,j,res);
    cout<<res<<endl;
  }
  return 0;
}

Measured memory_bytes: 1164
// Last Change: 02/03/2019 21:21:37.
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

void LoopUntilZeroInpput() {
  int hogegegege = 0;
  while (cin >> hogegegege && hogegegege != 0) {
  }
}

int main() {
  int N;
  cin >> N;
  vector<ll> L(N);
  for (int i = 0; i < N; ++i) {
    cin >> L.at(i);
  }
  sort(L.begin(), L.end());

  ll sum = 0;
  for (int i = 0; i < N - 1; ++i) {
    sum += L.at(i);
  }

  if (sum > L.at(N - 1)) {
    cout << "Yes";
  } else {
    cout << "No";
  }
  cout << endl;

  //LoopUntilZeroInpput();
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
#include <tuple>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <random>
#include <set>
#include <stack>

//#include <bits/stdc++.h>
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i,i0,n) for(int (i)=(i0);(i)<(n);(i)++)
#define FORR(i,i0,n) for(int (i)=(n)-1; (i)>=(i0);(i)--)
#define SORT(x) sort(x.begin(),x.end())
#define SORTR(x) sort(x.begin(),x.end(),greater<int>())
#define rn return
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#include <time.h>
typedef std::pair<int,int> pii;
using namespace std;
using ll = long long;


int main(){
    int n,k;
    cin >> n >> k;
    vector<int> h(n);
    rep(i,n) cin >> h[i];
    vector<int> dp(n,1001001001);
    dp[0] = 0;
    rep(i,n){
        int j = 1;
        while(j <= k && i-j >= 0) {
            dp[i] = min(dp[i-j] + abs(h[i-j] - h[i]) , dp[i]);
            j++;
        }
    }
    cout << dp[n-1];
}









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

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> h(N + 1, 0);
  for (int i = 1; i <= N; i++) cin >> h[i];

  vector<int> dp(N + 1, 1000000000);
  dp[0] = dp[1] = 0;
  dp[2] = abs(h[2] - h[1]);
  for (int i = 3; i <= N; i++) {
    for (int j = 1; j <= K; j++) {
      if (i - j == 0) break;
      dp[i] = min(dp[i], dp[i - j] + abs(h[i - j] - h[i]));
    }
  }
  cout << dp[N] << endl;
}

Measured memory_bytes: 1024
n,m = map(int,input().split())
a = set([int(input()) for _ in range(m)])

dp = [0] * (n+1)
dp[0] = 1

if 1 not in a:
    dp[1] = 1
    
for i in range(2,n+1):
    if i not in a:
        dp[i] = dp[i-1] + dp[i-2]
        dp[i] %= 1000000007
        
print(dp[n])

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

int n;
int ax[5000],ay[5000];
int bx[5000],by[5000];

vector< ll > X,Y;

vector< int > lower_edge[5000];
vector< int > upper_edge[5000];
int imos[5000];

int main(){
  //入力
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>ax[i]>>ay[i]>>bx[i]>>by[i];
    X.push_back(ax[i]);
    Y.push_back(ay[i]);
    X.push_back(bx[i]);
    Y.push_back(by[i]);
  }

  //座標圧縮の前準備(典型的、詳細は関連リンク1をご覧ください)
  sort(X.begin(),X.end());
  sort(Y.begin(),Y.end());
  X.erase( unique( X.begin(), X.end()) , X.end() );
  Y.erase( unique( Y.begin(), Y.end()) , Y.end() );

  for(int i=0;i<n;i++){
    //座標圧縮
    ax[i]=lower_bound(X.begin(),X.end(),ax[i])-X.begin();
    ay[i]=lower_bound(Y.begin(),Y.end(),ay[i])-Y.begin();
    bx[i]=lower_bound(X.begin(),X.end(),bx[i])-X.begin();
    by[i]=lower_bound(Y.begin(),Y.end(),by[i])-Y.begin();

    //lower_edge[yi]にはy=yi上にある下辺のxの座標をpush_backしている、upper_edgeは上辺の情報
    lower_edge[ ay[i] ].push_back( ax[i] );
    lower_edge[ ay[i] ].push_back( bx[i] );
    upper_edge[ by[i] ].push_back( ax[i] );
    upper_edge[ by[i] ].push_back( bx[i] );
  }
  ll ans=0;

  for(int y=0;y+1<(int)Y.size();y++){
    //imosの更新
    for(int i=0;i<(int)upper_edge[y].size();i+=2){
      //upper_edgeの偶数番目には辺の左側、奇数には辺の右側の点が入っている(lower_edgeも同様)
      int left=upper_edge[y][i];
      int right=upper_edge[y][i+1];
      for(int x=left;x<right;x++)imos[x]++;
    }
    for(int i=0;i<(int)lower_edge[y].size();i+=2){
      int left=lower_edge[y][i];
      int right=lower_edge[y][i+1];
      for(int x=left;x<right;x++)imos[x]--;
    }


    for(int x=0;x+1<(int)X.size();x++){
      //imosが0じゃないならそのマスは長方形内に含まれる
      if(imos[x]==0)continue;
      ans+=(Y[y+1]-Y[y])*(X[x+1]-X[x]);
    }
  }
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 3640
from collections import Counter
from itertools import product

def f(x, y, z):
    return x**2 + y**2 + z**2 + x*y + y*z + z*x

cnt = Counter()
N = int(input())
for x, y, z in product(range(1, 101), repeat=3):
    cnt[f(x, y, z)] += 1
for i in range(1, N+1):
    print(cnt[i])

Measured memory_bytes: 11768
'use strict'
function main(input) {
  input = input.trim().split(' ')
  input.push(input[0] - 1)
  input.push(input[1] - 1)
  input.sort((a, b) => Number(b) - Number(a))
  console.log(Number(input.shift()) + Number(input.shift()))
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 21064
# encoding: utf-8

class Point
  attr_reader :x, :y
  def initialize(x = 0, y = 0)
    @x, @y = x, y
  end

  def + o
    Point.new(@x + o.x, @y + o.y)
  end

  def - o
    Point.new(@x - o.x, @y - o.y)
  end
end

class Vector
  attr_reader :a, :b

  def initialize(a = 0, b = 0)
    @a, @b = a, b
  end

  def + o
    Vector.new(@a + o.a, @b + o.b)
  end

  def - o
    Vector.new(@a - o.a, @b - o.b)
  end

  def cross o
    @a * o.b - @b * o.a
  end
end

def sign(x)
  x < 1e-6 ? -1 : (x > 1e-6 ? 1: 0)
end

def main
  while nums = gets
    nums = nums.split(/\s/).collect { |x| x.to_f}
    a = Point.new(nums[0], nums[1])
    b = Point.new(nums[2], nums[3])
    c = Point.new(nums[4], nums[5])
    p = Point.new(nums[-2], nums[-1])
    v1 = Vector.new(a.x - p.x, a.y - p.y)
    v2 = Vector.new(b.x - p.x, b.y - p.y)
    v3 = Vector.new(c.x - p.x, c.y - p.y)
    s1 = sign(v1.cross(v2))
    s2 = sign(v2.cross(v3))
    s3 = sign(v3.cross(v1))
    if s1 * s2 >= 0 and s2 * s3 >= 0 and s3 * s1 >= 0
      puts "YES"
    else
      puts "NO"
    end
  end
end

main

Measured memory_bytes: 6152