akhauriyash/Code-Regression huggingface dataset:
#include"bits/stdc++.h"
using namespace std;
#define REP(k,m,n) for(ll (k)=(m);(k)<(n);(k)++)
#define rep(i,n) REP((i),0,(n))
using ll=long long;

int main()
{
	int N;
	cin>>N;
	vector<int> A(N);
	rep(i,N)cin>>A[i];

	auto mx=A;
	sort(mx.begin(),mx.end());
	rep(i,N){
		if(A[i]==mx.back())cout<<mx[N-2]<<endl;
		else cout<<mx[N-1]<<endl;
	}
	return 0;
}


Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef pair<P,int> T;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
int N;
int a[505][505];
void f(vector<int> vs,int d){
	vector<int> p[2];
	for(int i=0;i<vs.size();i++){
		p[i%2].pb(vs[i]);
	}
	for(int i=0;i<p[0].size();i++){
		for(int j=0;j<p[1].size();j++){
			int u = p[0][i];
			int v = p[1][j];
			if(u>v)swap(u,v);
			a[u][v] = d;
		}
	}
	if(p[0].size()>1)f(p[0],d+1);
	if(p[1].size()>1)f(p[1],d+1);
	return;
}
int main(){
	cin >> N;
	vector<int> vec;
	for(int i=0;i<N;i++)vec.pb(i);
	f(vec,1);
	for(int i=0;i<N-1;i++){
		for(int j=i+1;j<N;j++){
			cout << a[i][j];
			if(j+1<N)cout << ' ';
			else cout << endl;
		}
	}
	return 0;
}



Measured memory_bytes: 1536
import java.util.*;
//import static java.lang.Integer.*;
//import static java.lang.Long.*;
//import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		char[] S = sc.next().toCharArray();
		sc.close();
		int n = 0;
		int w = 0;
		int s = 0;
		int e = 0;
		for (i = 0; i < S.length; i++) {
			switch(S[i]) {
			case 'N':
				n++;
				break;
			case 'W':
				w++;
				break;
			case 'S':
				s++;
				break;
			case 'E':
				e++;
				break;
			}
		}
		boolean f = true;
		if((n == 0 && s > 0) || n > 0 && s == 0) f = false;
		if((w == 0 && e > 0) || w > 0 && e == 0) f = false;
		out.println(f?"Yes":"No");
	}
}


Measured memory_bytes: 21972
#include <iostream>
#include <string>

int main(int argc, char** argv)
{
    int N;
    std::cin >> N;

    int ans = 0;
    for (int i = N; i > 0; i--) {
        if ((std::to_string(i).length() % 2) == 1) {
            ans++;
        }
    }

    std::cout << ans << std::endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        //コード
    	Scanner sc = new Scanner(System.in);
    	int N = sc.nextInt();
    	int M = sc.nextInt();

    	int s = 0;

    	for(int i=0;i<M;i++) {
    		s = s + sc.nextInt();
    	}

    	if(N>=s) {
    		System.out.println(N-s);
    	} else {
    		System.out.println(-1);
    	}
    }
}

Measured memory_bytes: 38024
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
//    String s=sc.next();
//    int x=sc.nextInt();
    int a=sc.nextInt();
    int b=sc.nextInt();
//    int[] a={sc.nextInt(),sc.nextInt(),sc.nextInt()};
//    Arrays.sort(a);
    System.out.println(a%b==0?0:1);
  }
}


Measured memory_bytes: 23764
#include<iostream>
using namespace std;
int main()
{
        int a,b,c,d,e,w,m,v;
        cin>>a>>b>>c>>d>>e;
        if(a<0)
        {
                w=-a*c;
                m=d;
                v=b*e;
        }
        else if(a==0)
        {
                w=0;
                m=d;
                v=b*e;
        }
        else
        {
                w=0;
                m=0;
                v=(b-a)*e;
        }
        cout<<w+m+v<<endl;
        return 0;
}

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

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> P(N + 1);
  for (int i = 1, sum = 0, p; cin >> p; i++) P.at(i) = sum += ++p;
  int ma = 0;
  for (int i = 0; i + K <= N; i++) ma = max(ma, P.at(i + K) - P.at(i));
  cout << fixed << setprecision(6) << (double)ma / 2 << "\n";
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <algorithm>
#include <sstream>
#include <istream>

using namespace std;

typedef long long ll;
typedef pair<ll, int> P;

