akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=(a); i<=(b); i++)
#define f first
#define s second
#define mp make_pair
#define pb push_back
using namespace std;

typedef long long ll;

signed main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n,d;
    double a,b;
    cin >> n >> d;
    int ans=0;
    REP(i,0,n-1){
        cin >> a >> b;
        ll c=ceil(sqrt(a*a+b*b));
        ans+=(c<=d);
    }
    cout << ans;
    return 0;
}

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

int main() {

	int n; cin >> n;
	string s; cin >> s;
	vector<int> accumW(n + 1, 0);
	vector<int> accumE(n + 1, 0);
	for (int i = 1; i <= n; i++) {
		accumW[i] += accumW[i - 1];
		accumE[i] += accumE[i - 1];
		if (s[i - 1] == 'W') accumW[i] += 1;
		if (s[i - 1] == 'E') accumE[i] += 1;
	}
	int ans = 2147483647;
	for (int i = 1; i <= s.size(); i++) {
		int tmp = 0;
		tmp += accumW[i - 1];
		tmp += accumE[n] - accumE[i];
		ans = min(ans, tmp);
	}
	cout << ans << endl;
	return 0;
}

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

#include <vector>
using namespace std;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define deg_to_rad(deg) (((deg) / 360) * 2 * M_PI)
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)

typedef long long ll;

int main() {
    int N;
    int cnt = 0;
    cin >> N;
    vector<int> A(N + 1);
    rep(i, N) cin >> A[i + 1];

    for (int i = 1; i < N + 1; i++) {
        if (i % 2 == 0) continue;
        if (A[i] % 2 == 1) cnt++;
    }
    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 3624
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

a=int(input())
b=int(input())
h=int(input())
print((a+b)*h//2)

Measured memory_bytes: 38256
#include<iostream>
#include<string>
#include<math.h>
#include<algorithm>

using namespace std;

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


	long long N = 0;
	cin >> N;

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

	long long ans = 0;
	long long MIN = 1000000000;
	long long MAX = 0;

	for (int i = 1; i <= N; i++) {
		MIN = min(MIN, A[i]);
		MAX = max(MAX, A[i]);
	}

	cout << (MAX - MIN) << endl;


}

Measured memory_bytes: 256
const input=require('fs').readFileSync('/dev/stdin','utf8').split(/[\s]/);let input_i=-1;const tn=():number=>{input_i++;return Number(input[input_i])};const tnn=(n:number):number[]=>{const a=[];for(let i=0;i<n;i++){a.push(tn())}return a};const ts=():string=>{input_i++;return String(input[input_i])};const tss=(n:number):string[]=>{const a=[];for(let i=0;i<n;i++){a.push(ts())}return a};const to=(...arg)=>{console.log(...arg)};const abs=(a)=>{return Math.abs(a)};const min=(...a)=>{return Math.min(...a)};const max=(...a)=>{return Math.max(...a)};const floor=(a)=>{return Math.floor(a)};const ceil=(a)=>{return Math.ceil(a)};const asc=(ar:number[])=>{const t=[...ar];return ar.sort((a,b)=>{return a-b})};const desc=(ar:number[])=>{const t=[...ar];return t.sort((a,b)=>{return b-a})};const sw=(a,arr:any[],op:'=='|'>='|'>'|'<='|'<'='==')=>{for(let i=0;i<arr.length-1;i+=2){if(eval(a+op+arr[i])){return arr[i+1]}}return arr[arr.length-1]};const near=(n:number,arr:number[]):number=>{let ne=arr[0],ni=0;for(let i=1;i<arr.length;i++){if(Math.abs(n-ne)>Math.abs(n-arr[i])){ne=arr[i];ni=i}}return ni};const deduplicate=(a:any[]):any[]=>{return Array.from(new Set(a))};const gcd=(x,y)=>{while(y){[x,y]=[y,x%y]}return x};const sum=(arr)=>{return arr.reduce((a,b)=>a+b);};const isPrime=(n:number):boolean=>{if(n<2)return false;const suq=Math.sqrt(n);for(let i=2;i<=suq;i++){if(n%i==0){return false;}}return true;};
const main=()=>{
  let s=ts()
  to(String.fromCharCode(s.charCodeAt(0)+1))
}
main()


Measured memory_bytes: 7372
#include<iostream>

using namespace std;

int main(int argc, const char** argv) {
    int arr[100];
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>arr[i];
    }
    int num_of_odd = 0;
    for(int i=0;i<n;i+=2){
        if(arr[i]&1){
            num_of_odd++;
        }
    }
    cout<<num_of_odd;

    return 0;
}

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

int cnt = 0;

void insertionSort(int A[], int n, int g) {
    for (int i = g; i < n; ++i) {
        int 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;
    }
}

int main() {
    int n, A[1000000];
    cin >> n;
    for (int i = 0; i < n; ++i) cin >> A[i];

    int m = 1, G[20];
    G[0] = n / 2;
    for (int i = 0; G[i] > 1; ++i) {
        G[i + 1] = G[i] / 2;
        ++m;
    }
    for (int i = 0; i < m; ++i) insertionSort(A, n, G[i]);

    cout << m << endl;
    for (int i = 0; i < m; ++i) {
        if (i) cout << ' ';
        cout << G[i];
    }
    cout << endl << cnt << endl;
    for (int i = 0; i < n; ++i) cout << A[i] << endl;

    return 0;
}


Measured memory_bytes: 6896
#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];
  }
  
  int MAX = 0;
  
  for (int i = 0; i < N; i++) if (MAX < A[i]) MAX = A[i];
  
  int count = 0;
  
  for (int i = 0; i < N; i++) if (A[i] == MAX) count++;
  
  int m = 0;
  
  if (count == 1) {
    for (int i = 0; i < N; i++) {
      if (A[i] < MAX && m < A[i]) m = A[i];
    }
  }
  
  for (int i = 0; i < N; i++) {
    
    if (A[i] == MAX && count == 1) cout << m << endl;
    
    else cout << MAX << endl;
  
  }
  
  
}

