akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <map>
#include <string.h>
#include <math.h>
#include <set>
#include <vector>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < n; i++)
#define All(a) (a).begin(), (a).end()
using namespace std;
int main(){
    int n, c, k;
    cin >> n >> c >> k;
    vector<int> t(n);
    rep(i, n) cin >> t[i];
    sort(All(t));
    int cnt = 0, tmp = 0, last = INT_MIN;
    rep(i, n){
        if(t[i] <= last + k & tmp < c){
            tmp++;
        }else{
            cnt++;
            last = t[i];
            tmp = 1;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;

class Program
{
    public void Proc()
    {


        Reader.IsDebug = false;

        Console.WriteLine(string.Join(" ", Reader.ReadLine().Split(',')));
    }




    public class Reader
    {
        public static bool IsDebug = true;
        private static String PlainInput = @"







";
        private static System.IO.StringReader Sr = null;
        public static string ReadLine()
        {
            if (IsDebug)
            {
                if (Sr == null)
                {
                    Sr = new System.IO.StringReader(PlainInput.Trim());
                }
                return Sr.ReadLine();
            }
            else
            {
                return Console.ReadLine();
            }
        }
    }
    static void Main()
    {
        Program prg = new Program();
        prg.Proc();
    }
}

Measured memory_bytes: 2648
n = int(input())
p = list(map(int, input().split()))

pp = range(1, n+1)

c = 0
ans = 'YES'
for i in range(n):
	if i+1 != p[i]:
		if p[p[i]-1] == i+1 and c == 0:
			p[p[i]-1] = p[i]
			c = 1
		else:
			ans  = 'NO'
			break

print(ans)


Measured memory_bytes: 3060
#include<iostream>
#include <algorithm>
#include <vector>
int N;
int main(){
    std::cin >> N;
    std::vector<int> vec;
    int tmp;
    int before_len = 0, after_len = 0;
    for(int i=0; i<N; i++){
        std::cin >> tmp;
        vec.push_back(tmp);
    }
    std::sort(vec.begin(), vec.end());
    before_len = vec.size();
    decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());
    vec.erase(result, vec.end());
    after_len = vec.size();
    if(before_len == after_len){
        std::cout << "YES\n";
    }else{
        std::cout << "NO\n";
    }
    return 0;
}

Measured memory_bytes: 1400
// #pragma GCC optimize ("O3")
#include <bits/stdc++.h>
// #include <ext/pb_ds/tree_policy.hpp>
// #include <ext/pb_ds/assoc_container.hpp>

using namespace std;
// using namespace __gnu_pbds;
// using namespace __gnu_cxx;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

// #define oset tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 

#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound

#define sz(x) (int)x.size()
#define beg(x) x.begin()
#define en(x) x.end()
#define all(x) beg(x), en(x)
#define zero(a) memset(a,0,sizeof(a))

// #define int ll

const ll INF = 1e18;
const ld PI = 4*atan((ld)1);
const int MOD = 1000000007; // 998244353

const int N = 100022;
int pre[N],post[N];


int main(){
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int n;cin >> n;
	vector<int> v(n);
	for(int i=0;i<n;i++) cin >> v[i];
	int p = 0;
	for(int i=0;i<n;i++){
		pre[i] = p;
		p = __gcd(p,v[i]);
	}
	p = 0;
	for(int i=n-1;i>=0;i--){
		post[i] = p;
		p = __gcd(p,v[i]);
	}
	int ans = 1;
	for(int i=0;i<n;i++){
		ans = max(ans,__gcd(pre[i],post[i]));
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1408
/*** ??§?´? ***/

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

int main(){
	int n;
	int i, j;
	int hh, mm, ss;
	int time[100000], count;
	
	cin >> n;
	while(n!=0){
		for(i=0; i<100000; ++i) time[i]=0;
		
		for(i=0; i<n; ++i){
			scanf("%d:%d:%d", &hh, &mm, &ss);
			//cin >> hh >>":" >> mm >> ":" >> ss;
			time[ss+60*mm+3600*hh]++;
			scanf("%d:%d:%d", &hh, &mm, &ss);
			//cin >> hh >>":" >> mm >> ":" >> ss;
			time[ss+60*mm+3600*hh]--;
		}
		
		count=0;
		for(i=0; i<100000; ++i){
			if(i>0) time[i]+=time[i-1];
			count = max(count, time[i]);
		}
		cout << count << endl;
		cin >> n;
	}
	return 0;
}

Measured memory_bytes: 3520
import java.util.Scanner;
 
public class Main {
 
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
 
		String a = sc.next();
		
		long len = a.length();
		
		long[] f = new long[26];
		
		for(int i = 0; i < 26; i++) {
			f[i] = 0;
		}
		
		for(int i = 0; i < len; i++) {
			f[a.charAt(i)-'a']++;
		}
		
		long sum = 0;
		for(long x:f) {
			sum += x * (x - 1) / 2;
		}
 
		System.out.println(len*(len - 1) / 2 - sum + 1);
		
	}
}

Measured memory_bytes: 26680
// #pragma GCC optimize("O3", "unroll-loops")
// #pragma GCC target("avx2")
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include<bits/stdc++.h>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define M 1000000007LL
#define rep(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define sep(i,a,b) for(ll i=(ll)a;i>=(ll)b;i--)
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define sz(v) ((ll)v.size())
#define mp make_pair
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pii pair<ll,ll> 
#define mod 998244353LL
#define mod1 1000000007LL
#define MAXN 1000002
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
set<ll> ss[26];
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    string s,t;
    cin>>s>>t;
    ll i;
    for(i=0;i<s.size();i++){
        ss[s[i]-'a'].insert(i);
    }
    ll cnt=0,ans=0;
    for(i=0;i<t.size();i++){
      auto it=t[i];
      auto x=ss[it-'a'].lower_bound(cnt);
      
      if(x==ss[it-'a'].end()){
        if(cnt==0){
          cout<<-1;
          return 0;
        }
        ans++;
        cnt=0;
        i--;
        continue;
      }
      cnt=*x+1;
    }
    cout<<ans*s.size()+cnt;


    return 0;
}

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

#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl
#define rep(i, n) for (int i = (int)(0); i < (int)(n); i++)
#define repp(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define all(v) v.begin(), v.end()
#define dump(v)                  \
    cerr << #v ":[ ";            \
    for (auto macro_vi : v) {    \
        cerr << macro_vi << " "; \
    }                            \
    cerr << "]" << endl;
using lint       = long long;
const int INF    = 1e9;
const lint LINF  = 1e18;
const lint MOD   = 1e9 + 7;
const double EPS = 1e-10;

int main() {
    int n;
    cin >> n;
    string N = to_string(n);
    vector<vector<int>> cij(10, vector<int>(10, 0));
    for (int x = 1; x <= n; x++) {
        int left = x / pow(10, to_string(x).size() - 1), right = x % 10;
        // d(x) dd(left, right);
        cij[left][right]++;
    }
    int ans = 0;
    for (int a = 1; a <= 9; a++) {
        for (int b = 1; b <= 9; b++) {
            ans += ((cij[a][b] % MOD) * (cij[b][a] % MOD)) % MOD;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
int main(){
  string s;
  cin>>s;
  int ans=0;
  for(int i=0;i<4;i++){
    if(s.at(i)=='+'){
      ans++;
    }
    else{
      ans--;
    }
  }
  cout<<ans<<endl;
}


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

int main() {
  int n, t, a;
  cin >> n >> t >> a;
  
  int place;
  double temp = 600;
  for(int i=1; i<=n; i++) {
    int x;
    double y;
    cin >> x;
    y = abs(a-(t-x*0.006));
    if(temp > y) { 
      temp = y;
      place = i;
    }
  }
  cout << place << endl;
  return 0;
}

Measured memory_bytes: 3632
#include  <iostream>
#include  <algorithm>

using namespace std;

int main()
{
	int x, k;
	cin >> k >> x;

	int l, r;
	r = x + k - 1;
	l = x - k + 1;

	if (l < -1000000)  l = -1000000;
	if (r > 1000000)  r = 1000000;

	while (l <= r) {
		cout << l << ' ';
		l++;
	}
	cout << endl;
}

Measured memory_bytes: 256
#pragma region header
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cctype>
#include <assert.h>
#include <time.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>
#include <cstring>
#include <array>
// ===============================================================
//using系
#pragma region header
using namespace std;
using lint = long long;
using ld = long double;
using ulint = unsigned long long;
const int dx[] = { 1,0,-1,0 };
const int dy[] = { 0,1,0,-1 };
constexpr lint mod = 1000000007;
constexpr long double pi = 3.141592653589793238462643383279;
#pragma endregion
// ========================================================================
//define
#define INF (lint)10000000000000000;
#define mod (int)1000000007
#pragma endregion

int main(void) {
	lint n, k; cin >> n >> k;
	vector<lint> a(n);
	for (int i = 0; i < n; i++) cin >> a[i];
	int r = mod;
	int l = 0;
	while (l + 1 < r) {
		int mid = (r + l) / 2;
		lint cnt = 0;
		for (int i = 0; i < n; i++) {
			cnt += (a[i] + mid - 1) / mid - 1;
		}
		if (cnt > k) l = mid;
		else r = mid;
	}
	cout << r << endl;

	return 0;
}

Measured memory_bytes: 4852
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

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

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

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

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

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

fn main() {
    input! {
        a: i64,
        b: i64,
    }

    let c: i64 = (vec![a.to_string() + &b.to_string()].join("")).parse::<i64>().unwrap();
    for i in 0..c / 2 {
        if i * i == c {
            println!("Yes");
            return;
        }
    }
    println!("No");

}

Measured memory_bytes: 4352
#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() {
    string s;
    cin >> s;

    int indexA = -1;
    int indexZ = 0;
    for (int i = 0; i < s.size(); ++i) {
        if (s.at(i) == 'A' && indexA == -1) indexA = i;
        if (s.at(i) == 'Z') indexZ = i;
    }
    cout << indexZ - indexA + 1 << endl;

}


Measured memory_bytes: 3732
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define MOD 1000000007
#define PI 3.141592653589793
const int INF = 100000000;
int dx[] = {0,1,-1,0,1,-1,1,-1};
int dy[] = {1,0,0,-1,1,-1,-1,1};

int main(){
    int a;
    string s;
    cin >> a >> s;
    cout << (a >= 3200 ? s : "red") << endl;
}


Measured memory_bytes: 256
#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() {
	ios::sync_with_stdio(false);
	cin.tie(0);

	int			n;
	int			max;
	int			second_max;
	cin >> n;
	vector<int>	A(n);
	vector<int>	B(n);

	rep(i, n)
		cin >> A.at(i);
	B = A;
	sort(B.begin(), B.end(), greater<>());
	max = B.at(0);
	second_max = B.at(1);
	rep(i, n)
	{
		if (A.at(i) != max)
			printf("%d\n", max);
			/* cout << max << "\n"; */
		else
			printf("%d\n", second_max);
			/* cout << second_max << "\n"; */
	}
}



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

public class Main {

  public static void main(String[] args) throws IOException {
    
    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      int n = Integer.parseInt(br.readLine());
      int minv = Integer.parseInt(br.readLine());
      int n1   = Integer.parseInt(br.readLine());
      int maxv = n1- minv;
      if ( n1 < minv ) minv = n1;

      for( int i=2,r,mv; i<n; i++) {
        r = Integer.parseInt(br.readLine());
        if ( (mv = r-minv) > maxv ) maxv = mv;
        if ( r < minv ) minv = r; 
      }

      System.out.println(maxv);
    }
  }
}


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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];

    OP(*max_element(ALL(a)) - *min_element(ALL(a)));

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
int main()
{
    fastio;
    int n,i; cin >> n;
    long long int v[n],v1[n+1];
    for(i=0;i<n+1;i++) cin>>v1[i];
    for(i=0;i<n;i++) cin>>v[i];
    long long int ans=0;
    for(i=0;i<n;i++) 
    {
        long long int s = min(v1[i],v[i]);v1[i]-=s;v[i]-=s;ans+=s;
        s=min(v[i],v1[i+1]);v[i]-=s;v1[i+1]-=s;ans+=s;
    }
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 1792
import java.io.*;

public class Main{
    public static void main(String[]args)throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int[] data = new int[10];

        for(int i=0; i<10; i++){
            data[i] = Integer.parseInt(br.readLine());
        }
        for(int i=0; i<3; i++){
            int maxIndex = i;
            for(int k=i+1; k<10; k++){
                if(data[maxIndex] < data[k]){
                    maxIndex = k;
                }
            }
            int tmp = data[maxIndex];
            data[maxIndex] = data[i];
            data[i] = tmp;
        }
        for(int i=0; i<3; i++){
            System.out.println(data[i]);
        }
    }
}

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

int n;
int com1[100], com2[100];	//0????????????, 1?????????, 2?????????

//k???????????????????????????-1???A????????????1???B????????????
int hantei( int a, int b, int k ){
	if( a == 0 && com1[k] == 1 && b == 0 && com2[k] == 1 )
		return 0;
	if( a == 0 && com1[k] == 1 )
		return 1;
	if( b == 0 && com2[k] == 1 )
		return -1;
		
	//a?????????
	if( com1[k] == 1 ){
		if( a == 5 )
			return -1;
		//b?????????
		if( com2[k] == 1 ){
			if( a > b )
				return -1;
			return 1;
		}
		//b???????????????
		if( com2[k] == 0 )
			return -1;
	}
	//a????????????????????????b?????????
	if( com2[k] == 1 && (b == 5 || com1[k] == 0) )
		return 1;
	//????????????
	return 0;
}

int main()
{
	int i, n;
	
	cin >> n;
	for( i = 0; i < n; i++ ){
		string s;
		string t[3] = {"tameru", "kougekida", "mamoru"};
		cin >> s;
		for( int j = 0; j < 3; j++ ){
			if( s == t[j] )
				com1[i] = j;
		}
	}
	for( i = 0; i < n; i++ ){
		string s;
		string t[3] = {"tameru", "kougekida", "mamoru"};
		cin >> s;
		for( int j = 0; j < 3; j++ ){
			if( s == t[j] )
				com2[i] = j;
		}
	}
	
	//????????\??¬????????§???
	int a = 0, b = 0;
	int res;
	for( i = 0; i < n; i++ ){
		res = hantei(a, b, i);
		if( res != 0 )
			break;
		
		if( com1[i] == 0 )
			a++;
		if( com1[i] == 1 )
			a = 0;
		if( com2[i] == 0 )
			b++;
		if( com2[i] == 1 )
			b = 0;
		if( a > 5 )
			a = 5;
		if( b > 5 )
			b = 5;
	}
	
	if( res == -1 )
		cout << "Isono-kun" << endl;
	if( res == 0 )
		cout << "Hikiwake-kun" << endl;
	if( res == 1 )
		cout << "Nakajima-kun" << endl;
	return 0;
}

Measured memory_bytes: 1216
#include<bits/stdc++.h>
using namespace std;
using pi=pair<int,int>;
#define mp make_pair
main(){
  int n;
  string t;
  cin>>n;
  vector<vector<bool>> s(n,vector<bool>(n,false));
  for(int i=0;i<n;++i){
    cin>>t;
    for(int j=0;j<n;++j)if(t[j]=='1')s[i][j]=true;
  }
  int res=-1;
  for(int src=0;src<n;++src){
    bool cont=true;
    vector<int> p(n,-1);
    queue<pi> que,dumq;
    que.push(mp(src,0));
    while(!que.empty()){
      pi q=que.front();que.pop();
      if(p[q.first]<0)p[q.first]=q.second;
      else continue;
      for(int i=0;i<n;++i){
        if(s[i][q.first])que.push(mp(i,q.second+1));
      }
    }
    int maxp=0;
    for(int i=0;cont&&i<n;++i){
      for(int j=0;cont&&j<n;++j){
        if(s[i][j]&&abs(p[i]-p[j])!=1)cont=false;
        else maxp=max(maxp,max(p[i],p[j]));
      }
    }
    if(cont)res=max(res,maxp+1);
  }
  cout<<res;
}

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

int H;
int W;
int po[100][100];
char s[100][100];

int rec(int i, int j){
    if (po[i][j] >= 0) return po[i][j];
    int res;
    if (s[i][j] == '.'){
        if (i < H-1 && j< W-1){
            res = min(rec(i,j+1),rec(i+1,j));
        }else if (i == H-1 && j < W-1){
            res = rec(i,j+1);
        }else if (i < H-1 && j == W-1){
            res = rec(i+1,j);
        }else if (i == H-1 && j == W-1){
            res = 0;
        }
    }else if(s[i][j] == '#'){
        if (i < H-1 && j< W-1){
            int rec_pa,rec_po;
            rec_pa = rec(i,j+1)+1;
            rec_po = rec(i+1,j)+1;
            if (s[i][j+1] == '#') rec_pa = rec(i,j+1);
            if (s[i+1][j] == '#') rec_po = rec(i+1,j);
            res = min(rec_pa,rec_po);
        }else if (i == H-1 && j < W-1){
            if (s[i][j+1] == '#'){
                res = rec(i,j+1);
            }else{
                res = rec(i,j+1)+1;
            }
        }else if (i < H-1 && j == W-1){
            if (s[i+1][j] == '#'){
                res = rec(i+1,j);
            }else{
                res = rec(i+1,j)+1;
            }
        }else if (i == H-1 && j == W-1){
            res = 1;
        }
    }
    return po[i][j] = res;
}

int main()
{
    memset (po, -1,sizeof(po));
    cin >> H >> W;
    for (int i = 0; i < H; i++)
    {
        for (int j = 0; j < W; j++)
        {
            cin >> s[i][j];
        }
    }
    cout << rec(0,0);
}

Measured memory_bytes: 256
class SegmentTree:
    def __init__(self, size, f=lambda x,y : x+y, default=0):
        self.size = 2**(size-1).bit_length()
        self.default = default
        self.dat = [default]*(self.size*2)
        self.f = f

    def update(self, i, x):
        i += self.size
        self.dat[i] = x
        while i > 0:
            i >>= 1
            self.dat[i] = self.f(self.dat[i*2], self.dat[i*2+1])

    def query(self, l, r):
        l += self.size
        r += self.size
        lres, rres = self.default, self.default
        while l < r:
            if l & 1:
                lres = self.f(lres, self.dat[l])
                l += 1

            if r & 1:
                r -= 1
                rres = self.f(self.dat[r], rres)
            l >>= 1
            r >>= 1
        res = self.f(lres, rres)
        return res

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

n = int(input())
a = list(map(int, input().split()))
s = SegmentTree(n, gcd)
for i in range(n):
    s.update(i, a[i])

ans = 1
for i in range(n):
    left = s.query(0, i)
    right = s.query(i+1, n)
    res = gcd(left, right)
    if ans < res:
        ans = res
print(ans)

Measured memory_bytes: 117656
#include<bits/stdc++.h>
using namespace std;
typedef long long hey;
#define hi string
#define pi 3.141592653589793238
#define fi first
#define mod 1000000007
#define se second
#define pb push_back 
#define pop pop_back 
#define bs binary_search
#define mp make_pair
#define ma map< hey,hey >
#define vi vector < hey > 
#define all(v) v.begin(),v.end()
#define qu priority_queue< hey >
#define endl '\n'
#define forn(i, n) for (hey i = 0; i <hey(n); ++i)
#define yorn(i, n) for (hey i = 1; i <=hey(n); ++i)
#define vp vector< pair<hey,hey> >
// lower bound - first element equal to or greater than given value.
// upper bound - first element greater than given value.
hey frog(hey n,hey k,hey a[])
{
    
    hey dp[n];
    dp[0]=0;
    for(int i=1;i<n;i++)
    dp[i]=INT_MAX;
    for(int i=0;i<n-1;i++)
    for(int j=i+1;j<=min((i+k),n);j++)
    {
        dp[j]=min(dp[j],dp[i]+abs(a[j]-a[i]));
    }
    return dp[n-1];
}
void hellogadhi()
{
    hey n,k;
    cin>>n>>k;
    hey a[n];
    forn(i,n)
    cin>>a[i];
    cout<<frog(n,k,a);
}
int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int t=1;
	//cin>>t;
	while(t--)
	{
	    hellogadhi();
	}
	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long int lld;
typedef pair<int,int> pi;
typedef pair<lld,lld> pl;
typedef vector<int> vit;
typedef vector<vit> vitt;
typedef vector<lld> vlt;
typedef vector<vlt> vltt;
typedef vector<pi> vpit;
typedef vector<vpit> vpitt;
typedef long double ld;
#define x first
#define y second
#define all(v) v.begin(), v.end()
#define sz(x) (int)x.size()
#define mk(a,b) make_pair(a,b)
bool isrange(int y,int x,int n,int m){
	 if(0<=y&&y<n&&0<=x&&x<m) return true;
	 return false;
}
int dy[4] = {1,0,-1,0},dx[4]={0,1,0,-1},ddy[8] = {1,0,-1,0,1,1,-1,-1},ddx[8] = {0,1,0,-1,1,-1,1,-1};
int dp[222222];
vector<int> ans;
int main(void){
	int n;
	string s;
	cin >> n >> s;
	lld tot = 0;
	for(int e=0;e<sz(s);e++) if(s[e]=='1') tot++;
	lld f1=0,f2=0,l1=1,l2=1;
	for(int e=sz(s)-1;e>=0;e--){
		if(s[e]=='1'){
			f1 = (f1 + l1)%(tot+1);
			if(tot-1!=0)f2 = (f2 + l2)%(tot-1);
		}
		l1 = (l1*2)%(tot+1);
		if(tot-1!=0)l2 = (l2*2)%(tot-1);
	}
	dp[1] = 1;
	for(int e=2;e<222222;e++){
		int tt = 0,tmp = e;
		while(tmp!=0){
			if(tmp%2) tt++;
			tmp/=2;
		}
		lld rr = (e%tt);
		dp[e] = dp[rr] + 1;
	}
	l1 = 1;
	l2 = 1;
	for(int e=sz(s)-1;e>=0;e--){
		if(s[e]=='0'){
			int lf = (f1 + l1)%(tot+1);
			ans.push_back(dp[lf]+1);
		}else{
			if(tot-1==0) ans.push_back(0);
			else{
				int lf = (f2 - l2 + (tot-1))%(tot-1);
				ans.push_back(dp[lf]+1);
			}
		}
		l1 = (l1*2)%(tot+1);
		if(tot-1!=0) l2 = (l2*2)%(tot-1);
	}
	for(int e=sz(ans)-1;e>=0;e--) printf("%d\n",ans[e]);
	return 0;
}


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

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

	vector < int > a(n);

	for ( int i = 0; i < n; i++ ) {
		cin >> a[i];
	}
	sort( a.begin(), a.end() );
	cout << a[n / 2] - a[n / 2 - 1];
}