int main(){
    int n,k;
    string s;
    vector<int> v;
    v.push_back(0);

    cin >> n >> k;
    cin >> s;

    if(s[0]=='0'){
        v.push_back(0);
    }
    for(int i=1;i<n;i++){
        if(s[i-1]!=s[i]){
            v.push_back(i);
        }
    }
    if(s[n-1]=='0'){
        v.push_back(n);
    }
    v.push_back(n);
    int m = v.size();
    int ans = 0;
    for(int i=0;i<m;i+=2){
        ans = max(ans,v[min(i+2*k+1,m-1)]-v[i]);
    }
    //for(int i=0;i<m;i++) cout << v[i] << endl;


    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1020
#include<iostream>
#include<string>
#include<vector>

#define CI cin >>
#define CO cout <<
#define E << endl;

using namespace std;

int main(void) {
	vector<vector<int> >num;
	int temp1 = 0;
	int temp2 = 0;
	int n_end = 0;

	int i = 0;

	while (1) {
		CI temp1;
		CI temp2;
		if (temp1 == 0 && temp2 == 0) {
			n_end = i;
			break;
		}
		num.push_back(vector<int>(2,0));
		
		if (temp1 > temp2) {
			num[i][0] = temp2;
			num[i][1] = temp1;
		}
		else {
			num[i][0] = temp1;
			num[i][1] = temp2;
		}
		++i;
	}
	
	for (int i = 0; i < n_end; ++i) {
		CO num[i][0] << " " << num[i][1] E
	}

}

Measured memory_bytes: 1352
#include <iostream>
using namespace std;
#define nMAX 100
#define WMAX 10000
int n,W;
int w[nMAX],v[nMAX];
int dp[nMAX+1][WMAX+1];
int rec(){
	for (int i = n-1; i >= 0; --i)
	{
		for (int j = 0; j <= W; ++j)
		{
			if(j-w[i] >= 0){
				dp[i][j] = max(dp[i][j-w[i]] + v[i],dp[i+1][j]);
			}else{
				dp[i][j] = dp[i+1][j];
			}
		}
	}
	return dp[0][W];
}
int main(){
	cin >> n >> W;
	for (int i = 0; i < n; ++i)
	{
		cin >> v[i] >> w[i];
	}
	cout << rec() << "\n";
	return 0;
}

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

int main() {
  int n;
  cin >> n;
  int x = n,sum;
  while(x>0) sum += x%10,x = x/10;
    
  if(n%sum == 0)
    cout << "Yes" << endl;
  
  else
    cout << "No" << endl;
}



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

using namespace std;
using LL = long long int;
const LL mod = 1000000007;

const int MAX_N = 1005;

int N, M;
LL X[MAX_N], Y[MAX_N], Z[MAX_N];
LL XX[MAX_N], YY[MAX_N], ZZ[MAX_N];

LL solve()
{
    vector<LL> vec;
    for(int i = 0; i < N; i++) {
        vec.push_back(XX[i] + YY[i] + ZZ[i]);
    }

    sort(begin(vec), end(vec), greater<LL>());
    LL ret = 0;
    for(int i = 0; i < M; i++) {
        ret += vec[i];
    }

    return ret;
}

int main() {
    cin >> N >> M;
    for(int i = 0; i < N; i++) {
        cin >> X[i] >> Y[i] >> Z[i];
    }

    LL ans = -114514191981036436;
    for(int i = 0; i < 2; i++) {
        for(int j = 0; j < 2; j++) {
            for(int k = 0; k < 2; k++) {
                for(int n = 0; n < N; n++) {
                    XX[n] = X[n] * (i == 0 ? 1 : -1);
                    YY[n] = Y[n] * (j == 0 ? 1 : -1);
                    ZZ[n] = Z[n] * (k == 0 ? 1 : -1);
                }
                ans = max(ans, solve());
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
ll GetDigit(ll num){ return log10(num)+1; } //numの桁数を求める

int main()
{
    int n;
    cin >> n;
    string s;
    cin >> s;
    int size = s.length();
    rep(i,size) {
        int a = s[i]+n;
        if(a > 90) a -= 26;
        printf("%c",a);
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 3628
import java.util.*;
import java.io.*;
import java.math.*;
import java.util.Collections;

class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long N = sc.nextLong();
        long K = sc.nextLong();

        long x = N;

        long v1 = x % K;
        long v2 = Math.min(v1, Math.abs(v1 - K));

        System.out.println(v2);
    }

}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define LINF 3e18+7
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;

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; }
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};

const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const double PI = acos(-1.0);
const double EPS = 1e-10;

ll N,M;
vector<vector<int>> G;
vector<int> ans;
bool visited[101010];

void dfs(int v){
    ans.push_back(v+1);
    visited[v] = 1;

    for(auto nv:G[v]){
        if(!visited[nv]) return dfs(nv);
    }
    return;
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin>>N>>M;
    G.resize(N);
    REP(i,M){
        int a,b;
        cin>>a>>b;
        --a,--b;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    
    dfs(0);
    reverse(ans.begin(),ans.end());
    ans.pop_back();
    dfs(0);

    cout<<ans.size()<<endl;
    for(auto x:ans) cout<<x<<" ";
    cout<<endl;
}


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

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(obj) (obj).begin(), (obj).end()
#define bit(n) (1LL << (n))

using namespace std;

typedef long long ll;

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n; cin>>n;
  
  if(n==1) {
    cout<<"Hello World";
  } else {
    int a,b; cin>>a>>b;
    
    cout<<a+b;
  }
  
}

Measured memory_bytes: 3616
s = list(input())
n = len(s)
for i in range(2 ** (n - 1)):
    ans = int(s[0])
    for j in reversed(range(n - 1)):
        if (i >> j) & 1:
            ans += int(s[j + 1])
        else:
            ans -= int(s[j + 1])
    if ans == 7:
        for j in reversed(range(n - 1)):
            if (i >> j) & 1:
                s.insert(j + 1, '+')
            else:
                s.insert(j + 1, '-')
        print(''.join(s) + '=7')
        exit()


Measured memory_bytes: 38740
import java.io.*;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int i = in.nextInt();
            int o = in.nextInt();
            int t = in.nextInt();
            int j = in.nextInt();
            int l = in.nextInt();
            int s = in.nextInt();
            int z = in.nextInt();
            long res = o;
            int modCnt = i%2 + j%2 + l%2;
            if (modCnt > 1 && i > 0 && j > 0 && l > 0) {
                i--; j--; l--; res+=3;
            }
            res += (i / 2) * 2;res += (j / 2) * 2;res += (l / 2) * 2;
            out.println(res);

        }
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

    }
}



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

int main() {
  int H,W;
  cin>>H>>W;
  vector<vector<char>> a(H,vector<char>(W));
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      cin>>a[i][j];
    }
  }
  for(int i=0;i<H+2;i++){
     for(int j=0;j<W+2;j++){
       if(i==0||i==H+1){
          cout<<"#";
      }
      else {
        if(j==0||j==W+1){
          cout<<"#";
        }
        else {
              cout<<a[i-1][j-1];
        }
      }   
     }
    cout<<endl;
  }
}


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

