akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <cmath>
#include <iomanip>
#include <set>

using namespace std;


int main() {
	string s, t;
	cin >> s >> t;
	int k = -1;
	for (int i = 0; i < s.size(); ++i) {
		int j = 0;
		for (; j < t.size(); ++j) {
			if (j + i >= s.size()) break;
			if (s[i+j] != '?' && s[i+j] != t[j]) break;
		}
		if (j == t.size()) k = i;
	}
	if (k == -1) {
		cout << "UNRESTORABLE" << endl;
		return 0;
	}
	for (int i=0; i < t.size(); ++i){
		s[i+k] = t[i];
	}
	for (int i=0; i < s.size(); ++i){
		if (s[i] == '?') s[i] = 'a';
	}
	cout << s << endl;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
flag = [False]*n
wa = [0]*n
penalty = 0
corr = 0
for i in range(m):
    p, s = input().split()
    p = int(p) - 1
    if s == 'AC':
        if flag[p]:
            continue
        else:
            corr += 1
            flag[p] = True
    else:
        if not flag[p]:
            wa[p] += 1
for j in range(n):
    if flag[j]:
        penalty += wa[j]

print(corr, penalty)

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

typedef vector<int> vi;

int N;
string S;
vector<vi> C;

void make_count(void) {
	C.resize(26, vi(N + 1, 0));
	for (int i = 1; i <= N; ++i) {
		int c = (int)(S[i - 1] - 'a');
		for (int j = 0; j < 26; ++j) {
			C[j][i] = C[j][i - 1];
			if (j == c)
				++C[j][i];
		}
	}
}

int solve(void) {
	int max_cnt = 0;
	for (int i = 2; i <= N - 1; ++i) {
		int cnt = 0;
		for (int j = 0; j < 26; ++j) {
			int l = C[j][i - 1];
			int r = C[j][N] - C[j][i - 1];
			if (l > 0 && r > 0)
				++cnt;
		}
		max_cnt = max(cnt, max_cnt);
	}
	return max_cnt;
}

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

	make_count();
	int ans = solve();

	cout << ans << '\n';
	return 0;
}


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

const int N= 200001;
int parent[N];
int rnk[N];

void make_set(int r){
    parent[r]=r;
    rnk[r]=0;
}

int find_set(int r){
    if(parent[r]==r){
        return r;
    }else{
        return parent[r]=find_set(parent[r]);
    }
}

void union_set(int a, int b){
    a= find_set(a);
    b=find_set(b);
    if(a!=b){
        if(rnk[a]>rnk[b]){
            swap(a,b);
        }
        parent[b]=a;
    }
}

int main(){
    int n,q;
    cin>>n>>q;
    for(int i=0;i<n;++i){
        make_set(i);
    }
    for(int i=0; i<q; ++i){
        int t,u,v;
        cin>>t>>u>>v;
        if(t==0){
            union_set(u,v);
        }else{
            cout<<((find_set(u)==find_set(v))? 1:0)<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 5068
A, B = map(int, input().split())

def f(x):
    d = {}
    for i in range(45):
        k = 2**i
        if x-k<0:
            d[i] = 0
        else:
            A = (x-k)//k
            v = k*(A-A//2)
            if A%2==0:
                v += x-(A+1)*k+1
            d[i] = v
    return d

b = f(B)
for i,j in f(A-1).items():
    b[i] -= j

ans = 0
for i,j in b.items():
    if j%2:
        ans += 2**i
print(ans)


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

using namespace std;

#define ll long long
#define ld long double
#define pb push_back
#define ff first
#define ss second 

int main()
{
	ld w,h,x,y;
	cin>>w>>h>>x>>y;

	ld area = w * h;

	area /= (ld)(2.0);

	cout<<fixed<<setprecision(10)<<area<<" ";

	if((2.0 * x == w) && (2.0 * y == h))
	{
		cout<<1;
	}
	else
	{
		cout<<0<<endl;
	}


}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var n int
	var s string
	fmt.Scan(&n)
	fmt.Scan(&s)

	countR := 0
	countW := 0
	for _, r := range s {
		if r == 'R' {
			countR++
		} else {
			countW++
		}
	}
	if countR == 0 || countW == 0 {
		fmt.Println(0)
		return
	}

	maxR := make([]int, 0)
	minW := make([]int, 0)
	for i, r := range s {
		if r == 'R' {
			maxR = append(maxR, i)
		} else {
			minW = append(minW, i)
		}
	}

	nn := min(len(maxR), len(minW))

	count := 0
	for i := 0; i < nn; i++ {
		if minW[i] < maxR[len(maxR)-1-i] {
			count++
		}
	}
	fmt.Println(count)

}

func min(i, j int) int {
	if i < j {
		return i
	}
	return j
}


Measured memory_bytes: 9144
import sys
N, M = map(int, sys.stdin.readline().split())
graph = [[False for i in range(N)] for i in range(N)]
ab = []
for i in range(M):
    a, b = map(int, sys.stdin.readline().split())
    a -= 1
    b -= 1
    ab.append([a, b])
    graph[a][b] = graph[b][a] = True

all_use = (1 << N) - 1


def rec(v, use):
    use |= 1 << v
    for u in range(N):
        if (not graph[u][v]) or (use >> u) & 1:
            continue
        use |= rec(u, use)
    return use


ans = 0
for a, b in ab:
    graph[a][b] = graph[b][a] = False
    if rec(0, 0) != all_use:
        ans += 1
    graph[a][b] = graph[b][a] = True
print(ans)


Measured memory_bytes: 9204
import std.stdio;
import std.algorithm;
import std.range;
import std.conv;
import std.format;
import std.array;
import std.math;
import std.string;
import std.container;

void main() {
  string S, T;
  readlnTo(S);
  readlnTo(T);

  int[] a = new int[26];
  int[] b = new int[26];

  a.fill(-1);
  b.fill(-1);

  bool ok = true;
  foreach(i; 0..S.length) {
    auto s = S[i] - 'a';
    auto t = T[i] - 'a';

    if (a[s] >= 0) {
      ok = ok && (a[s] == t);
    }

    if (b[t] >= 0) {
      ok = ok && (b[t] == s);
    }

    if (a[s] < 0) a[s] = t;
    if (b[t] < 0) b[t] = s;
  }

  writeln(ok ? "Yes" : "No");
}

// helpers
void readlnTo(T...)(ref T t) {
  auto s = readln.split;
  assert(s.length == t.length);
  foreach(ref ti; t) {
    ti = s[0].to!(typeof(ti));
    s = s[1..$];
  }
}


Measured memory_bytes: 2872
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
    int N = sc.nextInt(); //棒の全体数
    int K = sc.nextInt(); //取る棒の本数
    int[] rodList = new int[55];
    int rodSum = 0;
    for(int i=0; i < N; i++){
      rodList[i] = sc.nextInt();  
    }
    //降順ソート
    for(int j = 0; j < 55; j++){
    for(int i = 54; i > j; i--){
      if(rodList[i - 1] < rodList[i]){
        int swap = rodList[i-1];
        rodList[i-1] = rodList[i];
        rodList[i] = swap;
      }
    }
    }
    for(int i = 0; i < K; i++){
      rodSum += rodList[i];
    }
   System.out.println(rodSum); 
  }
}

Measured memory_bytes: 21844
#include <iostream>
#include <cstdint>
#include <cmath>
#include <map>

using namespace std;

int main(){
    int64_t n;
    cin >> n;
    if(n==1){
        cout << "0\n";
        return 0;
    }
    map<int, int> ps;
    int64_t m = sqrt(n) + 1;
    while(n%2==0){
        ps[2] += 1;
        n /= 2;
    }
    for(int64_t i = 3; i <= m; i += 2){
        while(n%i==0){
            ps[i] += 1;
            n /= i;
        }
    }
    if(n != 1){
        ps[n] = 1;
    }
    //for(auto [k,v] : ps){
    //    cout << k << '^' << v << '\n';
    //}
    int count = 0;
    for(auto [p,e] : ps){
        (void)p;
        for(int k = 1; e >= k; ++k){
            e -= k;
            count += 1;
        }
    }
    cout << count << '\n';
}


Measured memory_bytes: 3724
#include <bits/stdc++.h>
#define ll long long
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end))) // rep(i, 1, 5) --> {1,2,3,4} // rep(i, 5, 1) --> {4,3,2,1} // rep(it, end(v), begin(v)) --> *it

