akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
#define ld long double
#define ll long long
#define mod 1000000007
#define IINF INT_MAX
#define INF 1LL << 30


int main() {
    int n; cin >> n;
    V<ll> c(n), s(n), f(n);
    for(int i = 0; i < n - 1; i++){
        cin >> c[i] >> s[i] >> f[i];
    }

    for(int i = 0; i < n - 1; i++){
        ll t = 0;
        for(int j = i; j < n - 1; j++){
            // sより小さければsで更新
            if(t < s[j]) t = s[j];
            else if(t % f[j] != 0){
                // ちょうど出発でなければ次の出発時間
                t += f[j] - (t % f[j]);
            }
            t += c[j];
        }
        cout << t << endl;
    }
    cout << 0 << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 #define endl '\n'
int main()
{
ll n,k,i,sum=0;
cin>>n>>k;
ll a[n+1];
for(i=0;i<n;i++)cin>>a[i];
sort(a,a+n);
for(i=0;i<min(n,k);i++){
    sum+=a[i];
}
cout<<sum;
}


Measured memory_bytes: 3636
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main(void){

	double a,b;
	while(cin>>a>>b){
	if(a<35.5&&b<71){
	    cout<<"AAA"<<endl;

	}
	else if(a<37.5&&b<77){
	    cout<<"AA"<<endl;

	}
	else if(a<40&&b<83){
	    cout<<"A"<<endl;

	}
    else if(a<43&&b<89){
	    cout<<"B"<<endl;

	}
	else if(a<50&&b<105){
	    cout<<"C"<<endl;

	}
	else if(a<55&&b<116){
	    cout<<"D"<<endl;

	}
	else if(a<70&&b<148){
	    cout<<"E"<<endl;

	}
	else cout<<"NA"<<endl;

	}
	return 0;
}

Measured memory_bytes: 1220
#include <bits/stdc++.h>
#include <unordered_map> 
using namespace std;
 
int main() {
  std::unordered_map<std::string, string> mp;
  mp["A"] = "T";
  mp["T"] = "A";
  mp["G"] = "C";
  mp["C"] = "G";
  string x;
  cin >> x;
  cout << mp[x] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, from, to) for (int i = from; i < to; i++)
int main()
{
  int A, B;
  cin >> A >> B;
  string pa[2] = {"#.###", "###.#"};
  string pb[2] = {".#...", "...#."};
  string pW = ".....";
  string pB = "#####";
  cout << "100 100" << endl;
  rep(i, 0, 49)
  {
    rep(j, 0, 20)
    {
      if (--A > 0)
        cout << pa[i % 2];
      else
        cout << pB;
    }
    puts("");
  }
  rep(i, 0, 20) cout << pW;
  puts("");
  rep(i, 0, 50)
  {
    rep(j, 0, 20)
    {
      if (--B > 0)
        cout << pb[i % 2];
      else
        cout << pW;
    }
    puts("");
  }
  return 0;
}


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

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

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;

int n;
int a[105];
int sum, sum2;
int main() {
    int res = 1e9;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        sum += a[i];
    }
    for (int i = 0; i < n; ++i) {
        sum2 += a[i];
        res = min(res, abs(sum - sum2 * 2));
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3524
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define ll long long
#define ld long double
using namespace std;
const int N = 1e5 + 5;
ll n, m, u, v, p[N], rnk[N], ans[N];
vector<pair<int, int>>edges;
void in(){
    for(int i = 0; i < N; i++)
        p[i] = i, rnk[i] = 1;
}
int parent(int node){
    if(p[node] == node)
        return node;
    return p[node] = parent(p[node]);
}
void connect(int node1, int node2){
    int p1 = parent(node1), p2 = parent(node2);
    if(rnk[p1] >= rnk[p2])
        p[p2] = p1, rnk[p1] += rnk[p2];
    else
        p[p1] = p2, rnk[p2] += rnk[p1];
}
int main()
{
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    in();
    cin >> n >> m;
    for(int i = 0; i < m; i++){
        cin >> u >> v;
        edges.push_back({u, v});
    }
    ans[m - 1] = (n * (n - 1)) / 2;
    for(int i = m - 1; i > 0; i--){
        int p1 = parent(edges[i].first), p2 = parent(edges[i].second);
        if(p1 != p2)
            ans[i - 1] = ans[i] - (rnk[p1] * rnk[p2]), connect(p1, p2);
        else
            ans[i - 1] = ans[i];
    }
    for(int i = 0; i < m; i++)
        cout << ans[i] << '\n';
    return 0;
}


Measured memory_bytes: 4596
#include <iostream>
using namespace std;
#include <stdio.h>
int main()
{
	char a[100];
	int i;
	while(cin>>a)
	{
		a[5]=' ';
		a[13]=' ';
		for(i=0;i<19;i++)
		cout<<a[i];
		cout<<endl;
	}
}

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

const long long INF = 1LL << 60;
int MOD = 1000000007;
double PI = 3.14159265358979323846;
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; }

typedef long long ll;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define For(i,s,n) for (int i=s;i<(int)(n);i++)
#define vi vector<int>
#define vll vector<ll>
#define vii vector< vector<int> >
#define vs vector<string>
#define All(c) (c).begin(), (c).end()
#define Print(x) cout<<(x)<<"\n"

ll N, A[200010];

int main() {
	cin >> N; ll S = 0;
	rep1(i, N + 1) { cin >> A[i]; S += A[i]; }

	ll minx = S, sum = 0;
	rep1(i, N + 1) {
		sum += A[i];
		chmin(minx, abs(sum - (S - sum)));
	}

	cout << minx << endl;
}


Measured memory_bytes: 1792
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main
{

  public static void main(String[] args) throws IOException
  {
    BufferedReader r = new BufferedReader(new InputStreamReader(System.in), 1);
    String s = r.readLine();
    int n = Integer.parseInt(s);

    long b[] = {0, 0, 0, 0, 0};

    for(int i = 0; i < n; i++)
    {
      s = r.readLine();
      char c = s.charAt(0);
      switch(c)
      {
        case 'M':
          b[0]++;
          break;
        case 'A':
          b[1]++;
          break;
        case 'R':
          b[2]++;
          break;
        case 'C':
          b[3]++;
          break;
        case 'H':
          b[4]++;
          break;
      }
    }

    long a = 0;

    for(int i = 0; i < 3; i++)
      for(int j = i + 1; j < 4; j++)
        for(int k = j + 1; k < 5; k++)
        {
          a += b[i] * b[j] * b[k];
        }

    System.out.println(a);

  }

}


Measured memory_bytes: 52436
import java.util.*;

public class Main {
    public static int gcd(int a,int b){
        if(a<b) return gcd(b,a);
        if(a%b==0) return b;
        else return gcd(b,a%b);
    }
    
    public static int gcd(int a,int b,int c){
        return gcd(gcd(a,b),c);
    }
    public static void main(String[] args) throws Exception {
        Scanner sc=new Scanner(System.in);
        int K=sc.nextInt();
        
        int ans=0;
        
        for(int i=1;i<=K;i++){
            for(int j=1;j<=K;j++){
                for(int k=1;k<=K;k++){
                    ans+=gcd(i,j,k);
                }
            }
        }
        
        System.out.println(ans);
    }
}


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

#define lld long long
#define pii pair<int,int>
#define pll pair<lld,lld>
#define pb push_back
#define next nextt
#define Inf 1000000000
#define Linf 1000000000000000000LL
#define Mod 1000000007

using namespace std;

int N,M;
int dv[100002];
bool checkv[100002];
map<int,int> d[100002];
vector<pii> edge[100002];
map<int,vector<int>> grp[100002];
priority_queue<pair<int,pii>,vector<pair<int,pii>>,greater<pair<int,pii>>> q;

int main(){
	scanf("%d %d",&N,&M);
	for(int i=1; i<=M; i++){
		int x,y,z;
		scanf("%d %d %d",&x,&y,&z);
		edge[x].pb({y,z});
		edge[y].pb({x,z});
		d[x][z] = d[y][z] = Inf;
		grp[x][z].pb(y); grp[y][z].pb(x);
	}
	for(int i=1; i<=N; i++) dv[i] = Inf;
	d[1][0] = dv[1] = 0;
	q.push({0,{1,0}});
	while(!q.empty()){
		int v,color,value;
		v = q.top().second.first;
		color = q.top().second.second;
		value = q.top().first;
		q.pop();
		if(!checkv[v]){
			checkv[v] = true;
			for(auto &i : edge[v]){
				dv[i.first] = min(dv[i.first],dv[v]+1);
				if(d[i.first][i.second] > dv[v]+1){
					d[i.first][i.second] = dv[v]+1;
					q.push({dv[v]+1,{i.first,i.second}});
				}
			}
		}
		for(auto &i : grp[v][color]){
			dv[i] = min(dv[i],value);
			if(d[i][color] > value){
				d[i][color] = value;
				q.push({value,{i,color}});
			}
		}
	}
	if(dv[N] == Inf) dv[N] = -1;
	printf("%d\n",dv[N]);

	return 0;
}


Measured memory_bytes: 87788
#include<cstdio>
#include<iostream>
#define MAX 100000
using namespace std;

int parent(int i) { return i / 2; }
int left(int i) { return 2 * i; }
int right(int i) { return 2 * i + 1; }

int main() {
	int n, A[MAX+1], i;

	cin >> n;

	for (i = 1; i <= n; i++) {
		cin >> A[i];
	}

	for (i = 1; i <= n; i++) {
		cout << "node " << i << ": key = " << A[i] << ", ";
		if (parent(i) >= 1)cout << "parent key = " << A[parent(i)] << ", ";
		if (left(i) <= n)cout << "left key = " << A[left(i)] << ", ";
		if (right(i) <= n)cout << "right key = " << A[right(i)] << ", ";
		cout << endl;
	}

	return 0;
}


Measured memory_bytes: 3112
#include <bits/stdc++.h>
 
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
 
typedef long long ll;
typedef vector<ll> vl;
typedef long double ld;
typedef vector<ld> vd;
typedef bool bl;
typedef vector<bl> vb;
 
const ll e5 = 1 << 20;
const ll mod = 998244353;
const ll e3 = 1 << 13;
const ll INF = 1ll << 60;
 
int main() {
  int n;
  cin >> n;
  vl a(n, 0);
  ll sum = 0;
  rep(i, n) {
    cin >> a[i];
    if (i % 2 == 0) {
      sum += a[i];
    } else {
      sum -= a[i];
    }
  }
  ll alpha = sum / 2;
  cout << alpha * 2 << " ";

  ll ans = alpha;
  for(int i = 0; i < (n-1); i++) {
    ans = a[i] - ans;
    cout << ans * 2 << " ";
  }
  return 0;
}

Measured memory_bytes: 2048
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization("unroll-loops")
#include <bits/stdc++.h>
#define FOR(i, a, b)    for(int i = a; i <= b; i++)
#define REP(i, a, b)    for(int i = a; i >= b; i--)
#define maxN       200005
#define inf        (int) 1e9
#define mode       (int) 1000000007
#define ll         long long

using namespace std;

ll n, k, d;

void enter() {
    scanf("%lld %lld %lld", &n, &k, &d);
}

void solve() {
    n = abs(n);
    ll t = min(n / d, k);
    k -= t, n -= 1ll * t * d;
    ll ans = abs(n);
    if(k == 0) {printf("%lld", ans); return;}
    else if(k == 1) {printf("%lld", min({abs(n - d),  abs(n + d)}));}
    else {
         if(k % 2 == 0)
            printf("%lld", min({ans, abs(n - 2 * d)}));
         else printf("%lld", min({n + d, abs(n - d)}));
    }
}

int main() {
    //freopen("main.inp", "r", stdin);
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    enter();
    solve();
}


Measured memory_bytes: 3868
import java.util.Scanner;

public class Main {

	public static void main(String... nui) {
		
		Scanner sc = new Scanner(System.in);
		
		String s = sc.next();
		
		int cnt = 0;
		
		if (s.charAt(0) == '1') cnt++;
		if (s.charAt(1) == '1') cnt++;
		if (s.charAt(2) == '1') cnt++;
		
		System.out.println(cnt);
	}

}


Measured memory_bytes: 23252
use std::io::*;

fn main() {
    let h = read();
    let w = read();

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

    for c in 0..h {
        let v = read_v();
        for d in v.iter() {
            write!(out, "{}", d);
        }
        out.write(b"\n");
        for d in v.iter() {
            write!(out, "{}", d);
        }
        out.write(b"\n");
    }
}

fn read_v() -> Vec<char> {
    let s = stdin();
    let b = s.bytes()
        .map(|c| c.unwrap() as char)
        .take_while(|c| !c.is_whitespace())
        .collect::<Vec<char>>();
    b
}

fn read() -> usize {
    let s = stdin();
    let b = s.bytes()
        .map(|c| c.unwrap() as char)
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    b.parse().ok().unwrap()
}


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

signed main() {
    int N,M;
    cin>>N>>M;
    vector<int> cnt(N,0);
    REP(i,M) {
        int a,b;
        cin>>a>>b;
        a--,b--;
        cnt[a]++;
        cnt[b]++;
    }
    REP(i,N) {
        if(cnt[i]%2) {
            cout<<"NO"<<endl;
            return 0;
        }
    }
    cout<<"YES"<<endl;
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <queue>

using namespace std;
using TP = tuple<int,int,int>;

int bfs(const int& h, const int& w, const vector<string>& s) {
    bool goal = false;
    int goalc = 0;
    queue<TP> q;
    q.emplace(0,0,1);
    vector<vector<bool>> visited(h, vector<bool>(w, false));
    const vector<int> dx = {-1, +0, +1, +0};
    const vector<int> dy = {+0, +1, +0, -1};

    while(!q.empty()) {
        int x,y,c;
        tie(x,y,c) = q.front(); q.pop();
        if (visited[y][x]) continue;
        visited[y][x] = true;
        if (x == w-1 && y == h-1) {
            goal = true;
            goalc = c;
        }
        for (int i=0; i<4; i++) {
            int xi = x + dx[i];
            int yi = y + dy[i];
            if (xi < 0 || w <= xi) continue;
            if (yi < 0 || h <= yi) continue;
            if (s[yi][xi] == '#') continue;
            q.emplace(xi,yi,c+1);
        }
    }

    int cnt = 0;
    for (int i=0; i<h; i++)
        cnt += count(s[i].begin(), s[i].end(), '.');

    if (!goal) return -1;
    return cnt - goalc;
}

int main() {
    int h,w;
    cin >> h >> w;
    vector<string> s(h);
    for (int i=0; i<h; i++) cin >> s[i];
    cout << bfs(h,w,s) << endl;
}

Measured memory_bytes: 256
//Nihal Mittal - nihal_47
//Strike First , Strike Hard , No Mercy !!

/**⠀⠀⠀⠀⠀⠀⣀⣤⣤⣄⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⣠⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣦⣀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⣰⣿⣿⣿⣿⠿⠿⣿⣿⣿⣿⣿⣿⣿⣧⢀⠀⠀⠀⠀
⠀⠀⠀⣿⣿⣿⠋⠀⠀⠀⠀⠀⠙⠀⠙⣿⣿⣿⣷⢳⢀⠀⠀⠀
⠀⠀⣠⣿⣿⣿⢸⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⣿⣿⣿⢀
⠀⠀⣸⣿⣿⣿⠸⠀⠀⠀⠒⠒⠒⠐⠀⠀⢿⣿⣿⣿⣿⣿⠀⠀
⠀⣴⣿⣿⣿⡿⠀⠒⣋⣙⡒⢰⠀⠤⣖⠒⢾⣿⣿⣿⣿⣧⠀⠀
⢺⣿⣿⣿⣿⢀⠀⠀⠉⠉⠉⠸⠀⡇⠉⠉⠀⢿⣿⣿⣿⣄⠀⠀
⠀⠙⣿⣿⣧⢻⠀⠀⠀⠀⠀⠠⠀⠰⠀⠀⠀⣸⠸⣿⣿⠿⠰⠀
⠀⠀⠀⠹⣿⣿⣿⣷⠀⡠⠙⣲⣔⣅⢡⣰⣷⣿⣿⣿⣧⠀⠀⠀
⠀⠀⠀⣼⣿⣿⣿⣿⠀⡿⠭⠭⠭⠭⢿⠀⣿⢻⣿⣿⠃⠀⠀⠀
⠀⠀⠀⠙⠛⣿⢻⠹⣿⠐⠙⠛⠟⠉⢀⣴⡟⢿⣿⡏⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⡟⠀⠀⠻⣦⣤⣶⠾⠋⠀⠀⠁⡦⢄⢀⠀⠀⠀
⠀⠀⠀⠀⡠⠁⡇⠑⢄⠀⠀⠀⠀⠀⠀⠔⠀⠀⠁⠀⠀⠀⠉⠁
⠀⠔⠊⠁⠀⠀⣇⠀⠀⠀⠑⡤⠤⢎⠁⠀⠀⡘⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⢢⠠⠀⡠⢆⠀⠀⡠⠙⢄⠀⡸⠀
**/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define mk make_pair
#define pb push_back
#define in insert
#define se second
#define fi first
#define mod 1000000007
#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define all(v) (v).begin(),(v).end()
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(0);
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
#define pii pair<ll,ll>
#define vi(x) vector<x>
#define maxn 100005
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
using namespace std;
using namespace __gnu_pbds;

signed main()
{
    fast;
   
    ll n,x,t;
    cin>>n>>x>>t;
    ll sum=0,ti=0;
    while(sum<n)
    {
    	sum += min(x,n-sum);
    	ti += t;
    }
    cout<<ti;
}

Measured memory_bytes: 3640
# -*- coding: utf-8 -*-
"""
D - Preparing Boxes
https://atcoder.jp/contests/abc134/tasks/abc134_d

"""
import sys


def solve(N, arr):
    res = [0] * (N//2) + arr[N//2:]
    for i in range(N//2, 0, -1):
        t = res[i-1::i]
        s = sum(t)
        res[i-1] = 1 if (s + 1) % 2 == arr[i-1] else 0
    #print(res)
    return sum(res), [i for i, a in enumerate(res, start=1) if a]


def main(args):
    N = int(input())
    arr = [int(i) for i in input().split()]
    M, balls = solve(N, arr)
    print(M)
    if M:
        print(*balls)


if __name__ == '__main__':
    main(sys.argv[1:])


Measured memory_bytes: 14644
///
// File:  c.cpp
// Author: ymiyamoto
//
// Created on Sat Oct 14 21:37:27 2017
//

#include <cstdint>
#include <iostream>
using namespace std;

#define SIZE 50

static uint32_t graph[SIZE][SIZE];

int32_t main()
{
  uint32_t N, M;
  cin >> N >> M;

  for (uint32_t i = 0; i < M; i++) {
    uint32_t from, to;
    cin >> from >> to;
    graph[from - 1][to - 1] = 1;
    graph[to - 1][from - 1] = 1;
  }

  uint32_t count = 0;
  while (true) {
    bool found = false;
    for (uint32_t i = 0; i < N; i++) {
      uint32_t connects = 0;
      int32_t at_i, at_j = 0;
      for (uint32_t j = 0; j < N; j++) {
        if (graph[i][j] == 1) {
          connects += 1;
          at_i = i;
          at_j = j;
        }
      }
      if (connects == 1) {
        count++;
        graph[at_i][at_j] = 0;
        graph[at_j][at_i] = 0;
        found = true;
      }
    }

    if (!found) {
      break;
    }
  }

  cout << count << endl;

  return 0;
}


Measured memory_bytes: 256
//By Koios1143
#include<bits/stdc++.h>
#define LL long long
#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define pii pair<int,int>
using namespace std;
const int MaxN = 100005;
int n,k,arr[MaxN],dp[MaxN];
int main(){
	IOS
	while(cin>>n>>k){
		for(int i=0 ; i<n ; i++){
			cin>>arr[i];
			dp[i]=INT_MAX;
		}
		dp[0]=0;
		for(int i=1 ; i<n ; i++){
			for(int j=1 ; i-j>=0 && j<=k ; j++){
				dp[i]=min(dp[i], dp[i-j] + abs(arr[i]-arr[i-j]));
			}
		}
		cout<<dp[n-1]<<'\n';
	}
	return 0;
}


Measured memory_bytes: 4420
#include <iostream>
#include <vector>
#include <queue>
using namespace std;

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

int main(void){
    int h, w;
    cin >> h >> w;
    
    vector<string> field;
    
    field.resize(h);
    
    for(int i = 0; i < h; i++){
        string tmp;
        cin >> tmp;
        field[i] = tmp;
    }
    
    int dist[1010][1010] = {0};
    
    queue<int> qx;
    queue<int> qy;
   
    for(int y = 0; y < h; y++){
        for(int x = 0; x < w; x++){
            if(field[y][x] == '#'){
                qy.push(y);
                qx.push(x);
            }
        }
    }
    
    while(!qy.empty()){
        int nowX = qx.front();
        int nowY = qy.front();
        
        qx.pop();
        qy.pop();
        
        for(int i = 0; i < 4; i++){
            int nextX = nowX + dx[i];
            int nextY = nowY + dy[i];
            
            if(nextX < 0 || nextX >= w || nextY < 0 || nextY >= h){
                continue;
            }
            
            if(field[nextY][nextX] == '#'){
                continue;
            }
            
            field[nextY][nextX] = '#';
            
            dist[nextY][nextX] = dist[nowY][nowX] + 1;
            
            qy.push(nextY);
            qx.push(nextX);
        }
    }
    
    int ans = 0;
    for(int y = 0; y < h; y++){
        for(int x = 0; x < w; x++){
            if(dist[y][x] > ans){
                ans = dist[y][x];
            }
        }
    }
    
    cout << ans << endl;
    
    
}


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

int main() {
  string s;
  cin >> s;
  if (s == "Sunny") {
    cout << "Cloudy" << endl;
  } else if (s == "Cloudy") {
    cout << "Rainy" << endl;
  } else if (s == "Rainy") {
    cout << "Sunny" << endl;
  }
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        String[] blue = new String[N];
        for(int i=0; i<N; i++){
        	blue[i] = new String(sc.next());
        }
        int M = sc.nextInt();
        String[] red = new String[M];
        for(int i=0; i<M; i++){
        	red[i] = new String(sc.next());
        }
        int count = 0;
        int max = 0;
        for(int i=0; i<N; i++){
        	count = 0;
        	String one = blue[i];
        	for(int j=0; j<N; j++){
        		if(blue[j].equals(one)){
        			count++;
        		}
        	}
        	for(int j=0; j<M; j++){
        		if(red[j].equals(one)){
        			count--;
        		}
        	}
        	
        	if(count > max)
        		max = count;
        }
        System.out.println(max);
 
	}
 
}

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

int f(vector<int> &w,int n,long long k,long long P){
    int cnt=0;
    long long t=k*P;
    for(int i=0;i<n;i++){
        if(P<w[i]) return 0;
        if((t%P)>=w[i]){
            t-=w[i];
            cnt++;
        }
        else{
            t=t/P*P;
            t-=w[i];
            cnt++;            
        }
        if(t<0) return 0;        
    }
    return cnt;
}

int main(){
    int n;
    long long k;
    cin>>n>>k;
    vector<int> w(n);
    for(int i=0;i<n;i++){
        cin>>w[i];
    }
    long long left=1;
    long long right=1000000001;
    long long mid;
    while(left<right){
        mid=(left+right)/2;
        if(f(w,n,k,mid)>=n){
            right=mid;
        }
        else{
            left=mid+1;
        }
    }
    cout<<right<<endl;  
}


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

#define ll long long
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>
#define endl '\n'
#define FASTIO std::ios::sync_with_stdio(false)

#define PRIME (1000000007)
#define oo (1 << 30)

#define debug(x) cerr << #x << " = " << x << endl
#define all(x) x.begin(), x.end()

#define loop(i, begin, end)                            \
  for (__typeof(end) i = (begin) - ((begin) > (end)); \
       i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

template <class T>
std::vector<T> ReadVec(int n) {
    std::vector<T> answer(n);

    loop(i, 0, n) {
        std::cin >> answer[i];
    }
    return answer;
}

template <class T>
void PrintVec(std::vector<T> v) {
    loop(i, 0, v.size()) {
        std::cout << v[i] << " ";
    }
    std::cout << endl;
}

using namespace std;

int main() {
    FASTIO;

    int a, b;

    cin >> a >> b;

    int aa = 1;
    int ans = 0;

    while(aa < b) {
        aa += a - 1;
        ans += 1;
    }

    cout << ans << endl;
    
}

Measured memory_bytes: 256
n,m=map(int,input().split())
A={int(input()) for _ in range(m)}
dp=[1]+[0]*(n+1)
for i in range(n):
    if i in A:
        continue
    dp[i+1] += dp[i]
    dp[i+2] += dp[i]
print(dp[n]%(10**9 + 7))

Measured memory_bytes: 462692
import java.util.Scanner;

public class Main{

	/**
	 * @param args
	 */
	public static void main(String[] args)
	{
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		String data;						//看板に書かれている文字列。
		int N = sc.nextInt();				//看板の数。
		String name = sc.next();			//お店の名前。
		int i;								//制御用。
		int count = 0;						//お店の名前を作ることが出来る看板の数。
		for(i=0; i<N; i++){					//データセットを管理するループ。
			data = sc.next();
			
			B:for(int k=0; k <= (data.length() - name.length()); k++){	//『お店の名前の1文字目』を探す。
				String kanban = data.substring(k, k+1);
				String namae = name.substring(0, 0+1);
				if(kanban.equals(namae)){
					for(int m=k+1; m <= (data.length() - (name.length()-1)); m++){	//『お店の名前の2文字目』を探す。
						kanban = data.substring(m, m+1);
						namae = name.substring(1, 1+1);
						if(kanban.equals(namae)){		//2文字目が見つかったら、
							int dist = m-k;				//文字と文字の間の文字数を計算する。これを関数に渡す必要がある。
							
							for(int x = 1, y = m; x < name.length(); x++){
								if(x==name.length()-1){
									count++;
									break B;
								}
								else if(y+dist >= data.length()){
									break;
								}
								kanban = data.substring(y+dist, (y+dist)+1);
								namae = name.substring(x+1, (x+1)+1);
								if(kanban.equals(namae)){
									y+=dist;
								}
								else{
									break;
								}
								
							}
							
							/*-----関数を使う場合：
							
							if(check00(name, data, 1, m, dist)==1){
								count++;
								break B;		//一度、『作れる』と分かったら、それ以上調べる必要はないので、このデータセットを抜ける。
							}
							
							-----------------*/
							
						}
					}
				}
			}
		}
		System.out.println(count);
		return;
	}
	
	static int check00(String name, String data, int x, int y, int dist)
	{
		if(x==name.length()-1){
			return 1;
		}
		else if(y+dist >= data.length()){
			return 0;
		}
		String namae = name.substring((x+1), (x+1)+1);
		String kanban = data.substring((y+dist), (y+dist)+1);
		if(kanban.equals(namae)){
			return check00(name, data, x+1, y+dist, dist);
		}
		else{
			return 0;
		}
		
	}

}

Measured memory_bytes: 23716
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int main()
{
    int t=1;
    // cin>>t;
    while(t--)
    {
        int n;
        cin>>n;
        vector<int>a(n);
        for(int i=0;i<n;i++)
            cin>>a[i];

        ll sum[n][n+1];
        //sum is sum of all elements in [i,j) (although one array is sufficient)
        for(int i=0;i<n;i++)
        {
            sum[i][i]=0;
            for(int j=i+1;j<=n;j++)
                sum[i][j]=sum[i][j-1]+a[j-1];       
        }

        ll dp[n][n+1];
        //dp[i][j] is the minimum cost that will be occurred for array compressing a[i,j) to one element
        for(int len=1;len<=n;len++)
        {
            for(int i=0;i+len-1<n;i++)
            {
                //find answer for a[i...i+len-1] i.e answer for dp[i][i+len]
                if(len==1)
                {
                    dp[i][i+len]=0;
                    continue;
                }
                dp[i][i+len]=LLONG_MAX;
                for(int j=i+1;j<=i+len-1;j++)
                    dp[i][i+len]=min(dp[i][i+len],dp[i][j]+dp[j][i+len]+sum[i][i+len]);
            }
        }

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

Measured memory_bytes: 6104
#include<stack>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define SC(x) scanf("%d",&x);
#define pr(x)  cout << x << endl;
#define mem(arr,v) memset(arr,v,sizeof arr);
#define bug(x) cout << "#x = " << x <<endl;
const int inf = 0x3f3f3f3f;
const int maxn = 1e5 + 5;
typedef long long ll;
using namespace std;
int a[maxn];
stack<int> s[2];

bool dfs(int pos) {
//	bug(pos)
	if(pos == 10) return true;
	int cur = a[pos];
	for(int i = 0; i < 2 ; i++) {
		if(s[i].empty() || s[i].top() <= cur) {
			s[i].push(cur);
			if(dfs(pos + 1)) return true;
			s[i].pop();
		}
	}
	return false;
}

int main() {
	int t;
	cin >> t;
	while(t--) {
		for(int i =0 ; i < 2; i++)
			while(!s[i].empty())
				s[i].pop();
		for(int i = 0 ; i < 10 ; i++)
			cin >> a[i];
		if(dfs(0))
			puts("YES");
		else
			puts("NO");
	}
}

Measured memory_bytes: 2988
#include <iostream>
using namespace std;
int n;

int main(){
	cin>>n;
	if(n==1||n==2||n==3||n==5||n==6||n==9||n==10||n==13||n==17){
		cout<<"No"<<endl;
	}else{
		cout<<"Yes"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,x,y) for (int i=(x);i<=(y);i++)
using namespace std;
const int N=2005;
int n,m,cnt,head[N],d[N],tot,x,y,ans;
struct edge{int to,nxt;}e[N<<1];
void adde(int x,int y){e[++cnt].to=y; e[cnt].nxt=head[x]; head[x]=cnt;}
void dfs(int u,int par){
	for (int i=head[u],v;i;i=e[i].nxt)
		if (v=e[i].to,v!=par) d[v]=d[u]+1,dfs(v,u);
}
int main(){
	scanf("%d%d",&n,&m);
	rep (i,1,n-1) scanf("%d%d",&x,&y),adde(x,y),adde(y,x);
	ans=n;
	if (m&1){
		rep (i,1,n-1){
			int x=e[2*i].to,y=e[2*i-1].to;
			d[x]=d[y]=0; dfs(x,y); dfs(y,x); tot=0;
			rep (j,1,n) if (d[j]>m/2) tot++;
			ans=min(ans,tot);
		}
	} else{
		rep (x,1,n){
			d[x]=0; dfs(x,0); tot=0;
			rep (j,1,n) if (d[j]>m/2) tot++;
			ans=min(ans,tot);
		}
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 384
import java.io.*;
import java.util.*;

class Main {
  public static void main (String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int m = sc.nextInt();
    int[][] coords = new int[n][2];
    int[][] checks = new int[m][2];
    for(int i = 0; i < n; i++) {
      coords[i][0] = sc.nextInt();
      coords[i][1] = sc.nextInt();
    }
    for(int i = 0; i < m; i++) {
      checks[i][0] = sc.nextInt();
      checks[i][1] = sc.nextInt();
    }
    for(int i = 0; i < n; i++) {
      int minDist = 1000000000;
      int minInd = -1;
      for(int j = 0; j < m; j++) {
        int dist = Math.abs(coords[i][0]-checks[j][0]) + Math.abs(coords[i][1]-checks[j][1]);
        if(minDist > dist) {
          minDist = dist;
          minInd = j;
        }
      }
      System.out.println(minInd+1);
    }
  }
}


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

int main()
{
    char s[11];
    scanf("%s", s);
    bool f1 = true;
    bool f2 = true;
    bool f3 = true;

    if (s[0] != 'A') f1 = false;

    int cnt = 0, len = strlen(s);
    for (int i=2; i<=len-2; i++)
    {
        if (s[i] == 'C') cnt ++;
    }
    if (cnt != 1) f2 = false;

    for (int i=0; i<len; i++)
    {
        if (i==0 || s[i] == 'C') continue;
        if (!('a' <= s[i] && s[i] <= 'z')) f3 = false;
    }
    if (f1 && f2 && f3) printf("AC\n");
    else printf("WA\n");
    return 0;
}


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

using ll = long long;

constexpr ll INF = 1'010'000'000'000'000'017LL;
constexpr ll MOD = 1'000'000'007LL;
constexpr double EPS = 1e-12;
constexpr double PI = 3.14159265358979323846;

#define FOR(i, start, end) for(ll i = (start); i < end; i++)
#define REP(i, n) FOR(i, 0, n)
#define ALL(v) v.begin(), v.end()

template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }

template<class T = ll> using V = vector<T>;
using vi = V<int>; using vl = V<>; using vvi = V< V<int> >;
using pint = pair<int, int>;
using pll = pair<ll, ll>; using vp = V<pll>;

ll mod(ll val, ll m){ ll res = val % m; if(res < 0) res += m; return res;}
ll modinv(ll a, ll m) { ll b = m, u = 1, v = 0; while (b) { ll t = a / b; a -= t * b; swap(a, b); u -= t * v; swap(u, v); } u %= m; if (u < 0) u += m; return u;}
ll modpow(ll a, ll n, ll mod) { ll res = 1; while (n > 0) { if (n & 1) res = res * a % mod; a = a * a % mod; n >>= 1;} return res;}
template<class T> T gcd(T a, T b) { if (a < b) std::swap(a, b); while (b) std::swap(a %= b, b); return a; }
template<class T> T lcm(const T a, const T b) { return a / gcd(a, b) * b; }


//---------------------------------------------------------------

void Main()
{
    double N, K, ans;
    cin >> N >> K;

    ans = log10(N) / log10(K);
    cout << (ll)(ans+1) << endl;
}

//---------------------------------------------------------------
int main()
{
    cout << fixed << setprecision(15);
    Main();
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <functional>
#include <stack>
#include <numeric>
typedef long long ll;
using namespace std;
const int MOD = (int)1e9 + 7;
const ll INF = (ll)1e18 + 7;
#define int long long
struct Point {
	int x, y;

	double dis(Point a, Point b) {
		double x = a.x - b.x;
		double y = a.y - b.y;
		return sqrt(x*x + y * y);
	}
};

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

	int X, Y;
	cin >> X >> Y;

	if (X%Y == 0) {
		cout << -1 << endl;
	}
	else {
		cout << X << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)






int main() {
    ll n;
    cin >> n;
    string s;
    cin >> s;
    vector<vector<ll>> cost(9, vector<ll>(9));
    REP(i, n - 1){
        ll a = s[i] - '0', b = s[i + 1] - '0';
        a--; b--;
        cost[a][b]++;
        cost[b][a]++;
    }
    vector<ll> ans;
    ll max_cost = INF;
    vector<ll> r = {0, 1, 2, 3, 4, 5, 6, 7, 8};
    do{
        vector<pair<ll ,ll>> p(9);
        REP(i, 9){
            p[r[i]] = {i / 3, i % 3};
        }
        ll sum = 0;
        REP(i, 9){
            REP(j, 9){
                if(i >= j || cost[i][j] == 0) continue;
                sum += (abs(p[j].first - p[i].first) + abs(p[j].second - p[i].second)) * cost[i][j];
            }
        }
        if(max_cost > sum){
            max_cost = sum;
            ans = r;
        }
    }while(next_permutation(r.begin(), r.end()));
    REP(i, 3){
        REP(j, 3){
            cout << ans[3 * i + j] + 1;
        }
        cout << endl;
    }
}



Measured memory_bytes: 3304
#include <bits/stdc++.h>
#define rep3(i, s, n, a) for (int i = (s); i < (int)(n); i += a)
#define rep2(i, s, n) rep3(i, s, n, 1)
#define rep(i, n) rep2(i, 0, n)

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

int main(){
    ll n;
    cin >> n;
    ll mid = sqrt(n);
    // cout << mid << endl;
    for(ll i=mid;i>0;i--){
        if(i*(n/i)==n){
            cout << i - 1 + n / i - 1 << endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=5010;
const ll mod=1e9+7;


int main(){
  int n,d,ans=0; cin >> n >> d;
  vector<vector<int>> x(n, vector<int>(d));
  rep(i,n)rep(j,d){ cin >> x[i][j]; }
  rep(i,n)for(int j=i+1; j<n; j++){
    ll dis=0;
    rep(v,d){
      dis += (x[i][v]-x[j][v])*(x[i][v]-x[j][v]);
    }
    bool flag=false;
    for(int k=0; k<=sqrt(dis); k++){
      if(k*k==dis){flag=true;}
    }
    if(flag){ ans++; }
  }
  
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)

// functions
int ceil(int a, int b) {
    return (a + b - 1) / b;
}
int round(int a, int b) {
    return (a + b / 2) / b;
}
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
template <class T> bool amax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

// main
int main() {
    int N, i;
    cin >> N >> i;
    cout << N - i + 1 << endl;
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("O2,Ofast,inline,unroll-all-loops,-ffast-math")
#pragma GCC target("popcnt")
#include <bits/stdc++.h>
#define maxn 400010
#define ll long long
#define ull unsigned long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define pii pair<int, int>
#define pil pair<int, ll>
#define pll pair<ll, ll>
#define IL inline
#define ss system
using namespace std;

int x[maxn], y[maxn], n, ans = 0;
map<pii, int> M;
template <class T> void read(T &x) {
  char ch = x = 0;
  bool fl = false;
  while (!isdigit(ch))
    fl |= ch == '-', ch = getchar();
  while (isdigit(ch))
    x = x * 10 + ch - '0', ch = getchar();
  x = fl ? -x : x;
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> x[i] >> y[i];
  }
  for (int i = 1; i <= n; i++) {
    for (int j = i + 1; j <= n; j++) {
      if (x[i] != x[j] || y[i] != y[j])
        M[{x[i] - x[j], y[i] - y[j]}]++, M[{x[j] - x[i], y[j] - y[i]}]++;
    }
  }
  for (auto &tmp : M) {
    ans = max(ans, tmp.se);
  }
  cout << n - ans << endl;
  return 0;
}

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

const int MOD = 1e9 + 7;

int n, last, shold;
int ans;
int a[100000], val[100000] = {};

int main(void){
    // Here your code !
    scanf("%d", &n);
    for (int i = 0; i < n; ++i) {
      scanf("%d", &a[i]);
    }
    sort(a, a + n);

    if (n % 2 == 0) {
      for (int i = 0; i < n; ++i) {
        shold = (i / 2);
        val[i] = 2 * shold + 1;
      }

      for (int i = 0; i < n; ++i) {
        if (a[i] != val[i]) {printf("0\n"); return 0;}
      }
    }
    else {
      val[0] = 0;
      for (int i = 1; i < n; ++i) {
        shold = (i + 1) / 2;
        val[i] = 2 * shold;
      }

      for (int i = 0; i < n; ++i) {
        if (a[i] != val[i]) {printf("0\n"); return 0;}
      }
    }

    ans = 1;
    for (int i = 0; i < n / 2; ++i) {ans = (ans * 2) % MOD;}
    printf("%d\n", ans);

    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using Int = int_fast64_t;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	Int l, r; cin >> l >> r;
	Int ans = 1e9;
	if(l+2018 <= r){
		ans = 0;
	}else{
		for(Int i=l; i<r; ++i)
			for(Int j=i+1; j<=r; ++j)
				ans = min(ans, i*j%2019);
	}
	cout << ans << "\n";
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author TM
 */


#include <bits/stdc++.h>

using namespace std;

class DWalkAndTeleport {
public:
    void solve(std::istream& cin, std::ostream& cout) {
      int64_t n,a,b;
      cin >> n >> a >> b;
      vector<int64_t> vec(n);
      for (int i = 0; i < n; ++i) cin >> vec[i];
      int64_t res = 0;
      int now = 0;
      for (int j = 1; j < n; ++j) {
        res += min((vec[j] -vec[now]) * a, b);
        now = j;
      }
      cout << res << endl;
    }
};


int main() {
    DWalkAndTeleport solver;
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 4032
def main():
  INF = 10 ** 20
  def minimum_cost(rest, h, init, dic):
    if h in dic:
      return dic[h]
  
    if not h:
      return 0
  
    ret = INF
    for nex in rest:
      accnex = acc[nex]
      cumsnex = cums[nex]
      nex_init = init + accnex
      nex_rest = rest[:]
      nex_rest.remove(nex)
      nex_h = h - 2 ** nex
      tmp =  minimum_cost(nex_rest, nex_h, nex_init, dic) +\
                     accnex - (cumsnex[nex_init] - cumsnex[init])
      if ret > tmp:
        ret = tmp
    dic[h] = ret
    return ret
  
  n, m = map(int, input().split())
  acc = [0] * m
  cums = [[0] for _ in range(m)]
  for _ in range(n):
    acc[int(input()) - 1] += 1
    for i in range(m):
      cums[i].append(acc[i])
  
  dic = {}
  h = sum([2 ** i for i in range(m)])
  print(minimum_cost([i for i in range(m)], h, 0, dic))

main()


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

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

string s="abcdefghijklmnopqrstuvwxyz";

char c;
cin>>c;

cout<<s[c-'a'+1];

return 0;
}




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

int main() {
  int N;
  string S, T;
  cin >> N >> S >> T;
  for (int i = 0; i < N; i++) {
  	cout << S.at(i);
    cout << T.at(i);
  }
  cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ft              first
#define sd              second
#define ll  		long long
#define pb              push_back
#define mkp           make_pair
#define pll             pair<ll,ll>
#define vll             vector<int>
#define mll             map<ll,ll>
#define pqg             priority_queue<ll>
#define pqs             priority_queue<ll,vll,greater<ll>>
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod          1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
void online_judge()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	freopen("error.txt", "w", stderr);
#endif
}
void ISO()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
}
int main() {

	ISO();
	online_judge();

	string s;
	cin >> s;
	string t;
	cin >> t;
	bool a = true;
	for(int i=0;i<s.length();++i)
	{
		if(s[i] == t[i])
			continue;
		else{
			a = false;
			break;
			}
	}
	if(a)
		cout <<"Yes\n";
	else
		cout <<"No\n";

	return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define mod 1000000007
#define db(a) cout << a << endl
#define db2(a,b) cout << a << " " << b << endl
#define dbp(a) cout << a.first << " " << a.second << endl
#define adb(a) for(auto i:a) cout << i << " "; cout << endl
#define adb2(a) for(auto i:a) cout << i.first << " " << i.second << endl;
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define N 100010
using namespace std;

int main()
{
    fastIO;
    long long n;
    cin >> n;

    long long a[n], i;
    for(i=0;i<n;i++) cin >> a[i];

    map<long long, long long> mp;
    long long ans = 0;
    for(i=0;i<n;i++)
    {
        ans += mp[(i+1)-a[i]];
        mp[a[i]+(i+1)]++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 27776
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
#include <utility>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#ifdef _DEBUG_
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl
#else
#define dump(val)
#endif

using namespace std;

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

template<typename T>
vector<T> make_v(size_t a, T b) {
    return vector<T>(a, b);
}
template<typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v(ts...))>(a, make_v(ts...));
}

template<typename T, T Func(T, T)>
class SegmentTree {
    vector<T> data;
    int n;
    T init;

public:
    SegmentTree(int _n, T _init) {
        n = 1;
        while (n < _n) {
            n *= 2;
        }
        init = _init;
        data.resize(2 * n - 1, init);
    }
    void update(int pos, T val) {
        pos += n - 1;
        //data[pos] = F(data[pos], val);
        data[pos] += val;
        while (pos > 0) {
            pos = (pos - 1) / 2;
            data[pos] = Func(data[2 * pos + 1], data[2 * pos + 2]);
        }
    }
    T query(int l, int r) {
        return query(l, r, 0, n, 0);
    }
    T query(int l, int r, int a, int b, int x) {
        if (b <= l || r <= a) return T(0, n + 1);
        if (l <= a && b <= r) return data[x];
        int mid = (a + b) / 2;
        return Func(query(l, r, a, mid, 2 * x + 1), query(l, r, mid, b, 2 * x + 2));
    }
};

P Max(P a, P b) {
    if (a.first != b.first) {
        return a.first > b.first ? a : b;
    } else {
        return a.second < b.second ? a : b;
    }
}

namespace std {
    P operator+=(P &a, P b) {
        a.first += b.first;
        a.second += b.second;
        return a;
    }
}  // namespace std

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n, q;
    cin >> n >> q;
    SegmentTree<P, Max> seg(n, P(0, 0));
    REP (i, 0, n) {
        seg.update(i, P(0, i + 1));
    }
    REP(i, 0, q) {
        int a, v;
        cin >> a >> v;
        seg.update(a - 1, P(v, 0));
        auto res = seg.query(0, n);
        cout << res.second << " " << res.first << endl;
    }
    return 0;
}



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

#define for0(i, n) for (ll i = 0; i < (ll)(n); ++i) // 0 based indexing
#define for1(i, n) for (ll i = 1; i <= (ll)(n); ++i) // 1 based indexing
#define forc(i, l, r) for (ll i = (ll)(l); i <= (ll)(r); ++i) // closed interver from l to r r inclusive
#define forr0(i, n) for (ll i = (ll)(n) - 1; i >= 0; --i) // reverse 0 based.
#define forr1(i, n) for (ll i = (ll)(n); i >= 1; --i) // reverse 1 based

#define ff first
#define ss second
#define pb push_back

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	ll x;
	cin >> x;
	// 120 is maximum limit 
	// similarly 0,-120 will be limit
	// so brute force should work
	ll a,b;
	forc(a,-120,120){
		forc(b,-120,120){
			if(pow(a,5) - pow(b,5) == x){
				cout << a << " "<<b << endl;
				return 0;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 4024
#include <bits/stdc++.h>
#define ll long long int
//#define m 1000000007
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp> //required
// #include <ext/pb_ds/tree_policy.hpp>     //required
// using namespace __gnu_pbds;              //required
// using namespace std;
// template <typename T>
// using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

// ordered_set<int> s;
// ordered_set<int>::iterator itr;
// /* or:
// typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// ordered_set s;
// This works in C++98 but the above version only works in C++11
// */
// //char str[10000000];
void swap(ll *xp, ll *yp)
{
    ll temp = *xp;
    *xp = *yp;
    *yp = temp;
}
bool vis[10000009] = {0};
vector<ll> vec;
ll dis[10000007] = {0};
ll longSubarrWthSumDivByK(ll arr[],
                          ll n, ll k)
{

    unordered_map<ll, ll> um;

    ll mod_arr[n], max = 0;
    ll curr_sum = 0;

    for (int i = 0; i < n; i++)
    {
        curr_sum += arr[i];

        mod_arr[i] = ((curr_sum % k) + k) % k;
    }

    for (int i = 0; i < n; i++)
    {

        if (mod_arr[i] == 0)

            max = i + 1;

        else if (um.find(mod_arr[i]) == um.end())
            um[mod_arr[i]] = i;

        else
            // if true, then update 'max'
            if (max < (i - um[mod_arr[i]]))
            max = i - um[mod_arr[i]];
    }

    return max;
}
int main()
{
    string str;
    cin >> str;
    cout << str[0] << str[1] << str[2] << "\n";
    return 0;
}

Measured memory_bytes: 3612
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
int a[110],b[110];
int main()
{
    int n,i,j,k,s,sum;
    scanf("%d",&n);
    j=0;
    s=0;
    for(i=0;i<n;i++)
       {
           scanf("%d",&a[i]);
           s=s+a[i];
           if(a[i]%10!=0)
           {
               b[j]=a[i];
               j++;
           }
       }
       sort(b,b+j);
       if(s%10==0)
       {
           if(j==0)
            sum=0;
           else
            sum=s-b[0];
       }
       else
        sum=s;
       printf("%d\n",sum);
       return 0;
}


Measured memory_bytes: 128
let n=read_int()open Array;;let a=init n(fun _->Scanf.scanf"%d "(fun e->e))and b=make n 0and c=make 10001 0;;iter(fun e->c.(e)<-c.(e)+1)a;iteri(fun i _->if i<>0then c.(i)<-c.(i)+c.(i-1))c;for i=n-1downto 0do b.(c.(a.(i))-1)<-a.(i);c.(a.(i))<-c.(a.(i))-1;done;print_int b.(0);for i=1to n-1do print_string" ";print_int b.(i);done;print_newline()

Measured memory_bytes: 36200