int main(){
    ll N,total=0,kotae=0;
    cin >> N;
    vector<ll> vec(N);
    rep(i,N){
        cin >> vec[i];
        total += vec[i];
    }
    
    ll j=-1,total2=0;
    
    while(total>total2*2){
        j++;
        total2 += vec[j];
        if(total2*2==total){
            cout << kotae << endl; 
            return 0;
        }
    }
    
    ll total3=0,total4=0;
    
    for(ll i=0;i<j;i++){
        total3+=vec[i];
    }
    
    total4=total3+vec[j];
    
    kotae=min(total-total3*2,total4*2-total);
    
    cout << kotae << endl;
    
    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define REP(i, n) for(int i=0;i<(n);++i)
#define RANGE(i, a, b) for(int i=(a);i<(b);++i)
#define RREP(i, n) for(int i=(n)-1;i>= 0;--i)

#define endl '\n'
#define pb push_back
#define eb emplace_back
#define pque priority_queue
#define umap unordered_map
#define uset unordered_set
#define BIG 2000000000
#define VERYBIG 1000000000000000ll
#define PI 3.141592653589793238
#define dcout cout<<fixed<<setprecision(50)

const long long dx[]={1,0,-1,0,1,1,-1,-1}, dy[]={0,-1,0,1,1,-1,1,-1};
const long long MOD = 1e9+7;

// typedef long long ll;
#define int long long
#define double long double

template<typename T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<typename T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template<typename T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template<typename T> inline T nHr(T a,T b){return nCr(a+b-1,b);}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}

typedef pair<int, int> INTP;
typedef vector<int> INTV;
struct edge2 {int to, cost;};
struct edge3 {int from, to, cost;};

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

  int N, M, p; string S; cin >> N >> M;
  bool ac[100000] = {};
  int wa[100000] = {};
  REP(i, M){
    cin >> p >> S; p--;
    if(S == "AC") ac[p] |= 1;
    else if(!ac[p]) wa[p]++;
  }
  int A = 0, B = 0;
  REP(i, N){
    A += ac[i];
    if(ac[i]) B += wa[i];
  }
  cout << A << ' ' << B << endl;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
using ll = long long;
const char newl = '\n';
#define var auto

const ll MAX = LONG_LONG_MAX - 1357183;

string s;

vector<vector<char>> priority;

vector<vector<ll>> memo;
ll dfs(int begin, int end){
    if (memo[begin][end] != MAX) return memo[begin][end];
    vector<ll> nums{};
    vector<char> ops{};
    vector<int> lens{};
    ll curNum = 0;
    int beginBracket = -1;
    int depth = 0;
    for (int i = begin; i <= end; i++){
        if (s[i] == '(') {
            if (depth == 0) beginBracket = i;
            depth++;
        }
        else if (s[i] == ')') {
            if (depth == 1){
                nums.push_back(dfs(beginBracket + 1, i - 1));
                lens.push_back(i);
            }
            depth--;
        }
        else if ('0' <= s[i] && s[i] <= '9'){
            if (depth != 0) continue;
            curNum = curNum * 10 + (s[i] - '0');
        }
        else{
            if (depth != 0) continue;
            if (s[i - 1] != ')') nums.push_back(curNum);
            curNum = 0;
            ops.push_back(s[i]);
        }
    }
    if (s[end] != ')'){
        nums.push_back(curNum);
        lens.push_back(end);
    }

    for (auto&& op : priority){
        vector<ll> newnums{};
        vector<char> newops{};
        newnums.push_back(nums[0]);
        for (int i = 0; i < ops.size(); i++){
            if (find(op.begin(), op.end(), ops[i]) == op.end()){
                newops.push_back(ops[i]);
                newnums.push_back(nums[i + 1]);
            }
            else{
                switch (ops[i]){
                    case '+':
                        newnums[newnums.size() - 1] += nums[i + 1];
                        break;
                    case '-':
                        newnums[newnums.size() - 1] -= nums[i + 1];
                        break;
                    case '*':
                        newnums[newnums.size() - 1] *= nums[i + 1];
                        break;
                }
            }
        }
        nums = move(newnums);
        ops = move(newops);
    }

    return memo[begin][end] = nums[0];
}

signed main(){
    cin >> s;
    ll res = LLONG_MIN;
    vector<char> op = {'+', '-', '*'};
    sort(op.begin(), op.end());
    vector<vector<int>> shit = {
            vector<int>{0, 0, 0},
            vector<int>{0, 0, 1},
            vector<int>{0, 1, 1},
            vector<int>{0, 1, 2}
    };
    do{
        for (auto&& hoge : shit){
            priority = vector<vector<char>>(3, vector<char>(0));
            for (int i = 0; i < 3; i++){
                priority[hoge[i]].push_back(op[i]);
            }
            memo = vector<vector<ll>>(200, vector<ll>(200, MAX));
            var curres = dfs(0, s.size() - 1);
            //cout << curres << endl;
            res = max(res, curres);
        }
    }
    while (next_permutation(op.begin(), op.end()));
    cout << res << endl;
}



Measured memory_bytes: 3708
n=int(input())
a=list(map(int,input().split()))
mod=10**9+7
t=0
for i in range(n):
    t=(t+a[i])%mod
s=t*t%mod
m=0
for i in range(n):
    m=(m+(a[i]**2)%mod)%mod
d=pow(2,mod-2,mod)
ans=((s-m)%mod)*d
print(ans%mod)

Measured memory_bytes: 31544
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ll long long
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define endl "\n"
#define pi 3.14159265358979323846264338327950288
#define MOD 1000000007
#define INF -100000000000000
#define ordered_set tree<pair< ll int ,ll  int>, null_type,less<pair<ll int, ll int>>, rb_tree_tag,tree_order_statistics_node_update> 
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
using namespace std;
#define lld long double
using namespace __gnu_pbds;
int main()
{
    fast;
    ll int n,x,t;
    cin>>n>>x>>t;
   ll int  w=n/x;
    if(n%x!=0)
        w++;
    cout<<w*t<<endl;
}

Measured memory_bytes: 3580
n = int(input())
h = list(map(int, input().split()))
for i in range(n-1, 0, -1):
    if h[i-1] - h[i] == 1:
        h[i-1] -= 1
    elif h[i] < h[i-1]-1:
        print("No")
        exit()
print("Yes")

