akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <regex>
using namespace std;
using pii  = pair<int,int>;
using ll=long long;
using ld=long double;
#define pb push_back
#define mp make_pair
#define sc second
#define fr first
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rRep(i,a,b) for(int i=a;i>=b;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
ll gcd(ll a,ll b){return (b == 0 ? a : gcd(b, a%b));}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll MOD=1000000007;
constexpr ll INF=1000000011;
constexpr ll MOD2=998244353;
constexpr ll LINF = 1001002003004005006ll;
constexpr ld EPS=10e-8;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T> istream& operator>>(istream& is,vector<T>& v){for(auto&& x:v)is >> x;return is;}
template<typename T,typename U> istream& operator>>(istream& is, pair<T,U>& p){ is >> p.first; is >> p.second; return is;}
template<typename T,typename U> ostream& operator>>(ostream& os, const pair<T,U>& p){ os << p.first << ' ' << p.second; return os;}
template<class T> ostream& operator<<(ostream& os, vector<T>& v){
    for(auto i=begin(v); i != end(v); ++i){
        if(i !=begin(v)) os << ' ';
        os << *i;
    }
    return os;
}

ll ans,M[100007];

ll compME(ll b, ll e, ll m){  // bのe乗のmod m を返す
    if (e == 0) return 1;
    ans = compME(b, e / 2, m);
    ans = (ans * ans) % m;
    if (e % 2 == 1) ans = (ans * b) % m;
    return ans;
}

int main(){
    ll N,A[100007],sum=0,C=0;
    cin >> N ;
    rep(i,N){
        cin  >> A[i];
    }
    sort(A,A+N);
    rep(i,N){
        if(sum*2<A[i]){
            C=1;
        }
        else{
            C++;
        }
        sum+=A[i];
    }
    cout << C << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e9;
int a, b, c;

int main()
{
    string s;
    cin >> s;
    if(s == "abc" or s == "acb" or s == "bac" or s == "bca" or s == "cab" or s == "cba")
        cout << "Yes\n";
    else
        cout << "No\n";
    return 0;
}


Measured memory_bytes: 3592
//verma_ankit484

#include<bits/stdc++.h>
typedef long long ll;

using namespace std;

ll n, wt;
vector<ll> v;
vector<ll> w;
vector<vector<ll> > dp;

void knap() {
  for(ll i = 1; i <= n; i++) {
    for(ll j = 1; j <= wt; j++) {
      if(j < w[i]) {
        dp[i][j] = dp[i-1][j];
      }
      else {
        dp[i][j] = max(dp[i-1][j], dp[i-1][j-w[i]]+ v[i]);
      }
    }
  }
  cout << dp[n][wt] << '\n';
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  #ifdef AV
  freopen("int.txt", "r", stdin);
  #endif
  cin >> n >> wt;
  v.assign(n+1, 0);
  w.assign(n+1, 0);
  dp.assign(n+1, vector<ll> (wt+1, 0));
  for(ll i = 1; i <= n; i++) {
    cin >> w[i] >> v[i];
  }
  knap();
  return 0;
}

Measured memory_bytes: 80256
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long LL;
LL N,X,ans;
int main()
{
//	freopen("AGC.in","r",stdin);
//	freopen("AGC.out","w",stdout);
	scanf("%lld%lld",&N,&X);
	ans+=N;N=N-X;
	while(N&&X)
	{
		if(X>N) swap(X,N);
		ans+=N/X*X*2;N%=X;
		if(!N) ans-=X;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 128
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int s = sc.nextInt();
        Set<Integer> set = new HashSet<>();
        int past = s;
        set.add(past);
        for (int i = 2 ;i<= 1000000 ;i++) {
            int cur;
            if (past % 2 == 0) {
                cur = past / 2;
            } else {
                cur = 3 * past +1;
            }
            if (set.contains(cur)) {
                System.out.println(i);
                return;
            }
            set.add(cur);
            past = cur;
        }
    }
}


Measured memory_bytes: 21716
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <bitset>
#include <map>
#include <string>
#include <utility>

#define repd(i,a,b) for(ll i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;

using namespace std;

int inputValue();
void inputArray(int*,int);
void inputVector(vector<int>*,int);
template <typename T>
void output(T,int);


int gcd(int a,int b){
	if(b>a){
		int temp=a;
		a=b;
		b=temp;
	}
	if(b==0){
		return a;
	}
	return gcd(b,a%b);
}
int gcd_vector(vector<int> vec){
	if(vec.size()==1){
		return vec[0];
	}
	if(vec.size()==2){
		return gcd(vec[0],vec[1]);
	}
	int last=*(vec.end()-1);
	vec.erase(vec.end()-1);
	int temp=gcd_vector(vec);
	return gcd(temp,last);
}

int main(){
	//source
	int n,x;
	cin >> n >> x;
	int c[n];
	rep(i,n){
		int temp;
		cin >> temp;
		c[i]=abs(temp-x);
	}

	int ans=c[0];
	rep(i,n){
		ans=gcd(ans,c[i]);
	}
	cout << ans << endl;
	return 0;
}

int inputValue(){
	int a;
	cin >> a;
	return a;
}

void inputArray(int *p,int a){
	rep(i,a){
		cin >> p[i];
	}
}

void inputVector(vector<int> *p,int a){
	rep(i,a){
		int input;
		cin >> input;
		p -> push_back(input);
	}
}

template<typename T>
void output(T a,int precision){
	if(precision > 0){
		cout << setprecision(precision) << a << "\n";
	}else{
		cout << a << "\n";
	}
}


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

const double pi = acos(-1);
#define INF 999999999
int main ()
{
    long long all=0,cnt,n,max=-INF,min=INF;

    cin >> n;
    vector<long long>v(n);
    for(int i=0;i<n;i++) {
    cin >> v.at(i);
    all+=v.at(i);
    
    if(max<=v.at(i)) max=v.at(i);
    if(min>=v.at(i)) min=v.at(i);
    }

    cout  << min << " " << max << " " << all << endl;


    
}



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

#define rep(i, x, n) for (int i = x; i < n; i++)
typedef long long ll;

const int INF = 1e9 + 7;

using namespace std;

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

	int k, x;
	cin >> k >> x;

	if (500 * k >= x)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}


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

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
// #define int long long
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000               // 2e9
#define LLINF 2000000000000000000ll  // 2e18 (llmax:9e18)
#define fi first
#define sec second
#define all(x) (x).begin(), (x).end()
#define sq(x) ((x) * (x))
#define dmp(x) cerr << #x << ": " << x << endl;

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

template <class T>
using MaxHeap = priority_queue<T>;
template <class T>
using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template <class T>
vector<T> vect(int len, T elem) {
  return vector<T>(len, elem);
}

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << p.fi << ',' << p.sec;
  return os;
}
template <class T, class U>
istream &operator>>(istream &is, pair<T, U> &p) {
  is >> p.fi >> p.sec;
  return is;
}
template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) {
    os << vec[i];
    if (i + 1 < vec.size()) os << ' ';
  }
  return os;
}
template <class T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) is >> vec[i];
  return is;
}
void fastio() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout << fixed << setprecision(20);
}