Measured memory_bytes: 640
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
 int a, b, c, t;
 
 cin >> a >> b >> c;
 if ( a > b ){t=a; a=b; b=t;}
 if ( a > c ){t=a; a=c; c=t;}
 if ( b > c ){t=b; b=c; c=t;}
 
 cout << a <<" "<< b <<" "<< c << endl;
 
  return 0;
}



Measured memory_bytes: 3052
#include <bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin>>s;

    sort(s.begin(),s.end());

    if(s[0]==s[1]&&s[1]!=s[2]&&s[2]==s[3]){
        cout <<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
}			

Measured memory_bytes: 256
import numpy as np
def resolve():
    N = int(input())
    V = np.array(list(map(int,input().split())))
    Vs = np.sort(V)
    ans = Vs[0] / 2**(N-1)
    for i in range(1,N):
        ans = ans + Vs[i] / 2**(N-i)
    print(ans)
resolve()

Measured memory_bytes: 12504
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <climits>
#include <set>
#include <map>
#include <iomanip>
#include <cassert>
#include <functional>
#include <cstring>

using namespace std;

#define mp make_pair
#define FOR(i, a, b) for(int (i)=a;(i)<(b);++(i))
#define rep(i, n)  FOR(i,0,n)
#define FFOR(i, a, b) for(int (i)=a;(i)>(b);--(i))
#define rrep(i,n) FFOR(i,0,n)
#define vsort(v) sort((v).begin(), (v).end());					//小さい順
#define rvsort(v) sort(v.begin(), v.end(),greater<>());		//大きい順
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define all(c) (c).begin(),(c).end()
#define ll long long
#define lb long double
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vs vector<string>
#define vc vector<char>
#define vvc vector<vector<char>>
#define Print(p) cout<<(p)<<endl
#define F first
#define S second
#define pb push_back
#define mod 1000000007LL
#define INF 1234567890123456
typedef pair<int, int> P;
typedef pair<int, P> PP;