using namespace std;

int main()
{
    ll h, w;
    cin >> h >> w;
    ll res = LLONG_MAX;
    if ((h * w) % 3 == 0)
        return cout << 0, 0;
    rep(i, 1, h)
    {
        ll s1 = i * w;
        ll rem = h - i;
        ll s2 = (rem / 2) * w;
        ll s3 = (rem - rem / 2) * w;
        res = min(res, max({s1, s2, s3}) - min({s1, s2, s3}));
        s2 = rem * (w / 2);
        s3 = rem * (w - w / 2);
        res = min(res, max({s1, s2, s3}) - min({s1, s2, s3}));
    }
    rep(i, 1, w)
    {
        ll s1 = i * h;
        ll rem = w - i;
        ll s2 = (rem / 2) * h;
        ll s3 = (rem - rem / 2) * h;
        res = min(res, max({s1, s2, s3}) - min({s1, s2, s3}));
        s2 = rem * (h / 2);
        s3 = rem * (h - h / 2);
        res = min(res, max({s1, s2, s3}) - min({s1, s2, s3}));
    }
    cout << res;
    return 0;
}

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

int main()
{
	string s;
	cin >> s;
	int n = s.size();
	auto isLowercase = [](char c) -> bool {
		return 'a' <= c && c <= 'z';
	};
	bool ans = s[0] == 'A' && isLowercase(s[1]) && isLowercase(s[n - 1]);
	int cnt = 0;
	if(ans){
		for(auto i = 2; i < n - 1; ++i){
			if(!isLowercase(s[i])){
				if(s[i] != 'C'){
					ans = false;
					break;
				}
				++cnt;
			}
		}
	}
	cout << (ans && cnt == 1 ? "AC" : "WA") << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std ;
int const maxn=200;
int ar[maxn];
int main()
{
	long long a,b,c,ans1,ans2,ans3;
	cin >> a >> b >> c;
	ans1=(a*b*((c+1)/2))-(a*b*(c/2));
	ans2=(a*c*((b+1)/2))-(a*c*(b/2));
	ans3=(b*c*((a+1)/2))-(b*c*(a/2));
	
	if(a%2==0)
		cout << 0;
	else if(b%2==0)
		cout << 0;
	else if(c%2==0)
		cout << 0;
	else 
	{
		cout << min(min(ans1,ans2),ans3);
	}
	
}


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();
    long K = sc.nextLong();
    int mod = 1000000007;
    int[] num = new int[N];
    for(int i = 0; i < N; i++){
      num[i] = Integer.parseInt(sc.next());
    }
    
    long ans = 0;
    for(int i = 0; i < N; i++){
      long n1 = 0;
      long n2 = 0;
      for(int j = 0; j < N; j++){
        if(num[i] > num[j]){
          if(i < j){
            n1++;
          }else if(i > j){
            n2++;
          }
        }
      }
      
      ans += (n1 * ((K*(K+1)/2)%mod)) % mod;
      ans += (n2 * ((K*(K-1)/2)%mod)) % mod;
      ans %= mod;
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 24920
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
int main() {
    int n; cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    sort(a.rbegin(), a.rend());
    ll sum = a[0];
    rep(i, n-2) {
        sum += a[i/2 + 1];
    }
    cout << sum;
}


Measured memory_bytes: 4796
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <string>
#include <algorithm>
#define inf 0x3f3f3f3f
#define LL long long

using namespace std;

int main()
{
    int n;
    while(scanf("%d",&n)!=EOF)
    {
        int a,b;
        int sum=0;
        for(int i=0;i<n;i++)
        {
            scanf("%d%d",&a,&b);
            sum=sum+(b-a+1);
        }
        printf("%d\n",sum);
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <algorithm>
#include <set>
#include <stack>
#include <deque>
#include <cmath>
#include <map>
using namespace std;
typedef long long LL;

int main() {
    double t, x;
    cin >> t >> x;
    cout << t / x << endl;
}


Measured memory_bytes: 256
s = input()
s=list(s)
t = input()
t=list(t)
k=len(t)
ans=k
for i in range(len(s)-k+1):
    su=0
    for j in range(k):

        if t[j]==s[i+j]:
            su+=1
        
    ans=min(ans,k-su)

print(ans)

Measured memory_bytes: 65320
# -*- coding: utf-8 -*-

import copy

abcd = list(map(int, list(input())))

for i in range(2 ** (len(abcd)-1)):
    abcd_c = copy.deepcopy(abcd)
    for j in range(len(abcd)-1):
        if (i >> j) & 1:
            abcd_c[j+1]*=-1
    if sum(abcd_c) == 7:
        break

for i, v in enumerate(abcd_c):
    if i > 0 and v >= 0:
        print('+', end='')
    print(v, end='')
print('=7')

Measured memory_bytes: 3444
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_C main
#include "bits/stdc++.h"
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LLONG_MAX/2)
const int MGN = 10;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
using psi = pair<string, int>;
// functions 

#endif


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

    int N; cin >> N;
    vi H(N); REP(i, N) cin >> H[i];

    if (N == 1) {
        cout << "Yes" << endl;
        return 0;
    }

    vi dh(N-1);
    REP(i, N-1) dh[i] = H[i + 1] - H[i];

    bool ok = true;
    int cnt = 0;
    REP(i, N-1) {
        if (dh[i] == -1) cnt++;
        else if (dh[i] > 0) cnt = 0;

        if (cnt>=2 || dh[i] < -1) {
            ok = false;
            break;
        }
    }

    string ans = ok ? "Yes" : "No";
    cout << ans << endl;

    return 0;
}

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

int main() {
  int N, M, cost[300], exp[300][3], dp[301];
  while(cin >> N >> M){
    for(int i = 0 ; i < N ; i++ ){
      string s;
      getline(cin, s), getline(cin, s);
      cin >> cost[i] >> exp[i][0] >> exp[i][1] >> exp[i][2];
    }
    int ret = 0;
    for(int i = 0 ; i < 3 ; i++ ){
      fill_n( dp, 301, 0);
      for(int j = 0 ; j < N ; j++ ){
        for(int k = 0 ; k <= M ; k++ ){
          if(k - cost[j] >= 0 ){
            dp[k] = max( dp[k], dp[k-cost[j]] + exp[j][i]);
            ret = max( ret, dp[k]);
          }
        }
      }
    }
    cout << ret << endl;
  }
}

Measured memory_bytes: 1208
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 1000000007; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;


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

  int N = s.size();

  bool a = false;
  bool b = false;
  bool c = false;
  bool d = false;
  REP(i, N){
    if(s[i] == 'N') a = true;
    if(s[i] == 'S') b = true;
    if(s[i] == 'W') c = true;
    if(s[i] == 'E') d = true;
  }

  if((a && !b) || (!a && b) || (c && !d) || (!c && d)) No;
  else Yes;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include <iomanip>
using ll = long long;
#define rep(i, n) for(ll i = 0; i < n; i++)
using namespace std;

int main(){
  int n, k;
  cin >> n >> k;
  double count = 0.0;
  rep(i, n){
    double x = (double)k / (i+1);
    int y = (int)log2(x);
    if (log2(x) <= 0.0) count += 1.0;
    else if (log2(x) == double(y)) count += 1.0 / pow(2, y);
    else count += 1.0 / pow(2, (y + 1));
  }
  double ans = count / n;
  cout << fixed << setprecision(12);
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 4188
#include<stdio.h>
int main(void){
	int i,n,x;
	scanf("%d",&n);
	for(i=1;i<=n;i++){
		x=i;
		if(x%3==0){
			printf(" %d",i);
		}
		else{
			while(x>0){
				if(x%10==3){
					printf(" %d",i);
					break;
				}
				else{
					x/=10;
				}
			}
		}
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 600
/*------------------------Original Copyright belongs to-------------------------/
!      																			!
!      ##  ##                                                		##  ##	    !
!      #   #             											#   #		!		                
!      				 ###  ####  ###   ###     ##         #                      !
!					#     #  #  #  #  #  #   #  #       ##                      !
!					#	  #  #  ###   ###    ####        #                      !
!					#     #  #  #  #  #  #   #  #        #                      !
!					 ###  ####  ###   #   #  #  #  ###  ### 			        !
!                                                                               !
/------------------------------------------------------------------------------*/
#include<bits/stdc++.h>
using namespace std;
//------------Template begins--------------------//
#define ss string
#define last(s) s.length()-1
#define lli long long int
#define v(type) vector<type>
#define pr(type1,type2) pair<type1,type2>
#define ma(type1,type2) map<type1,type2>
#define f first
#define s second
#define all(v) v.begin(),v.end()
#define pb push_back
#define pf push_front
#define mp make_pair
#define L(i,start,end) for(lli i=start;i<=end;i++)
#define R(i,start,end) for(lli i=start;i>=end;i--)
#define inp(var,start,end,array) for(var=start;var<=end;var++) cin>>array[var];
#define whatIs(x) cout<<#x<<" is "<<x<<endl
#define dbg1D(i,start,end,arr) for(lli i=start;i<=end;i++) cout<<i<<"th : "<<arr[i]<<endl;
#define dbg2D(i,j,s1,e1,s2,e2,arr) for (lli i=s1;i<=e1;i++) {cout<<i<<"th :"; for(lli j=s2;j<e2;j++)cout<<arr[i][j]<<" ";cout<<endl;}

lli dx[4]={-1, 0, 0, +1};
lli dy[4]={0, -1, +1, 0};
const lli LINF = 1e18;
const lli INF = 1e9;
const lli mod = 1e9+7;
lli power(lli a,lli b,lli m){ if(b==0) return 1; if(b==1) return a%m;
 		lli t=power(a,b/2,m); t=(t*t)%m; if(b&1) t=(t*a)%m; return t;}
lli modInverse(lli a, lli m) { return power(a, m-2, m); }
//---------------Template ends------------------//
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	#ifndef ONLINE_JUDGE
	//freopen("ip.txt","r",stdin);
//freopen("op.txt","w",stdout);
	#endif
//#################### CATCH HERE ##########################
   	/* Uncomment if t test cases
	lli t;
	cin>>t;
	while(t--)
	{
		lli n,ans,i,j;

		cout<<ans<<endl;
	}
	*/
	lli n,m,i;
	cin>>n>>m;
	map<lli,lli> fre;
	set <lli> ms;
	set <lli> :: iterator it;
	L(i,1,n)
	{
		lli val;
		cin>>val;
		ms.insert(val);
		fre[val]++;
	}
	lli v1,v2;
	L(i,1,m)
	{
		cin>>v1>>v2;
		while(v1)
		{
			if((*ms.begin())<v2)
			{
				if(fre[*ms.begin()]<=v1)
				{
					lli val=(*ms.begin());
					lli fr=fre[val];
					fre.erase(val);
					ms.erase(ms.begin());
					ms.insert(v2);
					fre[v2]+=fr;
					v1-=fr;
				}
				else
				{
					fre[*ms.begin()]-=v1;
					ms.insert(v2);
					fre[v2]+=v1;
					v1=0;
				}
			}
			else
				break;
		}
	}
	lli sum=0;
	for(it=ms.begin();it!=ms.end();it++)
	{
		sum+=((*it)*fre[*it]);
	}
	cout<<sum<<endl;
//##########################################################
	return 0;
} 

Measured memory_bytes: 11264
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cmath>

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define EPS (1e-15)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
#define bet(x, a, b) (a) <= (x) && (x) < (b)
typedef long long ll;
typedef unsigned long long ull;

int main()
{
	string S, T = "CODEFESTIVAL2016";
	int ans = 0;

	cin >> S;

	rep(i, 16) if (S[i] != T[i]) ans++;

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
/**
 * 
 */
//package AtCoder;
import java.util.*;
/**
 * @author Shivansh Singh
 *
 */
public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc=new Scanner(System.in);
		int n,k,i,min,j,p;
		n=sc.nextInt();
		k=sc.nextInt();
		int []arr=new int[n];
		for (i=0;i<n;i++)
			arr[i]=sc.nextInt();
		int []dp=new int[n+1];
		dp[0]=dp[1]=0;
		for (i=2;i<=n;i++) {
			j=i-1;
			min=dp[i-1]+(int)Math.abs(arr[i-1]-arr[i-2]);
			while(j>=1 && (i-j)<=k) {
				p=dp[j]+(int)Math.abs(arr[i-1]-arr[j-1]);
				min=(int)Math.min(min,p);
				j--;
			}
			dp[i]=min;
		}
		System.out.println(dp[n]);
		sc.close();
	}

}


Measured memory_bytes: 59056
//Author : Prakhar Asaiya
#include<bits/stdc++.h>
using namespace std;
#define REP(i,a,b) for(int i=a;i<b;++i)
#define REPN(i,a,b) for(int i=a;i<=b;++i)
#define REPV(i,a,b) for(int i = a; i>= b; --i)
#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define ll long long
#define INF 100000
#define ff first
#define ss second
const int M=1e9+7;


void solve()
{
	int x;
	cin>>x;
	if(x >= 30)
	cout<<"Yes\n";
	else
	cout<<"No\n";
}


int main()
{/*
#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
#*/
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  
  
  	solve();
  
  return 0;
}


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

namespace ABC114A
{
    class Program
    {
        static void Main(string[] args)
        {
            var X = int.Parse(Console.ReadLine());
            if (X == 3 || X == 5 || X == 7) Console.WriteLine("YES");
            else Console.WriteLine("NO");


            Console.ReadKey();
        }
    }
}


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

//
#define int long long
#define pb(x) push_back(x)
#define m0(x) memset((x), 0, sizeof(x))
#define mm(x) memset((x), -1, sizeof(x))

//container
#define ALL(x) (x).begin(), (x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define PERM(c) \
  sort(ALL(c)); \
  for (bool c##p = 1; c##p; c##p = next_permutation(ALL(c)))

// debug
#define GET_VAR_NAME(variable) #variable
#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;

// bit_macro
#define bit(n) (1LL << (n))
#define bitset(a, b) (a) |= (1 << (b))
#define bitunset(a, b) (a) |= ~(1 << (b))
#define bitcheck(a, b) ((((a) >> (b)) & 1) == 1)
#define bitcount(a) __builtin_popcountll((a))

//typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

//constant
const int INF = (int)1e18;
const int MOD = (int)1e9 + 7;
const double PI = (double)acos(-1);
const double EPS = (double)1e-10;
const int dx[] = {-1, 0, 0, 1, 0, -1, -1, 1, 1};
const int dy[] = {0, -1, 1, 0, 0, 1, -1, 1, -1};

//
template <typename T>
void chmax(T &a, T b) { a = max(a, b); }
template <typename T>
void chmin(T &a, T b) { a = min(a, b); }
//
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

//
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
};

string s;

signed main() {
  cin >> s;

  int a = 0, b = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == '0')
      a++;
    else
      b++;
  }

  cout << 2 * min(a, b) << endl;
  return 0;
}


Measured memory_bytes: 512
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	a := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i])
	}

	result := 0
	for {
		for i := 0; i < n; i++ {
			if a[i]%2 == 1 {
				fmt.Println(result)
				return
			}
			a[i] >>= 1
		}
		result++
	}
}