Measured memory_bytes: 2432
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(long long i=0;i<n;i++)
#define REP1(i,n) for(long long i=1;i<=n;i++)
#define REPB(i,n) for(long long i=((n)-1);i>=0;i--)
#define REPB1(i,n) for(long long i=(n);i>0;i--)
#define ITE(arr) for(auto ite=(arr).begin();ite!=(arr).end();ite++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define YNPRT(b) cout<<((b)?"Yes":"No")<<endl
#define REV(arr) reverse(ALL(arr))
typedef long long ll;
typedef pair<int,int> pii;
//---------------------
#define MAXN 100000
//---------------------
ll nums,numc;
int main(){
	cin>>nums>>numc;
	numc>>=1;
	cout<<((nums>numc)?(numc):((nums+numc)>>1))<<endl;
	return 0;
}

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

//#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<(o)<<" ";}
#define dumpl(o) if(DBG){cerr<<#o<<" "<<(o)<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }

signed main() {
	int N, F; cin >> N >> F;
	using P = pair<string, string>;
	map<P, int> mp;
	rep(i, 0, N) {
		int M; cin >> M;
		vector<string> v(M); rep(j, 0, M) { cin >> v[j]; }
		sort(all(v));
		rep(j, 0, M)rep(k, j + 1, M)mp[P(v[j], v[k])]++;
	}
	vector<string> ans;
	for (auto it = mp.begin(); it != mp.end(); it++) {
		if (it->second >= F) {
			ans.emplace_back(it->first.first + " " + it->first.second);
		}
	}
	cout << ans.size() << endl;
	rep(i, 0, ans.size()) {
		cout << ans[i] << endl;
	}
	return 0;
}

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

