akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <cmath>

using namespace std;
typedef long long ll;
//typedef unsigned long long ll;

#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define sz(x) ll(x.size())
//typedef pair<ll, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = LONG_LONG_MAX / 10;
//const ll INF = 1e15;
const ll MINF = LONG_LONG_MIN;
//const int INF = INT_MAX / 10;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
//typedef pair<int, int> P;
//typedef pair<double, double> P;

bool contain(set<P> &s, P a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);


void print_line(vector<ll> &line) {
    if (line.size() == 0ll) {
        cout << endl;
        return;
    }
    for (ll i = 0; i < line.size(); i++) {
        cout << line[i];
        if (i == line.size() - 1) cout << endl;
        else cout << ' ';
    }
}


typedef priority_queue<long long, vector<long long>, greater<long long>> PQ_ASK;
const int mod = 1000000007;


int main() {

    int n, p;
    cin >> n >> p;
    vector<vector<ll>> matrix(n);


    rep(i, p) {
        int q;
        cin >> q;
        if (q == 0) {
            int t;
            ll x;
            cin >> t >> x;
            matrix[t].push_back(x);
        } else if (q == 1) {
            int t;
            cin >> t;
            print_line(matrix[t]);
        } else if (q == 2) {
            int t;
            cin >> t;
            matrix[t].clear();
        }
    }

}


Measured memory_bytes: 8788
using System;
using System.Linq;

namespace AizuOnlineJudge
{
    class Program
    {
        static void Main(string[] args)
        {
            var dice1 = new Dice(Console.ReadLine().Split(' ').Select(int.Parse).ToArray());
            var dice2 = new Dice(Console.ReadLine().Split(' ').Select(int.Parse).ToArray());

            for(var i = 0; i < dice1.Sides.Length; ++i)
            {
                for(var k= 0; k < dice1.Sides.Length; ++k)
                {
                    if(dice1.FromTopFront(dice1[i], dice1[k]) != dice2.FromTopFront(dice1[i], dice1[k]))
                    {
                        Console.WriteLine("No");
                        return;
                    }
                }
            }
            Console.WriteLine("Yes");
        }
    }

    internal class Dice
    {
        private int[] _num = new int[7];
        private int[] _rev = new int[101]; //0 <= SideInt <= 100
        public int[] Sides { private set; get; }

        public int this[int i]
        {
            get { return Sides[i]; }
        }

        private int Num(int i)
        {
            if (i == 0) return 0;
            return this[i - 1];
        }


        public Dice(int[] v)
        {
            Sides = v;
            for(var i = 0; i < v.Length; ++i)
            {
                _rev[v[i]] = i + 1;
            }
        }

        internal int FromTopFront(int top, int front)
        {
            return Num(Right(_rev[top], _rev[front]));
        }

        private int Right(int t, int f)
        {
            int x = 0;

            if (t == 2 && f == 3 || t == 3 && f == 5 || t == 4 && f == 2 || t == 5 && f == 4)
                x = 1;
            else if (t == 1 && f == 4 || t == 3 && f == 1 || t == 4 && f == 6 || t == 6 && f == 3)
                x = 2;
            else if (t == 1 && f == 2 || t == 2 && f == 6 || t == 5 && f == 1 || t == 6 && f == 5)
                x = 3;
            else if (t == 1 && f == 5 || t == 2 && f == 1 || t == 5 && f == 6 || t == 6 && f == 2)
                x = 4;
            else if (t == 1 && f == 3 || t == 3 && f == 6 || t == 4 && f == 1 || t == 6 && f == 4)
                x = 5;
            else if (t == 2 && f == 4 || t == 3 && f == 2 || t == 4 && f == 5 || t == 5 && f == 3)
                x = 6;

            return x;
        }
    }
}


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

using namespace std;

typedef long long LL;

struct cww{cww(){
    ios::sync_with_stdio(false);cin.tie(0);
}}star;
#define fin "\n"
#define FOR(i,bg,ed) for(int i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)

#define fi first
#define se second
#define pb push_back

template <typename T>inline void chmin(T &l,T r){l=min(l,r);}
template <typename T>inline void chmax(T &l,T r){l=max(l,r);}

template <typename T>
istream& operator>>(istream &is,vector<T> &v){
    for(auto &it:v)is>>it;
    return is;
}
#define S_SS 0
#define S_SW 1
#define S_WS 2
#define S_WW 3
#define W_SS 4
#define W_SW 5
#define W_WS 6
#define W_WW 7
string s;
int N;
string res;
bool test(){
    FOR(i,1,N-1){
        if(s[i]=='o'&&res[i]=='S')res[i+1]=res[i-1];
        if(s[i]=='x'&&res[i]=='S')res[i+1]=res[i-1]^1;
        if(s[i]=='o'&&res[i]=='S'^1)res[i+1]=res[i-1]^1;
        if(s[i]=='x'&&res[i]=='S'^1)res[i+1]=res[i-1];
    }
    char p=res[1];char q=res.back();
    if(s.front()=='o'&&res.front()=='S'&&p!=q)return false;
    if(s.front()=='o'&&res.front()!='S'&&p==q)return false;
    if(s.front()=='x'&&res.front()=='S'&&p==q)return false;
    if(s.front()=='x'&&res.front()!='S'&&p!=q)return false;
    p=res[0];q=res[N-2];
    if(s.back()=='o'&&res.back()=='S'&&p!=q)return false;
    if(s.back()=='o'&&res.back()!='S'&&p==q)return false;
    if(s.back()=='x'&&res.back()=='S'&&p==q)return false;
    if(s.back()=='x'&&res.back()!='S'&&p!=q)return false;
    
    
    REP(i,N)if(res[i]=='S'^1)res[i]='W';
    return true;
}
int main(){
    cin>>N;
    cin>>s;
    res=s;
    res[0]='S';res[1]='S';if(test()){cout<<res<<endl;return 0;}
    res[0]='S';res[1]='S'^1;if(test()){cout<<res<<endl;return 0;}
    res[0]='S'^1;res[1]='S';if(test()){cout<<res<<endl;return 0;}
    res[0]='S'^1;res[1]='S'^1;if(test()){cout<<res<<endl;return 0;}
    cout<<-1<<endl;
    return 0;
}


Measured memory_bytes: 640
#include<stdio.h>
#include<stdlib.h>
#define MAX 2000001
#define VMAX 10000