Measured memory_bytes: 512
#include<stdio.h>
int main()
{
	int i, j, h1[3], m1[3], s1[3], h2[3], m2[3], s2[3], ansh[4], ansm[4], anss[4];;
	for (i = 0; i< 3; i++) {
		scanf("%d %d %d %d %d %d", &h1[i], &m1[i], &s1[i],& h2[i], &m2[i], &s2[i]);
		if (s1[i] <= s2[i]) {
			anss[i] = s2[i] - s1[i];
		}
		else{
			anss[i] = s2[i] + 60 - s1[i];
			m2[i]--;
		}
		if (m1[i] <= m2[i]) {
			ansm[i] = m2[i] - m1[i];
		}
		else {
			ansm[i] = m2[i] + 60 -m1[i];
			h2[i]--;
		}
		ansh[i] = h2[i] - h1[i];

	}
	for (i = 0; i < 3; i++) {
		printf("%d %d %d\n", ansh[i], ansm[i], anss[i]);
	}
}

Measured memory_bytes: 2760
/*Author : Kartik Bansal
 *Date : 07/09/19
*Time : 16:14 */
#include <bits/stdc++.h>
using namespace std;
typedef long long ll ;
#define tc int t ;cin>>t ;while(t--)
#define pb push_back
#define mp make_pair
#define FOR(i,n) for(int i =0;i<n;i++)
#define loop(i,a,b) for(int i=a;i<b;i++)
#define tra(a) for(auto it : a )cout<<it<<" " ;
#define all(v) v.begin() , v.end()
#define vi  vector<int>
#define vll  vector<long long >
#define vpp vector<pair<int , int >>
#define inf INT_MAX
#define minf INT_MIN
#define ss second
#define ff first
int main()
{
       ios::sync_with_stdio(0) ;
       cin.tie(0) ; cout.tie(0) ;
		 // #ifndef ONLINE_JUDGE
  	// 		    freopen("input.txt", "r", stdin);
 		// 	    freopen("output.txt", "w", stdout);
   //    #endif
 			    string s ; 
 			    cin>>s ;
 			    set<char> ss ; 
 			    FOR(i , 3 )
 			    {
 			    	ss.insert(s[i]); 
 			    }
 			    if(ss.size() >= 2 )
 			    	cout <<"Yes\n" ; 
 			    else 
 			    	cout<<"No\n" ; 

 			    

  return 0 ;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,int> pli;
typedef pair<int,int> pii;
#define rep(i,a,b) for(ll i=a ; i<b ; i++)
#define qrep(que, ite) for(auto ite=begin(que) ; ite!=end(que) ; ite++)
const int max_n = 1e5;
const ll mod = 1e9+7;
const ll INF = 1e17;
const int inf = 1e5;
typedef long double ld;
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; }
ll gcd(ll a, ll b) { return a ? gcd(b%a, a) : b; }
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
struct UnionFind {
    vector<int> par;

    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    int size(int x) {
        return -par[root(x)];
    }
};
struct SegmentTree{
  int N;
  vector<int> node;
  public :
    void intit(vector<int>v){
      int sz = v.size();
      N=1;
      while(N<sz) N*=2;
      node.resize(N);
      for(int i=0 ; i<sz ; i++) node[i+N-1] = v[i];
      for(int i=N-2 ; i>=0 ; i--) node[i] = min(node[i*2+1], node[i*2+2]);
    }
    void update(int x, int val){
      x += N-1;
      node[x+N-1] = val;
      while(x>0){
        x = (x-1)/2;
        node[x] = min(node[x*2+1], node[x*2+2]);
      }
    }
    int getmin(int a, int b, int k, int l, int r){
      if(b<=l || r<=a) return inf;
      else if(a<=l && r<=b) return node[k];
      else{
        int vl = getmin(a, b, 2*k+1, l, (l+r)/2);
        int vr = getmin(a, b, 2*k+2, (l+r)/2, r);
        return min(vl, vr);
      }
    }
};
vector<ll> divisor(ll n){
  vector<ll> res;
  for(ll i=1; i*i<=n ; i++){
    while(n%i==0){
      ++res[i];
      n /= i;
    }
  }
  if(n!=1) res[n]=1;
  return res;
}
int isOk(string s, int N){
    int ok = 1;
    char c = s[0];
    rep(i,0,N) if(s[i]!=c) ok=0;
    return ok;
}
ll S;
int main(){
  cin >> S;
  ll dp[S+1];
  rep(i,0,3) dp[i] = 0;
  rep(i,3,S+1) dp[i] = 1;
  rep(i,3,S+1){
    for(ll j=3 ; i+j<=S ; j++){
        dp[i+j] = (dp[i+j]+dp[i])%mod;
    }
  }
  cout<<dp[S]<<endl;
  return 0;
}   

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