int main() {
    int k, s, ans = 0;
    cin >> k >> s;
    for(int x=0; x<=k; x++) {
        for(int y=0; y<=k; y++) {
            if(s-x-y<=k && s-x-y>=0) ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
<?php
$input = explode(' ', trim(fgets(STDIN)));

$a = (int)$input[0];
$b = (int)$input[1];

$max = max($a,$b);
if ($max === $a) {
	$max2 = max($max-1, $b);
}else{
	$max2 = max($max-1, $a);
}
echo $max + $max2;

Measured memory_bytes: 4728
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define REP(i, n) for(int i = 1; i < (int)(n); ++i)
using namespace std;

int main() {
    int N, K;
    string S;
    cin >> N >> K >> S;
    
    int ans = 0;
    rep(i, N) {
        if (i == 0 && S[i] == 'L') continue;
        if (i == N - 1 && S[i] == 'R') continue;
        if (S[i] == 'L') {
            if (S[i - 1] == 'L') ++ans;
        } else {
            if (S[i + 1] == 'R') ++ans;
        }
    }
    cout << min(N - 1, ans + 2 * K) << endl;
    return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main(){
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int n,k; cin>>n>>k;
    vector<int> v(n+1,0);
    int d,x;
    for(int i=1;i<=k;i++){
        cin>>d;
        for(int j=1;j<=d;j++){
            cin>>x; v[x]++;
        }
    }
    int c=0;
    for(int i=1;i<=n;i++){
        if(v[i]==0) c++;
    }
    cout<<c;
    return 0;
}

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

void a()
{
    int n;
    cin >> n;
    string n_str = to_string(n);
    for (int i = 0; i < 3; i++)
    {
        if (n_str[i] == n_str[i + 1])
        {
            cout << "Bad";
            return;
        }
    }
    cout << "Good";
    return;
}
void b()
{
    int n, l;
    cin >> n >> l;
    int lmax = l + n - 1;
    int lmin = l;
    int sum = (l - 1) * n + n * (n + 1) / 2;
    if (lmax > 0 && lmin < 0)
    {
    }
    else if (lmax <= 0)
        sum -= lmax;
    else
        sum -= lmin;
    cout << sum;
    return;
}
long long int unable_to_div(long long int l, long long int c, long long int d)
{
    long long int x = l / c;
    long long int y = l / d;
    long long int z = l / (c * d);
    return l - x - y + z;
}
void c()
{
    long long int a, b, c, d;
    cin >> a >> b >> c >> d;
    long long int l = a - 1;
    long long int m = b;
    long long int sum_l = unable_to_div(l, c, d);
    long long int sum_m = unable_to_div(m, c, d);
    cout << sum_m - sum_l;
}
int main(void)
{
    b();
    return 0;
}

Measured memory_bytes: 256
S = input()
K = int(input())
key = []
if S.count("1") == len(S):
  print(1)
else:
  for i in range(len(S)):
    if S[i] != "1":
      key.append([i,S[i]])
      break
  if K - 1 < key[0][0]:
    print(1)
  else:
    print(key[0][1])



Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main(){
	string s;
	cin >> s;
	string a="KIHBR...";
	int flag = 0;
	int x = 0;
	int ans = 1;
	for(int i = 0; i < s.size(); i++){
		if(s[i] == 'A'){
			if(flag == 0){
				flag = 1;
			}else ans = 0;
		}else
		if(s[i] == a[x]){
			if(x == 0 || x == 1)flag = 1;
			else flag = 0;
			x++;
		}else
		ans = 0;
	}
	if(ans && x ==5)cout <<"YES"<<endl;
	else cout <<"NO"<<endl;
}

Measured memory_bytes: 256
// Problem : B - Tag
// Contest : AtCoder - Tokio Marine & Nichido Fire Insurance Programming Contest 2020
// URL : https://atcoder.jp/contests/tokiomarine2020/tasks/tokiomarine2020_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
using namespace std;
typedef unsigned int ui;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef complex<double> cd;
typedef pair<int,int> pii;
typedef pair<int,ll > pil;
typedef pair<ll ,int> pli;
typedef pair<ll ,ll > pll;
typedef vector<int> vi;
typedef vector<ll > vl;
#define pque priority_queue
#define rep(i,l,r) for(i=(l);i<=(r);++i)
#define per(i,l,r) for(i=(l);i>=(r);--i)
#define REP(i,l,r) for(i=(l);i< (r);++i)
#define PER(i,l,r) for(i=(l);i> (r);--i)
#define mp make_pair
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define fi first
#define se second
#define bugf(...) fprintf(stderr,__VA_ARGS__);
#define bugs(x) cerr<<"    "<<(x);
#define bugx(x) cerr<<"    "<<(#x)<<" = "<<(x);
#define bugl cerr<<"\n";
#define bugL cerr<<"\n================================================\n";
#define bugt bugx(clock());bugl;
template<class IT>inline void cmax(IT &a,IT b){if(a<b)a=b;}
template<class IT>inline void cmin(IT &a,IT b){if(b<a)a=b;}
template<class IT>inline bool bmax(IT &a,IT b){if(a<b){a=b;return true;}else return false;}
template<class IT>inline bool bmin(IT &a,IT b){if(a>b){a=b;return true;}else return false;}
//const int N=;

inline void ac(){
	ll a,v,b,w,t;
	scanf("%lld%lld%lld%lld%lld",&a,&v,&b,&w,&t);
	a-=b;
	if(a<0ll)a=-a;
	if((v-w)*t>=a)puts("YES");else puts("NO");
}
int main(){
	//freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
	
	ac();
	return 0;
}
#undef pque
#undef rep
#undef per
#undef REP
#undef PER
#undef mp
#undef pb
#undef pf
#undef pob
#undef pof
#undef fi
#undef se
#undef bugs
#undef bugx
#undef bugl

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

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define ll long long
#define ll1 1ll
#define ONE 1ll
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF =
sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>
istream &operator>>(istream &is, pair<T, S> &p) {
	is >> p.first >> p.second;
	return is;
}
template <typename T, typename S>
ostream &operator<<(ostream &os, pair<T, S> &p) {
	os << p.first << " " << p.second;
	return os;
}

template <typename T> void printvv(const vector<vector<T>> &v) {
	cerr << endl;
	rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
		if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
			cerr << "INF";
		}
		else
			cerr << v[i][j];
		cerr << (j == v[i].size() - 1 ? '\n' : ' ');
	}
	cerr << endl;
}
/*
typedef __int128_t Int;
std::ostream &operator<<(std::ostream &dest, __int128_t value) {
std::ostream::sentry s(dest);
  if (s) {
	__uint128_t tmp = value < 0 ? -value : value;
	char buffer[128];
	char *d = std::end(buffer);
	do {
	  --d;
	  *d = "0123456789"[tmp % 10];
	  tmp /= 10;
	} while (tmp != 0);
	if (value < 0) {
	  --d;
	  *d = '-';
	}
	int len = std::end(buffer) - d;
	if (dest.rdbuf()->sputn(d, len) != len) {
	  dest.setstate(std::ios_base::badbit);
	}
  }
  return dest;
}

__int128 parse(string &s) {
  __int128 ret = 0;
  for (int i = 0; i < s.length(); i++)
	if ('0' <= s[i] && s[i] <= '9')
	  ret = 10 * ret + s[i] - '0';
  return ret;
}
*/

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T> bool chmax(T &a, const T &b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
template <class T> bool chmin(T &a, const T &b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}

signed main(signed argc, char *argv[]) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(12);

	int N, M; cin >> N >> M;
	int K; cin >> K;
	vector<int>A(N); rep(i, 0, N) { cin >> A[i]; }
	vector<vector<int>>dp(K + 1, vector<int>(N + 2));
	rep(k, 1, K + 1) {
		rep(i, 0, N) {
			dp[k][i] = dp[k - 1][i + 1] + (K - k + 1) * A[i];
		}
		deque<int>deq;
		rep(i, 0, N + M - 1) {
			if (i < N) {
				while (deq.size() and dp[k][deq.back()] <= dp[k][i])deq.pop_back();
				deq.push_back(i);
			}
			if (i - M + 1 >= 0) {
				dp[k][i - M + 1] = dp[k][deq.front()];
				if (deq.front() == i - M + 1)deq.pop_front();
			}
		}
	}
	cout << *max_element(all(dp[K])) << endl;

	return 0;
}


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

public class Main {
	static FastReader f = new FastReader();
	static PrintWriter out = new PrintWriter(System.out);

	public static void main(String[] args) {
		long n = f.nextInt(), x = f.nextInt(), t =  f.nextInt();
		out.println(((n-1)/x+1)*t);
		out.close();
	}
		

	static class FastReader {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st;

		String next() {
			while(st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch(IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		String nextLine() {
			String str = "";

			try {
				str = br.readLine();
			} catch(IOException e) {
				e.printStackTrace();
			}
			return str;
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}
	}
}

Measured memory_bytes: 32976
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,i,x;
  cin>>n;
  vector<int> a(n);
  set<int> b;
  for(i=0;i<n;i++) cin>>a.at(i);
  x=1;
  while(x!=2&&!b.count(x)){
    b.insert(x);
    x=a.at(x-1);
  }
  if(x==2) cout<<b.size()<<endl;
  else cout<<-1<<endl;
}

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

typedef pair<int,int> P;
#define ll long long
#define ld long double
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define sz(x) ((int)(x).size())
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

template <class T>
T PowMod(T n, T m)
{
    if (m == 0)
    {
        return 1;
    }
    if (m % 2 == 0)
    {
        T temp = PowMod(n, m / 2);
        return temp * temp;
    }
    return n * PowMod(n, m - 1) % MOD;
}

template <class T>
T inv_num(T num)
{
    return PowMod(num, MOD - 2);
}
template <class T>
T COM(T n, T a)
{
    T X, Y;
    X = 1;
    Y = 1;
    rep(i, a)
    {
        X *= (n - i) % MOD;
        Y *= (a - i) % MOD;
    }
    return X * (inv_num(Y)) % MOD;
}
int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    sort(a.begin(),a.end());
    int x,y;
    x = a[n-1];
    int mn = INF;
    rep(i,n-1)
    {
        if(mn > abs(2*a[i]-x))
        {
            mn = abs(2 * a[i] - x);
            y = a[i];
        }
    }
    cout << x << " " << y<< endl;

}

Measured memory_bytes: 640
import java.util.Scanner;

// DP 動的計画法
public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int N = Integer.parseInt(scanner.next());
        int K = Integer.parseInt(scanner.next());

        int[] h = new int[N];
        for (int i = 0; i < N; i++) {
            h[i] = Integer.parseInt(scanner.next());
        }

        scanner.nextLine();

        int[] dp = new int[N];

        // 最小化問題なのでMaxValueで初期化
        for (int i = 0; i < N; ++i) dp[i] = Integer.MAX_VALUE;

        // 足場0 のコストは0
        dp[0] = 0;

        for (int i = 1; i < N; ++i) {
            for (int j = 1; j <= K; j++) {
                if (i - j >= 0) {
                    dp[i] = Math.min(dp[i], dp[i - j] + Math.abs(h[i] - h[i - j]));
                }
            }
        }

        System.out.println(dp[N - 1]);
    }
}


Measured memory_bytes: 47540
import sys
N=int(input())

H=[int(x) for x in input().rstrip().split()]
flag=0
mi=-1
for i in range(N-1):

  if H[i]<=H[i+1] and mi<=H[i]:
    mi=max(mi,H[i]-1)
    continue
  elif H[i+1]<H[i]:
    H[i]=H[i]-1
    mi=max(mi,H[i])
    if H[i+1]<H[i] or H[i]<mi:
      flag=1
      print("No")
      sys.exit()

if flag==0:
  print("Yes")



Measured memory_bytes: 63984
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T> using vt = vector<T>;
template<class T> using vvt = vector<vt<T>>;
template<class T> using ttt = tuple<T,T>;
using tii = tuple<int,int>;
using tiii = tuple<int,int,int>;
using vi = vector<int>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define mt make_tuple
#define ALL(a) (a).begin(),(a).end()
#define FST first
#define SEC second
#define DEB cerr<<"!"<<endl
#define SHOW(a,b) cerr<<(a)<<" "<<(b)<<endl
#define DIV int(1e9+7)
const int INF = (INT_MAX/2);
const ll LLINF = (LLONG_MAX/2);
const double eps = 1e-8;
//const double PI = M_PI;  
inline ll pow(ll x,ll n,ll m){ll r=1;while(n>0){if((n&1)==1)r=r*x%m;x=x*x%m;n>>=1;}return r%m;}
inline ll lcm(ll d1, ll d2){return d1 / __gcd(d1, d2) * d2;}
int main(){
  ll n; cin >> n;
  vector<ll> in(5);  rep(i,5)  cin >> in[i];
  ll min_s = *min_element(ALL(in));
  cout << 5 + n/min_s - (!(!(n % min_s == 0)))<< endl;
}

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

using ll = long long;
#define countof(a) (sizeof(a)/sizeof((a)[0]))
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
#define all(a) begin(a),end(a)
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
template<class T> void cout_v(const vector<T>& c)
{ for (int i = 0; i < c.size(); i++) cout << c[i] << endl; }
template<class T> void cout_h(const vector<T>& c)
{ for (int i = 0; i < c.size(); i++) cout << c[i] << (i==c.size()-1?"\n":" "); }
template<class T> inline bool chmin(T& a, T b) {return a>b?a=b,true:false;}
template<class T> inline bool chmax(T& a, T b) {return a<b?a=b,true:false;}
void Yes(bool f){cout<<(f?"Yes":"No")<<endl;}
#define SP << " " <<
#define D(a) cout<<#a<<":"<<a<<"\n"
#define D2(a,b) cout<<#a<<":"<<a<<","<<#b<<":"<<b<<endl 
#define D3(a,b,c) cout<<#a<<":"<<a<<","<<#b<<":"<<b<<","<<#c<<":"<<c <<endl
#define D4(a,b,c,d) cout<<#a<<":"<<a<<","<<#b<<":"<<b<<","<<#c<<":"<<c<<","<<#d<<":"<<d<<endl 
#define MOD 1000000007

int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    //cout<<std::fixed<<std::setprecision(10);

    string S; cin >>S;

    ll ans = 0;
    ll border = -1;
    ll a_border = 0;
    ll a = 0;
    rep(i, S.size()) {
        // D3(i, S[i], border);
        if (S[i] == '<') {
            a++;
            ans += a;
            border = i;
            a_border = a;
        } else {
            if (i != 0 && S[i-1] == '<') {
                a = 0;
            } else {
                a--;
            }
            ans += a;
            if (a < 0) {
                a++;
                ans += i - border;
                if (a_border == i - border - 1) {
                    ans++;
                    a_border++;
                }
            }
        }
        // D3(a, ans, border);
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 1172
#include <stdio.h>


int main (void){
  
 long long int a=0,b=0,c,max=0,n=0,i,k,flag=0,sum=0,count;
 
 scanf("%lld%lld%lld",&a,&b,&c);
 sum=0;
 count=0;
 for(sum=c;sum<=a;count++)
 {
     sum+=b;
     sum+=c;
    
 }
 printf("%lld",(sum>n)?(count-1):count);

return 0;
    
}

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

using ll = long long;
using ii = pair<ll, int>;
using vi = vector<int>;
#define all(v) (v).begin(), (v).end()
#define sz(v) (int) (v).size()

int main(int argc, char* argv[]) {
  ios::sync_with_stdio(0); cin.tie(0);
  int n, m, k;
  cin >> n >> m >> k;
  vector<int> a(n), b(m);
  for (int i = 0; i < n; i++)
    cin >> a[i];
  for (int i = 0; i < m; i++)
    cin >> b[i];
  set<pair<ll, int>> pref;
  ll cur = 0;
  for (int i = 0; i < m; i++) {
    cur += b[i];
    pref.insert(ii(cur, i));
  }
  int ans = 0;
  auto pos = pref.lower_bound(ii(k + 1, -1));
  if (pos != pref.begin()) {
    --pos;
    ii cur = *pos;
    ans = cur.second + 1;
  }
  ll sum = 0;
  for (int i = 0; i < n; i++) {
    sum += a[i];
    if (sum <= k)
      ans = max(ans, i + 1);
    pos = pref.lower_bound(ii(k - sum + 1, -1));
    if (pos != pref.begin()) { 
      --pos;
      ii cur = *pos;
      ans = max(ans, i + cur.second + 2);
    }
  } 
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 17164
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <vector>

using namespace std;
typedef long long llong;
const int MOD=1000000007;

int main(int argc, char**argv){
    string s;
    cin >> s;
    cout << s[0] << s.size()-2 << s[s.size()-1] << endl;

    return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;

constexpr int mod = 1e9 + 7;

template <class T> inline bool chmax(T &a, const T &b) {
    if(a >= b) return false;
    a = b;
    return true;
}
template <class T> inline bool chmin(T &a, const T &b) {
    if(a <= b) return false;
    a = b;
    return true;
}

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

int h, w, dp[2][1001];

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

    cin >> h >> w;
    FOR(i, 1, h + 1) FOR(j, 1, w + 1) {
        char c;
        cin >> c;
        if(i + j == 2)
            dp[i][j] = 1;
        else if(c == '.') {
            dp[i & 1][j] = dp[i + 1 & 1][j] + dp[i & 1][j - 1];
            if(dp[i & 1][j] > mod) dp[i & 1][j] -= mod;
        } else
            dp[i & 1][j] = 0;
    }

    cout << dp[h & 1][w] << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

import javax.xml.transform.OutputKeys;

public class Main {

	public static void main(final String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt(), y = sc.nextInt();
		boolean ok = false;
		for (int i=0;i<=100;i++) {
			for (int j=0;j<=100;j++) {
				if (i + j == x && i * 2 + j * 4 == y) {
					ok = true;
					break;
				}
			}
		}
		if (ok)
		System.out.println("Yes");
		else 
			System.out.println("No");
	}
}


Measured memory_bytes: 35720
<?php

define("ASCII_A", ord('a'));

while($line = fgets(STDIN)){
	$arr = explode(" ", trim($line));
	
	$hit = 0;
	for($i = 1; $i <= 256 && $hit == 0; $i++){
		foreach($arr as $word){
			if($word == ""){
				continue;
			}
			$arr2 = explode(".", $word);
			foreach($arr2 as $word2){
				if($word2 == ""){
					continue;
				}
				$new = trans($word2, $i);
				if($new == "the" || $new == "this" || $new == "that"){
					$hit = $i;
					break;
				}
			}
		}
	}
	
	echo trans($line, $hit);
}


function trans($word, $slide){
	$ret = array();
	$len = strlen($word);
	for($i = 0; $i < $len; $i++){
		$c = substr($word, $i, 1);
		if($c == " " || $c == "." || $c == "\n"){
			$ret[] = $c;
			continue;
		}
		$x = ord($c) - ASCII_A + $slide;
		$ret[] = chr(($x % 26) + ASCII_A);
	}
	return implode("", $ret);
}

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

using ll = long long;

template<typename T>
T gcd(T a, T b)
{
	if (a < b)	return gcd(b, a);
	T r;
	while ((r = a % b))
	{
		a = b;
		b = r;
	}
	return b;
}

template<typename T>
T lcm(T a, T b)
{
	return a * b / gcd(a, b);
}

template<typename T>
T ext_gcd(T a, T b, T& x, T& y)
{
	x = 1;
	y = 0;
	T x0 = 0, y0 = 1;
	while (b != 0)
	{
		T q = a / b;
		a -= q * b;
		swap(a, b);
		x -= q * x0;
		swap(x, x0);
		y -= q * y0;
		swap(y, y0);
	}
	return a;
}

template<typename T>
T inv_mod(T a, T mod)
{
	T t1, t2;
	ext_gcd(a, mod, t1, t2);
	t1 %= mod;
	if (t1 < 0)		t1 += mod;
	return t1;
}

template<typename T>
T combination_large(T n, T k, T mod)
{
	if (n < k || n < 0 || k < 0)	return 0;
	vector<T> inv(n + 1, 1), fact(n + 1, 1), fact_inv(n + 1, 1);
	for (T i = 2; i <= n; ++i)
	{
		inv[i] = mod - inv[mod % i] * (mod / i) % mod;
		fact[i] = (fact[i - 1] * i) % mod;
		fact_inv[i] = fact_inv[i - 1] * inv[i] % mod;
	}
	return fact[n] * (fact_inv[k] * fact_inv[n - k] % mod) % mod;
}

template<typename T>
T combination(T n, T k, T mod = 1)
{
	vector<vector<T>> table(n + 1, vector<T>(k + 1, 1));
	for (T i = 1; i <= n; ++i)
	{
		table[i][0] = 1;
		for (T j = 1; j <= n; ++j)
		{
			table[i][j] = (table[i - 1][j - 1] + table[i - 1][j]) % mod;
		}
	}
}


int main(int, char**)
{
	long long N;
	scanf("%lld",&N);
	std::string S;
	std::cin >> S;

	ll count = 0;
	for (ll i = 0; i < N - 2; ++i)
	{
		if (S[i] == 'A' && S[i + 1] == 'B' && S[i + 2] == 'C')
		{
			++count;
		}
	}

	cout << count << endl;

	return 0;
}


Measured memory_bytes: 256
//{{{
#include<algorithm>
#include<cmath>
#include<deque>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<random>
#include<set>
#include<sstream>
#include<sys/time.h>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(printde) FUNC(printdbe) FUNC(printdwe) FUNC(printdu) FUNC(printe) FUNC(printe0);
#endif
template <template <class T, class = std::allocator<T>> class V, class E>
istream& operator >> (istream& in, V<E>& v){ for(auto& e : v){ in >> e; } return in; }
//}}}

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<int> ls(n); cin >> ls;
    sort(ls.begin(), ls.end());
    int ans = 0;
    for(int i = 0; i < n; i++){
        for(int j = i + 1; j < n; j++){
            for(int k = j + 1; k < n; k++){
                if(ls[i] == ls[j] || ls[j] == ls[k]){ continue; }
                ans += ls[i] + ls[j] > ls[k];
            }
        }
    }
    cout << ans << '\n';
}


Measured memory_bytes: 3108
import sys
from collections import deque
sys.setrecursionlimit(500000)
n,q=map(int,input().split())
edge=[[] for i in range(n)]
cost=[0]*n
for i in range(n-1):
  p,s=map(int,input().split())
  p-=1;s-=1
  edge[p].append(s)
  edge[s].append(p)
for i in range(q):
  x,c=map(int,input().split())
  x-=1
  cost[x]+=c
visited=[False]*n
queue=deque([0])
visited[0]=True
while len(queue)!=0:
  a=queue.popleft()
  for i in edge[a]:
    if visited[i]==True:continue
    queue.append(i)
    visited[i]=True
    cost[i]+=cost[a]
for i in range(n):
  cost[i]=str(cost[i])
print(" ".join(cost))

Measured memory_bytes: 133188
#include <iostream>

using namespace std;

int main()
{
    int a, b;

    cin >> a >> b;
    if (a < b)
    {   
        cout << "a < b\n";
    } else if (a > b) {
        cout << "a > b\n";
    } else {
        cout << "a == b\n";
    }   

    return 0;
}

Measured memory_bytes: 1124
#include <stdio.h>

void calcX(int i, int r, int D, long x) {
    if (0 < i) {
        printf("%ld\n", r * x - D);
        calcX(i - 1, r, D, r * x - D);
    }
}

int main() {
    int r, D, x;
    scanf("%d %d %d", &r, &D, &x);

    calcX(10, r, D, x);

    return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int tt = 0;
		int tx = 0;
		int ty = 0;
		for (int i = 0; i < n; i++) {
			int t = sc.nextInt();
			int x = sc.nextInt();
			int y = sc.nextInt();
			int dt = Math.abs(t - tt);
			int dx = Math.abs(x - tx);
			int dy = Math.abs(y - ty);
			if (dt < dx + dy || (dt - dx - dy) % 2 == 1) {
				System.out.println("No");
				sc.close();
				return;
			}
		}
		sc.close();
		System.out.println("Yes");
	}
}


Measured memory_bytes: 88016
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
const int INF (1<<30);

struct edge {int to, cost;};
typedef pair<int, int> P;

void dijkstra(int s, vector<int> &d, vector<vector<edge> > &G) {
  priority_queue<P, vector<P>, greater<P> > que;
  rep(i,d.size()) d[i] = INF;
  d[s] = 0;
  que.push(P(0, s));

  while (!que.empty()) {
    P 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(P(d[e.to], e.to));
      }
    }
  }

}