int main() {
 unsigned short *A, *B;
 
 int C[VMAX+ 1];
 int n, i, j;
	scanf("%d", &n);
 
 A = malloc(sizeof(short) * n + 1);
 B = malloc(sizeof(short) * n + 1);
 
 for ( i = 0; i <= VMAX; i++ ) C[i] = 0;
 
 for ( i = 0; i < n; i++ ) {
   scanf("%hu", &A[i+1]);
   C[A[i+1]]++;
  }
  
  for ( i = 1; i <= VMAX; i++ ) C[i] = C[i] + C[i - 1];
  
  for ( j = 1; j <= n; j++ ){
    B[C[A[j]]] = A[j];
    C[A[j]]--;
 }
 
 for ( i = 1; i <= n; i++ ){
  if ( i > 1 ) printf(" ");
  printf("%d", B[i]);
 }
 printf("\n");
 
 return 0;
 }


Measured memory_bytes: 9540
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <random>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STLL(s) strtoll(s.c_str(), NULL, 10)
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
#define endl '\n';
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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;}
inline string getline(){string s; getline(cin,s); return s;}
inline void yn(const bool b){b?fin("yes"):fin("no");}
inline void Yn(const bool b){b?fin("Yes"):fin("No");}
inline void YN(const bool b){b?fin("YES"):fin("NO");}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;


int main() {
    
    int n;
    cin>>n;
    string a,b,c;
    cin>>a>>b>>c;
    int ans=0;
    rep(i,n){
        if(a[i]==b[i]&&a[i]==c[i])continue;
        if(a[i]==b[i]||a[i]==c[i]||c[i]==b[i])ans++;
        else ans+=2;
    }
    fin(ans);
}



Measured memory_bytes: 256
from collections import deque

N = int(input())
S = [[]for i in range(N)]
for i in range(N-1):
    u,v,w = map(int,input().split())
    S[u-1].append([v-1,w])
    S[v-1].append([u-1,w])
Node = [None]*N
Node[0] = True
queue = deque([0])
while queue != deque([]):
    p = queue.popleft()
    for u,w in S[p]:
        if Node[u] == None:
            queue.append(u)
            Node[u] = (Node[p])^(w%2==1)
for i in range(N):
    print([0,1][Node[i]])

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,a,b) for(int i=(a);i<(b);i++)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second

using vint=vector<int>;
using pint=pair<int,int>;
using vpint=vector<pint>;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

template<class A,class B>
ostream& operator<<(ostream& ost,const pair<A,B>&p){
	ost<<"{"<<p.first<<","<<p.second<<"}";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost,const vector<T>&v){
	ost<<"{";
	for(int i=0;i<v.size();i++){
		if(i)ost<<",";
		ost<<v[i];
	}
	ost<<"}";
	return ost;
}

long long gcd(long long a,long long b){
	while(b){
		swap(a%=b,b);
	}
	return a;
}
long long lcm(long long a,long long b){
	return a/gcd(a,b)*b;
}