bool f(const long kind, const size_t n, const vector<long>& a){
    map<long,long> c;
    long len = a[0];
    for(size_t i=1; i<n; i++){
        const long n_len = a[i];
        if(len>=n_len){
            c.erase(c.lower_bound(n_len), c.end());
            long j=n_len-1;
            auto oit = c.end();
            for(;;){
                auto it = c.find(j);
                if(it == c.end()){
                    it = c.insert(oit, make_pair(j, 1));
                }else{
                    it->second++;
                }
                if(it->second<kind){
                    c.erase(c.upper_bound(j), c.end());
                    break;
                }else if(j<=0){
                    return false;
                }
                oit = it;
                j--;
            }
        }
        len = n_len;
    }
    return true;
}

bool strict_increasing(const vector<long>& a){
    size_t n = a.size();
    for(size_t i=1; i<n; i++){
        if(a[i-1]>=a[i]){
            return false;
        }
    }
    return true;
}

int main(void){
    long n;
    cin >> n;
    vector<long> a(n);
    for(long i=0; i<n; i++){
        cin >> a[i];
    }
    if(strict_increasing(a)){
        cout << 1 << endl;
        return 0;
    }
    long left=1, right=n;
    for(;;){
        const long mid = (left+right)/2;
        if(right-left<=1){
            if(f(right, n, a)){
                cout << right << endl;
            }else{
                cout << left << endl;
            }
            return 0;
        }
        const bool b = f(mid, n, a);
        //printf("[%ld, %ld] %ld %s\n", left, right, mid, b ? "true" : "false");
        if(b){
            right=mid;
        }else{
            left=mid;
        }
    }
}