#define endl "\n"

void solve() {
  int N;
  cin >> N;
  vector<int> a(N);
  cin >> a;
  map<int, int> m;
  for (int i = 0; i < N; i++) { m[a[i]]++; }
  int ans = 0;
  int db = 0;
  for (auto &p : m) {
    if (p.second >= 3) p.second = 2 - p.second % 2;
    if (p.second == 1)
      ans++;
    else
      db++;
  }
  ans += db - db % 2;
  cout << ans << endl;
  return;
}

signed main() {
  fastio();
  solve();
  // int t; cin >> t; while(t--)solve();
  return 0;
}


Measured memory_bytes: 5376
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <stdio.h>
#include <string.h>
#include <math.h>
using namespace std;

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

    int n;
    cin >> n;

    int64_t r = 0;
    int b = 0;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        if (a == 0) {
            b = 0;
            continue;
        }
        if (b) {
            a -= b;
            r++;
        }
        r += a / 2;
        b = a % 2;
    }

    cout << r << endl;

    return 0;
}

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

using namespace std;

int func(int x) {
	if (x % 2 == 1)  return 0;
	return func(x / 2) + 1;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int n;
	cin >> n;
	
	int ans = 1;
	for (int i = 1; i <= n; i++) {
		if (func(i) > func(ans))  ans = i;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i = ((ll) a); i < ((ll) n); i++)
#define INF (1LL << 60)
using namespace std;
typedef long long ll;

struct edge {
  ll v, dist;
};

struct state {
  ll v, cost;

  bool operator>(const state s) const {
    return cost > s.cost;
  }
};

vector<ll> dijkstra(vector< vector<edge> > &E, ll S) {
  vector<ll> dp(E.size(), INF);
  priority_queue<state, vector<state>, greater<state> > q;
  q.push((state) { S, 0 });

  while(!q.empty()) {
    ll v = q.top().v, cost = q.top().cost;
    q.pop();

    if(dp[v] <= cost) continue;
    dp[v] = cost;

    REP(i, 0, E[v].size()) {
      ll nv = E[v][i].v, ncost = cost + E[v][i].dist;
      if(dp[nv] > ncost) q.push((state) { nv, ncost });
    }
  }

  return dp;
}

int main(void) {
  ll A, B;
  cin >> A >> B;
  vector< vector<ll> > D(A + 1, vector<ll>(B + 1));
  REP(i, 1, A + 1) REP(j, 1, B + 1) cin >> D[i][j];

  struct data { ll p, q, r; };
  vector<data> e;
  vector< vector<bool> > ok(A + 1, vector<bool>(B + 1, false));

  REP(p, 0, 101) REP(q, 0, 101) REP(r, 0, 100 + 1) {
    bool f = true;
    REP(x, 1, A + 1) REP(y, 1, B + 1) {
      ll v = p * x + q * y + r;
      f = f && D[x][y] <= v;
    }
    if(!f) continue;
    ll cnt = 0;
    REP(x, 1, A + 1) REP(y, 1, B + 1) {
      ll v = p * x + q * y + r;
      if(!ok[x][y] && D[x][y] == v) {
        ok[x][y] = true;
        cnt++;
      }
    }
    if(cnt > 0) e.push_back((data) { p, q, r });
  }

  bool possible = true;
  REP(a, 1, A + 1) REP(b, 1, B + 1) possible = possible && ok[a][b];

  if(!possible) {
    cout << "Impossible" << endl;
    return 0;
  }

  ll N = 202, M = 200 + e.size(), S = 1, T = 102;
  cout << "Possible" << endl;
  cout << N << " " << M << endl;
  REP(i, S, S + 100) cout << i << " " << i + 1 << " X" << endl;
  REP(i, T, T + 100) cout << i + 1 << " " << i << " Y" << endl;
  REP(i, 0, e.size()) cout << S + e[i].p << " " << T + e[i].q << " " << e[i].r << endl;
  cout << S << " " << T << endl;

  REP(x, 1, A + 1) REP(y, 1, B + 1) {
    vector< vector<edge> > E(N + 1);
    REP(i, S, S + 100) E[i].push_back((edge) { i + 1, x });
    REP(i, T, T + 100) E[i + 1].push_back((edge) { i, y });
    REP(i, 0, e.size()) E[S + e[i].p].push_back((edge) { T + e[i].q, e[i].r });
    ll d = dijkstra(E, S)[T];
    assert(d == D[x][y]);
  }
}


Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
    int N,x,num,sum;
    sum=0;
    vector<int> child;
    cin >> N >> x;
    for(int i=0;i<N;i++){
        cin >> num;
        child.push_back(num);
    }
    sort(child.begin(),child.end());
    for(int i=0;i<N;i++){
        sum+=child[i];
        if(sum>x){
            cout << i;
            return 0;
        }
    }
    if(sum==x){
        cout << N;
    } else {
        cout << N-1;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int n, m, q, ans = 0;
vector<int> a(60), b(60), c(60), d(60);

void solve(vector<int> ret){
    if(ret.size() == n){    
        int now = 0;
        rep(i, q){
            if(ret[b[i]]-ret[a[i]] == c[i])now+=d[i];
        }
        ans = max(ans, now);
        return;
    }
    else{
        for(int i = ret.back(); i <= m; i++){
            vector<int> v;
            v = ret;
            v.push_back(i);
            solve(v);
        }
    }
}

int main() {
    cin >> n >> m >> q;
    rep(i, q){
        cin >> a[i] >> b[i] >> c[i] >> d[i];
        a[i]--; b[i]--;
    }
    rep(i, m){
        vector<int> ret;
        ret.push_back(i+1);
        solve(ret);
    }
    cout << ans << endl;
}


Measured memory_bytes: 3608
#include <iostream>

using namespace std;

int main(){
string s;
cin >> s;
int sad = 0, sol = 0;
for(int i = 0 ; i < (int)s.size() ; ++i){
	if(s[i] != 'A' && s[i] != 'C' && s[i] != 'G' && s[i] != 'T'){
		sol = max(sol, sad);
		sad = 0;
	}
	else{
		sad++;
	}
}
sol = max(sol, sad);
cout << sol << endl;

return 0;
}



Measured memory_bytes: 256
m = input()
l = []

for char in m:
    l.append(char)

k = []

for i in range(len(l)):
        if l[i] == "B":
            if k == []:
                pass
            else: k = k[:(len(k))-1]
        else: k.append(l[i])

result = ""
for j in k:
    result += j

print(result)

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

typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)

int main() {
  ll a,b;
  cin >> a >> b;
  ll k=a+b;
  if (k%2==0){
    k/=2;
    cout << k << endl;
  }
  else cout << "IMPOSSIBLE" << endl; 
  return 0;
}

Measured memory_bytes: 256
N, A, B = map(int, input().split())
L = str(input())

total = 0
kaigai = 0

for i in range(0, len(L)):
	if L[i] == 'a':
		if total < A + B:
			print('Yes')
			total += 1
		else:
			print('No')
	elif L[i] == 'b':
		if total < A + B and kaigai < B:
			print('Yes')
			total += 1
			kaigai += 1
		else:
			print('No')
	else:
		print('No')

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

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

/*--------------------------------------------*/

int main(){
  ll n, m;
  cin >> n >> m;
  
  vector<ll> a(n),b(n);
  rep(i,n){
    cin >> a[i];
    b[i] = a[i];
  }
 
  vector<pair<ll,ll> >  vec[n];
  
  ll count = 0;
  
  rep(i,n){
    while(a[i] > 0){
      vec[i].PB(MP(a[i]-a[i]/2,i));
      a[i]/=2;
      count++;
      //cout << a[i] <<  endl;
    }
  }

  vector<pair<ll,ll> > fin(count);
  
  ll index = 0; 
  
  rep(i,n){
    rep(j,vec[i].size()){
      fin[index].first = vec[i][j].first;
      fin[index].second = vec[i][j].second;
      index++;
    }
  }
  
  sort(fin.begin(), fin.end());
  reverse(fin.begin(), fin.end());
  
  ll ans = 0;
  
  if(m >= count){
      cout << 0 <<endl;
      return 0;
  }
  
  rep(i,m){
    b[fin[i].second]/=2;
  }
  
  

  rep(i,n){
    ans+=b[i];
  }
  
  cout << ans << endl;
}
  


Measured memory_bytes: 102656
#include <bits/stdc++.h>
using namespace std;
#define int         long long
#define endl        "\n"

const int mod = 1e9+7;

inline int add(int a, int b) { int res = a + b; if(res >= mod) res -= mod;  return res; }
inline int sub(int a, int b) { int res = a - b; if(res < 0) res += mod; return res;}
inline int mul(int a, int b) { return (a * b)%mod; }

void solve() {
    int k; cin >> k;
    int ans = 0;
    for(int i=1; i<=k; i++)
        for(int j=1; j<=k; j++)
            for(int l=1; l<=k; l++)
                ans += __gcd(i, __gcd(j, l));
    cout << ans << endl;
}

signed main() {

    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    cout << fixed << setprecision(12);

    int T = 1;
    //cin >> T;

    while(T--) {
        solve();
    }
    return 0;
}

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

bool check(int a,int b,int c){
	if(a==b || b==c || a==c){
		return false;
	}
	vector<int> v={a,b,c};
	sort(v.begin(),v.end());
	return v[0]+v[1]>v[2];
}

const int N = 2e5 + 5;
int32_t main()
{
	IOS;
	int n;
	cin>>n;
	int arr[n+1];
	for(int i=1;i<=n;i++){
		cin>>arr[i];
	}
	int ans=0;

	for(int i=1;i<=n;i++){
		for(int j=i+1;j<=n;j++){
			for(int k=j+1;k<=n;k++){
				if(check(arr[i],arr[j],arr[k])){
					ans++;
				}
			}
		}
	}
	cout<<ans<<"\n";
	return 0;
}


Measured memory_bytes: 3652
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define trav(a, x) for (auto &a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<char> vc;
pii numbers_of_diffrent_letters_in_substring1(string s, int isplit)
{
    // string sub1 = s.substr(0, isplit);
    // string sub2 = s.substr(isplit, sz(s) - isplit);
    map<char, int> sub1m;
    map<char, int> sub2m;
    rep(i, 0, isplit)
    {
        sub1m[s[i]]++;
    }
    rep(i, isplit, sz(s))
    {
        sub2m[s[i]]++;
    }
    return make_pair<int, int>(sz(sub1m), sz(sub2m));
}
int intersection_num(string s, int isplit)
{
    // string sub1 = s.substr(0, isplit);
    // string sub2 = s.substr(isplit, sz(s) - isplit);
    set<char> S1, S2;
    vc vOut(26);
    rep(i, 0, isplit)
    {
        S1.insert(s[i]);
    }
    rep(i, isplit, sz(s))
    {
        S2.insert(s[i]);
    }
    auto it = set_intersection(all(S1), all(S2), vOut.begin());
    return it - vOut.begin();
}

int main()
{
    // freopen("B.01.in","r",stdin);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    char s[256];
    int n;
    scanf("%d %s", &n, &s);
    int mx = 0, ansi = -1;
    rep(i, 1, n - 1)
    {
        if (mx < intersection_num(s, i))
        {
            ansi = i;
            mx = max(mx, intersection_num(s, i));
        }
    }
    printf("%d",mx);
    return 0;
}

Measured memory_bytes: 3716
// BEGINNING WITH THE NAME OF ALMIGHTY GOD ALLAH
// AUTHOR:: MOHAMMAD FAISAL
#include<bits/stdc++.h>
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.flush();
	int a,b;
    cin >> a >> b;
    if(a>8 || b>8)
      cout<<":(";
  	else
      cout<<"Yay!";

	return 0;
	// BYE BYE 
}


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

const int maxn = 500055;

string s;
int n;
int a[maxn], b[maxn], c[maxn];

bool ok(int k) {
	k *= 9;
	int m = k;
	int p = 0;
	while (m) {
		b[p++] = m % 10;
		m /= 10;
	}
	int carry = 0;
	for (int i = 0; i < n; i++) {
		if (p <= i) b[i] = 0;
		c[i] = a[i] + b[i] + carry;
		carry = c[i] / 10;
		c[i] %= 10;
	}
	int sum = accumulate(c, c + n, 0);
	return sum <= k;
}

int main() {
	cin >> s;
	n = s.size();
	reverse(s.begin(), s.end());
	for (int i = 0; i < n; i++) a[i] = s[i] - '0';
	int carry = 0;
	n += 20;
	for (int i = 0; i < n; i++) {
		a[i] *= 9;
		a[i] += carry;
		carry = a[i] / 10;
		a[i] %= 10;
	}
	int low = 0, high = 500005, mid;
	while (low < high) {
		int mid = low + high >> 1ll;
		if (ok(mid)) high = mid;
		else low = mid + 1;
	}
	cout << low << endl;
	return 0;
}

Measured memory_bytes: 6788
#include<bits/stdc++.h>
using namespace std ;
#define ll long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pb push_back
#define mp make_pair
#define bs binary_search
#define FOR(i,a,b) for(int i=a; i<b; i++)
#define For(i,a,b) for(int i=a; i>=b ;i--)
#define mem(a,b) memset(a,b,sizeof(a))
#define setprec(x) cout << fixed << setprecision(x);
#define one(x) __builtin_popcount(x)
#define endl "\n"
#define mod 1000000007

int main()
{
	ll int n;
	cin>>n;
	ll int arr[n+1];
	FOR(i,0,n) cin>>arr[i];
	ll int ans=0, sum=0;
	FOR(i,0,n) 
	{
		sum+=arr[i];
		sum%=mod;
	}
	FOR(i,0,n-1)
	{
		sum-=arr[i];
		if(sum<0)
			sum+=mod;
		ans+=arr[i]*sum;
		ans%=mod;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 5164
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,n1,n2) for(ll i=n1;i<n2;i++)
#define bFOR(i,n1,n2) for(ll i=n1;i>=n2;i--)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef long long int ll;
typedef pair<ll,ll> Pi;
typedef tuple<ll,ll,ll> Tu;
const int INF=(ll)(1LL<<30)-1;
const double INFd=100000000000.0;
const double PI=3.14151926535;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
const ll tMOD=(ll)998244353;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
int dx[4]={0,-1,0,1},dy[4]={-1,0,1,0};
int mdx[8]={0,1,0,-1,1,1,-1,-1},mdy[8]={-1,0,1,0,1,-1,1,-1};


template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main(){
    ll n,ans;
    cin>>n;
    for(ans=0;pow(3,ans)<n;ans++);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3260
#import pysnooper
#import os,re,sys,operator,math,heapq,string
from collections import Counter,deque
#from operator import itemgetter
#from itertools import accumulate,combinations,groupby,combinations_with_replacement
from sys import stdin,setrecursionlimit
#from copy import deepcopy

setrecursionlimit(10**6)
input=stdin.readline

n=int(input().rstrip())
a=[int(i) for i in input().split()]
b=[int(i) for i in input().split()]
c=[int(i) for i in input().split()]
ans=0
before=-1
for i in range(n):
    ans+=b[a[i]-1]
    if a[i]-1==before:
        ans+=c[before-1]
    before=a[i]
print(ans)

Measured memory_bytes: 3316
#include "bits/stdc++.h"

using namespace std;


#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()

#define int long long

#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second

#define mod 1000000007

template <typename T>
void print(T x)
{
	std::cout << x <<" " ;
}


template <typename T>
void println(T x)
{
	std::cout << x << "\n";
}


signed main(void) {
	int N,K;
	cin >> N >> K ;

	vector<int>h;
	h.resize(N);
	rep(i, N) {
		cin >> h[i];
	}
	int ans = 0;
	sort(h.begin(), h.end(),greater<int>());

	rep(i, N) {
		if (i <= K - 1) {
			continue;
		}
		else ans += h[i];
	}
	print(ans);
	
}

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

using namespace std;


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

    vector<int> ans;
    for (int i = 1; i <= N; ++i) {
        int a;
        cin >> a;
        for (int j = 0; j < a; ++j) {
            ans.emplace_back(i);
        }
    }

    for (int i = 0; i < H; ++i) {
        if (i % 2 == 1) {
            reverse(ans.begin() + i * W, ans.begin() + (i + 1) * W);
        }
    }

    int cnt = 0;
    for (auto x:ans) {
        cout << x;
        cnt++;
        if (cnt % W == 0) {
            cout << endl;
        } else {
            cout << " ";
        }
    }
    return 0;
}



Measured memory_bytes: 384
#include<bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define int long long int

using namespace std;
typedef pair<int, int> PII;
typedef pair<PII, int> PPI;
typedef pair<int, PII> PIP;
typedef pair<PII, PII> PPP;
typedef vector<PII> VP;
typedef VP::iterator VPI;
typedef vector<int> VI;
const int INF = 3e18;
const double PI = acos(-1);
const int MOD = 1e9 + 7;

string s, sample = "CODEFESTIVAL2016";
int counter = 0;
signed main()
{
  cin >> s;

  for(int i = 0; i < s.size(); i++){
    if(s[i] != sample[i]){
      counter++;
    }
  }

  cout << counter << endl;
  return 0;
}


Measured memory_bytes: 256
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}
typedef struct {
    double x;
    double y;
    double arg;
} P;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    double x[110], y[110];
    rep(i,0,N) cin >> x[i] >> y[i];
    vector<P> vp;
    rep(i,0,N){
        double tans = atan2(y[i], x[i]);
        vp.push_back((P) {x[i], y[i], tans});
    }
    sort(vp.begin(), vp.end(), [](P p1, P p2){
        return p1.arg < p2.arg;
    });
    double ans = 0.0;
    rep(i,0,N){
        rep(j,1,N+1){
            double x_sum = 0.0, y_sum = 0.0;
            rep(k,i,i+j){
                ll p = k % N;
                x_sum += vp[p].x;
                y_sum += vp[p].y;
            }
            ans = max(ans, sqrt(x_sum*x_sum + y_sum * y_sum));
        }

    }
    cout << setprecision(12) << ans << endl;

    

}