int main() {
  int N, X, Y;
  cin >> N >> X >> Y;
  X--;
  Y--;

  vector<vector<edge>> G(N);
  for (int i = 0; i < N-1; i++) {
    G[i].push_back((edge){i+1, 1});
    G[i+1].push_back((edge){i, 1});
  }
  G[X].push_back((edge){Y, 1});
  G[Y].push_back((edge){X, 1});

  vector<int> ans(N, 0);
  rep(i, N) {
    vector<int> d(N);
    dijkstra(i, d, G);
    for (auto x : d) {
      ans[x]++;
    }
  }

  for (int i = 1; i < N; i++) {
    cout << ans[i]/2 << endl;
  }



  return 0;
}


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

#define N 100
#define GR 1
#define BL 2
#define WH 0

int n, M[N][N];
int tt, color[N], d[N], f[N];

void dfs_visit(int u){
    int aa;
    color[u] = GR;
    d[u] = ++tt;
    
    for(aa=0 ; aa<n ; aa++){
        if(M[u][aa] == 0){continue;}
        if(color[aa] == WH){dfs_visit(aa);}
    }
    
    color[u] = BL;
    f[u] = ++tt;
}

void dfs(){
    int u;
    
    for(u=0 ; u<n ; u++){color[u] = WH;}
    tt = 0; 
    
    for(u=0 ; u<n ; u++){
        if(color[u]==WH){dfs_visit(u);}
    }
    for(u=0 ; u<n ; u++){
        printf("%d %d %d\n", u+1, d[u], f[u]);
    }
}