Measured memory_bytes: 1792
#include <cstdio>
#include <iostream>

using namespace std;

void makeMemo(int v, int i, int A[], int n, int memo[]) {

	memo[v] = 1;

	if (i == n)
		return;

	makeMemo(v, i + 1, A, n, memo);
	makeMemo(v + A[i], i + 1, A, n, memo);
}

//?????¢
int main() {

	int n;
	scanf("%d", &n);
	int A[n];
	for (int i = 0; i < n; ++i) {
		scanf("%d", &A[i]);
	}

	int q;
	scanf("%d", &q);
	int m[q];
	for (int i = 0; i < q; ++i) {
		scanf("%d", &m[i]);
	}

	int memo[2001];
	for (int i = 0; i <= 2000; ++i) {
		memo[i] = 0;
	}
	makeMemo(0, 0, A, n, memo);

	for (int i = 0; i < q; ++i) {
		if (memo[m[i]] == 1) {
			cout << "yes" << endl;
		} else {
			cout << "no" << endl;
		}
	}
	return 0;
}

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


int main()
{
    int t=1;
    //cin>>t;
    while( t-- )
    {
        ll n;
        cin>>n;

        ll ac=0,wa=0,tle=0,re=0;
        for( int i=0 ; i<n ; i++ )
        {
            string s;
            cin>>s;

            if(s=="AC")
                ac++;
            else if( s=="WA" )
                wa++;
            else if( s=="TLE" )
                tle++;
            else
                re++;
        }

        cout<<"AC x "<<ac<<endl
            <<"WA x "<<wa<<endl
            <<"TLE x "<<tle<<endl
            <<"RE x "<<re;
    }
    return 0;
}


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