Measured memory_bytes: 512
//#include <bits/stdc++.h>
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <climits>
#include <iomanip>
#include <stack>
#include <bitset>

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define ROF(i, j, k) for(int i = (int)(j); i >= (int)(k); --i)
#define FORLL(i, n, m) for(long long i = n; i < (long long)(m); i++)
#define SORT(v, n) sort(v, v+n)
#define REVERSE(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;
const ll MOD=1000000007LL;
typedef pair<int, int> P;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }

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(a>b){a=b;return 1;}return 0;}

int n, m;
int k[12];
int s[12][12];
int t[12][12];
int p[12];

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

  cin >> n >> m;
  REP(i, m){
    cin >> k[i];
    REP(j, k[i]) {
      int val;
      cin >> val;
      val--;
      s[i][val]++;
    }
  }
  REP(i, m) cin >> p[i];
  /*
  REP(i, m){
    REP(j, n){      
      cerr << s[i][j] << " ";
    }
    cerr << endl;
  }  
  */
  int ans = 0;
  REP(bit, (1<<n)){
    cerr << bitset<10>(bit) << endl;
    memset(t, 0, sizeof(t));    
    REP(j, n){
      if(bit & (1<<j)){
	REP(i, m){
	  t[i][j]++;
	}
      }
    }
    /*
    REP(j, n){
      REP(i, m){
        cerr << t[i][j] << " ";
      }
      cerr << endl;
    }
    */
    int cnt = 0;
    REP(i, m){
      int sum = 0;
      REP(itr, n) {
	//cerr << s[i][itr] << "vs" << t[i][itr] << endl;
	if(t[i][itr] && s[i][itr]) sum++;
      }
      if((sum)%2 == p[i]) cnt++;            
    }
    cerr << "cnt:" << cnt << endl;
    if(cnt == m) ans++;
  }
  cout << ans << endl;
  
  return 0;
}


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

