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

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a, b, c;
    cin >> a >> b >> c;

    string ans = "NO";
    for(int i=0; i<=b; i++)
    {
        if(a*i%b == c) ans = "YES";
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3588
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
using namespace std;

#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define ldb ldouble

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 11;
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;
#define szz(x) (int)(x).size()
#define rep(i, n) for(int i=0;i<n;i++)
#define Se second
#define Fi first

char in[3];
int main() {
	scanf("%s %s", in, in + 2);
	if (in[0] > in[2]) printf(">");
	else if(in[0] < in[2]) printf("<");
	else printf("=");
	return !printf("\n");
}

Measured memory_bytes: 256
#!/usr/bin/env python3
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def sum_of_arithmetic_progression(s, d, n):
    return n * (2 * s + (n - 1) * d) // 2


def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


def lcm(a, b):
    g = gcd(a, b)
    return a / g * b


def meet(diff, T1, T2, A1, A2, B1, B2):
    ans = 0
    pre_diff = diff
    a = T1 * A1
    b = T1 * B1

    diff += a
    diff -= b

    if (pre_diff * diff) < 0 or (pre_diff != 0 and diff == 0):
        ans += 1

    pre_diff = diff
    a = T2 * A2
    b = T2 * B2

    diff += a
    diff -= b

    if (pre_diff * diff) < 0 or (pre_diff != 0 and diff == 0):
        ans += 1

    return ans


def solve():
    T1, T2 = map(int, input().split())
    A1, A2 = map(int, input().split())
    B1, B2 = map(int, input().split())

    # 無限回
    if (T1 * A1 + T2 * A2) == (T1 * B1 + T2 * B2):
        print("infinity")
        return

    # 0回
    if (A1 > B1 and A2 > B2) or (A1 < B1 and A2 < B2):
        print(0)
        return

    one_diff = (T1 * A1 + T2 * A2) - (T1 * B1 + T2 * B2)

    ans = 0
    diff = 0
    for i in range(100):
        num = meet(diff, T1, T2, A1, A2, B1, B2)
        if num == 0:
            break
        ans += num
        diff += one_diff

    left = -1
    right = 10**20
    while right - left > 1:
        m = (right + left) // 2
        tmp = diff + m * one_diff
        if meet(tmp, T1, T2, A1, A2, B1, B2):
            left = m
        else:
            right = m

    x = max(0, left - 10)
    ans += meet(diff, T1, T2, A1, A2, B1, B2) * x
    diff += one_diff * x

    for i in range(100):
        num = meet(diff, T1, T2, A1, A2, B1, B2)
        if num == 0:
            break
        ans += num
        diff += one_diff

    print(ans)


def main():
    solve()


if __name__ == '__main__':
    main()


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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define ALL(a) (a).begin(),(a).end()

using namespace std;
using ll = long long;

const double PI = 3.14159265358979;

void solve()
{
  int n, k;
  cin >> n >> k;
  // n = 200000;
  // k = 100000;
  if (n <= k + 1)
  {
    for(int i = 0; i < n; ++i) cout << n << " ";
    return;
  }

  vector<int> a(n + 1, 0);
  for(int i = 0; i < n; ++i)
  {
    // a[i] = 1;
    cin >> a[i];
  }

  for(int i = 0; i < k; ++i)
  {
    vector<int> next_a(n + 1, 0);
    for(int j = 0; j < n; ++j)
    {
      next_a[ max(0, j - a[j]) ]++;
      next_a[ min(n, j + a[j] + 1) ]--;
      // cout << "add " << max(0, j - a[j]) << ", " << min(n, j + a[j] + 1) << endl;
    }
    int max_cd_num = 0;
    for(int j = 0; j < n; ++j)
    {
      next_a[j + 1] += next_a[j];
      max_cd_num += (next_a[j] == n);
    }
    a = next_a;
    if (max_cd_num >= n) break;
  }

  for(int i = 0; i < n; ++i) cout << a[i] << " ";


}

int main()
{
  fastio;
  solve();

  return 0;
}

Measured memory_bytes: 4792
#include <iostream>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#define endl "\n"
#define ll long long int
using namespace std;

int main()
{
    ll n, t;
    cin >> n >> t;

    vector <ll> v(n);

    for(ll i = 0; i < n; i ++)
    	cin >> v[i];

    ll currMax = 0;
    ll prev = 0;
    ll ans = 0;
    for(ll i = 0; i < n; i ++)
    {
    	if(currMax >= v[i])
    		currMax = v[i] + t;
    	else
    	{
    		ans = ans + currMax - prev;
    		prev = v[i];
    		currMax = v[i] + t;
    	}
    }

    ans = ans + currMax - prev;
    cout << ans << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <math.h>

int arr1[10] = {0,1,2,3,4,5,6,7,8,9};
int arr3[10] = {0,7,4,1,8,5,2,9,6,3};
int arr7[10] = {0,3,6,9,2,5,8,1,4,7};
int arr9[10] = {0,9,8,7,6,5,4,3,2,1};

int getNumber(int a, int b){
  switch(a){
    case 1:
      return arr1[b];
      break;
    case 3:
      return arr3[b];
      break;
    case 7:
      return arr7[b];
      break;
    case 9:
      return arr9[b];
      break;
    default:
      return -1;
      break;
  }
}

int main(){
  long k, c, r;
  std::cin >> k;
  int m = k % 10;
  c = 0;r = k;
  while(r > 0){
    if(c==0)r = k;
    int n = getNumber(m, (17 - r % 10) % 10);
    if(n == -1) {
      c = -1;
      break;
    }
    r += n * k;
    r /= 10;
    c++;
   // std::cout << r << std::endl;
  }
  
  std::cout << c << std::endl;
}




Measured memory_bytes: 3540
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <functional>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#include <unordered_map>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) ((a) <= (x) && (x) <= (b))
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MODU 1000000007
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int
#define PI 3.141592653589
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*) array, (T*) (array + N), val);
}
pii Dir [] = {
	{ 1,0 },{ 0,1 }
};
void visit(const vector<vector<int>> &g, int v, vector< vector<int> >& scc,
	stack<int> &S, vector<bool> &inS,
	vector<int> &low, vector<int> &num, int& time) {
	low[v] = num[v] = ++time;
	S.push(v); inS[v] = true;
	for (auto e : g[v]) {
		int w = e;
		if (num[w] == 0) {
			visit(g, w, scc, S, inS, low, num, time);
			low[v] = min(low[v], low[w]);
		}
		else if (inS[w])
			low[v] = min(low[v], num[w]);
	}
	if (low[v] == num[v]) {
		scc.push_back(vector<int>());
		while (1) {
			int w = S.top(); S.pop(); inS[w] = false;
			scc.back().push_back(w);
			if (v == w) break;
		}
	}
}
void stronglyConnectedComponents(const vector<vector<int>>& g,
	vector< vector<int> >& scc) {
	const int n = g.size();
	vector<int> num(n), low(n);
	stack<int> S;
	vector<bool> inS(n);
	int time = 0;
	REP(u, n) if (num[u] == 0)
		visit(g, u, scc, S, inS, low, num, time);
}
signed main() {
	int n;
	scanf("%d", &n);

	printf("%d\n", (1+n)*n/2);

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#include <bits/stdc++.h>
using namespace std;

const double TL = 1.5 * CLOCKS_PER_SEC;
mt19937 rng((unsigned int) chrono::steady_clock::now().time_since_epoch().count());
#define clr(x, y) memset(x, y, sizeof(x))
#define forn(i, n) for (int i = 0; i < n; i++)
#define LL long long


int n;
LL a[200005];
int main() {
  //auto start_clock = clock();
#ifdef LOCAL
  freopen("in", "r", stdin);
#endif
  scanf("%d", &n);
  map<LL, LL> mp;
  for(int i = 0; i < n; i++) {
    cin >> a[i];
    mp[a[i]] += 1;
  }
  LL sum = 0;
  for(auto& iter : mp) {
    if(iter.second >= 2) {
      sum += (iter.second - 1) * iter.second / 2; 
    }
  }
  for(int i = 0; i < n; i++) {
    cout << sum - mp[a[i]] + 1 << endl;
  }
  return 0;
}


Measured memory_bytes: 11136
class STNode:
    def __init__(self, k, l, r):
        self.key = k
        self.left = l
        self.right = r

def STinsert(h, z):
    p = None
    while True:
        if h.key == -1:
            break
        p = h
        if z.key < h.key:
            h = h.left
        else:
            h = h.right
    if z.key < p.key:
        p.left = z
    else:
        p.right = z

def preorder(head, h, A):
    if h.key == -1:
        return
    A.append(h.key)
    preorder(head, h.left, A)
    preorder(head, h.right, A)
    if head == h:
        print('', *A)

def inorder(head, h, B):
    if h.key == -1:
        return
    inorder(head, h.left, B)
    B.append(h.key)
    inorder(head, h.right, B)
    if head == h:
        print('', *B)

n = int(input())
NULLnode = STNode(-1, None, None)

first = list(input().split())
head = STNode(int(first[1]), NULLnode, NULLnode)
for i in range(n-1):
    temp = list(input().split())
    if temp[0] == "insert":
        z = STNode(int(temp[1]), NULLnode, NULLnode)
        STinsert(head, z)
    else:
        A = []
        B = []
        inorder(head, head, B)
        preorder(head, head, A)


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

#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false

int main()
{
    string s, sub;
    cin >> s;
    int temp=s.size();
    REP(i,1,temp){
        s=s.substr(0,s.size()-1);
        //cout<<s<<endl;
        sub = s.substr(0, (s.size()) / 2);
        string hoge= sub+sub;
        if (s == hoge)
        {
            cout << s.size()<<endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define IFOR(i,a,b) for(int i=(b-1);i>=(a);--i)
#define RPT(i,a,b) for(int i=(a);i<((a)+(b));++i)
#define IRPT(i,a,b) for(int i=((a)+(b)-1);i>=(a);--i)
#define BITBOOL(x,a) (((x)>>(a))&1)

template<class T>using V = vector<T>;
template<class T>using V2 = V<V<T>>;

void solve(){
  int n; ll k;
  cin >> n >> k;
  vector<ll> a(n), asum(n+1);
  FOR(i,0,n){ll aa; cin >> aa; a[i] = aa % k;}
  asum[0] = 0;
  FOR(i,0,n) asum[i+1] = (asum[i]+a[i])%k;
  ll ans = 0;
  map<ll,V<int>> mp;
  FOR(i,0,n+1){
    mp[(asum[i]-i+k*(1<<29))%k].push_back(i);
  }
  for(auto x: mp){
    auto xf = x.first;
    auto xs = x.second;
    sort(xs.begin(), xs.end());
    int l=0, r = 0;
    for(;l<xs.size();++l){
      while(r<xs.size() && xs[r]-xs[l]<k) ++r;
      --r;
      ans += r - l;
    }
  }
  cout << ans << endl;
  /*
  V2<ll> dp(n+1,V<ll>(k,0));
  dp[0][0] = 1;
  FOR(i,0,n){
    FOR(j,0,k){
      dp[i+1][j] = dp[i][j] + dp[i][ (2*k+j+a[i]-1)%k];
    }
  }
  FOR(i,0,n+1){
    FOR(j,0,k){
      cout << dp[i][j] << "  ";
    }
    cout << endl;
  }
  */
}

int main(){
  solve();
  return 0;
}


Measured memory_bytes: 25216
<?php
  $n = intval(fgets(STDIN));
  $a = explode(" ", trim(fgets(STDIN)));

  $result = -1;

  $resultArray = [];
  $count = 0;
  $next = 1;
  for($i=0; $i<$n; $i++){
    if($a[$i]==$next){
      $next++;
    }else{
      $count++;
    }
  }
  if($next>1){
    $result = $count;
  }else{
    $result = -1;
  }

/*
  $idx=0;
  $count = 0;
  $max = $n;
  while($idx<$max){
    if($a[$idx]==$idx+1){
      //現在地が一致したので次へ
      $idx++;
    }else{
      //現在地を砕く
      array_splice($a, $idx, 1);
      $count++;
      //砕いたのでループ数を減らす
      $max--;
    }
  }
  if($count==$n){
    $result = -1;
  }else{
    $result = $count;
  }
*/
  echo $result."\n";


Measured memory_bytes: 18932
#include <iostream>
#include <math.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <string.h>
#include <queue>
#include <vector>
#include <set>
#include <map>
using namespace std;

int main() {
	string S;
	cin >> S;
	long long int dp[100010][13] = {},len=S.length();
	dp[0][0] = 1;
	for (int i = 1; i <= len; i++)
	{
		int num = S[i - 1] - '0';
		for (int j = 0; j < 13; j++)
		{
			if (num != '?' - '0') {
				dp[i][(j * 10 + num) % 13] += dp[i - 1][j];
			}
			else
			{
				for (int k = 0; k < 10; k++)
				{
					dp[i][(j * 10 + k)%13] += dp[i - 1][j];
				}
			}
		}
		for (int j = 0; j < 13; j++)dp[i][j] %= 1000000007;
	}
	cout << dp[len][5];
}


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

typedef long long LL;

int n;

void into(){
  scanf("%d",&n);
}

void work(){
}

void outo(){
  printf("%d\n",n-1>>1);
}

int main(){
  into();
  work();
  outo();
  return 0;
}

Measured memory_bytes: 3732
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); ++i)
#define fi first
#define se second
#define INF 1000000009
#define LLINF 1000000000000000009LL
using ll = long long;

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

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

// combination mod prime
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
} comb(2000009);

int main(){
  int r1,c1,r2,c2;
  cin>>r1>>c1>>r2>>c2;
  mint ans=comb(r2+c2+2,r2+1)-comb(r1+c2+1,r1)-comb(r2+c1+1,c1)+comb(r1+c1,r1);
  cout<<ans.x<<endl;
  return(0);
}


Measured memory_bytes: 31488
// -----------------------------------------------
// Framework <https://github.com/vain0x/procon>
//
// See the bottom of file for solution.
// -----------------------------------------------

#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

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

#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim_right().to_owned()
}