Measured memory_bytes: 15020
#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdint.h>
#include<vector>
#include<deque>
#include<stack>
#include<string>
#include<cstring>
#include<time.h>
#include<iomanip>
#include<list>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<random>
#include<bitset>
#include <queue>
#include <map>


using namespace std;
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using ldouble = long double;


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




int main() {
	ldouble a, b, h, m;
	cin >> a >> b >> h >> m;
	ldouble as = ((ldouble)((int)h % 12) + m / 60.0) * 2 * 3.1415926535 / 12.0;
	ldouble bs = (m / 60.0) * 2 * 3.1415926535;
	ldouble ax, ay, bx, by;
	ax = a * cosl(as);
	ay = a * sinl(as);
	bx = b * cosl(bs);
	by = b * sinl(bs);
	std::cout << std::fixed;
	std::cout << std::setprecision(10) << sqrtl((ax - bx) * (ax - bx) + (ay - by) * (ay - by)) << endl;
	return 0;
}

Measured memory_bytes: 4168
#include <bits/stdc++.h>
    using namespace std;
     
    int main() {
      int s;
      int num = 0;
      cin >> s;
      int n100 = s/100;
      int n10 = s/10 - n100*10 ;
      int n1 =  s - n10*10 - n100*100 ;

      cout << n100+n10+n1  << endl;
    }

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

lint ans[55];

int main(){
    lint K; cin >> K;

    for(int i=2;i<=50;i++){
        lint x = (K+i-1) / i;
        lint bt = (i+1) * (x-1) + i - K;
        lint up = (i+1) * x + i - K;
        if(up<=bt || (lint)1e16+1001<up) continue;
        for(int j=0;j<i-1;j++) {ans[j] = (i+1) * x + i - K - 1;}
        lint x2 = K - (i-1) * x;
        ans[i-1] = (i+1) * x2 + i - K - 1;
        for(int j=0;j<i;j++) if(ans[j-1]<0) continue;
        cout << i << endl;
        for(int j=0;j<i;j++) cout << ans[j] << ' ';
        cout << endl;
        return 0;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    ll N;
    cin >>N;
    vector<ll>A(N+1);
    ll sum=0;
    ll now=0;
    rep(i,N){
        cin>>A[i];
        sum+=abs(A[i]-now);
        now=A[i];
    }
    sum+=abs(now);
    cout<<sum+abs(A[1])-abs(A[0])-abs(A[0]-A[1])<<endl;;
    rep2(i,N-1){
        ll ans = sum +abs(A[i-1]-A[i+1])-abs(A[i-1]-A[i])-abs(A[i]-A[i+1]);
        cout<<ans<<endl;
    }



    return 0;
    

}

Measured memory_bytes: 4052
//header{{{
#include<bits/stdc++.h>
  
using namespace std;
 
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define setout(n,x) setw(n+1) << setfill(x)
#define Fixed fixed << setprecision(10)
#define int int64_t
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod = 1e9+7; 

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

template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
  
int gcd(int a,int b){ return b ? gcd(b,a % b) : a;}
int lcm(int a,int b){ return a / gcd(a,b) * b;}
//}}}

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int m1,d1,m2,d2;
	cin >> m1 >> d1 >> m2 >> d2;
	if(abs(d1 - d2) > 1) cout << 1 << '\n';
	else cout << 0 << '\n';
	return 0;
}


Measured memory_bytes: 256
def main():
    a, b = scan()
    plag = 1
    cnt = 0
    while plag < b:
        plag -= 1
        plag += a
        cnt += 1
    print(cnt)

def iread():
    return int(input())


def sread():
    return input()


def aread(t="int"):
    if t == "int":
        ret = [int(i) for i in input().split()]
    elif t == "str":
        ret = list(input())
    return ret


def scan():
    return list(map(int, input().split()))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<map>
#include<iomanip>
#include<math.h>
#define rip(i,n) for(int i=0;i<n;i++)
#define ll long long
#define lb long double
#define vec vector<int>
#define set setprecision
using namespace std;
int main() {
    int n;
    cin >> n;
    vec a(n);
    vec b(n);
    rip(i, n)cin >> a[i];
    rip(i, n)cin >> b[i];
    vec c(n);
    rip(i, n) {
        c[i] = abs(a[i] - b[i]);
    }
    int p1 = 0;
    lb p2 = 0;
    lb p3 = 0;
    int maxx = 0;
    rip(i,n){
        p1 += c[i];
        p2 += pow(c[i], 2);
        p3 += pow(c[i], 3);
        maxx = max(maxx, c[i]);
    }
    p2 = sqrt(p2);
    p3 = cbrtl(p3);
    cout << p1 << endl;
    cout << fixed << set(10) << p2 << endl;
    cout <<fixed << set(10)<< p3 << endl;
    cout << maxx << endl;
}


Measured memory_bytes: 3604
#include "bits/stdc++.h"
#include "math.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define drep(i,a,b) for(ll i=(a);i>=(b);--i)
#define SIZE(a) int((a).size())
#define out(a) cout<<(a)<<endl;
const int INF=INT_MAX;
const int MAX = 510000;
const ll MOD = 1000000007;
ll fac[MAX], finv[MAX], inv[MAX];

int main(){
  ll n;cin>>n;
  ll cntx=0,cnt4=0;
  rep(i,0,n){
    ll a;cin>>a;
    if(a%2){cntx++;}
    if(a%4==0){cnt4++;}
  }

  if(cntx<=cnt4){cout<<"Yes"<<endl;}
  else{
    if(n==cntx+cnt4&&cntx==cnt4+1){
      cout<<"Yes"<<endl;
    }
    else{
      cout<<"No"<<endl;
    }
  }
}


Measured memory_bytes: 3612
import numpy as np
listA=list(map(int,input().split()))
x1=listA[0]
y1=listA[1]
x2=listA[2]
y2=listA[3]
A=np.array([x1,y1])
B=np.array([x2,y2])
C=B+np.dot(B-A,np.array([[0,1],[-1,0]]))
D=C+np.dot(C-B,np.array([[0,1],[-1,0]]))
print(C[0],C[1],D[0],D[1])

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