const int maxn =1e5 + 10;

//initialization here
//

//
//initialization finish


// your function is here
//


//
// your function finished



int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	// your code is here
	//
	int n; cin >> n;

	ll ans = 0;
	bool amari = false;
	rep(i, n)
	{
		int a; cin >> a;
		if (amari and a>0)
		{
			a--;
			ans++;
		}
		ans += a / 2;
		amari = a % 2 ? true : false;
	}

	Print(ans);
	//
	// your code finished


	return 0;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;
                                                                                                     
ll MOD=1000000007;                                                                                     
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    ll m,dcnt=0,dsum=0; cin>>m;
    rep(i,m){
        ll d,c; cin>>d>>c;
        dsum+=d*c;
        dcnt+=c;
    }
    cout<<dcnt-1+(dsum-1)/9<<endl;
}

Measured memory_bytes: 3612
#include <stdio.h>

int main(void)
{
    int n,i,result=100000;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        result=result*1.05;
        if(result%1000!=0){
            result=result-result%1000+1000;
        }
    }
    printf("%d\n",result);
    return 0;
}

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

#define INF (i64)(1e18)
#define MOD (i64)(1e9+7)
#define REP(i, n) for(i64 i = 0; i < (n); i++)
#define RREP(i, n) for(i64 i = (n)-1; i >= 0; i--)
#define RANGE(i, a, b) for(i64 i = (a); i < (b); i++)
#define RRANGE(i, a, b) for(i64 i = (b)-1; i >= (a); i--)
#define ALL(v) (v).begin(), (v).end()
#define SIZE(v) ((i64)(v).size())
template<class T> inline void chmax(T &a, const T &b) { if (a < b) a = b; }
template<class T> inline void chmin(T &a, const T &b) { if (a > b) a = b; }