// -----------------------------------------------
// Solution
// -----------------------------------------------

fn main() {
    let mut X = read![[i64]];
    X.sort();

    println!(
        "{}",
        if X.starts_with(&[1, 4, 7, 9]) {
            "YES"
        } else {
            "NO"
        }
    )
}


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

int main() 
{
    ll x, t=0, tmp =100;
    double in;
    cin>>x;
    while(tmp < x)
    {
        in = (tmp*1)/100;
        t++;
        tmp = tmp + in;
    }
    cout<<t;
    return 0;
}


Measured memory_bytes: 3596
//                                      KiSmAt
#include "bits/stdc++.h"
using namespace std;
 
using ll = long long;
using ld = long double;
 
const ll inf = 1e18;
const int N = 3 * 1e2 + 10;

ll res;
ll a[N], h[5];

ld dp[N][N][N];

void solve(){
    ll n, x;
    cin >> n;
    for(int i = 0; i < n; ++i){
        cin >> x;
        ++h[x];
    }
    for(int k = 0; k < N; ++k){
        for(int j = 0; j + k < N; ++j){
            for(int i = 0; i + j + k < N; ++i){
                if(i + j + k == 0)  continue;
                if(i + j + k > n)   continue;  
                ld pi = 1.0 * i / (i + j + k);
                ld pj = 1.0 * j / (i + j + k);
                ld pk = 1.0 * k / (i + j + k);
                dp[i][j][k] = 1.0 * n / (i +  j + k);
                if(i)   dp[i][j][k] += pi * dp[i - 1][j][k];
                if(j)   dp[i][j][k] += pj * dp[i + 1][j - 1][k];
                if(k)   dp[i][j][k] += pk * dp[i][j + 1][k - 1];
            }
        }
    }
    cout << fixed << setprecision(10) << dp[h[1]][h[2]][h[3]];
}
 
