akhauriyash/Code-Regression huggingface dataset:
package main

import (
	"fmt"
)

const n int = 100000

func main() {
	isPrime := make([]bool, n, n)
	for i := 0; i < n; i++ {
		isPrime[i] = true
	}
	isPrime[0] = false
	eratosthenes(isPrime)
	isLike := make([]bool, n, n)
	for i := 0; i < n; i++ {
		isLike[i] = false
	}
	calcIsLike(isLike, isPrime)
	likeNum := make([]int, n, n)
	likeNum[0] = 0
	for i := 1; i < n; i++ {
		likeNum[i] = likeNum[i-1]
		if isLike[i] {
			likeNum[i]++
		}
	}
	var q int
	fmt.Scan(&q)
	for i := 0; i < q; i++ {
		var l, r int
		fmt.Scan(&l)
		fmt.Scan(&r)
		if l > 1 {
			fmt.Println(likeNum[r-1] - likeNum[l-2])
		} else {
			fmt.Println(likeNum[r-1])
		}
	}
}

func eratosthenes(isPrime []bool) {
	for i := 1; i < n; i++ {
		if !isPrime[i] {
			continue
		}
		max := n / (i + 1)
		for j := 2; j <= max; j++ {
			isPrime[j*(i+1)-1] = false
		}
	}
}

func calcIsLike(isLike []bool, isPrime []bool) {
	for i := 0; i < n; i++ {
		if !isPrime[i] {
			continue
		}
		if isPrime[(i+2)/2-1] {
			isLike[i] = true
		}
	}
}


Measured memory_bytes: 5888
import           Control.Monad
import           Data.IORef
import           Data.List.Split
import           Data.Maybe
import           Data.List

main :: IO ()
main = do
  [h, w] <- map read . words <$> getLine
  image <- replicateM h getLine
  forM_ [0 .. h - 1] $ \x -> 
    putStrLn $ image !! x ++ "\n" ++ image !! x