int main() {
  i64 n, a, b;
  cin >> n >> a >> b;
  vector<i64> v(n);
  for(auto& x : v) cin >> x;
  sort(ALL(v), greater<i64>());
  double sum = 0;
  REP(i, a) sum += v[i];
  i64 m1 = 0, m2 = 0;
  REP(i, a) if (v[i] == v[a-1]) m1++;
  RANGE(i, a, n) if (v[i] == v[a-1]) m2++;
  vector<vector<i64>> C(n+1, vector<i64>(n+2));
  C[0][0] = 1;
  RANGE(i, 1, n+1) {
    C[i][0] = 1;
    RANGE(j, 1, i+1) {
      C[i][j] = C[i-1][j-1] + C[i-1][j];
    }
  }
  i64 ans = 0;
  if (a == m1) {
    REP(i, min(b-a, m2)+1) {
      ans += C[m1+m2][m1+i];
    }
  } else {
    ans = C[m1+m2][m1];
  }
  cout << setprecision(16) << sum/a << endl;
  cout << setprecision(16) << ans << endl;
  return 0;
}


Measured memory_bytes: 3816
#include <stdio.h>

int main(void)
{
 int n , k ,count = 0 , tas , i;
  scanf("%d %d",&n,&k);
  
 int x[n];
  for(int i = 0;i < n;i++){
   scanf("%d",&x[i]);
  }
  
  
  
 for(int i = 0;i < n;i++){
   tas = (x[i]<k-x[i]?x[i]:k-x[i]);
   count += tas*2;
 }
  printf("%d",count);
}

   