int main(int argc, char const *argv[]){
    ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
    ll t = 1;
    //cin >> t;
    while(t--){
        solve();
    }
}
// nEro

Measured memory_bytes: 450816
#include<stdio.h>
int main(){
  int n;
  int a;
  int mn=1000000000;
  int i,ans=-1000000000;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a);
    if(i==0 && mn>a) mn=a;
    if(i>0 && ans<a-mn) ans=a-mn;
    if(i!=0 && mn>a) mn=a;
  }
  printf("%d\n",ans);
  return 0;
}



Measured memory_bytes: 2144
import math

long, short, hour, minute = map(int, input().split())

total_minutes = 60 * hour + minute
long_angle = 0.5 * total_minutes
short_angle = (6.0 * total_minutes) % 360
#
# print(long_angle)
# print(short_angle)

# 直線のとき
if long_angle == short_angle:
    if long >= short:
        print(str(long - short))
        exit()
    else:
        print(str(short - long))
        exit()
elif long_angle - short_angle == 180 or long_angle - short_angle == -180 :
    print(str(long + short))
    exit()

if short_angle == 0:
    short_angle = 360

x = math.sqrt((long_angle - short_angle) ** 2) /2
y = 90 - x

a_down = short * math.sin(math.radians(x)) * 2
b_down = long * math.sin(math.radians(x)) * 2