int main(){
	int N,K;
  	cin>>N>>K;
  	int num = 1;
    for(int i = 0;i<N;i++){
    	if(num<K)
        	num *= 2;
        else
            num += K;
    }
  	cout<<num<<"\n";
}

Measured memory_bytes: 256
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <functional>
#pragma warning(disable : 4996)
using namespace std;
int n, a[100009];
int main() {
	cin >> n;
	for (int i = 0; i < n; i++) cin >> a[i];
	int p = (a[0] == 0 ? 1 : 0);
	long long ret = 0;
	for (int i = 1; i <= n; i++) {
		if (a[i] == 0) {
			long long sum = 0;
			for (int j = p; j < i; j++) sum += a[j];
			ret += sum / 2;
			p = i;
		}
	}
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 640
import sys
read = sys.stdin.read
write = sys.stdout.write
def solve():
    MOD = 10**9 + 7
    N, *A = map(int, read().split())

    L = 10**5

    fact = [1]*(L+1)
    rfact = [1]*(L+1)
    r = 1
    for i in range(1, L+1):
        fact[i] = r = r * i % MOD
    rfact[L] = r = pow(fact[L], MOD-2, MOD)
    for i in range(L, 0, -1):
        rfact[i-1] = r = r * i % MOD

    L0 = 1000
    pw10 = [1]*(L0+1)
    r = 1
    for i in range(1, L0+1):
        pw10[i] = r = r * 10 % MOD

    C = [0]*5
    V = [0]*5
    z = 0
    for a in A:
        if a == 0:
            z = 1
        l = len(str(a))
        C[l-1] += 1
        V[l-1] += a

    S = [0]*(N+1)
    r = 0
    for i in range(N+1):
        r += rfact[i]
        S[i] = fact[i] * r % MOD

    F = [[0]*(i+1) for i in range(N+1)]
    for i in range(N+1):
        for j in range(i+1):
            F[i][j] = fact[i] * rfact[i-j] % MOD

    CM = [[0]*(i+1) for i in range(N+1)]
    for i in range(N+1):
        for j in range(i+1):
            CM[i][j] = fact[i] * rfact[i-j] * rfact[j] % MOD

    def calc(C):
        c1, c2, c3, c4, c5 = C
        l0 = sum(C)
        res = 0
        F1 = F[c1]; G1 = F[c1-1]
        F2 = F[c2]
        F3 = F[c3]
        F4 = F[c4]
        F5 = F[c5]
        r1 = range(c1+1)
        r2 = range(c2+1)
        r3 = range(c3+1)
        r4 = range(c4+1)
        for d5 in range(c5+1):
            v5 = F5[d5]
            for d1 in r1:
                v1 = v5 * CM[d1+d5][d1] % MOD
                if z and d1 < c1:
                    p1 = F1[d1]; p2 = G1[d1]
                else:
                    p1 = F1[d1]; p2 = 0
                for d2 in r2:
                    v2 = v1 * F2[d2] * CM[d2+d1+d5][d2] % MOD
                    for d3 in r3:
                        e = d1+d2*2+d3*3+d5*5
                        f = d1+d2+d3+d5
                        v3 = v2 * F3[d3] * CM[f][d3] % MOD
                        for d4 in r4:
                            l = f+d4
                            v4 = v3 * F4[d4] * CM[l][d4] % MOD
                            res += ((p1 * S[l0-l] - p2 * S[l0-1-l]) * pw10[e+d4*4] % MOD) * v4 % MOD
        return res % MOD
    c1, c2, c3, c4, c5 = C
    ans = 0
    ans += calc([c1-1, c2, c3, c4, c5]) * V[0]
    ans += calc([c1, c2-1, c3, c4, c5]) * V[1]
    ans += calc([c1, c2, c3-1, c4, c5]) * V[2]
    ans += calc([c1, c2, c3, c4-1, c5]) * V[3]
    ans += calc([c1, c2, c3, c4, c5-1]) * V[4]
    ans %= MOD
    write("%d\n" % ans)
solve()


Measured memory_bytes: 14904
#include <stdio.h>
#include <string>
using namespace std;


int main()
{
	int N;
	scanf("%d",&N);
	char buf[6] = "", buf2[6] = "";
	int result = 1000;
	int goukei = 0;
	int A, B;
	for (int i = 1; i < N/2+1; i++)
	{
		goukei = 0;
		snprintf(buf, 6, "%d", i);
		snprintf(buf2, 6, "%d", N-i);

		for (int j = 0; j < 6; j++)
		{
			if (buf[j] >= '0' && buf[j] <= '9')
			{
				goukei += buf[j] - '0';
			}
		}
		for (int j = 0; j < 6; j++)
		{
			if (buf2[j] >= '0' && buf2[j] <= '9')
			{
				goukei += buf2[j] - '0';
			}
		}
		
		if (goukei < result)
		{
			result = goukei;
		}
	}
	printf("%d",result);
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector <int> vec(N);
  for(int i=0; i<N;i++){
    cin >> vec[i];
  }
  int rep=0;
  while(true){
    bool exist_odd=false;
    for(int i=0; i<N;i++){
      if(vec[i]%2==1){
        exist_odd=true;
      }
    }
    if(exist_odd){
      break;
    }
    for(int i=0; i<N;i++){
      vec[i]/=2;
    }
    rep++;
  }
  cout << rep << endl;
}

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

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

// a^{-1} mod を計算する
long modinv(long a, long mod) {
    return modpow(a, mod - 2, mod);
}

int kaijyo(int n){
    int ans = 1;
    REP(i, n)
        ans *= (i+1);
    return ans;
}


int main()
{
    int N;
    int P[10], Q[10];

    cin >> N;
    REP(i, N)
        cin >> P[i];
    REP(i, N)
        cin >> Q[i];

    int ansP, ansQ;

    vector<int> sei(N);
    REP(i, N)
        sei[i] = i+1;
    ansP = 0;
    REP(i, N-1){
        sort(sei.begin(), sei.end());
        ansP += kaijyo(N-1-i) * (int)(lower_bound(sei.begin(), sei.end(), P[i]) - sei.begin());
        sei.erase(remove(sei.begin(), sei.end(), P[i]), sei.end());
    }
    ansP++;
    //cout << ansP << endl;

    vector<int> sei2(N);
    REP(i, N)
        sei2[i] = i+1;
    ansQ = 0;
    REP(i, N-1){
        sort(sei2.begin(), sei2.end());
        ansQ += kaijyo(N-1-i) * (int)(lower_bound(sei2.begin(), sei2.end(), Q[i]) - sei2.begin());
        sei2.erase(remove(sei2.begin(), sei2.end(), Q[i]), sei2.end());
    }
    ansQ++;
    //cout << ansQ << endl;
    if(ansP > ansQ)
        cout << ansP - ansQ << endl;
    else
        cout << ansQ - ansP << endl;
    
    return 0;
}



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

  
const int MAX = 100000001; 
  
// array to store prime factors 
int factor[MAX] = { 0 }; 
  
void generatePrimeFactors() 
{ 
    factor[1] = 1; 
  
     
    for (int i = 2; i < MAX; i++) 
        factor[i] = i; 
  
    
    for (int i = 4; i < MAX; i += 2) 
        factor[i] = 2; 
  
    
    for (int i = 3; i * i < MAX; i++) { 
        
        if (factor[i] == i) { 
            
            for (int j = i * i; j < MAX; j += i) { 
                // if it has no prime factor before, then 
                // stores the smallest prime divisor 
                if (factor[j] == j) 
                    factor[j] = i; 
            } 
        } 
    } 
} 
  
// function to calculate number of factors 
int calculateNoOFactors(int n) 
{ 
    if (n == 1) 
        return 1; 
  
    int ans = 1; 
  
    // stores the smallest prime number 
    // that divides n 
    int dup = factor[n]; 
  
    // stores the count of number of times 
    // a prime number divides n. 
    int c = 1; 
  
    // reduces to the next number after prime 
    // factorization of n 
    int j = n / factor[n]; 
  
    // false when prime factorization is done 
    while (j != 1) { 
        // if the same prime number is dividing n, 
        // then we increase the count 
        if (factor[j] == dup) 
            c += 1; 
  
        /* if its a new prime factor that is factorizing n,  
           then we again set c=1 and change dup to the new  
           prime factor, and apply the formula explained  
           above. */
        else { 
            dup = factor[j]; 
            ans = ans * (c + 1); 
            c = 1; 
        } 
  
        // prime factorizes a number 
        j = j / factor[j]; 
    } 
  
    // for the last prime factor 
    ans = ans * (c + 1); 
  
    return ans; 
} 
  
// Driver program to test above function 
int32_t main() 
{ 
    generatePrimeFactors(); 
  
    int a,ans = 0;
    cin >> a;
  
    for(int i=1;i<a+1;i++){
    	ans += (i*calculateNoOFactors(i));
    }
	cout << ans<<endl;
    return 0; 
} 


Measured memory_bytes: 784860
#include<iostream>
#include<algorithm>
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define ll long long
#define pii pair<int,int>
#define F first
#define S second


int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n;
    cin>>n;
    string s;
    cin>>s;
    int c=1;
    for(int i=1;i<n;i++)
    {
        if(s[i]!=s[i-1])
            c++;
    }
    cout<<c;
}