Measured memory_bytes: 128
#include<stdio.h>
#include<math.h>
#include<string.h>
int main()
{
	int a,b,n;
	while(~scanf("%d%d%d",&a,&b,&n)){
		int count=0;
		for(int i=a;i<=b;i++){
			if(i%n==0){
				count++;
			}
		}
		printf("%d\n",count);
	}
	return 0;
}

Measured memory_bytes: 3208
#include <iostream>
#include <string>
#include <stack>

#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);++i)

using namespace std;

int main(){
  string str;
  cin >> str;
  stack<char> s;
  REP (i, 0, str.size()) {
      if (str[i] == 'S') {
          s.push('S');
      } else {
          if (s.size() > 0 && s.top() == 'S') s.pop();
          else s.push('T');
      }
  }
  cout << s.size() << endl;
  return 0;
}


Measured memory_bytes: 644
import sys

an = []
for i in range(3):
  a = [int(num) for num in input().split()]
  an.append(a)

n = int(input())  

number = []
for i in range(n):
  number.append(int(input()))

for b in number:
  for i in range(3):
    for j in range(3):
      if b == an[i][j]:
        an[i][j] = 0

for i in range(3):
  if an[i][0] == an[i][1] and an[i][0] == an[i][2]:
    print("Yes")
    sys.exit()

for j in range(3):
  if an[0][j] == an[1][j] and an[0][j] == an[2][j]:
    print("Yes")
    sys.exit()    

if an[0][0] == an[1][1] and an[0][0] == an[2][2]:
  print("Yes")
  sys.exit() 

if an[0][2] == an[1][1] and an[0][2] == an[2][0]:
  print("Yes")
  sys.exit() 
    
print("No")

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

int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
	
	ll X;
	cin>>X;
    ll ans = 0;

    ans +=1000*(X/500);
    X%=500;
    ans +=5*(X/5);
    cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 256
//shara's here
//私は大きな男の子
//SPEEEEEEEEEED IS KEEEEEEEEEEY
#include <bits/stdc++.h>
using namespace std;
//fold
typedef double w;
typedef string s;
typedef long long ll;
typedef long double ld;
const ll INF = 1e18 + 10;
const ll MINF = -(1e18 + 10);
#if defined(BANYANYA)
#include "/home/xsharawi/Desktop/cpp/debug.hpp"
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
#define pb push_back
#define speed ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
//endfold
int main(){
	s ss;
	cin>>ss;
	set<char>se;
	int n=(int)ss.size();
	for(int i=0;i<n;i++){
		se.insert(ss[i]);
		}
	if(se.size()==n)cout<<"yes"<<endl;
	else cout<<"no"<<endl;
return 0;}
/*
███████████████████████████████████████████████████
███████████████████████████████████████████████████
██████████████████████████████████▀████████████████
██████████████████████████████████░▀███████████████
██████████████████████████████▌███░░░▀▀████████████
██▀████████████████████▐██████░▐██░░░░░░▀▀█████████
██░████████████████████▐█████▌░██▌▄░░░░▄▄░▄████▀███
█▌░███████████████████▀░█████░░░█░░░▄████░░███▀▐███
█▌░▐██████████████████░░████▌░░░▀░░▀███▀▀░▐███▄████
██░▀██████████████▌▐█▐▄▄████▌░░░░░░░░░░░░░▌████████
███░███████████████▀░▄▄██▀█▐░░░░░░░░░░░░░░▐████████
███▄░██████████████▄░░░░░░▀▀▀░░░░░░░░░░░░░█▐███████
████▄░██████████████████▄▄▄▄▄▄▐▄░░░░░░░░░░░████████
█████▄█████████████████▀▀▀▀▀▀░░░░░░░░░░░░░░████████
████████████████████████▄░░░░░░░░░░░░░░░▄░░████████
██████████████████████████▄▄▄░░░░░░░░░▄█░▄█████████
████████████████████████████████▄░░░░██▄███▀░░▀████
█████████████████████████████▀█████▄███▀▀▀░░▄▄░████
████████████████████████████▀░░▀░░▀▀░░░░▄▄▄██▀░░▀▀█
███████████████████████████▌░░░░░░░░░░░███████░░░▄█
███████████████▄░▀████████▀░░░░░░▀░░░░███████▌░░░██
███▄▄████████████▄░▀██████▄░░░░░█░░░░████████░░░▀▀
░▀█████████████████▄░▀█████░░░░██░░░░▀██████░░░░░▄█
▐█▄▀█████████████████▄░▀████░░░██▌░░░▐████▀░░░░▄███
▐███▄▀▀█████████████████▄░▀▀░░░░▀██▌▄█▀▀░░░▄▄██████
▀▀▀▀▀░░░▀▀▀▀▀░░░▀▀▀▀▀▀▀▀▀▀▀░░░░░░░▀▀░░░░░░▀▀▀▀▀▀▀▀▀
*/


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