c = b_down - (b_down - a_down) / 2

d = math.sqrt(long **2 - (b_down/2) **2 ) - math.sqrt(short ** 2 - (a_down/2) **2)

ans = math.sqrt(d**2 + c **2)

print(ans)

Measured memory_bytes: 9568
using System;

class Program
{
    static void Main(string[] args)
    {
        var num = Console.ReadLine();
        var counter = 0;
        for(var i = 0; i < num.Length; i++)
        {
            if (num.Substring(i,1) == "1") counter++;
        }
        Console.WriteLine(counter);
    }
}



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

int main() {
  int n,k;
  int f=0;
  cin >> n;
  k=n;
  for(int i =0;i<8;i++){
    f+=n%10;
    n/=10;
  }
  if(k%f==0){
    cout << "Yes";
  }
  else{
    cout << "No";
  }
  
}

Measured memory_bytes: 256
import * as fs from 'fs'
const inputs = fs.readFileSync('/dev/stdin', 'utf8').split(/\r?\n/)
const [a, b, c, d] = inputs.shift()!.split(' ').map(s => parseInt(s, 10))

const can = (x: number, y: number) => Math.abs(x - y) <= d;
console.log((can(a, c) || (can(a, b) && can(b, c))) ? 'Yes' : 'No')

Measured memory_bytes: 7372
#include <bits/stdc++.h>
using namespace std;
//#define cerr if (false) cerr
#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define dbv(v) cerr << #v << "="; for (auto _x : v) cerr << _x << ", "; cerr << endl
#define dba(a, n) cerr << #a << "="; for (int _i = 0; _i < (n); ++_i) cerr << a[_i] << ", "; cerr << endl
template <typename A, typename B>
ostream& operator<<(ostream& os, const pair<A, B>& x) {
	return os << "(" << x.first << "," << x.second << ")";
}
typedef long long ll;
typedef long double ld;
bitset<50001> B[50005];
int main() {
	int n, m, t;
	scanf("%d%d%d", &n, &m, &t);
	vector<int> x(m), y(m);
	for (int i = 0; i < m; ++i) scanf("%d%d", &x[i], &y[i]);
	if (t == 2) {
		if (n < 3) {
			printf("-1\n");
			return 0;
		}
		auto dir = [](int a, int b) {
			return a > b ? '^' : 'v';
		};
		vector<pair<char, int>> p;
		int a = 1, b = 2, c = 3;
		int ab = -1, ac = -1;
		for (int i = 0; i < m; ++i) {
			if (y[i] == a) swap(x[i], y[i]);
			if (x[i] == a && y[i] == b) {
				p.emplace_back(dir(a, b), ac); // b-c
				p.emplace_back(dir(b, a), ac); // a-c
				swap(a, c);
			} else if (x[i] == a && y[i] == c) {
				p.emplace_back(dir(c, a), ab); // a-b
				p.emplace_back(dir(a, c), ab); // c-b
				swap(a, b);
			} else {
				// a-b
				p.emplace_back((y[i] == a || y[i] == b) ? dir(x[i], y[i]) : dir(y[i], x[i]), ab);
				// a-c
				p.emplace_back((y[i] == a || y[i] == c) ? dir(x[i], y[i]) : dir(y[i], x[i]), ac);
			}
			ab = p.size() - 2;
			ac = p.size() - 1;
		}
		string ans;
		for (; ab != -1;) {
			ans += p[ab].first;
			ab = p[ab].second;
		}
		reverse(ans.begin(), ans.end());
		printf("%s\n", ans.c_str());
		return 0;
	}
	for (int i = 1; i <= n; ++i) B[i][i] = 1;
	for (int i = m - 1; i >= 0; --i) {
		B[x[i]] |= B[y[i]];
		B[y[i]] = B[x[i]];
	}
	auto sum = B[1];
	for (int i = 2; i <= n; ++i) {
		sum &= B[i];
	}
	int take = -1;
	for (int i = 1; i <= n; ++i) {
		if (sum[i] == 1) {
			take = i;
			break;
		}
	}
	if (take == -1) printf("-1\n");
	else {
		auto b = sum;
		b.reset();
		b[take] = 1;
		string ans;
		for (int i = m - 1; i >= 0; --i) {
			if (b[x[i]] == 1) {
				b[y[i]] = 1;
				ans += '^';
			} else if (b[y[i]] == 1) {
				b[x[i]] = 1;
				ans += 'v';
			} else {
				ans += '^';
			}
		}
		reverse(ans.begin(), ans.end());
		printf("%s\n", ans.c_str());
	}
}


Measured memory_bytes: 306816
#include <stdio.h>
int main(void){
	int n;
	scanf("%d", &n);
	long x = 1;
	long y = 2;
	long z = 1;
	if(n<2){
		printf("0\n");
		return 0;
	} else {
		for(int i=0; i<n; i++){
			x = x*10%1000000007;
			y = y*9%1000000007;
			z = z*8%1000000007;
		}
		x = (x-y+z)%1000000007;
	}
	if(x<0){
		x += 1000000007;
	}
	printf("%ld\n", x);
	return 0;
}


Measured memory_bytes: 1736
use std::io;