signed main(){
	int N;cin>>N;
	vint A(N);rep(i,N)cin>>A[i];

	vint pre(N+1),suf(N+1);
	rep(i,N)pre[i+1]=gcd(pre[i],A[i]);
	for(int i=N-1;i>=0;i--)suf[i]=gcd(suf[i+1],A[i]);
	int ans=0;
	rep(i,N){
		chmax(ans,gcd(pre[i],suf[i+1]));
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 2560
s = input()
a = []
z = []

for i in range(len(s)):
    if s[i] == 'A':
        a.append(i)
    if s[i] == 'Z':
        z.append(i)
A= min(a)
Z= max(z)

print(len(s[A:Z+1]))
     




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

int main() {
	int n, k;
	cin >> n >> k;
  	int ans = 0;
	for(int i = 0; i < n; i++) {
    	int x;
      	cin >> x;
     	if(x >= k) {
        	ans++;
        }
    }
	cout << ans << endl;
 	return 0;
}


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

vector<vector<int> > edges;
vector<vector<int>> records;

int MAX = 1e9 + 7;

int go(int parent, int idx, bool pre_black){

//cout << "go (" << idx << "," << pre_black << "\n";

    if(records[idx][pre_black] != -1)
        return records[idx][pre_black];

//cout << "go (" << idx << "," << pre_black << "\n";
    
    
    long long int black_methods = 0;
    if(pre_black == false){
        // use black for this one
        black_methods = 1;
        for(int i = 0; i < (int)edges[idx].size(); i++){
            if(edges[idx][i] != parent)
                black_methods *= go(idx, edges[idx][i], 1);
                black_methods %= MAX;
        }
    }

//cout << "black=" << black_methods << "\n";

    long long int white_methods = 1;
    // use white for this one
    for(int i = 0; i < (int)edges[idx].size(); i++){
        if(edges[idx][i] != parent){
            long long int methods = go(idx, edges[idx][i], 0);
            white_methods *= methods;
            white_methods %= MAX;
        }
    }

    records[idx][pre_black] = (black_methods + white_methods) % MAX;

 //   cout << "(" << idx+1 << "," << pre_black << ")=" << records[idx][pre_black] << "\n";
    return records[idx][pre_black];
}

int paint(vector<vector<int> >& edges){
   int size = (int)edges.size();
   records = vector<vector<int> >(size, vector<int>(2, -1));

   return go(-1, 0, 0); 
}

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

    edges = vector<vector<int> >(n);

    for(int i = 0; i < n-1; i++){
        int x, y;
        cin >> x >> y;
        x--;
        y--;
        edges[x].push_back(y);
        edges[y].push_back(x);
    }
       
    int result = paint(edges);
    cout << result << "\n";

    return 0;
}


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

using namespace std;

const int N = 2e5 + 7;
const int mod = 998244353;

int n, k;
int dp[N], pref[N], L[N], R[N];

void add(int& a, int b) {
    a += b;
    a %= mod;
}

int main() {
    ios::sync_with_stdio(false);
    cin >> n >> k;
    for (int i = 0; i < k; i++) {
        cin >> L[i] >> R[i];
    }
    pref[1] = dp[1] = 1;
    for (int i = 2; i <= n; i++) {
        for (int j = 0; j < k; j++) {
            int l = i - R[j] - 1, r = i - L[j];
            l = max(l, 0);
            r = max(r, 0);
            add(dp[i], (pref[r] - pref[l] + mod) % mod);
        }
        add(pref[i], (pref[i - 1] + dp[i]) % mod);
    }
    cout << dp[n] << endl;
}

Measured memory_bytes: 5224
import sys
def main():
    # scan(展望台の数N, 道の数M)
    N,M = map(int, input().split())
    # 展望台の高さ
    H = list(map(int, input().split()))
    # 展望台の持つ道リスト
    obsstat = [0]*N # 展望台のstatus(自分より高いのが現れたら1になる)
    for _ in range(M):
        a1,a2 = map(int, input().split())
        if H[a1-1]==H[a2-1]:
            obsstat[a1-1] = 1
            obsstat[a2-1] = 1
        elif H[a1-1]<H[a2-1]:
            obsstat[a1-1] = 1
        else:
            obsstat[a2-1] = 1
    print(obsstat.count(0))

main()


Measured memory_bytes: 20012
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;

int main() {
    int n;
    while (cin >> n, n) {
        int y;
        cin >> y;
        int ans = 0;
        double tr_max = 0;
        for (int i = 0; i < n; i++) {
            int b, r, t;
            cin >> b >> r >> t;
            double tr = (t == 1) ? 1.0 + y * r / 100.0 : pow(1.0 + r / 100.0, y);
            if (tr_max < tr) {
                tr_max = tr;
                ans = b;
            }
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 1164
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const long double EPS=1e-9;
const long double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
long double ABS(long double a){return max(a,-a);}
char in[60][60];
int main(){
	int a,b;scanf("%d%d",&a,&b);
	for(int i=0;i<a;i++)scanf("%s",in[i]);
	for(int i=0;i<a;i++)for(int j=0;j<b;j++){
		if(in[i][j]=='#'&&(i==0||in[i-1][j]=='.')&&(j==0||in[i][j-1]=='.')&&(i==a-1||in[i+1][j]=='.')&&(j==b-1||in[i][j+1]=='.')){
			printf("No\n");return 0;
		}
	}printf("Yes\n");
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define x first
#define y second
#define ndl '\n'
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define up_b upper_bound
#define low_b lower_bound
#define sz(x) (int)x.size()
#define bit __builtin_popcount
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

using namespace std;
using namespace __gnu_pbds;

template<typename T> using indexed_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<int, ull> piu;
typedef vector<vector<int>> matrix;

const ll INF = 1e18 + 123;
const ld EPS = 1e-9;
const int inf = 1e9 + 123;
const int MOD = 1e9 + 7;
const int N = 5e5 + 13;
const int M = 1e6 + 123;
const double pi = acos(-1.0);
const int dx[] = {0, 0, 1, -1};
const int dy[] = {1, -1, 0, 0};

bool used[N];
int dp[N];

vector<int> g[N];

void dfs(int v){
    used[v] = 1;
    for (int to : g[v]){
        if (!used[to]){
            dfs(to);
        }
        dp[v] = max(dp[to]+1, dp[v]);
    }
}

int main(){
    #ifdef KAZAKH
        freopen("input.txt", "r", stdin);
    #endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    while (m--){
        int u, v;
        cin >> u >> v;
        g[v].pb(u);
    }
    for (int i = 1; i <= n; i++){
        if (!used[i]){
            dfs(i);
        }
    }
    cout << *max_element(dp+1, dp+1+n);
    return 0;
}


Measured memory_bytes: 20352
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = std::int_fast64_t;
using std::cout;
using std::cerr;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

int main() {
	int n; scanf("%d", &n);	std::vector<int> x(n), y(n);
	for(int i = 0; i < n; i++) scanf("%d%d", &x[i], &y[i]);

	long double ans = 0;
	std::vector<int> vec, used(n, 0);
	auto solve = [&](auto&& solve, int now) -> void {
		if(now == n) {
			for(int i = 0; i < n - 1; i++) {
				int a = vec[i], b = vec[i + 1];
				ans += sqrt((x[a] - x[b]) * (x[a] - x[b]) + (y[a] - y[b]) * (y[a] - y[b]));
			}
		} else {
			for(int i = 0; i < n; i++) {
				if(used[i]) continue;
				used[i] = 1;
				vec.push_back(i);
				solve(solve, now + 1);
				vec.pop_back();
				used[i] = 0;
			}
		}
	};
	solve(solve, 0);
	for(int i = 1; i <= n; i++) ans /= (long double)i;
	printf("%.12Lf\n", ans);
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fint register int
#define p 374282
#define h 5001
#define int long long
using namespace std;
const int inf=1e9;
int a[p]; 
int n,k;
inline int check(int x);
signed main()
{
	cin>>n>>k;
	int maxxs=0,minns=3478923;
	for(fint i=1;i<=n;i++)
	cin>>a[i],maxxs=max(maxxs,a[i]),minns=min(minns,a[i]);
	int l=1,r=inf;
	int ans=0;
	while(l<=r)
	{
		int mid=(l+r)/2;
		if(check(mid))
		r=mid-1,ans=mid;
		else
		l=mid+1;
	}
	cout<<ans;
	return 0;
}

inline int check(int x)
{
	int tt=0;
	for(fint i=1;i<=n;i++)
	tt+=(a[i]-1)/x;
	if(tt<=k)
	return 1;
	return 0;
}

/*
给你 N个木头，长度分别是ai 

让你切 K次，

切完后，让你求长度最大的木头最小值，（最大值最小)
*/

Measured memory_bytes: 5020
using System;
using System.Linq;

class B{
  static void Main(){
    char[] Ar = Console.ReadLine().ToCharArray();
    char[] Br = Console.ReadLine().ToCharArray();
    string ans = "";
    int i = Br.Length;
    for (int j = 0; j < i; j++){
      ans += Ar[j].ToString();
      ans += Br[j].ToString();
    }
    if (Ar.Length - i == 1){
      ans += Ar[Ar.Length - 1].ToString();
    }
    Console.WriteLine(ans);
  }
}


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

using namespace std;

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

#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<(b);i++)
#define repr(i,b,a) for(int i=int(b);i>=(a);i--)
#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool valid(int lx,int ux,int ly,int uy,int x,int y){
	return lx<=x&&x<ux&&ly<=y&&y<uy; 
}
ll power(ll x,ll p){
	if(p==0)return 1;
	ll res=power(x*x%mod,p/2);
	if(p%2==1)res=res*x%mod;
	return res;
}

int main()
{
	int n,k;
	cin>>n>>k;
	vector<ll> a(n);
	rep(i,n)cin>>a[i];
	// ll p=1LL;
	// rep(i,k)p*=a[i];
	
	repi(i,k,n){
		// ll tmp=p*a[i];
		// tmp/=a[i-k];
		if(a[i]>a[i-k])cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
		// p=tmp;
	}
	return 0;
}

Measured memory_bytes: 4840
#include<iostream>
#include<queue>
#include<algorithm>
using namespace std;
int dx[6]={0,1,1,0,-1,-1},dy[2][6]={{1,0,-1,-1,-1,0},{1,1,0,-1,0,1}};
int dp[202][202][6];
bool out[202][202];
main()
{
	int sx,sy,gx,gy;cin>>sx>>sy>>gx>>gy;
	sx+=100,sy+=100,gx+=100,gy+=100;
	int n;cin>>n;
	for(int i=0;i<n;i++)
	{
		int x,y;cin>>x>>y;
		x+=100,y+=100;
		out[x][y]=true;
	}
	int lx,ly;cin>>lx>>ly;
	int Lx,Rx,Ly,Ry;
	Lx=100-lx,Rx=100+lx;
	Ly=100-ly,Ry=100+ly;
	for(int i=Lx;i<=Rx;i++)for(int j=Ly;j<=Ry;j++)for(int k=0;k<6;k++)dp[i][j][k]=2e9;
	dp[sx][sy][5]=0;
	priority_queue<pair<int,pair<pair<int,int>,int> > >P;
	P.push({0,{{sx,sy},5}});
	while(!P.empty())
	{
		int cost=-P.top().first;
		int x=P.top().second.first.first,y=P.top().second.first.second;
		int T=P.top().second.second;
		P.pop();
		if(dp[x][y][T]<cost)continue;
		for(int t=1;t<=6;t++)
		{
			for(int r=0;r<6;r++)
			{
				int tx=x+dx[r],ty=y+dy[x%2][r];
				int now=cost+t-(abs((x-100)*(y-100)*(T+t))%6==r);
				if(tx<Lx||tx>Rx||ty<Ly||ty>Ry||out[tx][ty]||dp[tx][ty][(T+t)%6]<=now)continue;
				dp[tx][ty][(T+t)%6]=now;
				P.push({-now,{{tx,ty},(T+t)%6}});
			}
		}
	}
	int ans=2e9;
	for(int t=0;t<6;t++)ans=min(ans,dp[gx][gy][t]);
	cout<<(ans<2e9?ans:-1)<<endl;
}



Measured memory_bytes: 4608
#include<iostream>
using namespace std;
int W,H,a,b,c;
int t[20][20];
char moji;
int ty[4] = {0,1,0,-1};
int tx[4] = {1,0,-1,0};

void syokika(){
  for(int i=0;i<20;i++){
    for(int j=0;j<20;j++){
      t[i][j]=0;
    }
  }
  c=0;
}
void visit(int y,int x){
  c++;
  t[y][x]=1;
  int nx,ny;
  for(int i=0;i<4;i++){
    ny=y+ty[i];
    nx=x+tx[i];
    if(0<=ny&&ny<H&&0<=nx&&nx<W&&t[ny][nx]==0){
      visit(ny,nx);
    }
  }
}
int main(){
  while(true){
    syokika();
    cin>>W>>H;
    if(W==0&&H==0)break;
    for(int i=0;i<H;i++){
      for(int j=0;j<W;j++){
	cin>>moji;
	if(moji=='.')t[i][j]=0;
	if(moji=='@'){
	  a=i;
	  b=j;
	}
	if(moji=='#')t[i][j]=-1;
      }
    }
    visit(a,b);
    cout<<c<<endl;
  }
  return 0; 
}

Measured memory_bytes: 1172
#include <stdio.h>
#include <string.h>

void strrev(char *s) {
	char tmp = '\0';
	char *first = s;
	char *last = s;

	if (*first == '\0') return;

	while (*(last+1) != '\0') last++;

	while(first < last) {
		tmp = *first;
		*first = *last;
		*last = tmp;

		first++;
		last--;
	}
	return;
}

int main() {
	char S1[3010], S2[3010];
	scanf("%s", S1);
	scanf("%s", S2);
	int len1 = strlen(S1);
	int len2 = strlen(S2);
	int DP[3010][3010];
	for (int i = 0; i < 3010; i++) {
		for (int j = 0; j < 3010; j++) {
			DP[i][j] = 0;
		}
	}

	for (int i = 1; i < len1+1; i++) {
		for (int j = 1; j < len2+1; j++) {
			int max = DP[i-1][j-1] + (S1[i - 1] == S2[j - 1]);

			if (max < DP[i-1][j]) max = DP[i-1][j];
			else if (max < DP[i][j - 1]) max = DP[i][j - 1];
			DP[i][j] = max;
		}
	}

	int point = 0;
	char ans[3010];
	for (int i = 0; i< 3010; i++) ans[i] = '\0';
	int i = len1, j = len2;

	while (i != 0 && j != 0) {
		if (DP[i][j] == DP[i-1][j]) i--;
		else if (DP[i][j] == DP[i][j-1]) j--;
		else {
			ans[point] = S1[i-1];
			i--; j--;
			point++;
		}
	}
	strrev(ans);
	printf("%s\n", ans);
	return 0;
}


Measured memory_bytes: 35584
#include <stdio.h>
#define N 200000

main(){
  int n, i, R[N], max, a, min;

  scanf("%d", &n);
  for(i = 0;i < n;i++){
    scanf("%d", &R[i]);
  }
  min = R[0];
  max = R[1] - R[0];
  for(i = 1;i < n;i++){
    if(max < R[i]-min){
      max = R[i]-min;
    }
    if(min > R[i]){
      min = R[i];
    }
  }
  printf("%d\n", max);
  return 0;
}

Measured memory_bytes: 1380
#include<iostream>
#include<cstring>
#include<cstdio>
#include<vector>
#define MN 200000
#define mod 1000000007
using namespace std;
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
vector<int> v[MN+5];
int n,head[MN+5],mm,cnt,ans=1,in[MN+5],c[MN+5],num,vis[MN+5],found;
int Fa[MN+5],q[MN+5],top,p[MN+5],inv[MN+5],size[MN+5],d[MN+5],f[MN+5];
struct edge{int to,next;}e[MN*2+5];
inline void ins(int f,int t)
{
    e[++cnt]=(edge){t,head[f]};head[f]=cnt;
    e[++cnt]=(edge){f,head[t]};head[t]=cnt;
}
void dfs(int x,int fa)
{
    vis[x]=1;q[++top]=x;
    for(int i=head[x];i;i=e[i].next)
        if(++mm,!vis[e[i].to]) Fa[e[i].to]=x,dfs(e[i].to,x);
        else if(e[i].to!=fa&&!found)
        {
            for(int t=x;t!=e[i].to;t=Fa[t]) c[++num]=t;
            c[++num]=e[i].to;found=1;
        }
}
void Mark(int x,int fa)
{
    Fa[x]=fa;
    for(int i=head[x];i;i=e[i].next)
        if(e[i].to!=fa&&!in[e[i].to]) Mark(e[i].to,x);
}
inline int CC(int n,int m){return 1LL*p[n]*inv[m]%mod*inv[n-m]%mod;}
void Solve(int x)
{
    size[x]=1;f[x]=1;
    for(int i=0;i<v[x].size();++i)
    {
        Solve(v[x][i]);
        f[x]=1LL*f[x]*f[v[x][i]]%mod*CC(size[v[x][i]]+size[x]-1,size[v[x][i]])%mod;
        size[x]+=size[v[x][i]];
    }
}
int main()
{
    n=read();p[0]=inv[0]=p[1]=inv[1]=1;
    for(int i=2;i<=n<<1;++i) p[i]=1LL*p[i-1]*i%mod,inv[i]=1LL*(mod-mod/i)*inv[mod%i]%mod;
    for(int i=2;i<=n<<1;++i) inv[i]=1LL*inv[i-1]*inv[i]%mod;
    for(int i=1;i<=n<<1;++i)
    {
        int x=read(),y=read();
        ins(x,y+n);
    }
    for(int i=1;i<=n<<1;++i) if(!vis[i])
    {
        found=num=top=mm=0;int res=0,way=1;
        dfs(i,0);if(!found||mm/2!=top) return 0*puts("0");
        for(int j=1;j<=num;++j) in[c[j]]=j;
        for(int j=1;j<=num;++j) Mark(c[j],0);
        for(int j=1;j<=top;++j)
        {
            int to=in[q[j]]?c[in[q[j]]%num+1]:Fa[q[j]];
            for(int k=head[q[j]];k;k=e[k].next)
                if(e[k].to!=to&&e[k].to<to) v[q[j]].push_back(e[k].to),++d[e[k].to];
        }
        for(int j=1;j<=top;++j) if(!d[q[j]]) Solve(q[j]),way=1LL*way*f[q[j]]%mod*inv[size[q[j]]]%mod;
        res=way;way=1;
        for(int j=1;j<=top;++j) v[q[j]].clear(),d[q[j]]=0;
        for(int j=1;j<=top;++j)
        {
            int to=in[q[j]]?c[(in[q[j]]+num-2)%num+1]:Fa[q[j]];
            for(int k=head[q[j]];k;k=e[k].next)
                if(e[k].to!=to&&e[k].to<to) v[q[j]].push_back(e[k].to),++d[e[k].to];
        }
        for(int j=1;j<=top;++j) if(!d[q[j]]) Solve(q[j]),way=1LL*way*f[q[j]]%mod*inv[size[q[j]]]%mod;
        ans=1LL*ans*(res+way)%mod;
    }
    printf("%d",1LL*ans*p[n*2]%mod);
    return 0;
}


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

using namespace std;

const int mx = 3e5 + 9;

int e[mx], w[mx];

int main() {
    int n; scanf("%d", &n);
    getchar(); //for clearing newline character
    for (int i = 1; i <= n; i++) {
        char c = getchar();
        if (c == 'W') w[i] = 1;
        else e[i] = 1;
    }

    for (int i = n; i >= 1; i--) e[i] += e[i + 1];
        //e[i] diya ekhon bujhay i theke shuru kore dane koyta E ase
    for (int i = 1; i <= n; i++) w[i] += w[i - 1];
        //w[i] diya ekhon bujhay i theke shuru kore bame koyta W ase

    int ans = n * 2; // maximum ekta number dhore nei

    for (int i = 1; i <= n; i++) {
        //dhori i tomo ta leader
        //so leader er bame jara West dike takaya, tader ke Leader er dike ghurabo
        //mane leader er bamer shob W ke E korbo
        //leader er bame W ase w[i - 1] ta
        int temp = w[i - 1];
        //leader er dane E ase e[i + 1] ta, oderke leader er dike ghurabo
        temp += e[i + 1];
        ans = min(ans, temp);
    }

    printf("%d\n", ans);
}


Measured memory_bytes: 6052
n = int(input())
t = list(map(int, input().split()))
a = list(map(int, input().split()))
mod = 10 ** 9 + 7

ans, l, r = 1, 0, n - 1
for i in range(1, n):
    if t[i] == t[i - 1]:
        ans = ans * t[i] % mod
    if t[i] == a[i]:
        l = i
        break
for i in range(n - 1)[::-1]:
    if a[i] == a[i + 1]:
        ans = ans * a[i] % mod
    if t[i] == a[i]:
        r = i
        break

if t[l] != max(t) or a[r] != max(a) or max(t) != max(a):
    print(0)
else:
    print(ans * pow(t[l], max(r - l - 1, 0), mod) % mod)


Measured memory_bytes: 97744
N,A,B,C,D=map(int,input().split())
str=input()

str_ac = str[A-1:C]
str_bd = str[B-1:D]
str_bd2 = str[B-2:D+1]
#print(str_bd)
#print(str_ac)
#print(str_bd2)

if C<D:
  if str_bd.find("##")!=-1 or str_ac.find("##")!=-1:
    print("No")
  else:
    print("Yes")
else:
  if str_bd.find("##")!=-1 or str_ac.find("##")!=-1:
    print("No")
  else:
    if str_bd2.find("...")!=-1:
      print("Yes")
    else:
      print("No")

Measured memory_bytes: 3636
import java.io.IOException;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) throws IOException{

		Scanner sc = new Scanner(System.in);

		int x = sc.nextInt();
		int y = sc.nextInt();

		int[][] sheet = new int[x+1][y+1];
		int[] row = new int[x];
		int[] col = new int[y];
		int total = 0;

		for(int i=0;i<x+1;i++) {
			for(int j=0;j<y+1;j++) {
				if(i!=x && j!=y){
					sheet[i][j] = sc.nextInt();
					total += sheet[i][j];
					row[i] += sheet[i][j];
					col[j] += sheet[i][j];
				}else if(i!=x && j==y) {
					sheet[i][j] = row[i];
				}else if(i==x && j!=y) {
					sheet[i][j] = col[j];
				}else if(i==x && j==y) {
					sheet[i][j] = total;
				}
			}
		}

		for(int i=0;i<x+1;i++) {
			for(int j=0;j<y+1;j++) {
				System.out.print(sheet[i][j]);
				if(j!=y) {
					System.out.print(" ");
				}
			}
			System.out.println();
		}
		sc.close();
	}
}


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

int main(){
    long long x;
    long happy=0;

    cin >> x;

    for(x;x>=500;x-=500){
        happy+=1000;
    }
    for(x;x>=5;x-=5){
        happy+=5;
    }

    
    cout << happy << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<complex>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using Complex = complex<double>;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1145141919810364364LL;
double PI = acos(-1.0);
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)


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

	ll N, A, B;
	cin >> N >> A >> B;
	puts((N/(A+B))*A + min(N%(A+B),A));
	return 0;
}


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

#define REP(i, n ,N) for(ll i = (n); i < (N); i++)
#define p(s) cout<<(s)<<endl
#define p2(a, b) cout<<(a)<<" "<<(b)<<endl
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
ll inf = 1e18;


ll N;
ll h[100010];
ll dp[100010];
int main(){
	cin >> N;
	REP(i,0,N){
		cin >> h[i];
	}
	REP(i,0,N){
		dp[i]=inf;
	}
	dp[0]=0;
	REP(i,0,N){
		REP(j,i+1,i+3){
			dp[j] = min(dp[j], dp[i] + abs(h[i] - h[j]));
		}
	}
	p(dp[N-1]);
	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
# define mod 1000000007
# define INF (1 << 29)
# define MAX_N 1000010
/* ちゃんと考えてわかって実装 */

int main(void){
    int x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;
    vector<ll> p, q, r;
    for(int i=0; i<a; i++){
        ll tmpp;
        cin >> tmpp;
        p.push_back(tmpp);
    }
    for(int i=0; i<b; i++){
        ll tmpq;
        cin >> tmpq;
        q.push_back(tmpq);
    }
    for(int i=0; i<c; i++){
        ll tmpr;
        cin >> tmpr;
        r.push_back(tmpr);
    }
    sort(p.rbegin(), p.rend());
    sort(q.rbegin(), q.rend());
    sort(r.rbegin(), r.rend());

    priority_queue<ll, vector<ll>, greater<ll> >pq;

    for(int i=0; i<x; i++){
        pq.push(p[i]);
    }
    for(int i=0; i<y; i++){
        pq.push(q[i]);
    }

    for(int i=0; i<c; i++){
        if(r[i] > pq.top()){
            pq.pop();
            pq.push(r[i]);
        }
    }

    ll ans = 0;
    while(!pq.empty()){
        ans += pq.top();
        pq.pop();
    }

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

Measured memory_bytes: 4724
#include <bits/stdc++.h>
#include <math.h>
#define ALL(a)    a.begin(), a.end() 
#define rep(i, K, N)  for(long long int i = K; i < N; i++)
#define ll long long int
using namespace std;

ll F(ll N, ll a, ll p){
 
    if(a == 0)return 1;
 
    if(a%2 == 0 && a != 0)return (F(N, a/2, p)*F(N, a/2, p))%p;
 
    if(a%2 == 1)return N*F(N, a - 1, p)%p;
 
}

int main(){
ll x, y, k, K, n, N, Ans = 0;cin >> x >> y;
ll prime = 1000000007;
k = (x + y)/3;
n = min(2*k - x, 2*k - y);N = 1;
K = k - n + 1;
  
if((x + y)%3 != 0 || x > 2*k || y > 2*k){cout << 0;exit(0);}

if(n == 0){cout << 1;exit(0);}
  
else{
  
    rep(i, 1, n + 1){

        N *= i;N %= prime;

    }
  
}
  
rep(i, 1, n){

    K *= (k - n + 1) + i;K %= prime;

}

Ans = ( F(N, prime - 2, prime)%prime )*( K%prime );

cout << Ans%prime;
  
  return 0;
  
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int s,w; cin>>s>>w;
	if (s>w) cout<<"safe";
	else cout<<"unsafe";
	return 0;
}


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

int main(){

    int n, l;
    cin >> n >> l;
    int a, b,  sum = 0;

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

    a = n*(l - 1) + sum;
    b = (n - 1)*(l - 1) + sum;

    int min_num = 1e5, ans = 0;;
    for (int i=1; i<=n; i++){
        int temp = abs(a - (b - i));

        if (min_num > temp){
            min_num = temp;
            ans = b - i;
        }
    }

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

Measured memory_bytes: 256
H,W = list(map(int,input().split()))

if W == 1 or H == 1 :
    v = 1
elif W % 2 != 0 :
    v = (W // 2) * H + ( (H+1) // 2)
else :
    v = (W // 2) * H
    
print(v)

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

#define sup ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)

vector<vector<int>> g(100005);
vector<int> dis(100005, -1);
vector<bool> vis(100005, false);

int dfs(int v) {
    vis[v] = true;

    if(dis[v] != -1)
        return dis[v];

    int s = -1;

    for(auto u : g[v])
        s = max(s, dfs(u));

    return dis[v] = s + 1; 
}


int main()
{
	sup;
    
    int n, m, a, b, ans = 0;
    cin >> n >> m;

    for(int i = 0; i < m; i++) { 
        cin >> a >> b;
        g[a].push_back(b);
    }

    for(int i = 1; i <= n; i++)
        if(!vis[i])
            ans = max(ans, dfs(i));
        

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 10932
alias Task = Tuple!(int, "start", int, "end");

void main() {
	auto ip = readAs!(int[]), N = ip[0], M = ip[1];
	Task[] tasks = new Task[](M);
	foreach(i; 0..M) {
		auto s = readAs!(int[]);
		tasks[i] = Task(s[0], s[1]);
	}
	tasks.sort!"a.end < b.end";

	int d = int.min;
	int res;
	foreach(t; tasks) {
		if(d <= t.start) {
			d = t.end;
			res++;
		}
	}
	res.writeln;

}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.conv;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}

Measured memory_bytes: 4092
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,d,c=0;
  cin>>n>>d;
  int a[n][d];
  for(int i=0;i<n;i++)
  {
    for(int j=0;j<d;j++)
      cin>>a[i][j];
  }
  for(int i=0;i<n;i++)
  {
    for(int j=i+1;j<n;j++)
    {
      int sum=0;
      for(int k=0;k<d;k++)
      {
        sum+=(a[i][k]-a[j][k])*(a[i][k]-a[j][k]);
      }
      float x=sqrt(sum);
      if(x-floor(x)==0)
        c++;
    }
  }
  cout<<c;
  return 0;
}
      

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
#define fix10 cout << fixed << setprecision(10);
#define rep(i,n) for(int i=0; i<(int)(n);i++)

int main(){
  string s;
  long k;
  cin >> s >> k;
  int n = s.size();
  int dif = n+1;
  char num;
  rep(i,n){
    if(s.at(i) != '1'){
      dif = i+1;
      num = s.at(i);
      break;
    }
  }
  if(dif == n+1 || k < dif){
    cout << 1;
    return 0;
  }else{
    cout << num;
    return 0;
  }
  
}


Measured memory_bytes: 256
#include <iostream>
#include <limits>
#include <numeric>
#include <type_traits>
#include <algorithm>
#include <vector>
using namespace std;

int main(){
  	int A, B, K;
  	cin >> A >> B >> K;
  	
  	int G;
  	G = __gcd(A,B);
  	vector<int> div;
  	for(int i=1; i<=G; i++){
    	if(G%i == 0){
        	div.push_back(G/i);
        }
    }
  	
  	cout << div[K-1] << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <stdio.h>
#include <stack>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e5 + 50;
int n, x, y;
int a[N];
ll ans1 = 0, ans2 = 0;

int main( ){
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) {
        scanf("%d", &a[i]);
    }
    sort(a+1, a+n+1);
    int l = 1, r = n+1;
    int num = 1;
    y =  x = a[1];
    while (l < r) {
        if (num % 2) {
            r--;
            if (l < r) {
                ans1 += abs(a[r] - x);
                x = a[r];
            }
            r--;
            if (l < r) {
                ans1 += abs(a[r] - y);
                y = a[r];
            }
        }
        else {
            l++;
            if (l < r) {
                ans1 += abs(a[l] - x);
                x = a[l];
            }
            l++;
            if (l < r) {
                ans1 += abs(a[l] - y);
                y = a[l];
            }
        }
        num++;
    }
    num = 0;
    x = y = a[n];
    l = 0, r = n;
    while (l < r) {
        if (num % 2) {
            r--;
            if (l < r) {
                ans2 += abs(a[r] - x);
                x = a[r];
            }
            r--;
            if (l < r) {
                ans2 += abs(a[r] - y);
                y = a[r];
            }
        }
        else {
            l++;
            if (l < r) {
                ans2 += abs(a[l] - x);
                x = a[l];
            }
            l++;
            if (l < r) {
                ans2 += abs(a[l] - y);
                y = a[l];
            }
        }
        num++;
    }
    printf("%lld\n", max(ans1, ans2));
    return 0;
}


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

const int N = 5e3 + 10;

int n, a, b, p[N];
long long f[N][N];

int main(void) {
  scanf("%d%d%d", &n, &a, &b);
  for(int i = 1; i <= n; i++) {
    scanf("%d", &p[i]);
  }
  memset(f, 0x3f, sizeof f);
  f[0][0] = 0;
  for(int i = 1; i <= n; i++) {
    for(int j = 0, t; j <= n; j++) {
      if(p[i] > j) {
	f[i][p[i]] = min(f[i][p[i]], f[i - 1][j]);
	f[i][j] = min(f[i][j], f[i - 1][j] + a);
      } else {
	f[i][j] = min(f[i][j], f[i - 1][j] + b);
      }
    }
  }
  long long ans = f[0][1];
  for(int i = 0; i <= n; i++) {
    ans = min(ans, f[n][i]);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 196480
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int main()
{
    int N, Q; cin >> N >> Q;
    vector<Int> K, S, powN(100, 1);
    S.push_back(0);
    K.push_back(1), S.push_back(1);
    for (int i = 1; i < 100; i++) {
        powN[i] = powN[i-1] * N;
    }
    for (int i = 1; i < 100 && K.back() <= 1e9; i++) {
        K.push_back(pow(N, i));
        S.push_back(S.back() + K.back());
    }
    auto f = [&](Int x) {
        int l = lower_bound(begin(S), end(S), x) - begin(S) - 1;
        int i = x - S[l] - 1;
        return make_pair(l, i);
    };
    auto g = [&](auto pv, auto pw) {
        int ok = 0, ng = min(pv.first, pw.first) + 1;
        while (ng - ok > 1) {
            int mid = (ok + ng) / 2;
            int s = pv.second / powN[pv.first - mid];
            int t = pw.second / powN[pw.first - mid];
            (s == t ? ok : ng) = mid;
        }
        return S[ok] + pv.second / powN[pv.first - ok] + 1;
    };
    for (int i = 0; i < Q; i++) {
        int v, w; cin >> v >> w;
        if (N == 1) cout << min(v, w) << '\n';
        else cout << g(f(v), f(w)) << '\n';
    }
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  
  int r=0;
  int w=0;
  //石の数を把握
  
  vector<char> T(N);
  for(int i=0;i<N;i++){
    cin >> T.at(i);
    if(T.at(i) == 'R'){
      r++;
    } else if(T.at(i) == 'W'){
      w++;
    }
  }
  
  int ans = 0;
  for(int i=0;i<r;i++){
    if(T.at(i) == 'W'){
      ans++;
    }
  }
  
  cout << ans << endl;
}


Measured memory_bytes: 3624
/////////////////////////////////////////////DEFALT19/////////////////////////////////////////////////////////////

#include<bits/stdc++.h>
#define sp ios::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define vec vector<ll>
#define all(a) a.begin(),a.end()
#define endl "\n"
#define ll long long int
#define MP make_pair
#define f(i,a,n) for(ll i=a;i<n;i++)
#define rf(i,a) for(ll i=a-1;i>=0;i--)
#define in(a) for(auto& i:a)cin>>i
#define ol(a) for(auto i:a)cout<<i<<" ";cout<<endl;
#define ov(a) cout<<a<<endl
#define ov2(a,b) cout<<a<<" "<<b<<endl
#define ov3(a,b,c) cout<<a<<" "<<b<<" "<<c<<endl
#define ov4(a,b,c,d) cout<<a<<" "<<b<<" "<<c<<" "<<d<<endl
#define pb push_back
#define sv(a) sort(a.begin(),a.end());
#define pp pop_back
#define yes cout<<"Yes"<<endl;
#define no cout<<"No"<<endl;
using namespace std;

#define mod 100000007
#define MAX 300005

/*vector<vec> v(MAX), v2(MAX);
vector<bool> vis(MAX);

void dfs(ll root)
{
  vis[root] = true;
  for (auto i : v[root])
  {
    if (!vis[i])
    {
      dfs(i);
    }
  }
}

void bfs(ll u)
{
  queue<ll> q;

  q.push(u);
  vis[u] = true;

  while (!q.empty()) {

    ll f = q.front();
    q.pop();

    cout << f << " ";

    for (auto i : v[f])
    {
      if (!vis[i]) {
        q.push(i);
        vis[i] = true;
      }
    }
  }
}

pair<ll, ll> psum(vec a, ll s)
{
  ll i = 0, j = a.size() - 1;

  while (i < j)
  {
    if (a[i] + a[j] == s) return make_pair(i, j);
    if (a[i] + a[j] > s) j--;
    if (a[i] + a[j] < s) i++;
  }
  return make_pair(-1, -1);
}

int bin(vec a, ll l, ll r, ll x)
{
  if (r >= l)
  {
    ll mid  = l + (r - l) / 2;

    if (a[mid] == x) return mid;
    if (a[l] == x) return l;
    if (a[r] == x) return r;

    if (a[mid] > x)
      return bin(a, l, mid - 1, x);

    return bin(a, mid + 1, r, x);
  }
  return -1;
}*/

void solve()
{
  ll n, k; cin >> n >> k;
  vec a(n); in(a);
  vec dp(n + 1, INT_MAX);
  dp[0] = 0;
  f(i, 1, n + 1)
  {
    f(j, 1, min(i + 1, k + 1))
    {
      dp[i] = min(dp[i], dp[i - j] + abs(a[i] - a[i - j]));
    }
  }
  ov(dp[n - 1]);
}

int main()
{
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
  sp
  ll t = 1;
  //cin >> t;
  while (t--) solve();
}

Measured memory_bytes: 4732
#include<iostream>
#include<string>
#include<algorithm>
 
using namespace std;
 
int main()
{
	string S;

	cin >> S;

	for( int i = 0; i < 1 << 3; i ++ )
	{
		string out_str;
		int result = 0;
		int temp = ( S[ 0 ] - '0' );
		int sign = 1;
		int j = 0;
		out_str += (char)S[ 0 ];
		for( ; j < 3; j ++ )
		{	// 1ビットずつ見ていって、+-かを決める
			result += temp * sign;
			if( i & ( 1 << j ) )
			{	// +
				sign = 1;
				out_str += '+';
			}
			else
			{	// -
				sign = -1;
				out_str += '-';
			}
			temp = ( S[ j + 1 ] - '0' );
			out_str += (char)S[ j + 1 ];
		}
		result += temp * sign;
		//cout << out_str << "=" << result << endl;
		if( result == 7 )
		{
			cout << out_str << "=7" << endl;
			break;
		}
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <map>
#include <deque>
#include <string.h>
using namespace std;

#define REP(i,n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef pair<string,string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pi> vpi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

double EPS = 1e-9;
int INFi = 1000000005;
long long INFll = 1000000000000000005ll;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};
ll MOD = 1000000007;

ll N;
const int MAX_N = 200000;
ll A[MAX_N];

int main(){
  cin >> N;
  REP(i, N) cin >> A[i];
  ll s = 0;
  map<ll, ll> mp;
  mp[0]++;
  REP(i, N) {
    s += A[i];
    mp[s]++;
  }

  ll ans = 0;
  for(auto itr = mp.begin(); itr != mp.end(); itr++) {
    ll c = itr -> second;
    ans += c * (c - 1) / 2;
  }

  cout << ans << endl;

}



Measured memory_bytes: 14336
#include<stdio.h>
int main(){
  int n;
  scanf("%d",&n);
  float p;
  int a;
  a=n/2;
  float b;
  b=a;
  float c;
  c=n;
  p=1-b/c;
 // printf("%f",b);
  printf("%f",p);
}


Measured memory_bytes: 1748
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;

int main()
{
  int N;
  cin >> N;
  int f, a, t, x, y;
  int ff, aa, tt, xx, yy;
  int ansl[2] = {-1, -1}, ansf[2] = {100000000, 100000000};
  cin >> f >> a >> t >> x >> y;
  for(int i = 1; i < N; i++)
  {
    cin >> ff >> aa >> tt >> xx >> yy;
    if(t == tt && a != aa)
    {
      int dx = xx - x, dy = yy - y;
      int v = dx * dx + dy * dy; 
      if(v > ansl[tt] || v == ansl[tt] && ff - f < ansf[tt])
      {
        ansl[tt] = v;
        ansf[tt] = ff - f ;
      }
    }
    f = ff;
    a = aa;
    t = tt;
    x = xx;
    y = yy;
  }
  for(int i = 0; i < 2; i++)
  {
    if(ansl[i] == -1)
      printf("-1 -1\n");
    else
      printf("%.10f %.10f\n", sqrt(ansl[i]), ansf[i] / 60.0);
  }
}

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

#define endl '\n'
#define pb push_back
#define mod 1000000007
typedef int integer;
#define int long long
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 0
#endif
using namespace std;

template<typename Arg1>
void __f(const char *name, Arg1 &&arg1) {
    cerr << name << ": " << arg1 << endl;
}

template<typename Arg1, typename... Args>
void __f(const char *names, Arg1 &&arg1, Args &&... args) {
    const char *comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << ": " << arg1 << " |";
    __f(comma + 1, args...);
}

int powmod(int a, int b) {
    int res = 1;
    a %= mod;
    assert(b >= 0);
    for (; b; b >>= 1) {
        if (b & 1)res = res * a % mod;
        a = a * a % mod;
    }
    return res;
}

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

const integer NN = (int) 5e5 + 2;
int ar[NN];
int n, m;


integer main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    cin >> n >> m;
    int cnt = 0;
    for (int i = 0; i < n; i++){
        double a, b;
        cin >> a >> b;
        double dist = sqrt(a * a + b * b);
        if (fabs(m - dist) < 1e-10){
            cnt++;
        } else if (dist <= m) cnt++;
    }
    cout << cnt << endl;


}


Measured memory_bytes: 3724