Measured memory_bytes: 512
import sys
import math
from collections import deque
from collections import defaultdict

def main():
    a,b = list(map(float,sys.stdin.readline().split()))
    a = int(a)
    b100 = round(b * 100)
    
    ans = (a * b100) // 100
    print(str(ans))

if __name__ == "__main__":
    main()

Measured memory_bytes: 9420
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <string>
#include <map>
#include <cmath>
#include <cstring>

#define fi first
#define se second
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for (int i = 1; i < (n); ++i)
#define drep(i,n) for (int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define all(x) (x).begin(), (x).end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define pb push_back
#define sz(x) (int)(x).size()
#define PQ(T) priority_queue<T, v(T), greater<T> >

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

const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;

const int mod = 1000000007;

int main() {
    ll t1, t2, a1, a2, b1, b2;
    cin >> t1 >> t2 >> a1 >> a2 >> b1 >> b2;

    a1 *= t1; a2 *= t2;
    b1 *= t1; b2 *= t2;

    ll a, b;
    a = a1 + a2;
    b = b1 + b2;
    if (a < b) {
        swap(a1, b1);
        swap(a, b);
    }

    ll d = a - b;
    if (d == 0) {
        cout << "infinity" << endl;
        return 0;
    }
    ll c = b1 - a1;
    ll ans = 0;
    if (c > 0) {
        ans = (c + d - 1) / d;
        ans *= 2;
        --ans;
        if (c % d == 0) ++ ans;
    }   
    cout << ans << endl;
    return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using Graph= vector<vector<ll>>;
struct edge{ll to ; ll cost ;} ;
using graph =vector<vector<edge>> ;
#define rep(i,n) for (ll i=0; i < (n); ++i)
#define rep2(i,n,m) for(ll i=n;i<=m;i++)
#define rep3(i,n,m) for(ll i=n;i>=m;i--)
#define pb push_back
#define eb emplace_back
#define ppb pop_back
#define mpa make_pair
#define fi first
#define se second 
#define set20 cout<<fixed<<setprecision(20) ;
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}
double pi=acos(-1) ;
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 main(){
  ll n ;cin>> n ;
  string s ; cin>> s ;
  ll q ; cin>> q ;
  
  rep(ww,q){
  ll k ; cin>> k ;
  ll a=0; ll b=0 ;
  ll ans=0 ;
  ll now=0 ;
  rep(i,n-1){
  if(s[i]=='C') ans+= now ;
  if(s[i]=='D') a++ ;  
  if(s[i]=='M') {b++ ; now+= a ;} 
  
  if(i>=k-1){
  if(s[i-(k-1)]=='D') { a-- ; now-= b ;} 
  if(s[i-(k-1)]=='M') b-- ;
  }
  
  }
  if(s[n-1]=='C') ans+= now ;

  cout<<ans<<endl ;
  }
   return 0 ;
 }