long long divide(long long a, long long b){
    if (a == 0) return 0;
    if ((a > 0 and b > 0) or (a < 0 and b < 0)) return abs(a)/abs(b);
    if (abs(a) % abs(b) == 0) return -(abs(a) / abs(b));
    return -(abs(a)/abs(b)) - 1LL;
}

int main(){
    long long N, A, B, C, D;
    cin >> N >> A >> B >> C >> D;
    if (C + D == 0){
        cout << ((A == B)? "YES" : "NO") << endl;
        return 0;
    }
    long long x = divide(B - A + D * (N - 1), C + D);
    if (0 <= x and x < N and B <= A - C * (N - 1) + (D + C) * x){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, K;
  cin >> N >> K;
  int x[N], a, b;
  int sum=0;
  
  for(int i=0; i<N; i++){
    cin >> x[i];
  }
  
  for(int i=0; i<N; i++){
    a = (x[i] - 0) * 2;
    b = (x[i] - K) * 2;
    if(b < 0)
      b = -b;
    if(a >= b)
      sum += b;
    else
      sum += a;
  }
  
  cout << sum << endl;
}

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

#define gcu getchar_unlocked
#define pcu putchar_unlocked
#define _T template <typename T>
#define _HT template <typename H, typename... T>
#define _il inline
#define _in _il int in
#define _sc _il bool scan
_T T in(int c){T n=0;bool m=false;if(c=='-')m=true,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0');return m?-n:n;} //&&c<='9'
_in() {return in<int>(gcu());}
_T T scan(T &n){int c=gcu();return c==EOF?false:(n=in<T>(c),true);}
_sc(char &c){c=gcu();gcu();return c!=EOF;}
//_sc(string &s){int c;s="";
//	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=c;}}
_HT _sc(H &h, T&&... t){return scan(h)&&scan(t...);}
#define _vo _il void out
#define _vl _il void outl
_vo(const char *s){while(*s)pcu(*s++);}
_vo(char c){pcu(c);}
//_vo(string &s){for(char c:s)pcu(c);}
//_vo(string s){for(char c:s)pcu(c);}
_T _vo(T n){static char buf[20];char *p=buf;
	if(n<0)pcu('-'),n*=-1;if(!n)*p++='0';else while(n)*p++=n%10+'0',n/=10;
	while (p!=buf)pcu(*--p);}
_vl(){out('\n');}
_T _vo(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);outl();}
_HT _vo(H&& h, T&&... t){out(h);out(move(t)...);}
template <typename... T> _vl(T&&... t){out(move(t)...);outl();}

int main() {
	vector<int> v(in());
	for (int &a :v)
		a = in();
	for (int q = in(); q; q--)
		outl((int) (binary_search(v.begin(), v.end(), in())));
}


Measured memory_bytes: 2632
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <numeric>
#include <fstream>
#include <iomanip>

typedef long double ld;
typedef long long ll;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1e9 + 7;

// Split
namespace util {

std::vector< std::string > split(std::string s, char delimiter)
{
  std::vector< std::string > vs;
  std::string sub;
  for (auto c : s) {
    if (c == delimiter) vs.push_back(sub), sub.clear();
    else sub += c;
  }
  vs.push_back(sub);
  return vs;
}

} // namespace util

// Minimum, Maximum
template<class T> T minimum(T head, T tail) { return std::min(head, tail); }
template<class H, class... T> H minimum(H head, T... tail) { return std::min(head, minimum(tail...)); }
template<class T> T maximum(T head, T tail) { return std::max(head, tail); }
template<class H, class... T> H maximum(H head, T... tail) { return std::max(head, maximum(tail...)); }

// Output
template<class T, class S> std::ostream& operator << (std::ostream& os, std::pair<T, S> p)
{
  return os << "(" << p.first << " " << p.second << ")";
}

template<class T> std::ostream& operator << (std::ostream& os, std::vector< T > v)
{
  for (ll i = 0; i < (ll)v.size(); i++){ os << " [" << i << "]" << v[i]; if (i % 10 == 9) os << std::endl; }
  //os << v[0]; for (ll i = 1; i < (ll)v.size(); i++){ os << " " << v[i]; }
  return os;
}

template<class T, class S> std::ostream& operator << (std::ostream& os, std::map< T, S > m)
{
  ll i = 0; for (auto p : m){ os << " [" << i << "]" << p.first << "->" << p.second; i++;}
  return os;
}

void print(){ std::cout << std::endl; }
template<typename H> void print(H head) { std::cout << head << std::endl; }
template<typename H, typename... T> void print(H head, T... tail){ std::cout << head << " ", print(tail...); }

// GCD, LCM
ll gcd(ll a, ll b) {
  while (b != 0) { a %= b; std::swap(a, b); }
  return a;
}
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }

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

  ll N;
  std::string S;
  std::cin >> N >> S;

  ll cnt = 0LL;
  for (ll i = 0; i < N; ++i) {
    if (S.substr(i, 3) == "ABC") cnt++;
  }

  print(cnt);
  return 0;
}


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