fn main() {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    let s = s.trim();
    
    let nt: Vec<&str> = s.split(" ").collect();
    let t: u32 = nt[1].parse().unwrap();
    
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    let s = s.trim();
    
    let vec: Vec<u32> = s.split(" ").map(|n|n.parse().unwrap()).collect();
    let mut result = 0;
    for n in 0..vec.len() {
        if n != 0 {
            let d = vec[n] - vec[n - 1];
            result += if d < t {
                d
            } else {
                t
            }
        } else {
            result += t;
        }
    }
    println!("{}", result);
}

Measured memory_bytes: 8444
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (1LL<<60)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
typedef unsigned long long int ull;
typedef long long lint;

int main(void){
    lint N;
    cin >> N;
    lint A[N];
    rep(i,N) cin >> A[i];
    lint count=0;
    lint mini=INF;
    rep(i,N){
        if(A[i]<=0) count++;
        if(llabs(A[i])<mini) mini=llabs(A[i]);
        A[i]=llabs(A[i]);
    }
    lint ans=accumulate(A,A+N,0LL);
    if(count%2) cout << ans-2*mini << endl;
    else cout << ans << endl;
}

Measured memory_bytes: 1024
import java.util.Scanner

object Main extends App {
  val sc = new Scanner(System.in)
  val r = sc.nextInt()
  val g = sc.nextInt()
  val b = sc.nextInt()

  println(if ((r * 100 + g * 10 + b) % 4 == 0) "YES" else "NO")
}

Measured memory_bytes: 25532
using System;
using System.Collections.Generic;

class Hoge {
    public static void Main()
    {
        string[] str = Console.ReadLine().Split(' ');
        int a = int.Parse(str[0]);
        int b = int.Parse(str[1]);
        List<int> aa = new List<int> { };

        aa.Add(a + b);
        aa.Add(a - b);
        aa.Add(a * b);
        int max = aa[0];

        if(max < aa[1])
        {
            max = aa[1];
        }
        if (max < aa[2])
        {
            max = aa[2];
        }
        Console.WriteLine(max);
    }
}

Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
#define rep(x,n) for(int x = 0 ; x < n ; x++)
#define pb push_back
#define all(c) (c).begin() , (c).end()
const ll mod = 1e9 + 7;
vi dp(1e5+10, 0);

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    
    int n, k;
    cin >> n >> k;
    vi a(n), b(k+2,0);
    rep(i, n)
        cin >> a[i];
    dp[0] = 1;
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j <= k; j++)
            b[j + 1] = (b[j] + dp[j]) % mod;
        for (int j = 0; j <= k; j++)
            dp[j] = (b[j+1] - b[max(0ll, j - a[i])] + mod) % mod;
    }
    cout << dp[k] << endl;
    return 0;
}

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

static int cnt = 0;

void insertionSort(vector<int> &A, int n, int g) {
    int v;
    for (int i=g; i<n; ++i) {
        v = A[i];
        int j = i - g;
        while (j >= 0 && A[j] > v) {
            A[j+g] = A[j];
            j -= g;
            cnt++;
        }
        A[j+g] = v;
    }
}

void shellSort(vector<int> &A, int n, int m, vector<int> &G) {
    cnt = 0;
    for (int i=m-1; i>=0; --i) {
        cout << G[i] << " ";
        insertionSort(A, n, G[i]);
    }
}

int main() {
    int n;
    cin >> n;
    vector<int> vec;
    int x;
    for (int i=0; i<n; ++i) {
        cin >> x;
        vec.push_back(x);
    }
    vector<int> G;
    int h = 1;
    int m = 0;
    while(h <= n) {
        G.push_back(h);
        h = 3*h + 1;
        m++;
    }
    cout << m << endl;
    shellSort(vec, n, m, G);
    cout << endl;
    cout << cnt << endl;
    for (int i=0; i<n; ++i) {
        cout << vec.at(i) << endl;
    }
}



Measured memory_bytes: 6936
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,m,count=1;
  cin>>n;
  vector<int> a(n);
  for(int i=0;i<n;i++)cin>>a[i];
  sort(a.begin(),a.end());
  m=a[a.size()-1];
  for(int i=0;i<n;i++){
    if(a[a.size()-1]==m)a.pop_back();
    else{
      count++;
      m=a[a.size()-1];
      i--;
    }
  }
  cout<<count<<endl;
}

Measured memory_bytes: 256
alpha_dict = {}
for i,c in enumerate(range(ord('a'),ord('z')+1)):
    alpha_dict[chr(c)] = 0

input_str = []

while True:
    try:
        input_value = input().lower()
        input_str.append(input_value)
    except:
        break
    

for input_row in input_str:
    for i in input_row:
        if i in alpha_dict.keys():
            alpha_dict[i] += 1

for key,value in alpha_dict.items():
    print("%s : %d" %(key,value))


Measured memory_bytes: 5564
from collections import defaultdict
N = int(input())
*S, = map(int, input().split())

ans = 0
c = 0
memo = defaultdict(int)
for a in range(N-1, 0, -1):
    d = 1
    m = min(N-1-a, a*a)
    while d*d <= m:
        if (N-1-a) % d == 0:
            e = (N-1-a) // d
            if a > d and (a % d > 0 or N-1 < 2*a):
                memo[a, d] = s = memo[a+d, d] + S[a] + S[N-1-a]
                ans = max(ans, s)
            if a > e and (a % e > 0 or N-1 < 2*a):
                k = (N-1-a) // e
                memo[a, e] = s = memo[a+e, e] + S[a] + S[N-1-a]
                ans = max(ans, s)
        d += 1
print(ans)

Measured memory_bytes: 159628
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <numeric>
#include <set>
#include <list>
#include <bitset>
#include <cstdlib>
using namespace std;