int main(){
    int u, v, k, i, j;
    
    scanf("%d", &n);
    for(i=0 ; i<n ; i++){
        for(j=0 ; j<n ; j++){M[i][j] = 0;}
    }
    
    for(i=0 ; i<n ; i++){
        scanf("%d %d", &u, &k);
        u--;
        for(j=0 ; j<k ; j++){
            scanf("%d", &v);
            v--;
            M[u][v] = 1;
        }
    }
    
    dfs();
    
    return 0;
}


Measured memory_bytes: 2104
#include <stdio.h>
#include <algorithm>

int main(void) {
  int i, j, k, n, q, ans = 0, t;
  scanf("%d", &n);
  int a[n];
  for(i = 0; i < n; ++i) scanf("%d", &a[i]);
  scanf("%d", &q);
   for(i = 0; i < q; ++i) {
    scanf("%d", &t);
    if(std::lower_bound(a, a + n, t) != std::upper_bound(a, a + n, t)) ++ans;
  }
  printf("%d\n", ans);
  return 0;
}


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

typedef long long ll;

const int MAX_KA = 2500;


ll dp[55][55][MAX_KA+1];

int main() {
	ll N, A;
	cin >> N >> A;
	vector<ll> x(N);
	ll sum=0;
	for (ll i = 0; i < N; i++) {
		cin >> x[i];
		sum += x[i];
	}

	dp[0][0][0] = 1;

	for (ll i = 0; i <= N; i++) {
		for (ll j = 0; j <= N; j++) {
			for (ll k = 0; k <= sum; k++) {
				if(i>=1 && k<x[i-1]) dp[i][j][k] = dp[i-1][j][k];
				if(i>=1 && j>=1 && k>=x[i-1]) dp[i][j][k] = dp[i-1][j][k] + dp[i-1][j-1][k-x[i-1]];
			}
		}
	}

	ll ans=0;
	for (ll k = 1; k <= N; k++) {
		ans += dp[N][k][k*A];
	}

	cout << ans << endl;
}