int main()
{
    int  a, b;
    cin >> a >> b;
    int h, m, s;
    if ( a < b)
    {
        cout << "a < b" << endl;
    }else if (a > b)
    {
        cout << "a > b" << endl;
    }
    else
    {
        cout << "a == b" << endl;
    }

}


Measured memory_bytes: 3080
#include<stdio.h>
#include <stdlib.h>



int main(){

	//int N, M, *A, *B, i, j, *W, *flag, sum=0, start, end, length, tmp;
	int H, W, A, B, **ans, flag=0, i, j, ans_0=0, ans_W=0;



	scanf("%d %d %d %d", &H, &W, &A, &B);

	ans = (int **)malloc(sizeof(int *)* H);


	for (i = 0; i<H; i++) {
		ans[i] = (int *)malloc(sizeof(int)* W);
	}

	for (i = 0; i < H; i++){
		for (j = 0; j < W; j++){
			ans[i][j] = 0;
		}
	}

	//A = (int *)malloc(N * sizeof(int));
	//B = (int *)malloc(N * sizeof(int));


	for (i = 0; i < B; i++){
		for (j = 0; j < A; j++){
				ans[i][j] = 1;
		}
	}
	for (i = B; i < H; i++){
		for (j = A; j < W; j++){
			ans[i][j] = 1;
		}
	}

	/*
	for (i = 0; i < H; i++){
		ans_0 += ans[i][0];
		ans_W += ans[i][W - 1];
	}
	if (ans_0 > H - ans_0)
		ans_0 = H - ans_0;

	if (ans_W > H - ans_W)
		ans_W = H - ans_W;


	if (ans_0 != B || ans_W != B){
		printf("No\n");
		return 0;
	}
	*/


	for (i = 0; i < H; i++){
		for (j = 0; j < W; j++){
			printf("%d", ans[i][j]);
		}
		printf("\n");
	}

	return 0;

}
    


Measured memory_bytes: 5120
n,k=map(int,input().split()) #足場は0番目からn-1番目までのn個
h=list(map(int,input().split())) #h[i]はi番目の足場の高さ
DP=[10**9+1]*n
DP[0]=0 #0番目の足場に到達するのに必要なコストは0
DP[1]=abs(h[1]-h[0]) 

#j番目からi番目まで飛ぶ場合の追加コストはabs(h[i]-h[j])、ただしi-1<=j<=i-k

for i in range(2,n):
    for j in range(max(0,i-k),i):
        DP[i]=min(DP[i],DP[j]+abs(h[i]-h[j]))
print(DP[-1])

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

using namespace std;

int main(){
  long long int A,B,V,W,T;
  cin >> A >> V >> B >> W >> T;
  if((V-W)*T >= abs(A-B)){
    cout << "YES" << endl;
  }else{
    cout << "NO" <<endl;
  }
  return 0;
}


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

#define MAXN 100100
int n,a[MAXN][3],dp[MAXN][3],k;

int main (){
    cin >> n;
    for (int i=0;i<n;++i){
        for (int j=0;j<3;++j){
            cin >> a[i][j];
        }
    }
    for (int i=0;i<n;++i){
        for (int j=0;j<3;++j){
            if (i==0){
                dp[i][j]=a[i][j];
            }
            else {
                dp[i][j]=max(dp[i-1][(j+1)%3],dp[i-1][(j+2)%3])+a[i][j];
            }
        }
    }
    cout << max(max(dp[n-1][0],dp[n-1][1]),dp[n-1][2]);
    return 0;
}


Measured memory_bytes: 2560
#include <iostream>


int bubble_sort(int arr[], int N);
void input_ex(int arr[], int *N);
void output_ex(int arr[], int N, int count);

int main()
{
    int arr[100];
    int N;
    int count = 0;

    input_ex(arr, &N);
    count = bubble_sort(arr, N);
    output_ex(arr, N, count);

    return 0;
}

int bubble_sort(int arr[], int N)
{
    int count = 0;
    int flag = 1;
    int v;

    while (flag){
        flag = 0;
        for (int j = N - 1; 0 < j; --j){
            if (arr[j] < arr[j - 1]){
                v = arr[j - 1];
                arr[j - 1] = arr[j];
                arr[j] = v;
                flag = 1;
                count++;
            }
        }
    }
    return count;
}

void input_ex(int arr[], int *N)
{
    std::cin >> *N;

    for (int x = 0; x < *N; ++x){
        std::cin >> arr[x];
    }

    return;
}

void output_ex(int arr[], int N, int count){
    for (int x = 0; x < N; ++x){
        if (x > 0){
            std::cout << " ";
        }
        std::cout << arr[x];
    }
        std::cout << std::endl;
        std::cout << count << std::endl;

}




Measured memory_bytes: 3100
#include <iostream>
#include <deque>
#include <cstdio>

using namespace std;
int a[200000];
deque<int> result;

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

    if (n % 2 != 0) {
        result.push_back(a[0]);
        for (int i = 1; i < n; i +=2) {
            result.push_back(a[i]);
            result.push_front(a[i + 1]);
        }
    }
    else if (n % 2 == 0) {
        for (int i = 0; i < n; i += 2) {
            result.push_back(a[i]);
            result.push_front(a[i + 1]);
        }
    }

    for (int i = 0; i < n; i++) {
        cout << result[i] << " ";
    }

    return 0;
}

Measured memory_bytes: 3840
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < int(n); i++)
using namespace std;
using ll = long long;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