Measured memory_bytes: 5328
#include <bits/stdc++.h>
#define ull unsigned long long
#define ll long long
#define endl '\n'
#define pb push_back
#define mod 1000000007
#define mp make_pair
#define pi acos(-1)
#define line cout<<"----------------------------"<<endl
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL)
#define filein freopen("input.txt","r",stdin)
#define fileout freopen("output.txt","w",stdout)
using namespace std;
const ll mx=200009;
ll s[mx],p[mx]; 
ll ara[mx]; 
vector<ll> m,c; 
bool bad(ll f1, ll f2, ll f3) ///change sign depending on slope and  upper/lower envelop
{
    return 1.0*(c[f3]-c[f1])*(m[f1]-m[f2])<=1.0*(c[f2]-c[f1])*(m[f1]-m[f3]); 
}
void add(ll m1,ll c1)
{
    m.pb(m1);
    c.pb(c1);
    ll sz=m.size(); 
    while(sz>=3 and bad(sz-3,sz-2,sz-1))
    {
        m.erase(m.end()-2);
        c.erase(c.end()-2);
        sz--;
    }
}
ll value(ll ind, ll x)
{
    return m[ind]*x+c[ind]; 
}
ll query(ll x) 
{
    ll low=0,high=(ll)m.size()-1; 
    ll ans=LLONG_MAX; 
    while(low<=high)
    {
        ll mid1 = low + (high-low)/3;
        ll mid2 = high - (high-low)/3; 
        if(value(mid1,x)<=value(mid2,x)) ///change sign depending on minimum/maximum value
        {
            ans=value(mid1,x);
            high=mid2-1; 
        }
        else 
        {
            ans=value(mid2,x);
            low=mid1+1; 
        }
    }
    return ans; 
}
int main()
{
    ll n,cc; 
    cin>>n>>cc; 
    for(ll i=1;i<=n;i++) cin>>ara[i]; 
    add(-2*ara[1],ara[1]*ara[1]);
    ll ans=0; 
    for(int i=1;i<=n;i++)
    {
        ans=query(ara[i])+ara[i]*ara[i]+cc; 
        add(-2*ara[i],ara[i]*ara[i]+ans);
    }
    cout<<ans<<endl; 
}


Measured memory_bytes: 5100
#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;

int main() {

    fast
    long n,k,q;
    cin>>n>>k>>q;
    long arr[100005]={0};
    long temp=q;
    long t;
    while(temp--){
           cin>>t;
            arr[t]++;
    }

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

        if(arr[i]+k-q>0)
            cout<<"Yes"<<endl;
        else
            cout<<"No"<<endl;


    }



	return 0;
}


/*
ll  modularExponentiation(ll x,ll n,ll M)
{

    ll result=1;

    while(n>0)
    {

	if(n%2==1)

 result=(result*x)%M;

  x=(x*x)%M;

  n=n/2;

}

  return result;
}



*/


Measured memory_bytes: 1408
#include <stdio.h>

int main (){
	
	int n,m,a,b;
	
	scanf("%d %d",&n,&m);
	
	if(n==1 && m==1){
		puts("0");
	}else{
		n--;
		m--;
		a=(n*(n+1))/2;
		b=(m*(m+1))/2;
	printf("%d\n",a+b);
}

return 0;
}



Measured memory_bytes: 3120
#include <bits/stdc++.h>
 
using namespace std;
 
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define fileio freopen("in.in", "r", stdin),freopen("out.out", "w", stdout);
#define ll long long int
#define FF first
#define SS second
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<long long int,long long int>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d\n",x)
#define plld(x) printf("%lld\n",x)
#define pss printf
#define MOD 1000000007
#define INF 1e18
#define eps 0.00001
#define endl '\n'
#define debug(n1) cout<<n1<<endl
string s;
string t="keyence";
int main()
{
	SPEED;
	cin>>s;
	int i=0;
	int cnt=0;
	while(i<s.length()&&s[i]==t[i])
		i++,cnt++;
	int j=t.length()-1;
	while(s.length()&&j>=0&&s.back()==t[j])
		j--,cnt++,s.pop_back();
	if(cnt>=t.length())
		cout<<"YES"<<endl;
	else
	cout<<"NO"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
//template <typename... T> void read(T& ... t){ ((cin >> t), ...); }
//template <typename... T> void write(T ... t){ ((cout << t), ...); }
//#define int long long
#define FAST ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define size(x) (int)x.size()
#define all(x) x.begin(),x.end()
#define ln '\n'
using LL = long long;
using pii = pair<int,int>;
const int INF = 2e9;
const int MAXN = 2e5 +3;
int n;
int arr[MAXN];

int32_t main(){ FAST;
	cin >> n;
	for(int i=1; i<=n; ++i) cin >> arr[i];
	sort(arr+1, arr+n+1);
	
	int ans = arr[n/2+1] - arr[n/2];
	cout << ans << ln;
}

Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <vector>
#include <cstdlib>
#define mem(i,a) memset(i,a,sizeof(i))
#define PI acos(-1.0)
#define DMAX 80000+5
#define eps 1e-8
#define mp make_pair
#define INF 1000000000+9
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
inline void read(int &f){
    f=0;
    ll x=1;
    char ch=getchar();
    while(ch<48 || ch>57) {
        if(ch=='-') {
            x=-1;
        }
        ch=getchar();
    }
    while(ch<=57 && ch>=48) {
        f=f*10+ch-'0';
        ch=getchar();
    }
    f*=x;
}
string s;
int cnta,cntb;
int main(){
    cin>>s;
    for(int i=0;i<3;i++){
        if(s[i]=='A'){
            cnta++;
        }
        else{
            cntb++;
        }
    }
    if(!cnta || !cntb){
        cout<<"No"<<endl;
    }
    else{
        cout<<"Yes"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String[] spaces = sc.nextLine().split("");
    int count = 0;

    for (String space: spaces) {
      if (Integer.parseInt(space) == 1) {
        count++;
      }
    }

    System.out.println(count);
  }
}


Measured memory_bytes: 21844