Measured memory_bytes: 54400
n = int(input())

ans = [0, 0, 0, 0]
for _ in range(n):
    tmp = input()
    if tmp == 'AC':
        ans[0] += 1
    elif tmp == 'WA':
        ans[1] += 1
    elif tmp == 'TLE':
        ans[2] += 1
    else:
        ans[3] += 1

print('AC x', ans[0])
print('WA x', ans[1])
print('TLE x', ans[2])
print('RE x', ans[3])


Measured memory_bytes: 9140
# Date [ 2020-09-19 21:00:10 ]
# Problem [ a.py ]
# Author Koki_tkg

import sys
# import math
# import bisect
# import numpy as np
# from decimal import Decimal
# from numba import njit, i8, u1, b1 #JIT compiler
# from itertools import combinations, product
# from collections import Counter, deque, defaultdict

# sys.setrecursionlimit(10 ** 6)
MOD = 10 ** 9 + 7
INF = 10 ** 9
PI = 3.14159265358979323846

def read_str():      return sys.stdin.readline().strip()
def read_int():      return int(sys.stdin.readline().strip())
def read_ints():     return map(int, sys.stdin.readline().strip().split())
def read_ints2(x):   return map(lambda num: int(num) - x, sys.stdin.readline().strip().split())
def read_str_list(): return list(sys.stdin.readline().strip().split())
def read_int_list(): return list(map(int, sys.stdin.readline().strip().split()))
def GCD(a: int, b: int) -> int: return b if a%b==0 else GCD(b, a%b)
def LCM(a: int, b: int) -> int: return (a * b) // GCD(a, b)

def Main():
    s = read_str()
    if s[-1] != 's':
        s += 's'
    else:
        s += 'es'
    print(s)

if __name__ == '__main__':
    Main()

Measured memory_bytes: 9160
#include <iostream>
#include <algorithm>
#include <climits>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
using namespace std;