class BIT {
  vector<long long> dat;
public:
  BIT(int n) : dat(n + 1, 0LL) {}
  void add(int i, long long x) {
    i++;
    while (i < (int)dat.size()) {
      dat[i] += x;
      i += i & -i;
    }
  }
  long long sum(int r) {
    long long res = 0;
    while (r > 0) {
      res += dat[r];
      r -= r & -r;
    }
    return res;
  }
};

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, q;
  cin >> n >> q;
  BIT bit(n);
  rep(i, n) {
    ll a;
    cin >> a;
    bit.add(i, a);
  }
  rep(_, q) {
    int que;
    cin >> que;
    if (que) {
      int l, r;
      cin >> l >> r;
      cout << bit.sum(r)-bit.sum(l) << '\n';
    } else {
      int p;
      ll x;
      cin >> p >> x;
      bit.add(p, x);
    }
  }
  return 0;
}

Measured memory_bytes: 8256
function Main(s){
  s = s.split("\n");
  var n = s[0].split(" ").map(a=>+a);
  var m = n[1];
  n = n[0];
  var a = [];
  for(var i = 0; i < m; i++){
    a[i] = s[i+1].split(" ").map(a=>+a);
  }
  a.sort((a,b)=>a[1]-b[1]);
  var ans = 0;
  var l = 0, r = 0;
  for(i = 0; i < m; i++){
    if(r <= a[i][0]){ans++; r = a[i][1];}
  }
  console.log(ans);
}
Main(require("fs").readFileSync("/dev/stdin","utf8"));

Measured memory_bytes: 49760
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <bits/stdc++.h>
#define ll long long
using namespace std;
void put(int x){
	if(x<0) {
		putchar('-');
		x*=-1;
	}
	if(x==0) {
		putchar('0');
	}
	int num=0;
	char c[15];
	while(x) {
		c[++num]=(x%10)+48;
		x/=10;
	}
	while(num) {
		putchar(c[num--]);
	}
	putchar('\n');
}
inline void in(int &x){
	char ch=getchar();
	int flag=1;
	while(!(ch>='0'&&ch<='9')) {
		if(ch=='-')
			flag*=-1;
		ch=getchar();
	}
	x=ch-'0';
	ch=getchar();
	while(ch>='0'&&ch<='9') {
		x=((x<<3)+(x<<1))+ch-'0';
		ch=getchar();
	}
	x*=flag;
}
int n,n1,sum;
int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	in(n);n1=n;
	while(n1){
		sum+=n1%10;n1/=10;
	}
	if(n%sum==0)printf("Yes\n");
	else printf("No\n");
	return 0;
}


Measured memory_bytes: 384
#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