int main()
{
    int N;
    cin >> N;
    vector<int> L(2 * N);
    for (int i = 0; i < 2 * N; i++)
    {
        cin >> L[i];
    }
    sort(L.begin(), L.end());
    int ans = 0;
    for (int i = 1; i < 2 * N; i += 2)
    {
        ans += min(L[i], L[i - 1]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.LinkedList;
import java.util.List;
import java.util.Scanner;

public class Main {
	private class Node {
		public int parentsCount = 0;
		public List<Integer> children = null;
		
		public int setParents = 0;
		public int trueParent = 0;
		public int trueDepth = 0;
		
		public Node() {
			children = new LinkedList<Integer>();
		}
		
		public void setDepth(int parent, int depth) {
			if (trueDepth < depth) {
				trueDepth = depth;
				trueParent = parent;
			}
			setParents++;
		}

		public int getDepth() {
			if (parentsCount > setParents) {
				return -1;
			}
			return trueDepth;
		}
		
		public int getTrueParent() {
			if (parentsCount > setParents) {
				return -1;
			}
			return trueParent;
		}
		
		public boolean isRoot() {
			if (parentsCount == 0) {
				return true;
			} else {
				return false;
			}
		}
	}
	
	private int getRoot(Node[] nodes) {
		int root = 0;
		for (root=1; root<nodes.length; root++) {
			if (nodes[root].isRoot()) {
				break;
			}
		}
		
		return root;
	}
	
	public void solve() {
		Scanner in = new Scanner(System.in);
		int N = in.nextInt();
		int M = in.nextInt();
		
		Node[] nodes = new Node[N+1];
		for (int i=0; i<N+1; i++) {
			nodes[i] = new Node();
		}
		
		for (int i=0; i<N+M-1; i++) {
			int a = in.nextInt();
			int b = in.nextInt();
			
			nodes[a].children.add(b);
			nodes[b].parentsCount++;
		}

		in.close();
		
		int root = getRoot(nodes);
		
		LinkedList<Integer> list = new LinkedList<Integer>();
		list.addFirst(root);
		
		while (list.size() > 0) {
			int target = list.removeFirst();
			int depth = nodes[target].getDepth();
			
			for (Integer x : nodes[target].children) {
				nodes[x].setDepth(target, depth+1);
				if (nodes[x].getDepth() != -1 && nodes[x].children.size() > 0) {
					list.addFirst(x);
				}
			}
		}
		
		for (int i=1; i<N+1; i++) {
			System.out.println(nodes[i].trueParent);
		}
	}
	
	public static void main(String[] args) {
		Main main = new Main();
		main.solve();
	}
}


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

int main() {
  FAST;
  int64_t X, Y, A, B, C;
  cin >> X >> Y >> A >> B >> C;
  vector<int64_t> p(A), q(B), r(C), s(X + Y + C);
  for (int64_t i = 0; i < A; i++) {
    cin >> p.at(i);
  }
  for (int64_t i = 0; i < B; i++) {
    cin >> q.at(i);
  }
  for (int64_t i = 0; i < C; i++) {
    cin >> r.at(i);
  }
  sort(p.begin(), p.end());
  reverse(p.begin(), p.end());
  sort(q.begin(), q.end());
  reverse(q.begin(), q.end());
  for (int64_t i = 0; i < X; i++) {
    s.at(i) = p.at(i);
  }
  for (int64_t i = 0; i < Y; i++) {
    s.at(i + X) = q.at(i);
  }
  for (int64_t i = 0; i < C; i++) {
    s.at(i + X + Y) = r.at(i);
  }
  sort(s.begin(), s.end());
  reverse(s.begin(), s.end());
  int64_t sum = 0;
  for (int64_t i = 0; i < X + Y; i++) {
    sum += s.at(i);
  }
  cout << sum << endl;
}

Measured memory_bytes: 4864
#include<iostream>
#include<cassert>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<deque>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
typedef pair<int, int>P;
const int MOD = 1e9 + 7;
const int INF = 1e10;
const long double PI = (acos(-1));

struct UnionFind {
	vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

	UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
		for (int i = 0; i < N; i++) par[i] = i;
	}

	int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
		if (par[x] == x) return x;
		return par[x] = root(par[x]);
	}

	void unite(int x, int y) { // xとyの木を併合
		int rx = root(x); //xの根をrx
		int ry = root(y); //yの根をry
		if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
		par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
	}

	bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};

signed main() {
	int N, M;
	cin >> N >> M;
	vector<int>p(N);
	rep(i, N)cin >> p[i];
	rep(i, N)p[i]--;
	UnionFind tree(N);
	rep(i, M) {
		int x, y;
		cin >> x >> y;
		x--; y--;
		tree.unite(x, y);
	}
	int ans = 0;
	rep(i, N) {
		if (tree.same(p[i], i))ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <array>
#include <cmath>
#include <memory>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define DEFOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin)-1; (LoopVariable) >= (numberOFend); (LoopVariable)--)
#define REP(LoopVariable,numberOFend) for(long long int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

constexpr long long int linf = numeric_limits<long long int>::max()-5;
constexpr int inf= numeric_limits<int>::max()-5;
constexpr long long int mod = 1000000007;



const long long int MAX = 200001;
const long long  MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];
// a^n mod を計算する
long long modpow(long long a, long long n) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (long long int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(long long int n, long long int k){
    long long int ue = n, sita = 1;
    FOR(i,1,k){
        ue*=n-i;
        ue %= mod;
        sita *= i + 1;
        sita %= mod;
    }

    return (ue*modpow(sita,1000000005))%mod;
    
}

int main(){
    COMinit();
    long long int n,a,b;
    cin>>n>>a>>b;
    long long int result=modpow(2,n);
    //cout << result << endl;
   // cout << COM(4, 2) << endl;
    result-=COM(n,a);
    result -= COM(n, b);
    result -= 1;
    while(result<0){
        result+=mod;
    }
    cout<<result<<endl;

    return 0;
}


Measured memory_bytes: 5496
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  
#include <chrono>
#include <random>
#include <time.h>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define tii tuple<int,int,int>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define edge(v,a,b) v[a].pb(b);v[b].pb(a);
#define MAX_V 400010
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define endl "\n"
#define ALL(c) (c).begin(),(c).end()
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}

#define INF 1e9+7
#define LLINF 1e18+7
ll MOD=1e9+7;
#define N 210000


main(){
    int n=in();
    string s;cin>>s;
    int a[N]={};
    rep2(i,1,n){
        if(s[i-1]=='#')a[i]=a[i-1]+1;
        else a[i]=a[i-1];
    }
    int sum=a[n];
    int ans=INF;
    rep2(i,0,n){
        ans=min(ans,a[i]+(n-(int)i-(sum-a[i])));
    }
    cout<<ans;
    return 0;
}


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

#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
// pll pp; -> (pp.first,pp.second)
// vector<vl> pp(n,vl(2)); sort(pp.begin(),pp.end(),[](vl a,vl b){return a[0]<b[0];});

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define RREP(i,n) for(ll (i)=(n)-1;(i)>=0;(i)--)
#define FOR(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define FORR(i,a,b) for(ll (i)=(b)-1;(i)>=(a);(i)--)
#define DEBUG(x) cout << #x << ": " << x << endl
#define CHMAX(a,b) a=max((a),(b))
#define CHMIN(a,b) a=min((a),(b))
/*}}}*/
int main() {
  ll x;
  cin >> x;
  ll ok = 1,ng = 1e9+1;
  while(abs(ok-ng)>1){
    ll m = (ok+ng)/2;
    if(m*(m+1)/2<=x) ok = m;
    else ng = m;
  }
  if(ok*(ok+1)/2==x) cout << ok << endl;
  else cout << ok+1<< endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;


int main()
{
	int n, k;
	cin >> n >> k;
	vector<int> h(n + 1);
	for (int i = 1; i <= n; i++) cin >> h[i];

	int dp[100001];
	dp[1] = 0;

	for (int i = 2; i <= n; i++) {
		dp[i] = INT32_MAX;
		for (int j = 1; (j <= k) && (i - j > 0); j++) {
			dp[i] = min(dp[i], dp[i-j] + abs(h[i] - h[i - j]));
		}
	}

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

Measured memory_bytes: 1024
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
int a[10];

int main()
{
    int i;
    scanf("%d%d%d",&a[0],&a[1],&a[2]);
    sort(a,a+3);
    printf("%d\n",a[0]+a[1]);
    return 0;
}


Measured memory_bytes: 128
import java.util.*; import java.io.*; import java.math.*;
public class Main{
	//Don't have to see. start------------------------------------------
	static class InputIterator{
		ArrayList<String> inputLine = new ArrayList<String>(1024);
		int index = 0; int max; String read;
		InputIterator(){
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			try{
				while((read = br.readLine()) != null){
					inputLine.add(read);
				}
			}catch(IOException e){}
			max = inputLine.size();
		}
		boolean hasNext(){return (index < max);}
		String next(){
			if(hasNext()){
				return inputLine.get(index++);
			}else{
				throw new IndexOutOfBoundsException("There is no more input");
			}
		}
	}
	static HashMap<Integer, String> CONVSTR = new HashMap<Integer, String>();
	static InputIterator ii = new InputIterator();//This class cannot be used in reactive problem.
	static PrintWriter out = new PrintWriter(System.out);
	static void flush(){out.flush();}
	static void myout(Object t){out.println(t);}
	static void myerr(Object t){System.err.print("debug:");System.err.println(t);}
	static String next(){return ii.next();}
	static boolean hasNext(){return ii.hasNext();}
	static int nextInt(){return Integer.parseInt(next());}
	static long nextLong(){return Long.parseLong(next());}
	static double nextDouble(){return Double.parseDouble(next());}
	static ArrayList<String> nextStrArray(){return myconv(next(), 8);}
	static ArrayList<String> nextCharArray(){return myconv(next(), 0);}
	static ArrayList<Integer> nextIntArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Integer> ret = new ArrayList<Integer>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Integer.parseInt(input.get(i)));
		}
		return ret;
	}
	static ArrayList<Long> nextLongArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Long> ret = new ArrayList<Long>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Long.parseLong(input.get(i)));
		}
		return ret;
	}
	static String myconv(Object list, int no){//only join
		String joinString = CONVSTR.get(no);
		if(list instanceof String[]){
			return String.join(joinString, (String[])list);
		}else if(list instanceof ArrayList){
			return String.join(joinString, (ArrayList)list);
		}else{
			throw new ClassCastException("Don't join");
		}
	}
	static ArrayList<String> myconv(String str, int no){//only split
		String splitString = CONVSTR.get(no);
		return new ArrayList<String>(Arrays.asList(str.split(splitString)));
	}
	public static void main(String[] args){
		CONVSTR.put(8, " "); CONVSTR.put(9, "\n"); CONVSTR.put(0, "");
		solve();flush();
	}
	//Don't have to see. end------------------------------------------
	static void solve(){//Here is the main function
		int N = nextInt();
		ArrayList<Integer> list = nextIntArray();
		long output = 1L << 50;
		long max = 0;
		for(int i = 0; i < N; i++){
			max += list.get(i);
		}
		long mae = 0;
		for(int i = 0; i < N - 1; i++){
			mae += list.get(i);
			long ato = max - mae;
			output = Math.min(output, Math.abs(mae - ato));
		}
		myout(output);
	}
	//Method addition frame start



	//Method addition frame end
}


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