#define INF 114514191

int N, K;
vector<int> path[5010];
int  cost[5010][5010];
int C[5010];
int R[5010];

int dijkstra(int dest) {
  vector<bool> used(N, false);
  vector<int> d(N, INF);
  d[0] = 0;

  while (true) {
    int v = -1;
    for (int u=0; u<N; u++) {
      if (!used[u] && (v == -1 || d[u] < d[v])) v = u;
    }
    if (v == -1) break;
    used[v] = true;

    for (int u=0; u<N; u++) {
      d[u] = min(d[u], d[v] + cost[v][u]);
    }
  }
  return d[dest];
}

void bfs(int x) {
  queue<int> q;
  q.push(x);
  q.push(0);
  vector<bool> used(N, false);
  used[x] = true;

  while (!q.empty()) {
    int s    = q.front(); q.pop();
    int dist = q.front(); q.pop();
    if (dist >= R[x]) continue;

    for (auto d : path[s]) {
      if (!used[d]) {
        q.push(d);
        q.push(dist+1);
        used[d] = true;
        cost[x][d] = C[x];
      }
    }
  }
}

int main() {
  cin >> N >> K;
  for (int i=0; i<N; i++) {
    cin >> C[i] >> R[i];
  }
  for (int i=0; i<K; i++) {
    int a, b;
    cin >> a >> b;
    path[a-1].push_back(b-1);
    path[b-1].push_back(a-1);
  }

  for (int i=0; i<N; i++) {
    for (int j=0; j<N; j++) {
      if (i == j) cost[i][j] = 0;
      else        cost[i][j] = INF;
    }
  }
  for (int i=0; i<N; i++) {
    bfs(i);
  }
  cout << dijkstra(N-1) << "\n";
  return 0;
}

Measured memory_bytes: 101360
import numpy as np

N = int(input())

arr = np.array([input().split() + [0] for _ in range(N)], dtype='int64')
for i in range(N):
    arr[i, 2] = arr[i, 0] + arr[i, 1]

arr = arr[np.argsort(arr[:, 2])][::-1]

print(np.sum(arr[::2, 0]) - np.sum(arr[1::2, 1]))

Measured memory_bytes: 45140
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
typedef long long ll;
using namespace std;
const ll INF = 100000000000000000;

int main(){
    string s,t;
    cin>>s>>t;
    rep(i,0,110){
        if(s==t){
            cout<<"Yes"<<endl;
            return 0;
        }
        s = s[s.length()-1] + s.substr(0,s.length()-1);
    }
    cout<<"No"<<endl;
    return 0;
}

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

using namespace std;

struct P{double l,a,b;};

int bitsum(int n){
	int ans = 0;
	for(int i = 1; i < 2*n; i <<= 1){
		if((i & n) == i)ans++;
	}
	return ans;
}

double calc(vector<P> &c, int n){
	vector<P> cc;
	double ans = 0;
	for(int i = 0; i < c.size(); i++){
		if(((1 << i) & n) == (1 << i)){
			//cerr << i << endl;
			cc.push_back(c[i]);
		}
	}
	for(int i = 1; i < cc.size(); i++){
		for(int j = 0; j < i; j++){
			ans += pow(cc[i].l - cc[j].l, 2) + pow(cc[i].a - cc[j].a, 2) \
				+ pow(cc[i].b - cc[j].b, 2);
		}
	}
	return ans;
}

int main(){
	int n,m; cin >> n >> m;
	vector<P> c(n);
	for(int i = 0; i < n; i++){
		cin >> c[i].l >> c[i].a >> c[i].b;
	}
	double ans = 0;

	for(int i = 1; i < (1 << n); i++){
		if(bitsum(i) == m){
			//cerr << i  << "a" << endl;
			ans = max(ans, calc(c,i));
		}
	}
	printf("%f\n",ans);
	return 0;
}

Measured memory_bytes: 3328
N,M = map(int,input().split())
A = set()
for i in range(M):
    A.add(int(input()))
count = [0] * (N+1)
count[0] = 1
mod = 10 ** 9 + 7
if 1 in A:
    if 2 in A:
        print(0)
        exit()
    count[2] = 1
    start = 3
else:
    count[1] = 1
    start = 2
for i in range(start, N+1):
    if i in A:
        continue
    count[i] = count[i-1] + count[i-2]
    count[i] %= mod
print(count[N])

Measured memory_bytes: 11884
//E - Sum Equals Xor

#include <iostream>
#include <string>
#define rep(i, start, end) for (int i = start; i < end; i++)
using namespace std;

static const int MOD = 1e9 + 7;
int dp[100005][2];

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

  dp[0][0] = 1;
  int n = s.size();
  /*
  桁の一致を記録する配列
  i: 上からi桁目まで見た
  j: 0 or 1
  j = 0: i桁が一致
  j = 1: "未満"であることが確定
  */
  rep(i, 0, n) {
    {//a + b = 0
      if (s[i] == '0') {
        dp[i+1][0] = dp[i][0];
        dp[i+1][1] = dp[i][1];
      } else {
        dp[i+1][1] = (dp[i][0] + dp[i][1]) % MOD;
      }
    }
    {//a + b = 1
      if (s[i] == '0') {
        (dp[i+1][1] += (dp[i][1] * 2) % MOD) %= MOD;
      } else {
        (dp[i+1][0] += (dp[i][0] * 2) % MOD) %= MOD;
        (dp[i+1][1] += (dp[i][1] * 2) % MOD) %= MOD;
      }
    }
  }
  int ans = (dp[n][0] + dp[n][1]) % MOD;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1788
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <stack>
#define rep(i, s, g) for (i = s; i < g; i++)
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1e18) + 1;

int main(void)
{
    int n;
    vector<int> x;
    int i, j;
    ll sum;
    ll ans = INF;

    cin >> n;

    x.resize(n);

    rep(i, 0, n)
    {
        cin >> x[i];
    }

    rep(i, 1, 101)
    {
        sum = 0;
        rep(j, 0, n)
        {
            sum += (x[j] - i) * (x[j] - i);
        }

        ans = min(sum, ans);
    }

    cout << ans << endl;
}

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

char s[1000000];
ll t[3][1000001];