#define mod (int)1e9+7
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl
#define pb push_back
#define make_pair mp
#define pi acos(-1)
int gcd(int a,int b)
{
    if(b==0)
    {
        return a;
    }
    return gcd(b,a%b);

}

int main()
{
   int n;
   cin>>n;
   if(n%2!=0)
   {
       cout<<"No"<<endl;
       return 0;
   }
   string s,t,k;
   cin>>s;

   for(int i=0;i<n/2;i++)
   {
       if(s.at(i)!=s.at(i+n/2))
       {
           cout<<"No"<<endl;
           return 0;
       }

   }
   cout<<"Yes"<<endl;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;

main() {
    int64_t h, w;
    cin >> h >> w;

    vector<vector<int64_t>> m(h);
    for (auto&& row : m) {
        string s;
        cin >> s;
        row.reserve(w);
        for (auto c : s) {
            if (c == '#') {
                row.push_back(0);
            } else {
                row.push_back(numeric_limits<int>::max());
            }
        }
    }


    for (auto i = 0; i < h; ++i) {
        int64_t current = 2000;
        for (int j = 0; j < w; ++j, ++current) {
            current = min(m[i][j], current);
            m[i][j] = current;
        }

        current = 2000;
        for (int j = w - 1; j >= 0; --j, ++current) {
            current = min(m[i][j], current);
            m[i][j] = current;
        }
    }

    for (auto j = 0; j < w; ++j) {
        int64_t current = 2000;
        for (int i = 0; i < h; ++i, ++current) {
            current = min(m[i][j], current);
            m[i][j] = current;
        }

        current = 2000;
        for (int i = h - 1; i >= 0; --i, ++current) {
            current = min(m[i][j], current);
            m[i][j] = current;
        }
    }

    int64_t ans = 0;
    for (auto i = 0; i < h; ++i) {
        for (auto j = 0; j < w; ++j) {
            ans = max(ans, m[i][j]);
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 8064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int Inf = 1000000000;
constexpr ll INF= 1e18;
constexpr ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<ll,ll> P;

template<typename T>
T Pow(T a,T b) {
    T ret = 1;
    for(int i = 0;i < b;i++) {
        ret *= a;
    }
    return ret;
}

ll mod(ll val) {
    ll res = val % MOD;
    if(res < 0) {
        res += MOD;
    }
    return res;
}

int main() {
    int N;
    cin >> N;
    ll K;
    cin >> K;
    vector<int> vec(N);
    for(int i = 0;i < N;i++) {
        cin >> vec.at(i);
        vec.at(i)--;
    }
    if(K <= 10000000) {
        int cnt2 = 0;
        for(int i = 0;i < K;i++) {
            cnt2 = vec.at(cnt2);
        }
        cout << cnt2 + 1 << endl;
        return 0;
    }
    vector<ll> cnt(N,-1);
    cnt.at(0) = 0;
    int cnt2 = 0;
    ll cnt3 = 1;
    ll cnt4 = 0;
    while(true) {
        cnt2 = vec.at(cnt2);
        if(cnt.at(cnt2) != -1) {
            cnt4 = cnt3 - cnt.at(cnt2);
            cnt3 = cnt.at(cnt2);
            break;
        }
        cnt.at(cnt2) = cnt3;
        cnt3++;
    }
    K -= cnt3;
    for(int i = 0;i < N;i++) {
        cnt.at(i) -= cnt3;
    }
    for(int i = 0;i < N;i++) {
        if(cnt.at(i) >= 0 && cnt.at(i) == K % cnt4) {
            cout << i + 1 << endl;
            break;
        }
    }
}

Measured memory_bytes: 5460
import java.util.*;
import java.util.ArrayList;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String line = sc.nextLine();
		String[] aa = line.split(",");
		System.out.print(aa[0]);
		for(int i =1;i< aa.length;i++){
			System.out.print(" "+aa[i]);
		}
		System.out.println();
	}
}

Measured memory_bytes: 21972
#include<bits/stdc++.h>
#define INF 1e9
using namespace std;
int num[50];
int fib(int n){
    if(n==0 || n==1) return 1;
    else if(num[n]!=INF) return num[n];
    else return fib(n-1) + fib(n-2);
}
int main(){
    for(int i=0;i<50;i++) num[i]=INF;
    for(int i=0;i<45;i++){
        num[i]=fib(i);
    }
    int n;
    cin>>n;
    cout<<num[n]<<endl;
    return 0;
}



Measured memory_bytes: 3112
// need
#include <iostream>
#include <algorithm>
// data structure
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <complex>
//#include <deque>
#include <valarray>
#include <unordered_map>
#include <array>
// stream
//#include <istream>
#include <sstream>
//#include <ostream>
#include <fstream>
// etc
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
//#include <chrono>
#include <random>
#include <numeric>
using namespace std;
 
int main()
{
  int N, K;
  std::cin >> N >> K;
  if((N+1)/2 >= K)
    std::cout << "YES" << endl;
  else
    std::cout << "NO" << endl;
  return 0;
}


Measured memory_bytes: 256
def f(a,b):
    def func(a,b):
        return a**4+(a**3)*b+(a**2)*(b**2)+a*(b**3)+b**4
    return (a-b)*func(a,b)

def calc(x):
    for a in range(0,100000):
        for b in range(-1000,1000):
            if(f(a,b)==x):
                print(a,b)
                return 0;
x = int(input())
calc(x)

Measured memory_bytes: 9220
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <algorithm>
#define MP make_pair
using ll = long long;
using namespace std;

int main()
{
  int N;
  cin >> N;
  vector<int>D(N);
  for(int i=0; i < N; i++)
    cin >> D[i];
  sort(D.begin(), D.end(), greater<int>());
  int p = 1000;
  int ans = 0;
  for(int i=0; i < N; i++){
    if(D[i] < p){
      ans++;
      p = D[i];
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int n;
    scanf("%d", &n);
    int a, b, c, d;
    d = n % 10;
    n /= 10;
    c = n % 10;
    n /= 10;
    b = n % 10;
    n /= 10;
    a = n;
    if (a + b + c + d == 7)printf("%d+%d+%d+%d", a, b, c, d);
    else if (a + b + c - d == 7)printf("%d+%d+%d-%d", a, b, c, d);
    else if (a + b - c + d == 7)printf("%d+%d-%d+%d", a, b, c, d);
    else if (a + b - c - d == 7)printf("%d+%d-%d-%d", a, b, c, d);
    else if (a - b + c + d == 7)printf("%d-%d+%d+%d", a, b, c, d);
    else if (a - b + c - d == 7)printf("%d-%d+%d-%d", a, b, c, d);
    else if (a - b - c + d == 7)printf("%d-%d-%d+%d", a, b, c, d);
    else if (a - b - c - d == 7)printf("%d-%d-%d-%d", a, b, c, d);
    printf("=7\n");
    return 0;
}

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

using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
#define REP(i,n) for(ll i = 0;i < (ll)n;i++)
#define REPD(i,n) for(ll i = (ll)n - 1;i >= 0;i--)
#define ALL(x) (x).begin(),(x).end()
#define FILLl(n,first_dimension_size,value) fill((ll*)n,(ll*)(n+first_dimension_size),value)
#define FILL(n,first_dimension_size,value) fill((int*)n,(int*)(n+first_dimension_size),value)
#define INF (1 << 30)
#define MOD 1000000007
//int dy[4] = {-1,0,0,1};
//int dx[4] = {0,1,-1,0};



int main(){

  string s;
  cin >> s;
  if((int)s.size() & 1)s.erase(s.end()-1);
  else s.erase(s.end()-2,s.end());
  for(int i = (int)s.size()-1;i >= 0;i -= 2){
    if(s.substr(0,(int)s.size()/2) == s.substr((int)s.size()/2,(int)s.size()/2)){
      break;
    }else{
      s.erase(s.end()-2,s.end());
    }
  }
  cout << s.size() << endl;


  

  return 0;
}


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

int main(){
  long long kazu,n;
  cin>>kazu>>n;
  vector<pair<long long,int>>fs;
  for(long long i=2;i*i<=n;++i){
    int x=0;
    while(n%i==0){
      n/=i;
      ++x;
    }
    fs.emplace_back(i,x);
  }
  if(n!=1)fs.emplace_back(n,1);
  long long ans=1;
  for(auto p:fs){
    long long x=p.second;
    long long y=p.first;
    while(kazu<=x){
      x-=kazu;
      ans*=y;
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 11540
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#define LL long long
using namespace std;
const LL Maxn = 1010;
const LL Mod = 1e9+7;
LL list[Maxn];
LL pr[Maxn], prl; bool v[Maxn];
LL n;
void pre (){
	memset ( v, false, sizeof (v) );
	for ( LL i = 2; i <= 1000; i ++ ){
		if ( v[i] == false ){
			pr[++prl] = i;
		}
		for ( LL j = 1; j <= prl && (i*pr[j]) <= 1000; j ++ ){
			v[i*pr[j]] = true;
			if ( i % pr[j] == 0 ) break;
		}
	}
}
int main (){
	LL i, j, k;
	pre ();
	scanf ( "%lld", &n );
	for ( i = 2; i <= n; i ++ ){
		LL p = i;
		for ( j = 1; j <= prl; j ++ ){
			if ( p < pr[j] ) break;
			if ( p % pr[j] == 0 ){
				while ( p % pr[j] == 0 ){ p /= pr[j]; list[j] ++; }
			}
		}
	}
	LL ans = 1;
	for ( i = 1; i <= prl; i ++ ){
		ans = (ans*(list[i]+1))%Mod;
	}
	printf ( "%lld\n", ans );
	return 0;
}

Measured memory_bytes: 128
N = int(input())
s = [int(input()) for _ in range(N)]

s.sort()

ans = sum(s)

if ans % 10 != 0:
    print(ans)
    exit()

for i in range(N):
    for j in range(i, N):
        if (ans - s[j]) % 10 != 0:
            print(ans - s[j])
            exit()
    ans -= s[i]

print(ans)


Measured memory_bytes: 3060
x, k, d = map(int, input().split())

if x < 0:
    x = x * (-1)

div = x // d
if k <= div:
    ans = x - k * d
else:
    if (k - div) % 2 == 1:
        ans = x - d * (div + 1)
    else:
        ans = x - d * div

print(abs(ans))


Measured memory_bytes: 9184
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1LL<<60;

ll solve() {
    ll H, N;
    cin >> H >> N;
    vector<ll> A(N), B(N);
    for ( int i = 0; i < N; i++ ) {
        cin >> A[i] >> B[i];
    }
    vector<ll> dp(H+2, INF);
    dp[0] = 0;
    for ( int i = 0; i < N; i++ ) {
        for ( int h = 0; h < H; h++ ) {
            int k = h + A[i];
            if ( k > H ) k = H + 1;
            dp[k] = min(dp[k], dp[h] + B[i]);
        }
    }
    ll ans = min(dp[H], dp[H+1]);
    return ans;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> Pl;
#define all(a) (a).begin(),(a).end()
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=(a);i<(b);i++)
#define rrep(i,n) for(ll (i)=(n)-1;(i)>=0;i--)
#define SHOW(x) cout << #x << ": " << x << endl;
const ll INF=1e18,MOD = 1e9+7;
const int iINF = 1e9;

int main(){
    int n,r;
    cin>>n>>r;
    cout<<r + max(0,10-n) * 100<<endl;
}

Measured memory_bytes: 256
# https://atcoder.jp/contests/abc102/tasks/arc100_a
# Aの数列を前処理で加工し、順番に依存しない数列Bに加工する
# abs(Bi-x)の和を最小化するxはBの中央値である。(立式しxで微分したのちKについて増減表を書いてみよ)
# それを答えとすれば良い
import sys
read = sys.stdin.readline


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


N = read_a_int()
A = read_ints()
B = [a - i for a, i in zip(A, range(1, N + 1))]
B.sort()

x = B[N // 2]
ans = 0
for b in B:
    ans += abs(x - b)


print(ans)


Measured memory_bytes: 25884
#include<stdio.h>
#include<math.h>

int main()
{
	int a1, a2, a3, a4, b1, b2, b3, b4;
	while (scanf("%d %d %d %d %d %d %d %d", &a1, &a2, &a3, &a4, &b1, &b2, &b3, &b4) != EOF)
	{
		int hit = 0, blow = 0;
		if (a1 == b1)hit++;
		if (a2 == b2)hit++;
		if (a3 == b3)hit++;
		if (a4 == b4)hit++;

		if (a1 == b2)blow++;
		if (a1 == b3)blow++;
		if (a1 == b4)blow++;
		if (a2 == b1)blow++;
		if (a2 == b3)blow++;
		if (a2 == b4)blow++;
		if (a3 == b1)blow++;
		if (a3 == b2)blow++;
		if (a3 == b4)blow++;
		if (a4 == b1)blow++;
		if (a4 == b2)blow++;
		if (a4 == b3)blow++;

		printf("%d %d\n", hit, blow);

	}
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int main(){
    int H,M,L;
    cin>>H;
    M=H*2 + 2;
    int A[M];
    for(int i=0;i<H;i++){
        L=i+H;
        cin>>A[i];
        A[L]=A[L+1]=A[L+2]=0;
    }
    
        for(int i=0;i<H;i++){
            M=i*2+1;
            L=i*2+2;
            if(i==0)  {
                
                cout<<"node "<<i+1<<": key = "<<A[0]<<", left key = "<<A[1]<<", right key = "<<A[2]<<", "<<endl;
            }
            else if(i>0 && A[M]!=0){
                int k,l,m;
                k=(i+1)/2-1;
                l=i*2 + 1;
                m=l+1;
                if(A[L]==0){
                    cout<<"node "<<i+1<<": key = "<<A[i]<<", parent key = "<<A[k]<<", left key = "<<A[l]<<", "<<endl;
                }
                else{
                    cout<<"node "<<i+1<<": key = "<<A[i]<<", parent key = "<<A[k]<<", left key = "<<A[l]<<", right key = "<<A[m]<<", "<<endl;
                }
            }
            else{
                int k;
                k=(i+1)/2-1;
                cout<<"node "<<i+1<<": key = "<<A[i]<<", parent key = "<<A[k]<<", "<<endl;
            }
                
    }
    
}


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

unsigned long min_cost(vector<int> cost, int k)
{
  int n = cost.size();
  int i,j;
  //cout << n << endl;
  
  vector<unsigned long> min_cost_table(n);
  min_cost_table[0] = 0;
  min_cost_table[1] = abs(cost[1] - cost[0]);
  
  for(i=2; i<n; i++)
  {
	unsigned long min_cost = min_cost_table[i-1] + abs(cost[i] - cost[i-1]);  
    for(j=2; j<n && j<=k; j++)
    {
      if(i>=j)
      	min_cost = min(min_cost, min_cost_table[i-j] + abs(cost[i] - cost[i-j]) ); 
      else
        break;
    }  
    min_cost_table[i] = min_cost;
    
    //cout << i << " " << min_cost_table[i] << endl;
  }
  
  return min_cost_table[n-1];
}

int main()
{
  int i,k,n;
  cin >> n >> k;
  
  vector<int> cost(n);
  for(i=0; i<n; i++)
  	cin  >> cost[i];
  
  cout << min_cost(cost,k) << endl; 
  
  return 0;
}

Measured memory_bytes: 1792
#include <iostream>
using namespace std;
int main(void){
    long a,b,v,w,t;
    cin >> a >> v;
    cin >> b >> w;
    cin >> t; 
    
    
    if(v > w){
          long d = abs(a - b);
          if(d <= t * (v - w)){
                cout << "YES" << endl;
          }else{
                cout << "NO" << endl;
          }
    }else{
          cout << "NO" << endl;
    }
}


Measured memory_bytes: 3608
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] arr = new int[n];
		for (int i = 0; i < n; i++) {
		    arr[i] = sc.nextInt();
		}
		int min = Integer.MAX_VALUE;
		for (int i = -100; i <= 100; i++) {
		    int cost = 0;
		    for (int j = 0; j < n; j++) {
		        cost += (arr[j] - i) * (arr[j] - i);
		    }
		    min = Math.min(min, cost);
		}
		System.out.println(min);
	}
}


Measured memory_bytes: 23764
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <iomanip>
#include <cassert>
#include <stack>
#include <queue>
#include <deque>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
//using namespace __gnu_pbds;

typedef long long ll;
typedef pair <int, int> pii;

// template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
//  order_of_key (k) : Number of items strictly smaller than k .
//  find_by_order(k) : K-th element in a set (counting from zero).
#define sz(a) (int)a.size()
#define all(a) a.begin(), a.end()
#define pb push_back
#define ppb pop_back
#define mkp make_pair
#define F first
#define S second
#define show(a) cerr << #a <<" -> "<< a <<"\n"
#define fo(a, b, c, d) for(int (a) = (b); (a) <= (c); (a) += (d))
#define foo(a, b, c ,d) for(int (a) = (b); (a) >= (c); (a) -= (d))
//#define int ll

const int N = 2e5 + 5;
const int oo = 1e9 + 5;

void solve() {
	int n;
	cin >> n;
	vector <int> a = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	cout << a[n-1];
}

int main () {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int tt = 1;
	while (tt --) {
		solve();
	}
	return 0;
}
/*
	If you only do what you can do, 
	You will never be more than you are now!
*/

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
#define P(x) cout << (x) << "\n"
#define p(x) cout << (x)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define vv(type, c, m, n, i) vector<vector<type>> c(m, vector<type>(n, i));
#define rep(i,a,n) for(int i=(a), i##_len=(n); i<i##_len; ++i)
#define rrep(i,a,n) for(int i=(a), i##_len=(n); i>i##_len; --i)
#define len(x) ((int)(x).size())
#define mp make_pair
#define eb emplace_back
#define fi first
#define se second
template<class T> void chmax(T &a, const T &b){if(a<b) a=b;}
template<class T> void chmin(T &a, const T &b){if(b<a) a=b;}
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
vi dp;
int main() {
	int n; cin >> n;
	dp.reserve(100001);
    int a; cin >> a;
    dp.eb(a);
    rep(i, 0, n) {
    	cin >> a;
        if(dp.back() < a) dp.eb(a);
        else *lower_bound(all(dp), a) = a;
    }
    P(len(dp));
	return 0;
}

Measured memory_bytes: 3168
#include<bits/stdc++.h>
#define fz1(i,n) for((i)=1;(i)<=(n);(i)++)
#define ff(c,it) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
using namespace std;
int n,m,i,j,dis[200005],cnt,a[200005],b[200005],ida[200005],idb[200005],s=0,t=200001,sum,vis[200005];
queue<int> qx;
struct ii
{
	int y,z;
}ee[1000005];
vector<int> bi[200005];
vector<int>::iterator fi[200005];
map<int,int> adj[200005];
void _add(int x,int y,int z)
{
	adj[x][y]+=z;
}
void add(int x,int y,int z)
{
	cnt++;
	ee[cnt+cnt-2]=(ii){y,z};
	ee[cnt+cnt-1]=(ii){x,0};
	bi[x].push_back(cnt+cnt-2);
	bi[y].push_back(cnt+cnt-1);
}
bool bfs(int s,int t)
{
	memset(dis,0x3f,sizeof(dis));
	dis[s]=0;qx.push(s);
	while(!qx.empty()){
		int x=qx.front();qx.pop();
		fi[x]=bi[x].begin();
		ff(bi[x],it)if(ee[*it].z){
			int y=ee[*it].y,z=dis[x]+1;
			if(dis[y]>z){
				dis[y]=z;
				qx.push(y);
			}
		}
	}
	return dis[t]<dis[t+1];
}
int dfs(int x,int tt,int flw)
{
	if(x==tt||!flw) return flw;
	int ans=0;
	for(vector<int>::iterator &it=fi[x];it!=bi[x].end();it++)if(ee[*it].z&&dis[x]+1==dis[ee[*it].y]){
		int t=dfs(ee[*it].y,tt,min(flw,ee[*it].z));
		flw-=t;ans+=t;ee[*it].z-=t;ee[(*it)^1].z+=t;
	}
	if(flw) dis[x]=-1;
	return ans;
}
int dinic(int s,int t)
{
	int ans=0;
	while(bfs(s,t))
	{
		ans+=dfs(s,t,0x3f3f3f3f);
	}
	return ans;
}
int main()
{
	scanf("%d",&n);
	fz1(i,n){
		scanf("%d",&a[i]);a[i]++;
	}
	fz1(i,n){
		scanf("%d",&b[i]);b[i]++;
	}
	
	memset(vis,0,sizeof(vis));
	fz1(i,n){
		int t=i;cnt++;
		while(!vis[t]){
			ida[t]=cnt;
			vis[t]=1;t=a[t];
		}
	}
	memset(vis,0,sizeof(vis));
	fz1(i,n){
		int t=i;cnt++;
		while(!vis[t]){
			idb[t]=cnt;
			vis[t]=1;t=b[t];
		}
	}
	
	// s-a : p[i]
	// a-t : i
	// s-b : i
	// b-t : q[i]
	fz1(i,n){
		if(a[i]==b[i]){
			if(a[i]==i) continue;
			sum++;
			_add(ida[i],idb[i],1);
			_add(idb[i],ida[i],1);
		}
		else{
			if(a[i]==i){
				sum++;
				_add(idb[i],t,1);
				continue;
			}
			if(b[i]==i){
				sum++;
				_add(s,ida[i],1);
				continue;
			}
			sum++;
			_add(idb[i],ida[i],1);
		}
	}
	for(i=0;i<=t;i++){
		ff(adj[i],it){
			add(i,it->first,it->second);
		}
	}
	
	cout<<sum-dinic(s,t)<<endl;
	return 0;
}

Measured memory_bytes: 34816
const lines=[];
const reader = require('readline').createInterface({
    input: process.stdin,
    output: process.stdout
});

reader.on('line', function (line) {
  lines.push(line);
});

//入力後の処理
reader.on('close', function () {
    const input = (lines[0] as string).split(" ");
    const a = +input[0];
    const b = +input[1];

    if (a == b) {
        console.log(1);
        return;
    } 
    let res = 0;
    let numSockets = 1;
    while(numSockets < b){
        numSockets =(numSockets - 1) + a;
        res++;
    }
    console.log(res);
});

Measured memory_bytes: 30112
s,x=gets.split;l=s.size-1;a=[*0..9]-gets.split.map(&:to_i)
(puts s;exit)if !j=(0..l).find{|i|!a.find{|e|e==s[i].to_i}}
k=j.downto(0).find{|i|x=a.find{|e|e>s[i].to_i}}||-1
puts"#{k<0?a[0]>0?a[0]:a[1]:s[0...k]+x.to_s}"+a[0].to_s*(l-k)

Measured memory_bytes: 1788
#include <iostream>
#include <bitset>
#include <cmath>

int main()
{
	const int max = 50021;
	std::bitset<max + 1> bitTable;
	
	bitTable.set(0);
	bitTable.set(1);
	
	int loop = sqrt(max);
	
	for (int i = 2; i <= loop; ++i) {
		if (bitTable.test(i) == false) {
			for (int j = i * i; j <= max; j += i) {
				bitTable.set(j);
			}
		}
	}
	
	int n;
	while (std::cin >> n) {
		int high = n, low = n;
		
		while (bitTable.test(--low));
		while (bitTable.test(++high));
		
		std::cout << low << " " << high << std::endl;
	}
	
	return 0;
}

Measured memory_bytes: 1164