int A[200005];
vector<int> F[200005], X;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(NULL), cout.tie(NULL);

    int N;
    cin >> N;

    for(int i=1; i<=N; i++)
    {
        cin >> A[i];

        for(int j=i; j<=N; j += i)
            F[j].push_back(i);
    }

    for(int i=N; i>=1; i--)
    {
        if(A[i])
        {
            X.push_back(i);

            for(auto f : F[i])
                A[f] ^= 1;
        }
    }

    cout << X.size() << "\n";

    for(auto x : X)
        cout << x << " ";
    
    return 0;
}


Measured memory_bytes: 23548
#include<bits/stdc++.h>
using namespace std;
#define ll	long long 
#define ld long double
#define pb push_back
#define pf push_front
#define mp make_pair
int gcd(int a, int b) 
{ 
	if (a == 0) 
		return b; 
	return gcd(b % a, a); 
} 
int invertBits(int num) 
{  
    int x = log2(num) + 1; 
    for (int i = 0; i < x; i++)  
       num = (num ^ (1 << i));  
   
    return num; 
} 
///////////////////////////////////////////////////////////////////////////////////////////////////////////

int main()
{
	string s;
	cin>>s;
	for(int i=0;i<s.length()-1;i++)
	{
		if(s[i]==s[i+1])
		{
			cout<<"Bad";
			return 0;
		}
	}
	cout<<"Good";
	return 0;
}