int main() {
  int n, q;
  scanf("%d%s%d", &n, s, &q);

  V D, C;
  rep(i, n) {
    rep(j, 3) t[j][i+1] = t[j][i];
    switch(s[i]){
      case 'D':
        ++t[0][i+1];
        D.push_back(i+1);
        break;
      case 'M':
        ++t[1][i+1];
        break;
      case 'C':
        ++t[2][i+1];
        C.push_back(i);
        break;
    }
  }

  ll sa1 = 0, sc1 = 0;
  for (auto &a : D) sa1 += t[1][a] * t[2][a];
  for (auto &c : C) sc1 += t[1][c] * t[0][c];

  rep(_, q) {
    int k; 
    scanf("%d", &k);
    ll ans = sa1 + sc1;
    ll sa2 = 0, sc2 = 0;
    for (auto &a : D) {
      if (a+k-1 < n) ans -= t[1][a] * t[2][a+k-1];
      else sa2 += t[1][a];
    }
    for (auto &c : C) {
      if (c-k+1 > 0) ans -= t[1][c] * t[0][c-k+1];
      else sc2 += t[1][c];
    }
    ans -= sa2 * t[2][n] + sc2 * t[0][0];
    printf("%lld\n", ans);
  }
  return 0;
}


Measured memory_bytes: 31764
using System;
using System.Collections.Generic;
using System.Linq;

class Program {
    static int ReadInt() { return int.Parse(Console.ReadLine()); }
    static int[] ReadInts() { return Console.ReadLine().Split().Select(int.Parse).ToArray(); }
    static string[] ReadStrings() { return Console.ReadLine().Split(); }

    static int Calc(int a, int b) {
        if (a > 0) return 1;
        if (a == 0 || b == 0) return 0;
        if (a < 0 && b > 0) return 0;

        int n = Math.Min(-1, b) - a + 1;
        if (n % 2 == 0) return 1;
        return -1;
    }

    static void Main() {
        var ab = ReadInts();
        int a = ab[0], b = ab[1];

        int ans = Calc(a, b);
        if (ans > 0) Console.WriteLine("Positive");
        else if (ans == 0) Console.WriteLine("Zero");
        else Console.WriteLine("Negative");
    }
}

Measured memory_bytes: 2776
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      int x = sc.nextInt();
      int a = sc.nextInt();
      int b = sc.nextInt();
      if(a>=b)System.out.println("delicious");
      else if(x>=b-a)System.out.println("safe");
      else if(x<=b-a-1)System.out.println("dangerous");
    }
}


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

int main() {
    int h, w;
  	string c;
  	cin >> h >> w;
  	rep(i, h) {
    	cin >> c;
      	cout << c << endl;
      	cout << c << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>

using namespace std;

#define rep(i, n) for (int i = 0; i < int(n); ++i)

int main() {
  long long n, m = 100000;
  cin >> n;
  rep (iii, n) {
    m = ceil((double)m * 1.05 / 1000) * 1000;
  }
  cout << m << endl;
  return 0;
}

Measured memory_bytes: 1160
#include<stdio.h>
int main(void)
{
	int a,x,s[101];
	x=0;
	while((scanf("%d",&a))!=EOF){
		x++;
		if(a!=0){
			s[x]=a;
		}
		else if(a==0){
			printf("%d\n",s[x-1]);
			x-=2;
		}
	}
	return 0;
}

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

int main() {
    long long N; cin >> N;
    long long K = 1;
    bool exist = false;
    for (K = 1; K <= N; ++K) {
        if (K * (K+1) / 2 == N) {
            exist = true;
            break;
        }
    }
        
    if (!exist) puts("No");
    else {
        puts("Yes");
        cout << K+1 << endl;
        vector<vector<long long> > res(K+1, vector<long long>());
        long long sum = 1;
        for (int k = K; k >= 1; --k) {
            for (int i = 0; i < k; ++i) {
                res[K-k].push_back(sum + i);
                res[K-k + i + 1].push_back(sum + i);
            }
            sum += k;
        }
            
        for (int i = 0; i < K+1; ++i) {
            cout << res[i].size();
            for (int j = 0; j < res[i].size(); ++j) cout << " " << res[i][j];
            cout << endl;
        }
    }
}

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

using namespace std;

#define endl            "\n"
#define sz(x)          (int) (x.size())
#define all(v)          v.begin(), v.end()
#define isOdd(n)       (n&1)
#define pow(n, m)      (ll)powl(n, m)
#define clr(x, val)     memset(x, val, sizeof(x))

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;

const int N = 1e5 + 5;
unordered_map<int, int> mp;
ll pfx[N];
int main()
{
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);

    ll n, x, m, a1; cin >> n >> x >> m;

    ll t1 = 1, t2 = n + 1;
    a1 = x;
    pfx[1] = a1;
    mp[a1] = 1;
    for(int i = 2; i <= n; i++){
        ll r = (a1 * a1) % m;
        if(mp.count(r)){
            t1 = mp[r];
            t2 = i;
            break;
        }
        mp[r] = i;
        a1 = r;
        pfx[i] = r;
    }

    for(int i = 1; i <= t2; i++) pfx[i] += pfx[i - 1];

    ll period_len = t2 - t1;
    ll period_counts = (n + 1 - t1) / period_len;
    ll sum = period_counts * (pfx[t2 - 1] - pfx[t1 - 1]);
    if((n + 1 - t1) % period_len){
        ll sub_period = (n - t1) % period_len;
        sum += pfx[t1 + sub_period] - pfx[t1 - 1];
    }
    cout << sum + pfx[t1 - 1];
    return 0;
}


Measured memory_bytes: 5568
from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf
from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from queue import Queue,LifoQueue,PriorityQueue
from copy import deepcopy
from time import time
from functools import reduce
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

n = INT()
a = LIST()
m = max(a)
c = [0]*(m+1)

for x in a:
    c[x] += 1

for i in range(1, m+1):
    if c[i] > 0:
        if c[i] > 1:
            c[i] = 0
        j = i + i
        while j <= m:
            c[j] = 0
            j += i    
ans = sum(c)
print(ans)

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

x = int(input())
ans = 0

if 400 <= x <= 599: ans = 8
if 600 <= x <= 799: ans = 7
if 800 <= x <= 999: ans = 6
if 1000 <= x <= 1199: ans = 5
if 1200 <= x <= 1399: ans = 4
if 1400 <= x <= 1599: ans = 3
if 1600 <= x <= 1799: ans = 2
if 1800 <= x <= 1999: ans = 1

print(ans)


Measured memory_bytes: 9184