constexpr inline long long sum(long long a, long long d, long long n) {
	return n * (2 * a + (n - 1) * d) / 2;
}

int main() {
	for(int n, m; scanf("%d %d", &n, &m), n;) {
		vector<int> p(m);
		for(int i = 0; i < m; ++i) {
			scanf("%d", &p[i]);
		}

		long long number = n;
		long long s = sum(1, 1, n);
		for(int i = 1; i < (1 << m); ++i) {
			const int num = __builtin_popcount(i);

			long long lcm = 1;
			for(int j = 0; j < m; ++j) {
				if(i & (1 << j)) {
					lcm = lcm / __gcd<long long>(lcm, p[j]) * p[j];
					if(lcm > n) break;
				}
			}

			const long long number_of_elements = n / lcm;
			if(num & 1) {
				number -= number_of_elements;
				s -= sum(lcm, lcm, number_of_elements);
			}
			else {
				number += number_of_elements;
				s += sum(lcm, lcm, number_of_elements);
			}
		}

		printf("%.10lf\n", (number ? static_cast<double>(s) / number : 0.0));
	}

	return EXIT_SUCCESS;
}

Measured memory_bytes: 1060
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define bg begin()
#define en end()

using namespace std;

typedef long long ll;

long double ans;
int N, M;

int main(void) {
    scanf("%d %d", &N, &M);
    
    int p = 1, time;
    rep(i, 0, M)  p *= 2;
    time = 1900 * M + 100 * (N-M);
  
    printf("%d\n", time*p);
    return 0;
}