Measured memory_bytes: 1404
#include <bits/stdc++.h>
using namespace std;
#define endl              "\n"
#define pb              push_back
#define fir               first
#define sec               second
#define all(v)            ((v).begin()), ((v).end())
#define sz(v)            ((int)((v).size()))
#define ll              long long
#define ld              long double
#define lp(i, n)        for(int i = 0 ; (int)i<n ; i++)
#define loop(i, x, n)       for(int i=x ; (int)i<=n ; i++)
#define isPowerOfTwo(s) (!(s & (s-1)))
typedef vector<int> vi;
typedef deque<int> de;
void origi() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
}
int n , arr[2000];
int bs(int i, int r) {
    int str = r, end = n - 1 , ans=r;
    while (str <= end) {
        int mid = (str + end ) / 2;
        if (arr[r] + arr[i] > arr[mid])
            ans = mid, str = mid + 1;
        else end = mid - 1;
    }
    return ans - r;
}
void tiranga() {
    int res = 0;
    cin >> n;
    lp(i, n) cin >> arr[i];
    sort(arr, arr + n);
    lp(i, n) {
        loop(r, i + 1, n - 1) res+=bs(i,r);
    }
    cout << res;
}
int main() {
#ifndef ONLINE_JUDGE
    //freopen("input.txt", "r", stdin);
#else
#endif 
    origi();
    tiranga();
   
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
int dy[4]={1,0,-1,0};
int dx[4]={0,1,0,-1};
vector<vector<int>> graph;

bool sort_sec(const pair<int,int> &a,const pair<int,int> &b){
   if(a.second<b.second){
      return true;
   }
   return false;
}

void swap(int *a,int *b){
   int temp=*a;
   *a=*b;
   *b=temp;
}

int main(void){
   int N,K;
   cin>>N>>K;
   vector<int> h(N);
   for(int i=0;i<N;i++){
      cin>>h[i];
   }
   vector<long long> dp(N,1000000007);
   dp[0]=0;
   for(int i=1;i<N;i++){
      if(i<=K){
         for(int j=1;j<=i;j++){
         dp[i]=min(dp[i],dp[i-j]+abs(h[i]-h[i-j]));
         }
      }else{
         for(int j=1;j<=K;j++){
         dp[i]=min(dp[i],dp[i-j]+abs(h[i]-h[i-j]));
         }
      }
   }
   cout<<dp[N-1]<<endl;
   return 0;
}

Measured memory_bytes: 1408
N = int(input())


def main():
    A1 = [int(i) for i in input().split()]
    A2 = [int(i) for i in input().split()]

    for i in range(N - 1):
        A1[i + 1] += A1[i]

    for i in range(N - 1, 0, -1):
        A2[i - 1] += A2[i]

    print(max([A1[i] + A2[i] for i in range(N)]))

    return


main()


Measured memory_bytes: 3064
#
# abc086 c
#
n = int(input())
ret = "Yes"
for i in range(n):
    t, x, y = map(int, input().split())
    if x + y > t:
        ret = "No"
        break
    if t % 2 == 0 and (x + y) % 2 == 1:
        ret = "No"
        break
    elif t % 2 == 1 and (x + y) % 2 == 0:
        ret = "No"
        break
print(ret)


Measured memory_bytes: 3060
n,a,b = gets.chomp.split.map(&:to_i)
x = gets.chomp.split.map(&:to_i)
ans = 0
x.each_cons(2) do |i, j|
    if (j - i) * a < b
        ans += (j - i) * a
    else
        ans += b
    end
end
puts ans

Measured memory_bytes: 9476
//
//  main.cpp
//

#include <algorithm>
#include <array>
#include <assert.h>
#include <iostream>
#include <limits>
#include <math.h>
#include <memory>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = long long;
using ull = unsigned long long;

int main() {
    constexpr int TYPE_A = 0;
    constexpr int TYPE_BC = 1;
    vector<vector<int>> types;
    vector<int> types_buffer;
    string s;
    cin >> s;
    bool waiting_c = false;
    for (char c : s) {
        if (c == 'A') {
            if (waiting_c) {
                types.emplace_back(move(types_buffer));
            }
            types_buffer.push_back(TYPE_A);
            waiting_c = false;
        } else if (c == 'B') {
            if (waiting_c) {
                types.emplace_back(move(types_buffer));
            }
            waiting_c = true;
        } else {
            assert(c == 'C');
            if (waiting_c) {
                types_buffer.push_back(TYPE_BC);
            } else {
                types.emplace_back(move(types_buffer));
            }
            waiting_c = false;
        }
    }
    types.emplace_back(move(types_buffer));
    ll count = 0;
    for (const vector<int>& seq : types) {
        ll bc_count = 0;
        for (int i = (int)seq.size()-1; i >= 0; i--) {
            if (seq[i] == TYPE_A) {
                count += bc_count;
            } else {
                bc_count++;
            }
        }
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 7664
n=int(input())
if 400<=n<=599:
  print(8)
elif 600<=n<=799:
  print(7)
elif 800<=n<=999:
  print(6)
elif 1000<=n<=1199:
  print(5)
elif 1200<=n<=1399:
  print(4)
elif 1400<=n<=1599:
  print(3)
elif 1600<=n<=1799:
  print(2)
else:
  print(1)

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

int main(){ 
          int a,b,c,d,r ;
		  double f ;
		  cin >> a >> b ;
		  d=a/b ;
		  r=a%b ;
		   f=1.0*a/b ;
		 printf ("%d %d %.5lf\n" , d , r , f) ;
	     
	return 0;
	 }
	

Measured memory_bytes: 1176
#include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<utility>
#include<functional>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<vector>
using namespace std;
typedef long long LL;
typedef pair<int, int> P;

int main(){
    int N;
    int a[10000];
    cin>>N;
    for(int i=0;i<N;i++){
        cin>>a[i];
    }
    sort(a,a+N);
    int al=0,bo=0;
    for(int i=N-1;i>=0;i--){
        if((N-1-i)%2==0){
            al+=a[i];
        }else{
            bo+=a[i];
        }
    }   
    cout<<al-bo<<endl;

    
    return 0;
}

Measured memory_bytes: 256
/*
 * Pawan Harendra Mishra
 */

/*
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
*/

/*
 * Windows Powershell
 * Get-Content input.txt | ./a.exe > output.txt
 */

#include <bits/stdc++.h>

using namespace std;

#define X first
#define Y second
#define mod 1000000007
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

string s;
ll n, m;

int main(int argc, char const *argv[])
{
    //ios::sync_with_stdio(false);
    //cin.tie(NULL);

    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // //freopen("output.txt", "w", stdout);
    // #else
    // // online submission
    // #endif
    
    cin >> s;
    ll n = stoi(s.substr(0,2));
    ll m = stoi(s.substr(2,2));
    bool yymm = false;
    bool mmyy = false;
    
    if (n>0 && n<=12) mmyy = true;
    if (m>0 && m<=12) yymm = true;

    if (yymm && mmyy) cout << "AMBIGUOUS" << endl;
    else if (yymm) cout << "YYMM" << endl;
    else if (mmyy) cout << "MMYY" << endl;
    else cout << "NA" << endl;
    return 0;
}

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

using namespace std;

int main(){
    int N;
    cin >> N;
    int ac= 0;
    int wa = 0;
    int tle = 0;
    int re = 0;
    for (int n = 0; n < N; n++)
    {
        string s;
        cin >> s;
        if(s=="AC"){
            ac++;
        }else if(s=="WA"){
            wa++;
        }else if(s=="TLE"){
            tle++;
        }else if(s=="RE"){
            re++;
        }
    }
    cout << "AC x " << ac << endl;
    cout << "WA x " << wa << endl;
    cout << "TLE x " << tle << endl;
    cout << "RE x " << re << endl;
}

Measured memory_bytes: 3620
a, b = map(int, input().split())

if a == 1 and b == 1:
    a = 14
    b = 14
elif a == 1:
    a = 14
elif b == 1:
    b = 14

if a > b:
    print('Alice')
elif a < b:
    print('Bob')
else:
    print('Draw')


Measured memory_bytes: 8996
#include<algorithm>
#include<stdio.h>
#include<stdlib.h>
#include<vector>

using namespace std;

int main(void) {

	int a = 1;
	int N, K;
	scanf("%d%d", &N, &K);
	for (int i = 0; i < N; i++) {
		if (a < K)
			a *= 2;
		else
			a += K;
	}
	printf("%d\n", a);
	return 0;
}

Measured memory_bytes: 128
while True:
    n = int(input())
    if n == 0:
        break
    l = [0] * 10
    for i in range(n):
        a = int(input())
        l[a] += 1
    for a in l:
        if a > 0:
            print("*" * a)
        else:
            print("-")


Measured memory_bytes: 5620
n = input()
a = list(map(int, input().split()))

even_list = []
for ai in a:
  if ai % 2 == 0:
    even_list.append(ai)

for e in even_list:    
  if e % 3 != 0 and e % 5 != 0:
    print('DENIED')
    exit()
print('APPROVED')

Measured memory_bytes: 2940
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define repr(i,n) for(ll i=(n-1);i>=0;i--)
#define all(x) x.begin(),x.end()
#define br cout << "\n";
using namespace std;
const long long INF = 1e9;
const long long MOD = 1e9+7;
using Graph = vector<vector<ll>>;
template<class T> inline bool chmin(T &a, T b) { if(a > b){ a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b) { if(a < b){ a = b; return true;} return false;}

// 0 false, 1 true 
// string to int : -48
// a to A : -32
// ceil(a)  1.2->2.0
// c++17	g++ -std=c++17 a.cpp

bool cmp(pair<ll,ll> a, pair<ll,ll> b){
    if(a.first != b.first){
        return a.first > b.first;
    }

    if(a.second != b.second){
        return a.second > b.second;
    }else{
        return true;
    }
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    ll n, m; cin >> n >> m;
    vector<long long> vec(n);
    for(long long i = 0; i < n; i++){
        cin >> vec[i];
    }
    sort(all(vec));

    vector<pair<ll,ll>> card(m);
    rep(i, m){
        ll b, c; cin >> b >> c;
        card[i] = make_pair(c, b);
    }
    sort(all(card));
    
    ll now = m-1;
    for(ll i = 0; i < n; i++){
        if(card[now].second <= 0){
            now -= 1;
        }
        if(now >= m){
            break;
        }
        if(vec[i] < card[now].first){
            vec[i] = card[now].first;
            card[now].second--;
        }
    }

    ll ans = 0;
    rep(i, n){
        ans += vec[i];
    }
    cout << ans << endl;
    
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define sz(v) (ll((v).size()))
#define forn(i,n) for(ll i=0;i<(n);i++)
#define forr(i,n) for(ll i=(n)-1;i>=0;i--)
#define forv(i,v) forn(i,sz(v))
#define fors(i,s) for(auto i=(s).begin();i!=(s).end();++i)
#define all(v) (v).begin(),(v).end()
#define clr(x) memset(x,0,sizeof(x))

const ll N =1e5+5;
const ll K =110;
ll dp[N]={0},a[K],cnt[K]={0},n,k;

int main()
{
    ios_base::sync_with_stdio(false);

	cin>>k>>n;
	forn(i,k)cin>>a[i];
	forn(i,a[0])dp[i]=0;
	for(int i=a[0];i<=n;i++)
	{
		clr(cnt);
		forn(j,k){if(i>=a[j])cnt[dp[i-a[j]]]++;}
		ll f=111;forn(j,111){if(cnt[j]==0){f=j;break;}}
		dp[i]=f;
	}
	//forn(i,n+1)cout<<dp[i]<<" ";cout<<endl;
	if(dp[n]==0)cout<<"Second";else cout<<"First";

}


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

using namespace std;
#define DBG(x)                         \
    (void)(cout << "L" << __LINE__     \
                << ": " << #x << " = " \
                << (x) << '\n')
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
typedef long long ll;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const long double PI = (acos(-1));
const long double EPS = 0.0000000001;
const int INF = 0x3f3f3f3f;
const int maxn = 1100000;

void run_case()
{
    int a, b;
    cin >> a >> b;
    cout << a * b << "\n";
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setiosflags(ios::fixed) << setprecision(12);
    run_case();
    cout.flush();
    return 0;
}

Measured memory_bytes: 3640
#include<string>
#include<string.h>
#include<map>
#include<set>
#include<vector>
#include<stdio.h>
#include<math.h>
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
int main()
{
	string o;
	string e;
	string a;

	cin>>o>>e;
	
	int m=o.size();
	int n=e.size();
	
	for(int i=0;i<min(m,n);i++)
	{
		a[2*i]=o[i];
		a[2*i+1]=e[i];
	}
	//int a1=sizeof a;
	
	if(m==n)
	{
		int k = n*2;
		for(int b=0;b<k;b++)
		{
			cout<<a[b];
		}
	}
	if(m!=n)
	{
		if(min(m,n)==m)
		{
			int k= m*2;
			for(int j=m;j<=n;j++)
			{
				a[k]=e[j];
				k++;				
			}
		}
		if(min(m,n)==n)
		{
			int k=n*2;
			for(int j=n;j<=m;j++)
			{
				a[k]=o[j];
				k++;
			}
		}
		int k = min(m,n)*2 + (max(m,n)-min(m,n));
		for(int c=0;c<k;c++)
		{
			cout<<a[c];
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define MOD 1000000007
typedef long long ll;

using namespace std;

int main() {
  int n;
  ll power = 1;
  cin >> n;
  FOR(i, 1, n+1)
  {
    power = (i * power)%MOD;
  }

  cout << power << "\n";

  return(0);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std ;
#define ll  long long 
#define dl long double
#define pb push_back
#define pf push_front
#define mp make_pair
#define f first
#define s second


int main ()
{

     
   
    string s ,c;
    int p = 0;
    cin >>s>>c;
    for (int i = 0 ;i<s.size();i++)
    {
        if (s[i]!=c[i])
        	p++;
    }
   cout<<p<<endl;
	return 0;

}

Measured memory_bytes: 3916
N, K = gets.chomp.split.map(&:to_i)
v = gets.chomp.split.map(&:to_i)

ans = 0

def max(a, b)
  a > b ? a : b
end

r = [N, K].min

0.upto(K) do |i|
  0.upto(K) do |j|
    m = i + j
    break if m > r
    tmp = (v[0,i] + v[N-j,j]).sort

    # 空な場合は飛ばす
    next if tmp.empty?

    # 和を取る
    tmp_sum = tmp.inject(:+)


    # k-m回まで取り除くことが可能
    len = [(K-m), tmp.size].min

    len.times do |l|
      break if tmp[l] >= 0
      tmp_sum -= tmp[l]
    end

    ans = max(ans, tmp_sum)
  end
end

p ans


Measured memory_bytes: 2044
#include <iostream>
#include <stdio.h>
#include <vector> 
#include <algorithm>
#include <functional>
#include <string>
#include <cstring>
using namespace std;

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

	long long int result = 0;

	//gdc
	for (int i = 1; i <= K; i++) {
		if (i % 3 == 0 || i % 5 == 0) {
			continue;
		}
		result += i;
	}

	cout << result << endl;
}

Measured memory_bytes: 3636
#include "bits/stdc++.h"
#include <set>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
#define int long long
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
#define mod 1000000007
template <typename T>

void print(T x)
{
	std::cout << x << " ";
}
template <typename T>

void println(T x)
{
	std::cout << x << "\n";
}


signed main(void) {
	string s;
	cin >> s;
	if (s[2] == s[3] && s[4] == s[5])print("Yes");
	else print("No");
}

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

using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()

struct UnionFind {
  vector<int> data;
  UnionFind(int size) : data(size, -1) { }
  bool unionSet(int x, int y) {
    x = root(x); y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return x != y;
  }
  bool findSet(int x, int y) {
    return root(x) == root(y);
  }
  int root(int x) {
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  int size(int x) {
    return -data[root(x)];
  }
};

typedef int Weight;
struct Edge {
  int src, dst;
  Weight weight;
  Edge(int src, int dst, Weight weight) :
    src(src), dst(dst), weight(weight) { }
};
bool operator < (const Edge &e, const Edge &f) {
  return e.weight != f.weight ? e.weight < f.weight : // !!INVERSE!!
    e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

typedef vector<Weight> Array;
typedef vector<Array> Matrix;

pair<Weight, Edges> MST(int n, const Edges& edges, Edge* unused) {
  UnionFind uf(n);
  priority_queue<Edge> Q;
  
  Weight total = 0;
  Edges F;

  FOR(e, edges){
    if(F.size() >= n - 1){
      break;
    }
    
    if(unused != NULL && unused->src == e->src && unused->dst == e->dst){
      continue;
    }

    if (uf.unionSet(e->src, e->dst)) {
      F.push_back(*e);
      total += e->weight;
    }
  }

  return pair<Weight, Edges>(total, F);
}

int main() {

  long long int n, m;
  cin >> n >> m;

  Edges edges;

  for ( long long int i = 0; i < m; i++ ) {

    long long int s, d, c;
    cin >> s >> d >> c;
    s--; d--;

    Weight w = c;
    Edge e(s, d, w);
    
    edges.push_back(e);
  }  

  sort(edges.begin(), edges.end());
  
  /*
  for(int i = 0; i < n; i++){
    for(int j = 0; j < g[i].size(); j++){
      //cout << g[i][j].src << " " << g[i][j].dst << " " << g[i][j].weight << endl;
    }
  }
  */

  pair<Weight, Edges> mst = MST(n, edges, NULL);

  int count = 0, costs = 0;
  FOR(e, mst.second){
    pair<Weight, Edges> another_mst = MST(n, edges, &(*e));

    if(mst.first != another_mst.first){
      //cout << e->src << " " << e->dst << " " << e->weight << endl;
      count++;
      costs += e->weight;
    }
  }
  
  cout << count << " " << costs << endl;

  return 0;

}

Measured memory_bytes: 1984
#include <iostream>
using namespace std;
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <math.h>
#include <string>
#include <cstdlib>

int dx[8] = {1, 2, 1, 2, -1, -2, -1, -2}, dy[8] = {2, 1, -2, -1, -2, -1, 2, 1};

int main() {

	int n; cin >> n;
	long long int taka = 1, ao = 1;

	for(int i = 0; i < n; i++) {
		int t, a; cin >> t >> a;
		long long int n = max((taka+t-1)/t, (ao+a-1)/a);
		taka = n*t;
		ao = n*a;
		//cout << taka << ao <<endl;
	}
	cout << taka+ao <<endl;
}

Measured memory_bytes: 256
N, M  = map(int, input().split())
wa = [0] * (N+1)
ac = set()
for _ in range(M):
    p,S = input().split()
    p = int(p)
    if p in ac:
        continue
    if S == "AC":
        ac.add(p)
    else:
        wa[p] += 1

cnt = 0
for p in ac:
    cnt += wa[p]

print(len(ac),cnt)



Measured memory_bytes: 12652
#include<iostream>

using namespace std;

int dp[(int)1e5 + 1];
int arr[(int)1e5 + 1];

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

	int n,k; cin >> n >> k;

	for(int i= 0; i < n; i++) cin >> arr[i];

	dp[0] = 0;
	dp[1] = abs(arr[1] - arr[0]);

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

	cout << dp[n-1] << '\n'; 

	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
#define INF 1000000000 // 1 billion, safer than 2B for Floyd Warshall’s
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pcont(x) for(auto i: x){cout << i << " ";} cout << "\n";

int main(){
    IOS;
    string a, b;
    cin >> a >> b;
    int n = (int)a.size();
    int ans = 0;
    for(int i = 0; i<n; i++){
        if(a[i] != b[i])ans++;
    }

    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 3896
H = int(input())
W = int(input())
N = int(input())

count1 = 0
count2 = 0
for i in range(1,W+1):
    count1 += 1
    if i*H >= N:
        break
for j in range(1,H+1):
    count2 += 1
    if j*W >= N:
        break
if count1 > count2:
    print(count2)
else:
    print(count1)

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

using namespace std;

unsigned long long k, n;
unsigned long long a[55];

int main() {
    cin >> k;

    unsigned long long n = 50;
    unsigned long long t = k / n;
    for(unsigned long long i = 1; i <= 50; i++) a[i] = i + t - 1;
    for(unsigned long long i = 1; i <= k % n; i++) {
        for(unsigned long long j = 1; j <= 50; j++) 
            if (i != j) a[j]--;
            else a[j] += 50;
    }

    cout << n << endl;
    for(unsigned long long i = 1; i <= n; i++) cout << a[i] << " ";
}

Measured memory_bytes: 256
#include <cstdio>
#include <set>
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <map>

using namespace std;

#define ll long long
const ll N = 1000000000;

#define M_PI 3.14159265358979323846264338327950288

void solve() {
    int n;
    cin >> n;

    if (n % 10 == 3) {
        cout << "bon";
    } else if (n % 10 == 0 || n % 10 == 1 || n % 10 == 6 || n % 10 == 8) {
        cout << "pon";
    } else {
        cout << "hon";
    }
}

int main(){
    int t;
    t = 1;
    while(t--) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3592
n = gets.to_i
a = gets.split(' ').map(&:to_i)

result = 0

200.times { |i|
  if i == 0
    a.count{|item| item/2%2 == 0 } == a.length ? result +=1 : break
  end
  a.count{|item| item/(2**(i+1)) %2 == 0 } == a.length ? result +=1 : break
}

p result

Measured memory_bytes: 1788
import java.util.*;

public class Main {
	Scanner sc = new Scanner(System.in);
	final int MOD = 1000000007;
	final int MAX = Integer.MAX_VALUE;
	final long LMAX = Long.MAX_VALUE;

	void doIt() {
		int n = sc.nextInt();
		int max = sc.nextInt();
		for(int i = 1; i < n; i++) {
			int val = sc.nextInt();
			//System.out.println(max + " " + val);
			if(max - 1 <= val) {
				max = Math.max(val, max);
			}
			else {
				System.out.println("No");
				return;
			}
		}
		System.out.println("Yes");


	}

	public static void main(String[] args) {
		new Main().doIt();
	}
}


Measured memory_bytes: 48336
#include<stdio.h>
#include<string.h>
int main(){
char str[21],c;
int i,length;
scanf("%s",str);
length=strlen(str);
for(i=0;i<(int)length/2;i++){
c=str[i];
str[i]=str[length-i-1];
str[length-i-1]=c;
}
printf("%s\n",str);
return 0;
}

Measured memory_bytes: 524
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;cin>>n;
  vector<int>a(n);
  for(int i=0;i<n;i++){
    cin>>a.at(i);
  }
  deque<int>b;
  for(int i=0;i<n;i++){
    if(i%2==0)b.push_back(a.at(i));
    else b.push_front(a.at(i));
  }
  if(n%2==1)reverse(b.begin(),b.end());
  int size=b.size();
  for(int i=0;i<size-1;i++){
    cout <<b.at(i)<<" ";
  }
  cout <<b.at(size-1)<<endl;
}

Measured memory_bytes: 4824
#include<algorithm>
#include <iostream>
#include<cstdio>
#include<cmath>
#include<iomanip>
#include<string>
using namespace std;
int main() {

	int A1,A2,A3;
	cin>>A1>>A2>>A3;
	  int sum = 0;
	sum=A1+A2+A3;

	if(sum>21){
	cout<<"bust"<<endl;
      }else{
	cout<<"win"<<endl;
	}
    


	return 0;
}

Measured memory_bytes: 256
// dfmt off
T lread(T=long)(){return readln.chomp.to!T;}T[] lreads(T=long)(long n){return iota(n).map!((_)=>lread!T).array;}
T[] aryread(T=long)(){return readln.split.to!(T[]);}void arywrite(T)(T a){a.map!text.join(' ').writeln;}
void scan(L...)(ref L A){auto l=readln.split;foreach(i,T;L){A[i]=l[i].to!T;}}alias sread=()=>readln.chomp();
void dprint(L...)(lazy L A){debug{auto l=new string[](L.length);static foreach(i,a;A)l[i]=a.text;arywrite(l);}}
static immutable MOD=10^^9+7;alias PQueue(T,alias l="b<a")=BinaryHeap!(Array!T,l);import std, core.bitop;
// dfmt on

void main()
{
    long H, W;
    scan(H, W);
    auto S = new string[](H);
    foreach (i; 0 .. H)
        S[i] = sread();
    auto R = new long[][](H, W);
    auto C = new long[][](H, W);
    foreach (w; 0 .. W)
    {
        long h = 0;
        while (h < H)
        {
            long len = 0;
            while (h + len < H && S[h + len][w] == '.')
                len++;
            foreach (i; h .. h + len)
                C[i][w] = len;
            h += max(1, len);
        }
    }
    foreach (h; 0 .. H)
    {
        long w = 0;
        while (w < W)
        {
            long len = 0;
            while (w + len < W && S[h][w + len] == '.')
                len++;
            R[h][w .. w + len] = len;
            w += max(1, len);
        }
    }
    long ans = 0;
    foreach (h; 0 .. H)
        foreach (w; 0 .. W)
            ans = ans.max(R[h][w] + C[h][w] - 1);
    writeln(ans);
}


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

int main() {
	vector<int> n(5);
	int a = 0;
	int m[5];
	for(int i = 0; i < 5; i++){
		cin >> n[i];
	}
	sort(n.begin(), n.end());
	int c = 200;
	for(int i = 0; i < 5; i++){
		m[i] = n[i] % 10;
		n[i] -= m[i];
		if(m[i] != 0){
			n[i] += 10;
			
		}else{
			m[i] = 10;
		}
		c = min(c, m[i]);
	
		a += n[i];
	}
	int b = 200;
	for(int i = 0; i < 5; i++){
		b = min(b,m[i]);
	}
	
	cout << b + a - 10 << endl;
	
	
	return 0;
}

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

#include <fstream>
using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << setprecision(20) << fixed;
  /*
  ifstream in("input.txt");
  cin.rdbuf(in.rdbuf());
  //*/
  int D, N;
  cin >> D >> N;
  if(N == 100) cout << (int)(pow(100,D) * 101)<<endl;
  else cout << (int)(pow(100, D) * N) <<endl;
}

Measured memory_bytes: 3804
#include <bits/stdc++.h>
using namespace std;
#define rep(i,ini,n) for(int i=ini;i<n;i++)
#define _rep(i,ini,n) for(int i=ini;i>=n;i--)
#define ToEnd(a) a.begin(),a.end()
uint64_t MOD=1000000007;

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

    string ans;
    for(auto s:S){
        if(s=='B'){
            if(!ans.empty()) ans.erase(ans.size()-1);
        }
        else ans+=s;
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<unordered_map>
#include<string>
#include<math.h>
#define ll long long
using namespace std;
const ll INF = 1LL << 60;
const int inf = 1 << 30;
const ll N= 1e8;
inline void fastio()
{ 
     ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
}
int main()
{
    int n;
    for (int i = 1; i <= 5;i++)
    {
        cin >> n;
        if(n==0)
            {
                cout << i;
                break;
            }
    }
    return 0;
}

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

int main(){
    int n, x, m[1000];
    cin >> n >> x;
    rep(i,n) cin >> m[i];

    sort(m, m + n);
    rep(i,n) x -= m[i];
    
    cout << x / m[0] + n << endl;

    return 0;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pint = pair<int,int>;
ll mod = 1000000007,mod2 = 998244353;

void chmin(long long &a, long long b) { if (a > b) a = b; }
void chmax(long long &a, long long b) { if (a < b) a = b; }
const long long INF = 1LL<<60;
ll gcd(ll a,ll b){
    if(b == 0) return a;
    else return gcd(b,a%b);
}


int main() {
    double l;
    cin >> l;
    cout << fixed << setprecision(10) << l*l*l/27 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  string s,t;
  cin >> s >> t;
  sort(s.begin(),s.end());
  sort(t.begin(),t.end());
  reverse(t.begin(),t.end());
  if(s<t) cout << "Yes" <<endl;
  else cout << "No" <<endl;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <deque>
#include <numeric>
#include <utility>
#include <bitset>
#define sign(a) ((a>0)-(a<0))
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define LL long long
#define INF (LL)(1LL<<60)
#define all(a) a.begin(), a.end()
#define gr greater<LL>()
#define b32 bitset<32>
#define ui32 uint32_t

using namespace std;

void solve(long long N, long long K, std::vector<long long> A, std::vector<long long> B){
    ui32 tmp=0;
    bitset<32> kb(K);
    vector<ui32> masks = {~((ui32)K)};
    rep(i, 31){
        if(kb[i]==1){
            ui32 mask=K;
            mask |= tmp;
            mask = ~mask;
            mask |= (1<<i);
            masks.emplace_back(mask);
            //cout << bitset<32>(mask) << endl;
        }
        tmp |= (1<<i);
    }
    LL ans=0;
    for(auto mask:masks){
        LL total=0;
        rep(j, N)if((mask&A[j]) == 0)total+=B[j];
        ans = max(ans, total);
    }
    cout << ans << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    std::vector<long long> A(N);
    std::vector<long long> B(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
        scanf("%lld",&B[i]);
    }
    solve(N, K, std::move(A), std::move(B));
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
 
typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;
#define MP make_pair
#define PB push_back
#define X first
#define Y second
 
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())
#define FILL(a, value) memset(a, value, sizeof(a))
#define debug(a) cerr << #a << " = " << a << endl;
 
template<typename T> void setmax(T& x, T y) {x = max(x, y);}
template<typename T> void setmin(T& x, T y) {x = min(x, y);}
 
const double PI = acos(-1.0);
const int INF = 1e9 + 47;
const LL LINF = 1LL * INF * INF;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());


int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int n;
	cin >> n;
	VI l(n);
	FOR(i, 0, n)
		cin >> l[i];
	sort(ALL(l));
	int ans = 0;
	FOR(i, 0, n)
	{
		FOR(j, i + 1, n)
		{
			FOR(k, j + 1, n)
			{
				if(l[i] != l[j] && l[i] != l[k] && l[j] != l[k] && l[k] < l[i] + l[j])
					ans++;
			}
		}
	}
	cout << ans << endl;
	
	cerr << "Time elapsed: " << clock() / (double)CLOCKS_PER_SEC << endl;
	return 0;
}
 


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

int main()
{
    int n;
    cin >> n;
    unordered_set<int> a;
    rep(i,n) {
        int ai;
        cin >> ai;
        if(a.count(ai) > 0) {
            cout << "NO" << endl;
            return 0;
        }
        a.insert(ai);
    }

    cout << "YES" << endl;
    return 0;
}

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

int main(void)
{
  string s;
  string tenki[3] = {"Sunny", "Cloudy", "Rainy"};
  
  cin >> s;
  
  for(int i = 0; i < 3; ++i){
    if(tenki[i] == s) cout << tenki[(i+1)%3] << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
N, L = [int(x) for x in input().split()]
pie = 0
for i in range(1, N + 1):
	pie += L + i - 1
	if i == 1:
		minimum = L + i - 1
	elif i == N:
		maximum = L + i - 1

if minimum < 0:
	if maximum > 0:
		eat = 0
	else:
		eat = maximum
else:
	eat = minimum

print(pie - eat)

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

const int mxN = 1e5 + 5, mod = 1e9 + 7, base = 31, base2 = 37;
int power_B[mxN], power_B2[mxN], hashing[mxN], hashing2[mxN];
string s;

int mul(long long x, int y) {
	return x * y % mod;
}

int add(int x, int y) {
	x += y;
	if(x >= mod)
		x -= mod;
	return x;
}

int sub(int x, int y) {
	x -= y;
	if(x < 0)
		x += mod;
	return x;
}

int get_Answer(int l, int r) {
	if(!l)
		return hashing[r];
	
	return sub(hashing[r], mul(hashing[l - 1], power_B[r - l + 1]));
}

int get_Answer2(int l, int r) {
	if(!l)
		return hashing2[r];
	
	return sub(hashing2[r], mul(hashing2[l - 1], power_B2[r - l + 1]));
}

bool can(int x) {
	map<int, vector<pair<int, int>>> mp;
	int n = s.size();
	bool ok = false;
	int cnt = 0;
	for(int i = x - 1; i < n; ++i) {
		int current_Hash = get_Answer(cnt, i);
		mp[current_Hash].push_back({cnt, i});
		++cnt;
	}
	map<int, vector<pair<int, int>>> :: iterator it = mp.begin();
	while(it != mp.end() && !ok) {
		for(pair<int, int> &cur : (it-> second)) {
			for(pair<int, int> &cur2 : (it-> second)) {
				if(cur2.first > cur.second)
					ok = true;
			}
		}
		++it;
	}
	return ok;
}

int main() {
	int n;
	cin >> n;
	cin >> s;
	power_B[0] = power_B2[0] = 1;
	for(int i = 1; i < n; ++i) {
		power_B[i] = mul(power_B[i - 1], base);
		power_B2[i] = mul(power_B2[i - 1], base2);
	}
	
	int current_Hash = 0;
	for(int i = 0; i < n; ++i) {
		hashing[i] = add(s[i] - 'a' + 1, mul(base, current_Hash));
		current_Hash = hashing[i];
	}
	
	current_Hash = 0;
	for(int i = 0; i < n; ++i) {
		current_Hash = add(s[i] - 'a' + 1, mul(power_B2[i], current_Hash));
		hashing2[i] = current_Hash;
	}
	int low = 1, high = n, answer = 0, mid;
	while(low <= high) {
		mid = (low + high) / 2;
		if(can(mid)) {
			answer = max(answer, mid);
			low = mid + 1;
		}
		else
			high = mid - 1;
	}
	cout << answer;
}


Measured memory_bytes: 4224
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;

using ll = long long;
using ld = long double;
const int INF = 1e9;
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;

int main()
{
  long long a;
  scanf("%lld", &a);
  cout << a + a * a + a * a * a << endl;

  return 0;
}


Measured memory_bytes: 3756
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <stack>
#include <deque>
 
#define ll long long
#define ull unsigned long long
 
using namespace std;
 
const int MOD = 1e9+7;
const int inf = 0x3f3f3f3f;
const int PI = acos(-1.0);
 
const int N = 2e5+10;
 
 
int main() {
	#ifdef local
		if(freopen("/Users/Andrew/Desktop/Problems/data.txt", "r", stdin) == NULL) printf("can't open this file!\n");
	#endif
 
    string s;
    cin >> s;
    if (s[3] == s[2] && s[5] == s[4]) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
 
	#ifdef local
	fclose(stdin);
	#endif
	return 0;
}


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

int main(){
    int k, x;
    cin >> k >> x;
    int left = x-k+1;
    int right = x+k-1;
    for(int i = left; i < right+1; i++) {
        cout << i << " ";
    }
    cout << endl;
    return 0;
}

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

using namespace std;

int main() {
  int n;
  scanf("%d", &n);
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &a[i]);
  }
  int ans = numeric_limits<int>::max();
  for (int all = -100; all <= 100; ++all) {
    int sum = 0;
    for (int i = 0; i < n; ++i) {
      sum += (a[i] - all) * (a[i] - all);
    }
    ans = min(ans, sum);
  }
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 256
<?php
//error_reporting(0);
list($X,$Y,$Z,$K) =  explode(" ",trim(fgets(STDIN)));
$A =  explode(" ",trim(fgets(STDIN)));
$B =  explode(" ",trim(fgets(STDIN)));
$C =  explode(" ",trim(fgets(STDIN)));

for($i=0;$i<$X;$i++) {
  for($j=0;$j<$Y;$j++) {
    $ab[]=$A[$i]+$B[$j];
  }
}
rsort($ab);
for($i=0;$i<min(3000,count($ab));$i++) {
  for($j=0;$j<$Z;$j++) {
    $abc[]=$ab[$i]+$C[$j];
  }
}
rsort($abc);
for($i=0;$i<$K;$i++) {
  printf("%d\n",$abc[$i]);
}


Measured memory_bytes: 170460
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	string s;
	set<string> q;
	for(int i=1;i<=n;i++)
	{
		cin>>s;
		q.insert(s);
	}
	cout<<q.size()<<endl;
	return 0;
}

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

int main()
{
	int N;
	string s;
	cin >> N >> s;
	int len = s.length();
	for(int i = 0 ; i < len ; i++){
		char c = ((s[i] - '@' + N)%26) + '@';
		c = c == '@' ? 'Z' : c;
		s[i] = c;
	}
	cout << s << '\n';
	return 0;
}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> iint;
typedef pair<ll,ll> llll;
#define ALL(x) (x).begin(),(x).end()
const ll zero = 0;
const ll one = 1;
const ll INF = 9223372036854775807; //10^18
const int inINF = 2147483647; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int main(){
    vector<int> a(9);
    for (int i = 0; i < 9; i++) {
        cin >> a[i];
    }
    int N;
    cin >> N;
    int b;
    vector<bool> c(9,false);
    for (int i = 0; i < N; i++) {
        cin >> b;
        for (int j = 0; j < 9; j++) {
            if(a[j] == b){
                c[j] = true;
            }
        }
    }
    bool ans = false;
    for (int i = 0; i < 3; i++) {
        if(c[3*i] && c[3*i+1] && c[3*i+2]){
            ans = true;
        }
        if(c[i] && c[3+i] && c[6+i]){
            ans = true;
        }
    }
    if(c[0] && c[4] && c[8]){
        ans = true;
    }
    if(c[2] && c[4] && c[6]){
        ans = true;
    }
    if(ans){
        Yes();
    }
    else{
        No();
    }

}

Measured memory_bytes: 3628
public class Main{
  static int top1 = 0;
  static int top2 = 0;
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
/*answer*/
    int[] stack1, stack2;
    int n, i, j, x, y;
    int[] a;

    n = sc.nextInt();
    stack1 = new int[10];
    stack2 = new int[10];
    a = new int[10];

    for(i = 0;i < n;i++){
      top1 = 0; top2 = 0;
      for(j = 0;j < 10;j++)a[j] = sc.nextInt();
      for(j = 0;j < 10;j++){
        x = seetop1(stack1); y = seetop2(stack2);
        if(x <= y && a[j] > y)push2(stack2, a[j]);
        else if(y < x && a[j] > x)push1(stack1, a[j]);
        else if(x <= y && a[j] > x)push1(stack1, a[j]);
        else if(y < x && a[j] > y)push2(stack2, a[j]);
        else break;
      }
      if(j < 10)out.println("NO");
      else out.println("YES");
    }

    sc.close();
  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }
  private static void push1(int[] stack, int a){
    stack[top1++] = a;
    return;
  }
  private static int seetop1(int[] stack){
    if(top1 == 0)return 0;
    else return stack[top1 - 1];
  }
  private static void push2(int[] stack, int a){
    stack[top2++] = a;
    return;
  }
  private static int seetop2(int[] stack){
    if(top2 == 0)return 0;
    else return stack[top2 - 1];
  }
}

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

using namespace std;

struct unionfind
{
	//rankのオーバーフローに注意
	vector<long> par, rank;
	unionfind(int n)
	{
		par.resize(n);
		rank.resize(n);
		for (int i = 0; i < n; i++)
		{
			par[i] = i;
			rank[i] = 1;
		}
	}

	bool same(int u, int v)
	{
		return root(u) == root(v);
	}

	void unite(int u, int v)
	{
		if (same(u, v)) return;
		u = root(u), v = root(v);
		if (rank[u] > rank[v]) swap(u, v);
		par[u] = v;
		rank[v] += rank[u];
	}

	int root(int v)
	{
		if (par[v] == v) return v;
		return par[v] = root(par[v]);
	}
};

void solve()
{
	int s, t;
	cin >> s >> t;
	vector<pair<int, int>> es(t);
	for (int i = 0; i < t; i++)
	{
		int a, b;
		cin >> a >> b;
		es[i] = make_pair(a-1, b-1);
	}
	reverse(es.begin(), es.end());

	unionfind uf(s);

	long a = 1L*s*(s-1)/2;
	vector<long> ans;

	for (auto e : es)
	{
		ans.push_back(a);
		int v = e.first, u = e.second;
		if (!uf.same(u, v)) a -= 1L*uf.rank[uf.root(u)]*uf.rank[uf.root(v)];
		uf.unite(u, v);
	}

	reverse(ans.begin(), ans.end());

	for (long a : ans)
	{
		cout << a << endl;
	}
}

int main(void)
{
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}


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

using namespace std;

int V[55];
int main() {
    int n, k;
    cin >> n >> k;
    for (int i = 1; i <= n; i++) {
        cin >> V[i];
    }
    int ans = 0;
    for (int i = 0; i <= n; i++) {
        for (int j = 0; i + j <= min(k, n); j++) {
            vector<int> v;
            for (int x = 1; x <= i; x++) v.push_back(V[x]);
            for (int x = 0; x < j; x++) v.push_back(V[n - x]);
            sort(v.rbegin(), v.rend());
            int k2 = k - i - j;
            while (k2 > 0 && !v.empty() && v.back() < 0) {
                v.pop_back();
                k2--;
            }
            int sum = 0;
            for (int x : v) sum += x;
            ans = max(ans, sum);
        }
    }
    cout << ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pint pair<int, int>
#define pll pair<ll, ll>
#define vint vector<int >
#define vll vector<ll >
#define ALL(x) (x).begin(), (x).end()
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i,n) for (int i = 0; i < (n); ++i)
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int n;
    string s,t;
    cin >> n >> s >> t;
    
    REP(i,n){
        cout << s[i] << t[i];
    }
    cout << "\n";
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  int n;
  cin >> n;
  vector<int> x(n);
  rep (i, n) cin >> x[i];
  ll ans = 10000000;
  for (int i = 0; i <= 100; i++){
    int s = 0;
    rep(j,n) {
      s+= (x[j] - i)*(x[j] - i);
    }
    if(s < ans) ans = s;
  }
  cout << ans << endl;
}




Measured memory_bytes: 3632
using System;

namespace ABC095_C_Half_and_Half
{
	internal class Program
	{
		public static void Main(string[] args)
		{
			string[] input = Console.ReadLine().Split(' ');
			int a = int.Parse(input[0]);
			int b = int.Parse(input[1]);
			int c = int.Parse(input[2]);
			int x = int.Parse(input[3]);
			int y = int.Parse(input[4]);

			bool xBiggerY = x >= y;

			int aBuyOne = a * x;
			int bBuyOne = b * y;
			int abBuySmaller;
			int abBuyBigger;
			
			if (xBiggerY)
			{
				abBuySmaller = c * y * 2 + a * (x - y);
				abBuyBigger = c * x * 2;
				
			}
			else
			{
				abBuySmaller = c * x * 2 + b * (y - x);
				abBuyBigger = c * y * 2;
			}

			

			if (aBuyOne + bBuyOne > abBuySmaller)
			{
				if (abBuySmaller > abBuyBigger)
				{
					Console.WriteLine(abBuyBigger);
				}
				else
				{
					Console.WriteLine(abBuySmaller);
				}
			}
			else
			{
				if (aBuyOne + bBuyOne > abBuyBigger)
				{
					Console.WriteLine(abBuyBigger);
				}
				else
				{
					Console.WriteLine(aBuyOne + bBuyOne);
				}
			}
		}
	}
}

Measured memory_bytes: 11092
try:
    n=int(input())
    m=10**9+7
    arr=[int(i) for i in input().split()]
    sm=sum(arr)%m
    ans=0
    for i in range(n-1):
        sm-=arr[i]
        x=arr[i]*sm
        ans+=x
        #print(x)
    print(ans%m)
except  EOFError as e:
    print(e)


Measured memory_bytes: 105360
#include <iostream>
#include <vector>
#include <set>
using namespace std;
int main(){
  int s;
  cin >> s;

  set<int> st;
  int prev = s;
  st.insert(s);
  for(int i=2;i<=1000000;i++){
    int n = prev%2==1 ? 3*prev+1:prev/2;
    auto itr = st.find(n);
    if(itr == st.end()){
      st.insert(n);
      prev = n;
    }else{
      cout << i << endl;
      break;
    }
  }
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void) {
  int N,P[10],p=0,ans=0,i;
  scanf("%d",&N);
  for(i=0;i<N;i++)scanf("%d",&P[i]);
  for(i=0;i<N;i++)if(P[p]<P[i])p=i;
  for(i=0;i<N;i++)ans+=P[i];
  ans-=P[p]/2;
  printf("%d",ans);
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
#define rep(i,n) for(int i = 0;i<n;i++)
using namespace std;
struct segtree{
  
  int n;
  vector<long long> v;
  vector<long long> lazy;
  
  segtree(int n_){
    n=1;
    while(n<n_)n*=2;
    for(int i=0;i<2*n-1;++i){
      v.push_back(0);
      lazy.push_back(0);
    }
  }
 
  long long query2(int a,int b,long long add){
    return query(0,n,a,b,0,add);
  }
 
  void push(int k){
    v[k]+=lazy[k];
    if(2*k+2<2*n-1){
      lazy[2*k+1]+=lazy[k];
      lazy[2*k+2]+=lazy[k];
    }
    lazy[k]=0;
  }
  
  long long query(int l,int r,int a,int b,int k,long long add){
    push(k);
    if(r<=a||b<=l){
      return -(1LL<<60);
    }else if(a<=l&&r<=b){
      lazy[k]+=add;
      push(k);
      return v[k];
    }else{
      long long vl=query(l,(l+r)/2,a,b,2*k+1,add);
      long long vr=query((l+r)/2,r,a,b,2*k+2,add);
      v[k]=std::max(v[2*k+1],v[2*k+2]);
      return std::max(vl,vr);
    }
  }

};
int main(){
    long long n,d,a;
    cin >> n >> d >> a;
    pair<long long ,long long> data[n];
    vector<long long> loc;
    rep(i,n){
        cin >> data[i].first >> data[i].second;
        loc.push_back(data[i].first);
    }
    sort(data,data+n);
    loc.push_back(1e11);
    sort(loc.begin(),loc.end());
    long long ans = 0;
    segtree tree(n);
    long long p[n];
    rep(i,n) tree.query2(i,i+1,data[i].second);
    rep(i,n){
        long long loca = data[i].first;
        long long now = loca+2*d;
        auto itr = upper_bound(loc.begin(),loc.end(),now);
        int k = (itr - loc.begin());
        long long need = max(0LL,(tree.query2(i,i+1,0)+a-1)/a);
        /*for(int j = i;j<k;j++){
            data[j].second-=(need*a);
        }*/
        tree.query2(i,k,-(need*a));
        ans+=need;
    }
    cout << ans << endl;
}

Measured memory_bytes: 16492
#include<stdio.h>

int main(void){
  int n,m,i,ai,bi,sum;
  int a[100000][2];
  sum = 0;
  scanf("%d %d", &n, &m);
  for(i=0;i<n;i++){
    scanf("%d", &a[i][0]);
    a[i][1] = 0;
  }
  for(i=0;i<m;i++){
    scanf("%d %d", &ai, &bi);
    if(a[ai-1][0] > a[bi-1][0])
      a[bi-1][1] = 1;
    else if(a[ai-1][0] == a[bi-1][0]){
      a[ai-1][1] = 1;
      a[bi-1][1] = 1;
    }else
      a[ai-1][1] = 1;
  }
  for(i=0;i<n;i++){
    if(a[i][1] == 0)
      sum++;
  }
  printf("%d", sum);
  return 0;
}

Measured memory_bytes: 2508