akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int main(){
	int N;
	cin>>N;
	int x[N],y[N],h[N];
	int m;
	for(int i=0; i<N; i++){
		cin>>x[i]>>y[i]>>h[i];
		if(h[i]>0) m=i;
	}
	for(int Cx=0; Cx<=100; Cx++ ){
		for(int Cy=0; Cy<=100; Cy++){
			int H=abs(Cx-x[m])+abs(Cy-y[m])+h[m];
			bool flag = true;
			for(int i=0; i<N; i++){
				if(max(0,H-abs(x[i]-Cx)-abs(y[i]-Cy))!=h[i]){
					flag =false;
					break;
				}
            }
		if(flag){
			cout<<Cx<<" "<<Cy<<" "<<H<<endl;
			return 0;
        }
        }
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<vector>

using namespace std;
#define lli long long int
int main(){
    lli n;
    cin>>n;

    string s;
    cin>>s;

    int l=s.size();
    int i=0,j=l-1;
    for(i;i<l;i++){
        if(s[i]=='W')break;
    }
    for(j;j>=0;j--)
        if(s[j]=='R')break;
    
    if(i==l || j<0){
        cout<<0<<endl;
        return 0;
    }
    int k=0;
    while(i<=j){
        if(s[i]=='W' && s[j]=='R'){
            swap(s[i],s[j]);
            k++;
        }
        if(s[i]!='W')i++;
        if(s[j]!='R')j--;
    }

    cout<<k<<endl;
    return 0;
}

Measured memory_bytes: 3424
#include<iostream>
#include<string>
#define value( x ) cout<< "value of "<< #x << " is "<< x<<endl;
using namespace std;
int main()
{
	
   
    string x;
    cin>>x;
    string y="";
    for(int i=x.length()-1;i>=0;i--) y+=x[i];
    	if(y==x) cout<<"Yes";
    else cout<<"No";
return 0;
}


Measured memory_bytes: 256
def main():
    N = int(input())
    B = list(map(int, input().split()))
    A = [0]*N
    A[0] = B[0]
    for i in range(1, N-1):
        A[i] = min(B[i-1], B[i])
    A[-1] = B[-1]
    print(sum(A))
main()

Measured memory_bytes: 9080
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<set>
#include<math.h>
using namespace std;
  

int main(){
    long N;
    cin >> N;
    vector<long> A(N+2, 0), B(N+1, 0);
    for(long i=1; i<=N+1; i++){
        cin >> A.at(i);
    }
    for(long i=1; i<=N; i++){
        cin >> B.at(i);
    }
    
    long kill=0, killtot=0;
    
    //cout << "i=" << 1 << "  A.at(1)=" << A.at(1) << "  B.at(i)=" << B.at(1) << "  A.at(1+1)=" << A.at(1+1)  << endl;
    
    for(long i=1; i<=N; i++){
        kill=min(A.at(i), B.at(i));
        A.at(i)-=kill;
        B.at(i)-=kill;
        killtot+=kill;
        //cout << "i=" << i << "  A.at(i)=" << A.at(i) << "  B.at(i)=" << B.at(i) << "  A.at(i+1)=" << A.at(i+1)  << endl;
        kill=min(B.at(i), A.at(i+1));
        B.at(i)-=kill;
        A.at(i+1)-=kill;
        killtot+=kill;
        //cout << "i=" << i << "  A.at(i)=" << A.at(i) << "  B.at(i)=" << B.at(i) << "  A.at(i+1)=" << A.at(i+1)  << endl;
    }
    cout << killtot << endl;

    
    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <algorithm> 
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i,n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<"\n"
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define mp make_pair
#define sz(x) (ll)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using vc = vector<char>;
using vvc = vector<vc>;
template<class T> inline bool chmax(T& a, T b) { 
 if (a < b) { a = b; return true; } return false; 
}
template<class T> inline bool chmin(T& a, T b) {
 if (a > b) { a = b; return true; } return false; 
}
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
int main(){
  ll n;
  cin>>n;
  vll a(n);
  for(int i=1;i<101;i++){
    for(int j=i;j<101;j++){
      for(int z=j;z<101;z++){
        ll cu=i*i+j*j+z*z+i*j+i*z+j*z;
        if(cu<=n){
          set<ll> s;
          s.insert(i);
          s.insert(j);
          s.insert(z);
          if(sz(s)==1){
            a[cu-1]+=1;
          }
          else if(sz(s)==2){
            a[cu-1]+=3;
          }
          else{
            a[cu-1]+=6;
          }
        }
      }
    }
  }
  rep(i,n){
    cout<<a[i]<<endl;
  }
}

Measured memory_bytes: 3564
#include "bits/stdc++.h"
using namespace std;
using lint = long long;
#define low lower_bound
#define upp upper_bound
#define rep(i, n) for (lint i = 0; i < lint(n); ++i)
#define Rep(i, n) for (lint i = lint(n); i >= 0; --i)
#define all(vec) (vec).begin(), (vec).end()
#define cend printf("\n");
#define prique(T) priority_queue<T, vector<T>, greater<T>>
#define prique2(T) priority_queue<T>

struct edge { int to; double cost; };
using P = pair<lint, lint>;
using D = pair<double, double>;
using DI = pair<double, int>;
//const lint mod = 998244353LL;
const lint mod = 1000000007LL;
const lint inf = 3LL * mod * mod;

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

lint modpow(lint x, lint n, lint m) {
	lint ans = 1;
	while (n > 0) {
		if (n & 1) {
			ans *= x;
			if (m <= ans) ans %= m;
		}
		x *= x;
		if (m <= x) x %= m;
		n >>= 1;
	}
	return ans;
}

lint fact[1000000];
void f_init(lint n) {
	if (1000000 <= n) return;
	fact[0] = fact[1] = 1;
	for (lint i = 2; i <= n; ++i) {
		fact[i] = i * fact[i - 1];
		if (mod <= fact[i]) fact[i] %= mod;
	}
	return;
}

lint inver[1000000]; bool inve[100000];
lint inv(lint x) {
	if (x == 0) return 0;
	else if (inve[x]) return inver[x];
	else {
		inve[x] = true;
		return inver[x] = modpow(x, mod - 2, mod);
	}
}

lint comb(lint n, lint r) {
	if (n < r) return 0;
	if (n == r) return 1;
	lint ans = fact[n] * inv(fact[n - r]) % mod * inv(fact[r]) % mod;
	if (ans < 0) return ans + mod;
	return ans;
}

lint nck[1010][1010];
void comb(lint n) {
	rep(i, n + 1) {
		rep(j, i + 1) {
			if (j == 0 || i == j) nck[i][j] = 1;
			else nck[i][j] = nck[i - 1][j - 1] + nck[i - 1][j];
		}
	}
}

lint gcd(lint a, lint b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

lint lcm(lint a, lint b) { return a / gcd(a, b) * b; }

bool pri(lint p) {
	for (lint i = 2; i * i <= p; i == 2 ? ++i : i += 2) if (p % i == 0) return false;
	return p > 1;
}

map<lint, lint> factring(lint n) {
	map<lint, lint>ans;
	for (lint i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			n /= i;
			++ans[i];
		}
	}
	if (n != 1) ++ans[n];
	return ans;
}

double dis(D a, D b) { return sqrt((a.first - b.first) * (a.first - b.first) + (a.second - b.second) * (a.second - b.second)); }

int n, sum;
string x;
map<string, int>mp;
int main() {
	cin >> n;
	rep(i, n) {
		string s;
		int t;
		cin >> s >> t;
		mp[s] = sum + t;
		sum += t;
	}
	cin >> x;
	cout << sum - mp[x] << endl;
}


Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)




typedef long long ll;
int N, M, R, Q;
vector<pair<int, int>> E[101010];
//-----------------------------------------------------------------------------------
#define INF 1LL<<60
ll C[101010][10];
bool vis[101010][10];
void pre() {
	rep(r, 0, R) {
		priority_queue<pair<ll, int>> que;
		rep(i, 1, N + 1) C[i][r] = INF;
		rep(i, 1, N + 1) if (i % R == r) {
			C[i][r] = 0;
			que.push({ 0, i });
		}
		while (!que.empty()) {
			auto q = que.top(); que.pop();
			
			ll c = -q.first;
			int i = q.second;

			if (vis[i][r]) continue;
			vis[i][r] = 1;

			for (auto p : E[i]) {
				int j = p.first;
				ll nc = c + p.second;
				if (vis[j][r]) continue;
				if (nc < C[j][r]) {
					C[j][r] = nc;
					que.push({ -nc, j });
				}
			}
		}
	}
}
//-----------------------------------------------------------------------------------
int main() {
	cin >> N >> M >> R >> Q;
	rep(i, 0, M) {
		int a, b, c; scanf("%d%d%d", &a, &b, &c);
		E[b].push_back({ a, c });
	}

	pre();

	ll ans = 0;
	rep(i, 0, Q) {
		int x, y, z; scanf("%d%d%d", &x, &y, &z);

		ll mi = INF;
		rep(a, 0, R) mi = min(mi, C[x][a] + C[y][a]);
		ll get = z - mi;
		if(0 < get) ans += get;
	}
	cout << ans << endl;
}

Measured memory_bytes: 17664
import numpy as np
N, K = map(int, input().split())
h = list(map(int, input().split()))
h = np.array(h)
dp = np.zeros(N, dtype = int)
for i in range(1, N):
  j = max(0,i - K)
  dp[i] = np.min(dp[j:i] + np.abs(h[i] - h[j:i]))
print(dp[N-1])

Measured memory_bytes: 22884
// https://atcoder.jp/contests/abc141/tasks/abc141_c
#include <bits/stdc++.h>
using namespace std;
using P = pair<int, int>;
using ll = long long;
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

int sum[100001];
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N, K, Q;
    cin >> N >> K >> Q;
    vector<int> v(Q);
    REP(i, Q) {
        int t;
        cin >> t;
        sum[t - 1]++;
    }
    REP(i, N) {
        if (K - Q + sum[i] > 0) {
            cout << "Yes\n";
        } else {
            cout << "No\n";
        }
    }

    return 0;
}

Measured memory_bytes: 1408
import java.util.*;
//SHAKYO
public class Main {
	private void doit(){
		Scanner sc = new Scanner(System.in);
		HashMap<String, Integer> list = new HashMap<String, Integer>();
		int length= 0,count=0;
		String countStr="", lenStr="";
		while(sc.hasNext()){
			String str = sc.next();
			if(list.containsKey(str)){
				list.put(str, list.get(str) + 1);
			}
			else{
				list.put(str, 1);
			}
			int value = list.get(str);
			if(value > count){
				count = value;
				countStr = str;
			}
			int nowlen = str.length();
			if(nowlen > length){
				length = nowlen;
				lenStr = str;
			}
		}
		System.out.println(countStr + " " + lenStr);
	}

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

Measured memory_bytes: 11000
#include <bits/stdc++.h>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
//template<typename key, typename val>
//using ordered_tree =
//  tree<key, val, greater<>, rb_tree_tag, tree_order_statistics_node_update>;
typedef long long int64;
typedef complex<double> comp;
const double pi = 3.14159265358979323846;
const int inf = (int)1e+9 + 2;
const int64 inf64 = (int64)1e+18 + 2;
const double dinf = 1e+20;
const int mod = 1'000'000'007;//998244353;
const int base = 2187;
const double eps = 1e-8;
const int N = 200'000;
const int LOGN = 19;

int n, m, k;

void solve(int test)
{
  cin >> n >> m;
  vector<vector<int>> x(N);
  for (int i = 0; i < n; ++i) {
    int a, b;
    cin >> a >> b;
    x[a].push_back(b);
  }
  multiset<int, greater<int>> st;
  int64 ans = 0;
  for (int i = 1; i <= m; ++i) {
    for (auto val : x[i]) {
      st.insert(val);
    }
    if (!st.empty()) {
      ans += *st.begin();
      st.erase(st.begin());
    }
  }
  cout << ans << '\n';
}

void precalc()
{
}

int main()
{
  ios::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  precalc();
  int test = 1;
  //cin >> test;
  //auto start = chrono::high_resolution_clock::now();
  for (int i = 1; i <= test; ++i)
    solve(i);
  //cerr << chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - start).count() << '\n';
  return 0;
}


Measured memory_bytes: 10112
#include<bits/stdc++.h>
using namespace std;
#define int long long

const int N = 2e5 + 10;
const int mod = 1e9 + 7;

vector<bool> bad(N, false);
vector<int> dp(N, 0);

signed main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int n, m;
    cin >> n >> m;
    for(int i = 0; i < m; i++) {
        int x;
        cin >> x;
        bad[x] = true;
    }
    dp[0] = 1;
    dp[1] = 1 - bad[1];
    for(int i = 2; i <= n; i++) {
        if(bad[i]) {
            continue;
        }
        dp[i] = dp[i - 1] + dp[i - 2];
        dp[i] %= mod;
    }
    cout << dp[n] << "\n";
}

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

// macro
#define rep(i,n) for(i=0;i<n;i++)
#define ll long long
#define all(v) v.begin(), v.end()

// code starts
int gcd(int a, int b)
{
  if(a%b == 0) return b;
  else return gcd(b, a%b);
}

int main()
{
  int n,k;
  cin >> n >> k;
  vector<int> a(n);
  int i;
  int vmax = 0;
  rep(i,n)
  {
    cin >> a[i];
    if(a[i] > vmax) vmax = a[i];
  }
  int mgcd = a[0];
  rep(i,n-1)
  {
    mgcd=gcd(mgcd, a[i+1]);
  }
  bool ok = true;
  if(k > vmax) ok = false;
  else if(k%mgcd != 0) ok = false;
  if(ok) cout << "POSSIBLE" << endl;
  else cout << "IMPOSSIBLE" << endl;
}


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

int main() {
	string s; getline(cin, s);
	int pos1, pos2;
	int begin = 0;
	while (1) {
		pos1 = s.find("peach", begin);
		pos2 = s.find("apple", begin);
		if (pos1 == string::npos && pos2 == string::npos)
			break;
		else if (pos2 == string::npos)
			s.replace(pos1, 5, "apple"), begin = pos1+1;
		else if (pos1 == string::npos)
			s.replace(pos2, 5, "peach"), begin = pos2+1;
		else if (pos1 < pos2)
			s.replace(pos1, 5, "apple"), begin = pos1+1;
		else
			s.replace(pos2, 5, "peach"), begin = pos2+1;
	}
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 0
#include <stdio.h>
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <bitset>
#include <map>
#include <set>
#include <tuple>
#include <string.h>
#include <math.h>
#include <random>
#include <functional>
#include <assert.h>
#include <math.h>

using namespace std;

using i64 = long long int;
using ii = pair<int, int>;
using ii64 = pair<i64, i64>;

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

    vector<int> a(n), b(n);

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

    for (int i = 0; i < n; i++)
        scanf("%d", &b[i]);

    int bitCount[30] = { 0, };

    for (int bit = 29; bit >= 0; bit--)
    {            
        // a[i] + b[j]의 bit번째 비트가 1이 되는 경우의 수를 구한다
        // 일단 > bit 위치는 신경쓸 필요가 없음
        // 따라서 bit+1 위치는 모두 날려준다
        for (int i = 0; i < n; i++)
            b[i] %= (1 << (bit + 1));

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

        for (int i = 0; i < n; i++)
        {
            int x = a[i] % (1 << (bit + 1));
            //bit 자리 두개 더해서 bit자리가 1이 되는 경우
            //0 ~ 2^(bit+2) - 2 사이 숫자중에 2^bit를 포함하는 숫자
            //합이 2^bit 이상이 되는 거, 2^(bit+1)이 되는거 두 위치를 찾아서 빼준다.
            int lo1 = lower_bound(b.begin(), b.end(), (1 << bit) - x) - b.begin();
            int hi1 = lower_bound(b.begin(), b.end(), (1 << (bit + 1)) - x) - b.begin();

            int lo2 = lower_bound(b.begin(), b.end(), (1 << (bit + 1)) + (1 << bit) - x) - b.begin();

            bitCount[bit] += hi1 - lo1;
            bitCount[bit] += n - lo2;
        }
    }

    int ans = 0;

    for (int i = 0; i < 30; i++)
    {
        if (bitCount[i] % 2 == 0)
            continue;

        ans |= (1 << i);
    }

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

    return 0;
}

Measured memory_bytes: 1792
def number_count(string, n):
    count = 0
    for i in range(len(string)):
        if int(string[i]) == n:
            count += 1
    return count


def main():
    s = str(input())
    k = int(input())

    if number_count(s, 1) == len(s):   # sの中身がすべて１の場合
        number = '1'

    else:
        for i in range(len(s)):
            if s[i] != '1':
                first_index = i
                break

        if k < first_index + 1:
            number = '1'
        else:
            number = s[first_index]


    print(number)


if __name__ == '__main__':
    main()

Measured memory_bytes: 9208
#include <bits/stdc++.h>
//#include "atcoder/all"
typedef long long int ll;
using namespace std;
// using namespace atcoder;
int main() {
    int x;
    cin >> x;
    int ret;
    if (x < 600) {
        ret = 8;
    }
    else if (x < 800) {
        ret = 7;
    }
    else if (x < 1000) {
        ret = 6;
    }
    else if (x < 1200) {
        ret = 5;
    }
    else if (x < 1400) {
        ret = 4;
    }
    else if (x < 1600) {
        ret = 3;
    }
    else if (x < 1800) {
        ret = 2;
    }
    else {
        ret = 1;
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 3632
#include<iostream>
using namespace std;
int main() {
	int line[101] = { 0 };
	int code;
	while (cin >> code) {
		++line[code];
	}
	int max = 0;
	for (int i = 1; i <= 100; ++i) {
		if (max < line[i])max = line[i];
	}
	for (int i = 1; i <= 100; ++i) {
		if (line[i] == max)cout << i << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
int ans = 1e9;

int sumStamnia(int x[110], int med, int n){
  int sum = 0;
  for(int i=0;i<n;i++){
    sum += pow(x[i]- med, 2);
  }
  return sum;
}
int main(){
  int n, x[110];
  scanf("%d", &n);
  for(int i = 0;i<n; i++){
    scanf("%d", &x[i]);
  }
  sort(x, x+n);
  for(int i=1; i<=x[n-1];i++)
    ans = min(ans, sumStamnia(x,i, n));
  printf("%d\n", ans);
  return 0;
}


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

int main(){
  string s; cin>>s; 
  int n=s.size();
  vector<char> v(n);
  rep(i,n){v[i]=s.at(i);}
  
  int i=0;
  while(count(v.begin(),v.end(),'B')>0){
    while(v[0]=='B'){v.erase(v.begin());}
    if(v[i+1]=='B'){
      v.erase(v.begin()+i+1);
      v.erase(v.begin()+i);
      i--;
    }
    else{i++;}
  }
  
  rep(j,v.size()){cout<<v[j];}
}





Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define sp std::fixed<<std::setprecision
#define MOD 1000000007
#define MAX 1e18
#define N 1000005
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll l , r , mn = MAX;
    cin >> l >> r;
    if( ( r - l ) >= 2019 )
    {
        cout << 0 << endl;
        return 0;
    }
    l = ( l % 2019 );
    r = ( r % 2019 );
    if( l >= r )
    {
        cout << 0 << endl;
        return 0;
    }
    for( int i = l ; i < r ; i++ )
    {
        for( int j = i + 1 ; j <= r ; j++ )
        {
            if( ( i % 2019 * j % 2019 ) % 2019 < mn )
                mn = ( i % 2019 * j % 2019 ) % 2019;
        }
    }
    cout << mn << endl;
    return 0;
}


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


#define  SZ(items) (int)items.size()
#define  CLR(a)  memset(a,0,sizeof(a))
#define  SET(a)  memset(a,-1,sizeof(a))
#define  el "\n";

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



template <class T> inline T biton(T n, T pos)
{
    return n | ((T)1 << pos);
}
template <class T> inline T bitoff(T n, T pos)
{
    return n & ~((T)1 << pos);
}
template <class T> inline T ison(T n, T pos)
{
    return (bool)(n & ((T)1 << pos));
}
template <class T> inline T gcd(T a, T b)
{
    while (b)
    {
        a = a % b;
        swap(a, b);
    }
    return a;
}
template <class T> inline T bigmod(T p, T e, T m)
{
    T ret = 1;
    for (; e > 0; e >>= 1)
    {
        if (e & 1)
            ret = (ret * p) % m;
        p = (p * p) % m;
    }
    return (T)ret;
};



#ifdef DEBUG
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template < typename Arg1 >
void __f(const char* name, Arg1&& arg1)
{
    cerr << name << " is " << arg1 << std::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) << " is " << arg1 << " | ";
    __f(comma + 1, args...);
}
#else
#define debug(...)
#endif


void solve()
{
    string str;
    cin>>str;

    cout<<((str[2]==str[3] && str[4]==str[5])?"Yes":"No")<<endl;

}

int main()
{
    ios_base::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(10);
    cout.tie(nullptr);
    cin.tie(nullptr);

    int t = 1;

    while (t--)
    {
        solve();
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <algorithm>
#include <string>
#include <numeric>
#include <math.h>

using namespace std;
void func()
{
	int N;
	cin >> N;
	
	int64_t sum = 0;
	int64_t a;
	cin >> a;
	for (int i = 1; i < N; ++i)
	{
		int64_t tmp;
		cin >> tmp;
		if (tmp < a)
		{
			sum += (a - tmp);
			tmp += (a - tmp);
		}
		a = tmp;
	}

	cout << sum << endl;

}

int main() {
//	while(1)
	func();
	return 0;
}


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

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

	int ans = 0;
	int count = 0;
	for (int i = 1; i <= n; i++) {
		if (i % 2 == 1) {
			for (int j = 1; j <= i; j++) {
				if (i % j == 0) {
					count++;
				}
			}
			if (count == 8) {
				ans++;
			}
			count = 0;
		}
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  bool ok = false;
  for (int i = 1; i < s.size(); i++) if (s[i - 1] == s[i]) ok = true;
  if (ok) cout << "Bad" << endl;
  else cout << "Good" << endl;
  return 0;
}


Measured memory_bytes: 256
/*
    Auther: ghoshashis545 Ashis Ghosh
    College: Jalpaiguri Govt Enggineering College
*/
#include<bits/stdc++.h>
#include<string>
#include<algorithm>
using namespace std;
#define ll int
#define int long long
#define ld long double
#define ff first
#define ss string 
#define se second
#define endl "\n"
#define alt(v) v.begin(),v.end()
#define ralt(v) v.rbegin(),v.rend()
#define pb emplace_back
#define mp make_pair
#define fab(i,a,b) for(int i=(a);i<(b);i++)
#define fba(i,a,b) for(int i=(b);i>=(a);i--)
#define level 20
int mod=1000000007;
// int mod=998244353;
int dx[]={-1,1,0,0};
int dy[]={0,0,1,-1};
bool test =0;

struct query{
    int l,r,i,ans;
};

int n,q,x,y;
void solve()
{

    cin>>n>>q;
    int sqrtn=(int)sqrt(n)+1;
    int a[n+5];
    
    for(int i=0;i<n;i++)
        cin>>a[i];
    
    
    query v[q];
    
    for(int i=0;i<q;i++)
    {
        cin>>v[i].l>>v[i].r;
        v[i].i=i;
        v[i].l--;
        v[i].r--;
    }
    sort(v,v+q,[&sqrtn](query &a,query &b){
        if(a.l / sqrtn != b.l / sqrtn)
            return a.l / sqrtn < b.l / sqrtn;
        return a.r < b.r;
        }
    );


    vector<int>m(n+1);
    int curl=1, curr=0;
    int cnt=0;
    for(int i=0;i<q;i++)
    {
        
        while(curr < v[i].r)
        {
            curr++;
            if(m[a[curr]]==0) cnt++;
            m[a[curr]]++;
        }
        while(curl > v[i].l){
            curl--;
            if(m[a[curl]]==0) cnt++;
            m[a[curl]]++;
        }
        while(curr > v[i].r){
            if(m[a[curr]]==1) cnt--;
            m[a[curr]]--;
            curr--;
        }
        while(curl < v[i].l){
            if(m[a[curl]]==1) cnt--;
            m[a[curl]]--;
            curl++;
        }
        v[i].ans=cnt;
    }
    sort(v,v+q,[&](query &a,query &b){return a.i < b.i;});
    for(int i=0;i<q;i++)
        cout<<v[i].ans<<"\n";





}






    

















signed main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    int t=1;
    if(test)
    cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}

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

using namespace std;

#define rep(i,n) for(int i=0;i<(n);++i)
#define out(S) cout<<(S)<<endl;
#define ShowAll(collection) for(auto i:collection){out(i);}
#define beginend(v) v.begin(),v.end()
#define Foreach(item,collection) for(auto item : collection)

using pii=pair<int,int>;
using vb=vector<bool>;
using ll=long long;
using ull=unsigned long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vvc=vector<vector<char>>;
using ti3=tuple<int,int,int>;
template<typename T> void removeAt(vector<T>& v, int index) { v.erase(v.begin() + index); }
#define OCB(c) (c&1)|(c&2)<<2|(c&4)<<4|(c&8)<<6|(c&16)<<8|(c&32)<<10|(c&64)<<12|(c&128)<<14

int dp[20001][256]; //dp[i][j]=i番目のサンプルをjにできる最小の差分

int solve(int n, int m){
  vi c(m,0),x(n,0);
  rep(i,m) cin>>c[i];
  rep(i,n) cin>>x[i];

  rep(i,n+1)rep(j,256) dp[i][j]=INT_MAX; 
  dp[0][128]=0;

  rep(i,n) rep(j,256) {
    if(dp[i][j]==INT_MAX) continue;
    Foreach(item,c){
      auto yi=j+item;
      if(yi<0) yi=0;
      if(yi>255) yi=255;
      auto diff=x[i]-yi;
      diff=diff*diff;
      dp[i+1][yi]=min(dp[i+1][yi],dp[i][j]+diff);
    }
  }

  return *min_element(dp[n],dp[n]+256);
}

int main(){
  int n,m;
  while(cin>>n>>m,n|m){
    out(solve(n,m));
  }
}



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

using namespace std;

#define REP(i, n)   for(int i = 0; i < (n); i++)
#define REPS(i, n)  for(int i = 1; i <= (n); i++)
#define RREP(i, n)  for(int i = (n)-1; i >= 0; i--)
#define RREPS(i, n) for(int i = (n); i > 0; i--)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define mp make_pair
#define mt make_tuple
#define pb push_back

using ll  = long long;
using pi  = pair<int, int>;
using pl  = pair<ll, ll>;
using vi  = vector<int>;
using vl  = vector<ll>;
using vs  = vector<string>;
using vb  = vector<bool>;
using vvi = vector<vi>;
using vvl = vector<vl>;

const int MOD = 1e9 + 7;
const int INF = 1e9 + 7;
const ll  INFL = 1e18;
const double PI = 3.141592653589793;
const double EPS = 1e-9;

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

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    int N, M; cin >> N >> M;
    vector<vb> G(N, vb(N, false));
    REP(i, M)
    {
        int a, b; cin >> a >> b;
        a--; b--;
        G[a][b] = true;
        G[b][a] = true;
    }

    vi t(N); REP(i, N) t[i] = i;

    int ans = 0;
    do
    {
        bool ok = true;
        REP(i, N-1)
        {
            if(!G[t[i]][t[i+1]]) ok = false;
        }
        if(ok) ans++;
    } while (next_permutation(t.begin()+1, t.end()));
    cout << ans << endl; 
}

Measured memory_bytes: 3604
#include<iostream>
#include<bitset>
#include<vector>

using namespace std;

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

  vector<int> s(m,0);

  int k;
  for(int i =0; i < m; ++i){
    cin >> k ;
    for(int j = 0; j < k; ++j){
      int a;
      cin >> a;
      --a;
      s[i] |= 1 << a;
    }
  }

  vector<int> p(m);
  //for(int i =0; i < m; ++i)cout << bitset<10>(s[i]) << endl;
  for(int i =0; i < m; ++i)cin >> p[i];

  int ans = 0;
  for(int i =0; i < (1 << n); ++i){
    int cnt = 0;
    for(int j =0; j < m; ++j){
      int res = 0;
      for(int k =0; k < n; ++k){
//        cout << bitset<10>(i) << " s:" << bitset<10>(s[j])<< " i  :" << bitset<10> (1 &(s[j] >> k)) << " j :" << bitset<10> (s[j] >> k) << endl;
        if( (1 & ( i >> k)) & (1 &( s[j] >> k)))res++;
//        cout << "res " <<res << endl;
      }
      if(res%2 == p[j])++cnt;
//      cout << "cnt " << cnt << endl;
    }
    if(cnt == m)++ans;
  }
  cout << ans << endl;
}





Measured memory_bytes: 256
#include<iostream>
#include<sstream>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<complex>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cassert>

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define mp make_pair
#define pb push_back
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define dbg(x) cerr<<__LINE__<<": "<<#x<<" = "<<(x)<<endl

using namespace std;

const double EPS = 1e-9;
typedef vector<int> vi;
typedef complex<double> P;

int n, r[1000];
int dp[1000];
P p[1000];

int rec(int c, const vi &idx){
	int &res = dp[c];
	if(res >= 0) return res;
	res = 0;
	rep(i, idx.size()) if(abs(p[c] - p[idx[i]]) + EPS < r[c] - r[idx[i]])
		res = max(res, rec(idx[i], idx));
	
	return ++res;
}

int main(){
	while(cin >> n, n){
		vi a, b;
		P pa, pb;
		int ans = 0;
		cin >> pa.real() >> pa.imag() >> pb.real() >> pb.imag();
		rep(i, n){
			cin >> p[i].real() >> p[i].imag() >> r[i];
			bool fa = abs(p[i] - pa) < r[i];
			bool fb = abs(p[i] - pb) < r[i];
			if(fa != fb){
				if(fa) a.pb(i);
				else b.pb(i);
			}
		}
		
		memset(dp, -1, sizeof(dp));
		rep(i, a.size()) rep(j, b.size()){
			if(abs(p[a[i]] - p[b[j]]) < r[a[i]] + r[b[j]] + EPS) continue;
			ans = max(ans, rec(a[i], a) + rec(b[j], b));
		}
		rep(i, a.size()) ans = max(ans, rec(a[i], a));
		rep(i, b.size()) ans = max(ans, rec(b[i], b));
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1304
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define print(A,x,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i]x;}cout<<endl;
#define pprint(A,y,m,n) rep(j,0,m){print(A[j],y,n);}
const long mod=1e9+7;
const int size=3e5;
const int inf=1e9;
int main(){
	string s;cin>>s;
	int num[s.size()+1] = {};
	long res = 0; long t = 1;
	for(int i = s.size()-1; i >= 0; i--){
		num[i] = num[i+1] + (s[i] - '0') * t;
		num[i] %= 2019;
		(t *= 10) %= 2019;
	}
	int cnt[2019] = {};
	for(int v:num){
		cnt[v]++;
	}
    int ans = 0;
	rep(i,0,2019) ans += cnt[i] * (cnt[i] - 1) / 2;
	cout<<ans<<endl;
}

Measured memory_bytes: 4512
#include <iostream>
#include <cmath>
#include <climits>
#include <vector>
#include <algorithm>

using namespace std;
using Int = long long int;
using UInt = unsigned long long int;
using VI = vector<unsigned long long int>;

// 基本的な演算
namespace BasicMath {
    // 分数の Ceil を求める関数
    static UInt Ceil(const UInt a, const UInt b);
    // 二つの値の最小値を求める関数
    static Int Min(const Int a, const Int b);

    // 分数の Ceil を求める関数
    UInt Ceil(const UInt a, const UInt b) {
        if (a % b == 0) {
            return a / b;
        } else {
            return a / b + 1;
        }
    }

    // 二つの値の最小値を求める関数
    Int Min(const Int a, const Int b) {
        if (a <= b) {
            return a;
        } else {
            return b;
        }
    }
}
using namespace BasicMath;

int main(void) {
    Int d, g;
    cin >> d >> g;
    VI c(d + 1);
    VI p(d + 1);
    for (Int i = 1; i <= d; ++i) {
        cin >> c[i] >> p[i];
    }

    Int result = INT_MAX;
    Int comb = pow(2, d);

    for (Int i = 0; i < comb; ++i) {
        Int cost = 0;
        Int loop_result = 0;
        for (Int j = 1; j <= d; ++j) {
            if (i & (1 << (j - 1))) {
                cost += (100 * j * c[j] + p[j]);
                loop_result += c[j];
            }
        }
        if (cost >= g) {
            result = min(result, loop_result);
        } else {
            Int diff = g - cost;
            for (Int j = 1; j <= d; ++j) {
                if ((i & (1 << (j - 1))) == 0) {
                    if (diff <= (c[j] * 100 * j)) {
                        result = Min(result, loop_result + Ceil(diff, 100 * j));
                    }
                }
            }
        }
    }
    cout << result << endl;
    return 0;
}


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

cur, nxt = [0] * 3, [0] * 3
for i in range(N):
    abc = [int(c) for c in input().split()]
    for k in range(3):
        for last in range(3):
            if k != last:
                nxt[k] = max(nxt[k], cur[last] + abc[k])

    cur = nxt
    nxt = [0] * 3

ans = max(cur[k] for k in range(3))
print(ans)


Measured memory_bytes: 46680
n = int(input())
s = input()
a = [0]*n
a[0] = s[1:].count('E')
for i in range(1,n):
    if s[i-1] == 'W':
        a[i] = a[i-1]+1
    else:
        a[i] = a[i - 1]
    if s[i] == 'E':
        a[i] -= 1
print(min(a))


Measured memory_bytes: 15436
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

typedef long long ll;
typedef int keytype;

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

/* a[0], ..., a[n-1] の数の最大公約数 */
int ngcd(int n, int a[])
{
    int i, d;

    d = a[0];
    for (i = 1; i < n && d != 1; i++)
        d = gcd(a[i], d);
    return d;
}

void quicksort(keytype a[], int first, int last)
{
    int i, j;
    keytype x, t;

    x = a[(first + last) / 2];
    i = first;  j = last;
    for ( ; ; ) {
        while (a[i] < x) i++;
        while (x < a[j]) j--;
        if (i >= j) break;
        t = a[i];  a[i] = a[j];  a[j] = t;
        i++;  j--;
    }
    if (first  < i - 1) quicksort(a, first , i - 1);
    if (j + 1 < last) quicksort(a, j + 1, last);
}

int is_prime(int x){
    if(x <= 1) return 0;
    for(int i = 2; i * i <= x; i++){
        if(x % i == 0) return 0;
    }
    return 1;
}

int is_substr(char s[], char t[], int i){
    int flag = 1;

    if(s[i] == '\0') flag = 0;

    for(int j = 0; j < strlen(t); ++j, ++i){
        if(s[i] != t[j]){
            flag = 0;
            break;
        }
    }
    return flag;
}

// factor list, number of factors, natural number
void factorize(int ftr[], int *num, int n){
    int a = 2, cnt = 0;

    while(n >= a){
        if(n % a == 0){
            n = n / a;
            ftr[cnt++] = a;
        }else{
            a++;
        }
    }
    *num = cnt;
}

//#define N 5
//int p[N + 1];
int nextperm(int p[], int N)  /* 辞書式順序で次の順列 */
{
    int i, j, t;

    i = N - 1;
    p[0] = 0;  /* 番人 */
    while (p[i] >= p[i + 1]) i--;
    if (i == 0) return 0;  /* 完了 */
    j = N;
    while (p[i] >= p[j]) j--;
    t = p[i];  p[i] = p[j];  p[j] = t;
    i++;  j = N;
    while (i < j) {
        t = p[i];  p[i] = p[j];  p[j] = t;  i++;  j--;
    }
    return 1;  /* 未了 */
}

void comb(int size1, int size2, int v[size1][size2]){
  for(int i = 0; i < size1; i++){
    v[i][0] = 1;
    v[i][i] = 1;
  }
  for(int k = 1; k < size1; k++){
    for(int j = 1; j < k; j++){
      v[k][j] = (v[k-1][j-1] + v[k-1][j]);
    }
  }
}

int abs_val(int a, int b){
    if(a > b) return a - b;
    else return b - a;
}

int min(int a, int b){
    if(a > b) return b;
    else return a;
}

const int inf = 1012345678;
int main(){
    int n, a, b;

    scanf("%d %d %d", &n, &a, &b);

    if((a * n) > b) printf("%d\n", b);
    else printf("%d\n", a * n);

    return 0;
}


Measured memory_bytes: 1724
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define debug(a) cerr << #a << ": " << a << endl
#define sz(a) int(a.size())
#define rep(i,n) for(int i=0;i<n;i++)
#define forr(i, st, en) for(int i = st; i <= en; i++)
#define all(v) (v).begin(),(v).end()
#define X first
#define Y second
#define pb push_back
#define fast cin.tie(0); ios::sync_with_stdio(false)
#define vi vector<int>
#define vii vector<vector<int>>
vii a;
vector<bool> vis;
int cnt;
void dfs(int u){
	vis[u] = true;
	cnt++;
	for(int nei : a[u]){
		if(!vis[nei]) dfs(nei);
	}
}
int32_t main(){ fast;
	int n, m; cin>>n>>m;
	a.resize(n);
	vis.resize(n, false);
	rep(i, m){
		int x, y; cin>>x>>y;
		x--; y--;
		a[x].pb(y);
		a[y].pb(x);
	}
	int cnt_CC = 0;
	int answer = 0;
	rep(i, n){
		if(!vis[i]){
			cnt = 0;
			vis[i] = true;
			cnt_CC++;
			dfs(i);
			answer = max(answer, cnt);
		}
	}
	//debug(cnt_CC);
	cout<<answer<<endl;
}


Measured memory_bytes: 20268
# include <bits/stdc++.h>
# define ll int64_t
# define rep(i,n) for(ll i=0;i<n;i++)
# define rrep(i,n) for(ll i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define mod 1000000007

using namespace std;

bool compare_by_b(pair<string,ll> a,pair<string,ll> b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

bool my_compare(pair<string,ll> a,pair<string,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;
}

ll factorial(ll n){
    ll x=1;
    rrep(i,n) x*=i;
    return x;
}

ll gcd(ll a,ll b)
{
   if (a%b == 0) return(b);
   else return(gcd(b,a%b));
}

ll lcm(ll a,ll b)
{
   return a/gcd(a,b)*b;
}



int main(){
    double n,k,maxi=-100,sum=0;
    cin>>n>>k;
    vector<double> p(n),q(n),r(n+1,0);
    rep(i,n) {
        cin>>p[i];
        q[i]=(1+p[i])/2;
        sum+=q[i];
        r[i+1]=sum;
    }
    if(n==1){
        cout<<q[0]<<endl;
        return 0;
    }
    rep(i,n-k+1){
        if(maxi<(r[i+k]-r[i])) maxi=r[i+k]-r[i];
    }
    cout<<fixed<<setprecision(30)<<maxi<<endl;
    return 0;
}


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

int main() {
  int N,M;
  cin >> N >>M;
  double A[N];
  double sum=0;
  for(int i=0;i<N;i++){
    cin >> A[i];
    sum += A[i];
  }
  double th = sum/(4*M);
  int cnt=0;
  for(int i=0;i<N;i++){
    if(A[i]>=th){
      cnt++;
    }
  }
  if(cnt>=M)
    cout <<"Yes" << endl;
  else
    cout <<"No" << endl;
    
}





Measured memory_bytes: 256
import std.stdio;
import std.string;
import std.conv;

void main() {
  double[] weight = [48, 51, 54, 57, 60, 64, 69, 75, 81, 91];
  string[] names =
    ["light fly", "fly", "bantam", "feather",
     "light", "light welter", "welter",
     "light middle", "middle", "light heavy", "heavy"];
  while(true) {
    string line = readln.chomp;
    if (stdin.eof) break;
    double num = line.to!(double);
    string ans;
    if (weight[0] >= num) ans = names[0];
    else if (weight[$ - 1] < num) ans = names[$ - 1];
    else {
      for(uint i = 0; i < (weight.length - 1); i++) {
        if (weight[i] < num && num <= weight[i + 1]) {
          ans = names[i + 1];
        }
      }
    }
    writeln(ans);
  }  
}

Measured memory_bytes: 1076
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define pow(x,y) modpow(x,y)
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REPS(i,n) for(ll (i)=1;(i)<=(n);(i)++)
#define RREP(i,n) for(ll (i)=(n-1);(i)>=0;(i)--)
#define RREPS(i,n) for(ll (i)=(n);(i)>0;(i)--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());

template <class T = int>T in(){
    T x;
    cin >> x;
    return (x);
}

template<class T> inline void chmin(T& a, T b){
    if (a > b){
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b){
    if (a < b){
        a = b;
    }
}

/* modとる */
inline ll modu(ll a){
    return(a % mod + mod) % mod;
}

/* modつき二項係数 前処理必要*/
const ll binomialmax = 510000;
ll fac[binomialmax], finv[binomialmax], inv[binomialmax];

void cominit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < binomialmax; i++){
        fac[i] = modu(fac[i - 1] * i);
        inv[i] = modu(-inv[mod%i] * (mod / i));
        finv[i] = modu(finv[i - 1] * inv[i]);
    }
}

/* 二項係数計算 */
ll com(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return modu(fac[n] * (modu(finv[k] * finv[n - k])));
}


signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    cominit();
    int N = in();
    int K = in();
    vector<ll> A(N);
    REP(i,N)A[i] = in<ll>();
    sort(ALL(A),greater<>());
    ll answer = 0;
    for(int i = 0;N-1-i >= K-1;i++){
        answer += modu((A[i]- A[N-1-i])*com(N-i-1,K-1));
        answer = modu(answer);
    }
    cout << answer << "\n";
}

Measured memory_bytes: 13056
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1000000007;
const LL INF=100000000000;
string u="abcdefghijklmnopqrstuvwxyz";


int main(){
    int N;
    cin >> N;
    N*=2;
    int l[N];
    for(int i=0;i<N;i++){
        cin >> l[i];
    }
    sort(l,l+N);
    int ans=0;
    for(int i=0;i<N;i+=2){
        ans+=min(l[i],l[i+1]);
    }
    cout << ans << endl;
    return 0;
}

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

int main()
{
 int A,B;
 cin>>A>>B;
if(A==1){A+=1000000;}
if(B==1){B+=1000000;}
if(A>B){cout<<"Alice"<<endl;}
else if(A<B){cout<<"Bob"<<endl;}
else{cout<<"Draw"<<endl;}
return 0;}




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

// ------------------------

void solve() {
    int N, R; cin >> N >> R;
    if(N >= 10){
        cout << R << endl;
    }else{
        cout << R + 100*(10 - N) << endl;
    }
}

signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}

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

int main() {
    int a, b;
    int 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: 3160
using System;
using System.Linq;

public class AtCoder
{
  public static void Main()
  {
    var input = Console.ReadLine().Trim().Split().Select(e => long.Parse(e)).ToArray();
    var a = input[0];
    var b = input[1];
  
    var x = input[2];

    Func<long, long> f = (n) => {
      if(n < 0) return 0;
      return n / x + 1; 
    };   

    var ans = f(b) - f(a - 1);
    Console.WriteLine(ans);
  }

}

Measured memory_bytes: 13396
#include <iostream>
#include <queue>
#include <map>
#include <algorithm>
#include <vector>
#include <string>
#include <tuple>
#include <functional>
using namespace std;

string S;

int main() {
	cin >> S;
	cout << S[0] << S.size() - 2 << S[S.size() - 1] << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
  int i,j,N,k,p;
  int v[1000];
  scanf("%d",&N);
  for(i=0; i < N;i++){
    scanf("%d",&v[i]);
  }
  for(i=0;i< N;i++){
    k=v[i];
    j=i-1;
    while(j>= 0 && v[j] > k){
      v[j+1]=v[j];
      j--;
      v[j+1]=k;
    }
    for(p=0;p < N ;p++){
        if (p<N-1) {
      printf("%d ",v[p]);
        } else {
            printf("%d",v[p]);
        }
    }
    printf("\n");
  }
  return 0;
}



Measured memory_bytes: 2140
#include<stdio.h>
#include<iostream>
#include<string>
#include<memory>
int main(){
    int length;
    std::cin>>length;
    int *B=nullptr;
    try{
        B=new int[length];
    }catch(const std::bad_alloc e){
        std::cout<<"cannnot be allocated."<< std::endl;
    }
    int ans=0;
    for(int i=0;i<length-1;i++){
        std::cin>>B[i];
        //std::cout<<B[i]<<std::endl;
    }

    ans+=B[0]+B[length-2];

    for(int i=1;i<length-1;i++){
        if(B[i]<B[i-1]) ans+=B[i];
        else ans+=B[i-1];
    }
    std::cout<<ans<<std::endl;
    delete B;
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

int main(){
    ll n, m;
    cin >> n >> m;
    ll ans = 1LL;
    for(ll i = 1; i * i <= m; ++i) {
        if(m % i != 0) continue;
        ll j = m / i;
        if(m - i*n >= 0) {
            ans = max(ans, i);
        }
        if(m - j*n >= 0) {
            ans = max(ans, j);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main()
{
	int tate[30];
	int yoko1,yoko2;
	int w,n;
	int temp;
	int i;
	
	scanf("%d",&w);
	scanf("%d",&n);
	for(i=0;i<w;i++)
	{
		tate[i]=i+1;
	}
	for(i=0;i<n;i++)
	{
		scanf("%d,%d",&yoko1,&yoko2);
		temp=tate[yoko1-1];
		tate[yoko1-1]=tate[yoko2-1];
		tate[yoko2-1]=temp;
	}
	for(i=0;i<w;i++)
	{
		printf("%d\n",tate[i]);
	}
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define FASTIO std::ios::sync_with_stdio(false);
#define MAXN 200005
int main(){
  FASTIO
  int n;
  cin>>n;
  int a[n], b[n], c[n], ans=0;
  for(int i=1;i<=n;i++)cin>>a[i];
  for(int i=1;i<=n;i++)cin>>b[i];
  for(int i=1;i<=n-1;i++)cin>>c[i];
  for(int i=1;i<=n;i++){
    if(i>1){
      if(a[i]==a[i-1]+1)ans+=c[a[i]-1]+b[a[i]];
      else {
        ans+=b[a[i]];
      }
    }
    else {
      ans+=b[a[i]];
    }

  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
def main():
    n = int(input())
    a=list(map(int,input().split()))
    temp=1
    cnt=0
    for i in range(n):
        if a[i]==temp:
            temp+=1
        else:
            cnt+=1
    if n == cnt:
        print(-1)
        return
    print(cnt)

if __name__=='__main__':
    main()


Measured memory_bytes: 26268
n = int(input())
t, a = map(int, input().split())
h = list(map(int, input().split()))
delta = float('inf')
index = 0

for i, v in enumerate(h):
  temp = abs(a - (t - v * 0.006))
  if temp < delta:
    delta = temp
    index = i+1

print(index)

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

long long a, b, n;

long long solve();

int main() {
  cin >> a >> b >> n;
  cout << solve() << endl;
  return 0;
}

long long solve() {
  if (n >= b) n = b - 1;
  return n % b * a / b;
}

Measured memory_bytes: 3628
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <chrono>
#include <random>
#include <tuple>
#include <utility>
#include <fstream>

const long INF = 1123456789012345678;

long n;
std::string s;
long cnt[2];

int main(){
	scanf("%ld", &n);
	std::cin >> s;
	for(int i = 0; i < n; i++){
		if(s[i] == 'R'){
			cnt[0]++;
		}else{
			cnt[1]++;
		}
	}
	if(cnt[0] > cnt[1]){
		printf("Yes\n");
	}else{
		printf("No\n");
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int MOD = pow(10, 9) + 7;
//const int MOD = 998244353;
//const int MOD = ;
int mod(int A, int M) {return (A % M + M) % M;}
const int INF = 1LL << 60;
const string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const string abc = "abcdefghijklmnopqrstuvwxyz";
template <class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template <class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
int divCeil(int A, int B) {return (A + (B - 1)) / B;}
int myctoi(char C) {return C - 48;}
char myitoc(int N) {return '0' + N;}

signed main()
{
  string S, T;
  cin >> S >> T;
  
  vector<vector<int>> dp(S.size() + 10, vector<int>(T.size() + 10, 0));

  for (int i = 0; i < S.size(); i++)
  {
    for (int j = 0; j < T.size(); j++)
    {
      if (S.at(i) == T.at(j))
        chmax(dp.at(i + 1).at(j + 1), dp.at(i).at(j) + 1);
      chmax(dp.at(i + 1).at(j + 1), dp.at(i + 1).at(j));
      chmax(dp.at(i + 1).at(j + 1), dp.at(i).at(j + 1));
    }
  }

  string ans = "";
  for (int i = S.size(), j = T.size(); i > 0 && j > 0; )
  {
    if (dp.at(i).at(j) == dp.at(i - 1).at(j)) i--;
    else if (dp.at(i).at(j) == dp.at(i).at(j - 1)) j--;
    else
    {
      ans = S.at(i - 1) + ans;
      i--; j--;
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 71296
//#include "pch.h"
#include <iostream>
#include <algorithm>
#include <numeric>
#include <string>
#include <vector>
using namespace std;

#define FOR(i, s, e) for(int i=s; i<e; i++)
#define REF(i, s, e) for(int i=s; i>e; i--)
typedef long long ll;
const int INF = 1<<30;

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

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

	vector<int> h(n);
	FOR(i, 0, n) cin >> h[i];
	sort(h.begin(), h.end());

	//cout << "h:" << endl;
	//FOR(i, 0, n) cout << h[i] << endl;
	//cout << endl;

	//h[i+k] - h[i]の最大値が答え
	int min1 = INF;
	FOR(i, 0, n - k + 1) {
		int tmp = h[i + k - 1] - h[i];
		//cout << "tmp: " << tmp << endl;
		min1 = min(min1, tmp);
	}
	cout << min1 << endl;

}

Measured memory_bytes: 640