int main() {
  int n;
  cin >> n;
  n %= 10;

  switch (n) {
    case 2:
    case 4:
    case 5:
    case 7:
    case 9:
      cout << "hon" << endl;
      break;
    case 0:
    case 1:
    case 6:
    case 8:
      cout << "pon" << endl;
      break;
    default:
      cout << "bon" << endl;
      break;
  }
  return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define x first
#define y second

using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
const ll INF=0x3f3f3f3f;
const ll MOD=998244353;
const ll MAX=10005;
ll ans=0,n,k1,k2;
ll fact[MAX],finv[MAX],cache[MAX];
char a[MAX],b[MAX];
ll power(ll x,ll y){
    if(y==0) return 1;
    ll t=power(x,y/2);
    if(y%2) return t*t%MOD*x%MOD;
    return t*t%MOD;
}
int main(){
    scanf(" %s %s",a,b);
    n=strlen(a);
    for(ll i=0;i<n;i++) {
        if(a[i]==b[i]&&a[i]=='1') k2++;
        else if(a[i]!=b[i]) k1++;
    }
    k1/=2;
    fact[0]=1;
    for(ll i=1;i<=n;i++) fact[i]=i*fact[i-1]%MOD;
    for(ll i=0;i<=n;i++) finv[i]=power(fact[i],MOD-2);
    for(ll i=0;i<=k1;i++) {
        cache[i]=power(k1-i,k1)*fact[k1]%MOD*finv[k1-i]%MOD*finv[i]%MOD;
        if(i%2) cache[i]=(MOD-cache[i])%MOD;
    }
    for(ll i=0;i<=k2;i++){
        ll t=0;
        for(ll i=0;i<=k1;i++){
            t=(t+cache[i])%MOD;
            cache[i]=(cache[i]*(k1-i))%MOD;
        }
        //printf("%lld %lld\n",t,t*fact[k1]%MOD*fact[k2]%MOD*fact[k1+k2]%MOD*finv[k1+i]%MOD);
        ans+=t*fact[k1]%MOD*fact[k2]%MOD*fact[k1+k2]%MOD*finv[k1+i]%MOD;
        ans%=MOD;
    }
    printf("%lld\n",ans);
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <boost/range.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/algorithm_ext.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>
using namespace std;
constexpr char nl = '\n';
using ll = long long;
using boost::irange;
namespace rng {
    using namespace boost;
    using namespace boost::range;
    using namespace boost::adaptors;
}

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

template<class C> auto operator>>(istream& in, C& c) -> typename enable_if<!is_void<decltype(c.begin())>::value && !is_same<C, string>::value, istream&>::type {
    for (auto& v : c) { in >> v; } return in; }
template<class C> auto operator<<(ostream& out, const C& c) -> typename enable_if<!is_void<decltype(c.begin())>::value && !is_same<C, string>::value, ostream&>::type {
    int i = 0; for (const auto& v : c) { if (i++) { out << ' '; } out << v; } return out; }
template<size_t N, class T, class R> using when_last = typename enable_if<N == tuple_size<remove_reference_t<T>>::value - 1, R>::type;
template<size_t N, class T, class R> using when_init = typename enable_if<N != tuple_size<remove_reference_t<T>>::value - 1, R>::type;
template<size_t N = 0, class T> auto operator>>(istream& in, T&& t) -> when_last<N, T, istream&> { return in >> get<N>(t); }
template<size_t N = 0, class T> auto operator>>(istream& in, T&& t) -> when_init<N, T, istream&> { return operator>><N + 1>(in >> get<N>(t), forward<T>(t)); }
template<size_t N = 0, class T> auto operator<<(ostream& out, const T& t) -> when_last<N, T, ostream&> { return out << get<N>(t); }
template<size_t N = 0, class T> auto operator<<(ostream& out, const T& t) -> when_init<N, T, ostream&> { return operator<<<N + 1>(out << get<N>(t) << ' ', t); }

#ifdef LOCAL
constexpr auto color_s_ = "\033[2m\033[33m", color_e_ = "\033[0m";
template<class T> void trace_(const T& v) { cerr << v; }
template<class T> void trace_(const vector<vector<T>>& m) { cerr << "\n"; for (const auto& v : m) { trace_(v); cerr << "\n"; } }
template<class T> void trace_(const char* s, const T& v) { cerr << color_s_ << s << "="; trace_(v); cerr << color_e_ << "\n"; cerr.flush(); }
template<class T, class... Ts> void trace_(const char* s, const T& v, const Ts&... vs) { cerr << color_s_; for (; *s != ','; ++s) { cerr << *s; } cerr << "="; trace_(v); cerr << ","; trace_(++s, vs...); }
#define TRACE(...) trace_(#__VA_ARGS__, __VA_ARGS__)
#else
#define TRACE(...)
#endif

int main() {
    double r;
    cin >> r;
    cout << (2 * M_PI * r) << nl;
}


Measured memory_bytes: 3792
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>

using namespace std;

class linkedlist
{
public:
	int data;
	linkedlist* next;
	linkedlist* back;
	linkedlist(int n)
	{
		data = n;
		next = nullptr;
		back = nullptr;
	}
	linkedlist(int n, linkedlist* b)
	{
		data = n;
		next = nullptr;
		back = b;
	}
	~linkedlist()
	{
		if (back && next)
		{
			linkedlist* t = this->back;
			this->back->next = this->next;
			this->next->back = t;
			return;
		}
		if (back && next == nullptr)
		{
			this->back->next = nullptr;
			return;
		}
		if (back == nullptr && next)
		{
			this->next->back = nullptr;
		}
	}
};

class Llist
{
public:
	linkedlist* now;
	linkedlist* last;
	Llist()
	{
		now = nullptr;
		last = nullptr;
	}
	~Llist()
	{
		//arekaku
	}
	void _insert(int n)
	{
		linkedlist* t = new	linkedlist(n);
		if (now == nullptr)
		{
			now = t;
			last = t;
		}
		else
		{
			t->back = now;
			now->next = t;
			now = t;
		}
	}
	void _delete(int n)
	{
		linkedlist* t = now;
		while (t)
		{
			if (t->data != n)
			{
				t = t->back;
				continue;
			}
			else
			{
				if (t == now)
				{
					now = (now->back) ? now->back : nullptr;
				}
				if (t == last)
				{
					last = (last->next) ? last->next : nullptr;
				}
				delete t;
				break;
			}
		}
	}
	void _deleteFirst()
	{
		if (!now->back)
		{
			delete now;
			now = nullptr;
			last = nullptr;
			return;
		}
		linkedlist* t = now->back;
		delete now;
		now = t;
	}
	void _deleteLast()
	{
		if (!now->back)
		{
			delete now;
			now = nullptr;
			last = nullptr;
			return;
		}

		if (last->next)
		{
			last = last->next;
			delete last->back;
		}
		else
		{
			delete last;
			last = nullptr;
			now = nullptr;
		}
	}
};


int main()
{
	//ios::sync_with_stdio(false);
	Llist* l = new Llist();
	int n;
	scanf("%d",&n);
	for (int i = 0; i < n; i++)
	{
		string s;
		int t;
		cin >> s;
		//scanf("%s", s);
		if (s == "deleteFirst")
		{
			l->_deleteFirst();
			continue;
		}
		if (s == "deleteLast")
		{
			l->_deleteLast();
			continue;
		}
		scanf("%d", &t);
		if (s == "insert")
		{
			l->_insert(t);
			continue;
		}
		if (s == "delete")
		{
			l->_delete(t);
			continue;
		}

	}

	linkedlist* t = l->now;
	while (t)
	{
		//cout << t->data;
		printf("%d", t->data);
		if (t->back == nullptr)
		{
			printf("\n");
		}
		else
		{
			printf(" ");
		}
		t = t->back;
	}
	delete l;
	return 0;
}

Measured memory_bytes: 34440
#include "bits/stdc++.h"
#define int long long
#define range(i, a, b) for(auto i = a; i < b; i++)
#define rep(i, a) range(i, 0, a)
#define all(a) (a).begin(),(a).end()
using namespace std;
const int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
const int MOD = 1000000007;
using vi = vector <int>;
using vvi = vector <vi>;


class Dijkstra{
private:
	struct edge{int to, cost;};
	int V;
	vector <vector <edge>> G;
	vector <int> d;
	priority_queue <pair <int, int>, vector <pair <int, int>>, greater <pair <int, int>>> que;

public:
	Dijkstra(int v, int maxv){
		V = v;
		G = vector <vector <edge>> (maxv);
		d = vector <int> (maxv);
	}

	void addEdge(int s, int t, int c){
		G[s].push_back({t, c});
	}

	int dist(int n){
		return d[n];
	}

	void execute(int s){
		for (int i = 0; i < V; i++)
			d[i] = INF;
		d[s] = 0;
		que.push({0 , s});
		while(!que.empty()){
			pair <int, int> p = que.top(); que.pop();
			int v = p.second;
			if(d[v] < p.first)continue;
			for(int i = 0; i < G[v].size(); i++){
				edge e = G[v][i];
				if(d[e.to] > d[v] + e.cost){
					d[e.to] = d[v] + e.cost;
					que.push({d[e.to], e.to});
				}
			}
		}
	}
};

signed main(){
	int v, e, r;
	cin >> v >> e >> r;
	Dijkstra dijkstra(v, 100000);

	rep(i, e){
		int s, t, d;
		cin >> s >> t >> d;
		dijkstra.addEdge(s, t, d);
	}

	dijkstra.execute(r);

	rep(i, v){
		if(dijkstra.dist(i) == INF)
			cout << "INF" << endl;
		else
			cout << dijkstra.dist(i) << endl;
	}
}

Measured memory_bytes: 19560
a,b,x=map(int,input().split())
import math
t_base=math.atan(b/a)
def judge(t):
    global a,b,x
    if t<=t_base:
        target=(a**2)*b-(a**3/math.tan(math.pi/2-t))/2
        if x<=target:
            return False
        else:
            return True
    else:
        target=(b**2/math.tan(t))*a/2
        if x<=target:
            return False
        else:
            return True

t_min=0
t_max=math.pi/2
for _ in range(10**4):
    t_mid=(t_max+t_min)/2
    if judge(t_mid):
        t_max=t_mid
    else:
        t_min=t_mid
print(t_mid*180/math.pi)

Measured memory_bytes: 3064