Measured memory_bytes: 256
def main():
    n = input().rstrip()
    w = [int(x) for x in input().split()]

    s = sum(w)
    o = s / 2
    old = 0
    curr = 0
    for x in w:
        curr += x
        
        if abs(old - o) <= abs(curr - o):
            print(abs(s-old*2))
            break
        old = curr
    
if __name__=='__main__':
    main()

Measured memory_bytes: 3064
def insersionSort(a, n, g)
  cnt = 0
  for i in g..n-1
    v = a[i]
    j = i - g
    while j >= 0 && a[j] > v
      a[j+g] = a[j]
      j = j - g
      cnt += 1
    end
    a[j+g] = v
  end
  return cnt
end

def shellSort(a, n)
  cnt = 0
  g = []
  g[0] = 1
  m = 0
  while 3*g[m]+1 < n
    g[m+1] = 3*g[m]+1
    m += 1
  end
  g = g.reverse
  puts m + 1
  puts g.join(" ")
  for i in 0..m
    cnt += insersionSort(a, n, g[i])
  end
  puts cnt
  a.each{|key|
    puts key
  }
end

n = gets.to_i
a = []
0.upto(n-1){|i|
  a[i]= gets.to_i
}
shellSort(a, n)

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

#define F first
#define S second
#define mp make_pair
#define pb push_back
#define f(i,x,n) for(int i=x;i<n;i++)
#define all(c) c.begin(),c.end()
#define deg(x) cout<<x<<" "


using ll = long long;
using pll = pair<ll,ll>;
using pii = pair<int,int>;
const int MOD = 1e9+7, N = 1e5 + 10;

int32_t main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int m,k;
	cin >> m >> k;
	if(m==1){
		if(k==0){
			cout << "0 0 1 1\n";
		}
		else{
			cout << "-1\n";
		}
	}
	else if(k>=(1<<m)){
		cout << "-1\n";
	}
	else{
		vector <int> res;
		f(i,0,(1<<m)){
			if(i!=k) res.pb(i);
		}
		for(auto el : res) cout << el << " ";
		cout << k << " ";
		reverse(all(res));
		for(auto el : res) cout << el << " ";	
		cout << k << "\n";
	}
	return 0;
}

Measured memory_bytes: 2424
import java.util.*;

public class Main {
	
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] arr = new int[3];
		for (int i = 0; i < 3; i++) {
			arr[i] = sc.nextInt();
		}
		Arrays.sort(arr);
		if (arr[0] + arr[1] == arr[2]) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 23892
N = int(input())
L = []

for j in range(1,201) :
    counter = 0
    if j % 2 != 0 :
        for i in range(1,N+1) :
            if j % i == 0 :
                counter += 1
        if counter == 8 :
            L.append(j)

p = 0
for i in L :
    if i <= N :
        p += 1
    else :
        break
print(p)

Measured memory_bytes: 3060
H,W = gets.split.map(&:to_i)
d = [[-1,0],[1,0],[0,-1],[0,1]]
route = Array.new(H){Array.new(W)}
c = Array.new(H)
blackcount=0
for i in 0..H-1
  c[i] = gets.chomp
  blackcount+=c[i].count('#')
end

route[0][0] = 0
que = []
que.push([0,0])
while que != []
  shift = que.shift
  for i in 0..3
    y = shift[0] + d[i][0]
    x = shift[1] + d[i][1]
    if (y<0||y>=H)||(x<0||x>=W)||c[y][x]=='#'
    elsif c[y][x] == '.'&&route[y][x] == nil
      route[y][x] = route[shift[0]][shift[1]] + 1
      c[y][x] = '#'
      que.push([y,x])
    end
  end
end
 
ans=route[H-1][W-1]

if !ans
    puts -1
else
    puts H*W-blackcount-ans-1
end

Measured memory_bytes: 3836
#include <bits/stdc++.h>
using namespace std;
int K,S,i,j,k,ans;
int main()
{
	scanf("%d%d",&K,&S);
	for(i=0;i<=K;i++)
	{
		for(j=0;j<=K;j++)
		{
			k=S-i-j;
			if(k>=0 && k<=K)
			ans++;
		}
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 256