Measured memory_bytes: 256
// 2017/07/18 Tazoe

#include <iostream>
#include <algorithm>
#include <map>
using namespace std;

int main()
{
	map<int, bool> memo;

	int N;
	cin >> N;

	int cnt = 0;

	for(int i=0; i<N; i++){
		int p[3];
		cin >> p[0] >> p[1] >> p[2];

		sort(p, p+3);

//		cout << p[0] << ' ' << p[1] << ' ' << p[2] << endl;

		int k = ((p[0]-1)*1000+(p[1]-1))*1000+(p[2]-1);

		if(memo.find(k)!=memo.end())
			cnt++;
		else
			memo[k] = true;
	}

	cout << cnt << endl;

	return 0;
}

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

int main() {
    int N;
    cin >> N;
    vector<int> a(N);
    for (int i=0; i<N; i++) cin >> a.at(i);
    sort(a.begin(), a.end());
    int Alice=0, Bob=0;
    for (int i=0; i<N; i++){
        if (i%2 == 0) Alice += a.at(N-i-1);
        else Bob += a.at(N-i-1);
    }
    cout << Alice - Bob << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
int N;
int c1, c2, c0;
int main()
{
    scanf("%d", &N);
    for(int i=0; i<N; ++i)
    {
        int t;
        scanf("%d", &t);
        if(t%4==0) ++c2;
        else if(t%2==0) ++c1;
        else ++c0;
    }
    if(c1) ++ c0;
    if(c2+1>=c0) puts("Yes");
    else puts("No");
}

Measured memory_bytes: 256
using System.Linq;

namespace ABC
{
    using static System.Console;
    using static System.Math;
    public class Program
    {
        private const int MOD = 1000000007;
        static void Main(string[] args)
        {
            WriteLine(Solve());
        }

        public static string Solve()
        {
            var s = ReadLine();
            for (int i = 1; i < s.Length; i++)
            {
                if (s[i - 1] == s[i])
                    return "Bad";
            }
            return "Good";
        }
    }
}


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

/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y) {
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
int main() {
	string s;
	cin >> s;
	for (int i = 2; i < s.size(); i = i+2) {
		for (int j = 0; j < (s.size()-i)/2; j++) {
			if (s[j] != s[(s.size() - i) / 2+j]) {
				break;
			}
			if (j == (s.size() - i) / 2 - 1) {
				cout << s.size() - i;
				return 0;
			}
		}
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <string>
#include <set>
#include <vector>
#include <queue>
#include <stack>
#include <map>
using namespace std;
#define ms(a, x) memset(a, x, sizeof(a))
#define fore(i, a, n) for (long long i = a; i < n; i++)
#define ford(i, a, n) for (long long i = n - 1; i >= a; i--)
#define si(a) scanf("%d", &a)
#define sl(a) scanf("%lld", &a)
#define sii(a, b) scanf("%d%d", &a, &b)
#define sll(a, b) scanf("%lld%lld", &a, &b)
#define slll(a, b, c) scanf("%lld%lld%lld", &a, &b, &c)
#define debug(a) cout << a << endl
#define pr(a) printf("%d ",a)
#define endl '\n'
#define pi acos(-1.0)
#define tr t[root]
#define lson t[root << 1]
#define rson t[root << 1 | 1]
#define IO ios::sync_with_stdio(false), cin.tie(0)
#define ull unsigned long long
const double eps = 1e-8;
inline int sgn(const double &x) { return x < -eps ? -1 : x > eps; }
typedef long long ll;
const int inf=0x3f3f3f3f;
const int MAXN = 1e5 + 10;
int n,a[MAXN],k;
ll dp[MAXN];
int main()
{
	sii(n,k);
	for(int i=1;i<=n;++i)si(a[i]);
	ms(dp,inf);dp[1]=0;dp[2]=abs(a[1]-a[2]);
	for(int i=3;i<=n;++i)
	{
		for(int j=1;i-j>=1&&j<=k;++j)
		dp[i]=min(dp[i],dp[i-j]+abs(a[i]-a[i-j]));
	}
	printf("%lld\n",dp[n]);
 } 

Measured memory_bytes: 1408
while True:
  H,W = map(int,input().split())
  if H == 0 and W == 0: break
  
  for x in range(H):
    for y in range(W):
      if (x+y) % 2 == 0:
        print("#",end="")
      else:
        print(".",end="")
    print("")
  print("")


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

int main()
{
    map<string, int> weekday;
    weekday["SUN"] = 0;
    weekday["MON"] = 1;
    weekday["TUE"] = 2;
    weekday["WED"] = 3;
    weekday["THU"] = 4;
    weekday["FRI"] = 5;
    weekday["SAT"] = 6;

    string S;
    cin >> S;
    cout << 7 - weekday[S] << endl;
    return 0;
}


Measured memory_bytes: 256
void main() {
	auto S = rs;
	ulong res;
	foreach(i; 0..2^^(S.length-1)) {
		auto flags = ("%." ~ (S.length-1).to!string ~ 'b').format(i);
		string formula;
		foreach(index, v; flags) {
			formula ~= S[index];
			if(v=='1') {
				formula ~= ' ';
			}
		}
		formula ~= S[$-1];
		res += formula.split.to!(ulong[]).sum;
	}
	res.writeln;
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.conv;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}

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

namespace Atcoder
{
    public class Program
    {
        static void Main(string[] args)
        {
            var r1 = ReadSplit();
            var n = r1[0].ToInt64();
            var k = r1[1].ToInt64();
            var h = new long[110000];
            var dp = new long[110000];
            var r = ReadSplit();
            var INF = 9999999999999;
            for (int i = 0; i < n; i++)
            {
                h[i] = r[i].ToInt64();
            }

            for (int i = 0; i < 110000; i++)
            {
                dp[i] = INF;
            }

            dp[0] = 0;

            for (int i = 0; i < n; i++)
            {
                for (int j = 1; j <= k; j++)
                {
                    if (dp[i + j] > dp[i] + Math.Abs(h[i] - h[i + j]))
                    {
                        dp[i + j] = dp[i] + Math.Abs(h[i] - h[i + j]);
                    }
                }
            }

            var ans = dp[n - 1];
            WriteRead(ans);
        }

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

        public static string[] ReadSplit()
        {
            return Console.ReadLine().Split(' ');
        }

        public static void WriteRead(object str)
        {
            Console.WriteLine(str);
            Read();
        }

        public static void Write(object str)
        {
            Console.WriteLine(str);
        }
    }
}


public static class Extentions
{
    public static int ToInt32(this object obj)
    {
        return int.Parse(obj.ToString());
    }

    public static long ToInt64(this object obj)
    {
        return long.Parse(obj.ToString());
    }

    public static decimal ToDecimal(this object obj)
    {
        return decimal.Parse(obj.ToString());
    }

    public static double ToDouble(this object obj)
    {
        return double.Parse(obj.ToString());
    }

    public static T2 GetValueZero<T1, T2>(this Dictionary<T1, T2> d, T1 key) where T2 : struct
    {
        T2 value;
        if (d.TryGetValue(key, out value))


        {
            return value;
        }
        return new T2();
    }
}



Measured memory_bytes: 19808
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll=long long;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;

int main(){
    int n;
    cin >> n;
    vector<int> m(100100);
    int ma=0;
    rep(i,n){
        int a;
        cin >> a;
        a++;
        m[a]++;
        m[a-1]++;
        m[a+1]++;
        ma = max(ma,a+1);
    }
    int ans=0;
    for(int i=0;i<ma+10;i++){
        if(m[i]>ans){
            //cout << "ttt" << endl;
            ans = m[i];
        }
    }
    cout << ans << endl;
}
//ABC072C

Measured memory_bytes: 640
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let s = read::<String>();
    if s == "Sunny" {
        println!("Cloudy");
    } else if s == "Cloudy" {
        println!("Rainy");
    } else {
        println!("Sunny");
    }
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 4352
#include<iostream>
using namespace std;
char a[16], b[16] = {'C', 'O', 'D', 'E', 'F', 'E', 'S', 'T', 'I', 'V', 'A', 'L', '2', '0', '1', '6'};//直接字符数组走一波，后面比较方便
int ans;
int main()
{
    cin >> a;
    for(int i = 0; i < 16; i ++){
        if(a[i] != b[i]) ans ++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define inf 1001001001
#define mod 1000000007
#define mod2 998244353
#define pi acos(-1)
#define all(x) (x).begin(),(x).end()
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; }

int main() {
  cin.tie(0); cin.sync_with_stdio(false);
  int a, b, c; cin >> a >> b >> c;
  cout << c - min(c, min(a - b, a)) << endl;
}


Measured memory_bytes: 3600