akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"

using namespace std;

vector<int> vals;
vector<int> minVal;
int dp(int currPos)
{
    if(currPos <= 0)
    {
        return 0;
    }
    if(currPos == 1)
    {
        return abs(vals[1] - vals[0]) ;
    }
    if(minVal[currPos] != INT_MAX)
    { 
        return minVal[currPos];
    }
    else
    {
        minVal[currPos] = min(dp(currPos - 1) + abs(vals[currPos] - vals[currPos - 1]), dp(currPos - 2) + abs(vals[currPos] - vals[currPos - 2]));
        return minVal[currPos];
    }
}
int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    int temp;
    for(int x = 0; x < n; ++x)
    {
        cin >> temp;
        vals.push_back(temp);
    }
    for(int x = 0; x < n; ++x)
    {
        minVal.push_back(INT_MAX);
    }
    cout <<  dp(n - 1);
    return 0;
}

Measured memory_bytes: 3576
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
using namespace std;
#define REP(i,x,n) for(int i = x; i < n; i++)
#define MAX 100

int N;
int A[114514];
// int dp[1000000001];

int main(void){
    // Your code here!
    cin >> N;
    
    // int ans = 0;
    int dis = 0;
    REP(i,0,N) {
        cin >> A[i];
        if(i == 0) {
            dis += abs(A[i]);
        }
        else {
            dis += abs(A[i] - A[i-1]);
        }
    }
    dis += abs(A[N-1]);
    // cout << dis << endl;
    
    REP(i,0,N) {
        int ans = 0;
        if(i == 0) {
            ans = dis - (abs(A[i+1] - A[i]) + abs(A[i]) - abs(A[i+1]));
            cout << ans << endl;
        }
        else if(i == N-1) {
            ans = dis - (abs(A[i]) + abs(A[i]-A[i-1]) - abs(A[i-1]));
            cout << ans << endl;
        }
        else {
            ans = dis - (abs(A[i+1] - A[i]) + abs(A[i]-A[i-1]) - abs(A[i+1]-A[i-1]));
            cout << ans << endl;
        }
    }
    
    
    // REP(i,0,N) {
    //     int dis = 0;
    //     int pos = 0;
    //     REP(j,0,N) {
    //         if (i == j) {
    //             continue;
    //         }
    //         else {
    //             dis += abs(A[j] - pos);
    //             // cout << dis << endl;
    //             pos = A[j];
    //         }
    //     }
    //     dis += abs(pos);
    //     cout << dis << endl;
    // }
    
    
   
    
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0 ; i < (int)(n) ; i++)
typedef long long ll;
typedef long double Double;
void solve(ll N, vector<ll> a, vector<ll> b){
	vector<ll> c(N);
	rep(i,N) c[i] = b[i] - a[i];
	sort(c.begin(),c.end());
	long long sum = 0;
	for(int i = 0 ; i < c.size() ; i++){
		if( c[i] < 0 ){
			sum -= -c[i];
		}else{
			sum += c[i] / 2;
		}
	}
	if( sum >= 0 ) cout << "Yes" << endl;
	else cout << "No" << endl;
}

int main(){	
	ll N;
	scanf("%lld",&N);
	vector<ll> b(N-1+1);
	vector<ll> a(N-1+1);
	for(int i = 0 ; i <= N-1 ; i++){
		scanf("%lld",&a[i]);
	}
	for(int i = 0 ; i <= N-1 ; i++){
		scanf("%lld",&b[i]);
	}
	solve(N, a, b);
	return 0;
}



Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
const int N=4000002;
char s[N],t[N];
int a,b,ne[N],ans,g[N],i,j;
int main(){
	scanf("%s%s",s+1,t+1),a=strlen(s+1),b=strlen(t+1);
	for (;a<b*2;a*=2)
		for (i=1;i<=a;i++) s[i+a]=s[i];
	for (i=1;i<=a;i++) s[i+a]=s[i];
	a*=2;
//	for (i=2,j=1;i<=b;i++){
//		while (j>1 && t[i]!=t[j]) j=ne[j-1];
//		if (t[i]==t[j]) j++;
//		ne[i]=j;
//	}
//	for (i=1,j=1;i<=a;i++){
//		while (j>1 && s[i]!=t[j]) j=ne[j-1];
//		if (s[i]==t[j]) j++;
//		if (j==b+1) ans=max(ans,g[i]=g[i-b]+1);
//	}
//	ne[0]=-1;
//	for (i=1;i<=b;i++){
//		j=i-1;
//		while (j && t[ne[j]+1]!=t[i]) j=ne[j];
//		ne[i]=ne[j]+1;
//	}
//	for (i=1,j=0;i<=a;i++){
//		while (~j && s[i]!=t[j+1]) j=ne[j];
//		if (++j==b) ans=max(ans,g[i]=g[i-b]+1);
//	}
	ne[0]=-1;
	for (i=1;i<=b;i++){
		j=i-1;
		while (j && t[ne[j]+1]!=t[i]) j=ne[j];
		ne[i]=ne[j]+1;
	}
	for (i=1;i<=b;i++) ne[i]++;
	for (i=1,j=1;i<=a;i++){
		while (j && s[i]!=t[j]) j=ne[j-1];
		if (++j==b+1) ans=max(ans,g[i]=g[i-b]+1);
	}
	printf("%d",ans>=a/b-1?-1:ans);
}


Measured memory_bytes: 23040
#include <stdio.h>
#define FALSE -1
int A[45];

int fibona(int n)
{
  if(n==0 || n==1) return A[n]=1;
  if(A[n]!=FALSE) return A[n];
  return A[n]=fibona(n-1)+fibona(n-2);
}

int main()
{
  int i,num;
  for(i=0;i<45;i++)A[i]=-1;
  scanf("%d",&num);
  printf("%d\n",fibona(num));
	 return 0;
}

Measured memory_bytes: 596
n=int(input())
seq=list(map(int,input().split()))
seq.sort()
t=n//2
s=seq[t:]
if 1==1:
        x=seq[-1]
        d=sum(s)-x
        d=d*2
        d+=x
        
        if n%2==0:
                print(d)
        else:
                print(d-seq[t])




Measured memory_bytes: 31500
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i < (n); i++)
#define lower(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
using namespace std;
using ll = long long;
int INF = 1001001001;

int main() {
  char c;
  cin >> c;
  printf("%c", c+1);
  return 0;
}

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

int main(){
  string s; cin>>s;
  int c0=0,c1=0;
  for(int i=0;i<s.size();i++){
    if(s[i]=='0') c0++;
    else c1++;
  }
  if(c0<c1) cout<<c0*2;
  else cout<<c1*2;
  cout<<endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
#define P(x) cout << (x) << endl
#define p(x) cout << (x)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define vv(type, c, m, n, i) vector<vector<type>> c(m, vector<type>(n, i));
#define rep(i,a,n) for(int i=(a), i##_len=(n); i<i##_len; ++i)
#define rrep(i,a,n) for(int i=(a), i##_len=(n); i>i##_len; --i)
#define len(x) ((int)(x).size())
#define mp make_pair
#define eb emplace_back
typedef long long ll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
constexpr int MAX = 1005;
inline int lcs(string X, string Y) {
	vv(int, c, MAX, MAX, 0);
	int m = len(X);
	int n = len(Y);
	int maxl = 0;
	X = ' ' + X;
	Y = ' ' + Y;
	rep(i, 1, m + 1) {
		rep(j, 1, n + 1) {
			if(X[i] == Y[j]) c[i][j] = c[i - 1][j - 1] + 1;
			else c[i][j] = max(c[i - 1][j], c[i][j - 1]);
			if(maxl < c[i][j]) maxl = c[i][j];
		}
	}
	return maxl;
}
int main() {
	int n; cin >> n;
	string s1, s2;
	rep(i, 0, n) {
		cin >> s1 >> s2;
		P(lcs(s1, s2));
	}
	return 0;
}

Measured memory_bytes: 6888
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
using namespace std;


int main(){
	int n;
	cin >> n;
	
	vector<double> r(n);
	for(int i=0; i<n; i++){
		cin >> r[i];
	}
	
	vector<double> p(n);
	p[0]=0.0;
	double left=-r[0], right=r[0];
	for(int i=1; i<n; i++){
		double newpos=0.0;
		for(int j=0; j<i; j++){
			newpos = max(newpos, p[j] +sqrt((r[i]+r[j])*(r[i]+r[j]) -(r[i]-r[j])*(r[i]-r[j])));
		}
		p[i] = newpos;
		left = min(left, newpos-r[i]);
		right = max(right, newpos+r[i]);
	}
	
	cout << fixed;
	cout << setprecision(6);
	cout << right -left << endl;
	return 0;
}

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

using namespace std;

#define FOR(i, n) for(int i = 0; i < (int) n; i++)
#define PB push_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define F first
#define S second

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

const ll MOD = 1e9+7;
const int MAX = 1e5+7;

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

	int n, k; cin >> n >> k;
	vi v(n); FOR(i, n) cin >> v[i];

	sort(all(v));

	ll ans = 1;
	if(v[0] >= 0){
		FOR(i, k){
			ans = 1LL * ans * v[n-i-1] % MOD;
		}
	}else if(v[n-1] <= 0){
		if(k%2){
			FOR(i, k) ans = 1LL * ans * v[n-i-1] % MOD;
		}else{
			FOR(i, k) ans = 1LL * ans * v[i] % MOD;
		}
	}else{
		int l = 0, r = n-1;
		if(k%2){
			ans = ans * v[r] % MOD;
			r--;
			k--; 
		}
		ll a1, a2;
		while(k){
			a1 = 1LL * v[l] * v[l+1];
			a2 = 1LL * v[r] * v[r-1];

			if(a1 > a2){
				a1 %= MOD;
				ans = ans * a1 % MOD;
				l+=2;
			}else{
				a2 %= MOD;
				ans = ans * a2 % MOD;
				r-=2;
			}

			k-=2;
		}
	}

	while(ans < 0) ans += MOD;
	
	cout << ans << '\n';

	return 0;
}


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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const int MOD = 1000000007;
#define MAX_N 110

template< typename T >
class CumulativeSum
{
public:
    vector< T > m_data;
    CumulativeSum() {};
    CumulativeSum(int sz) : m_data(sz, 0) {};

    // k に x を加える O(1)
    void Add(int k, int x) {
        assert(m_data.size() >= k);
        if(m_data.size() <= k) { m_data.push_back(x); }
        else { m_data[k] += x; }
    }

    // 累積和の構築 O(m_data.size())
    void Build() { for(int i = 1; i < m_data.size(); i++) { m_data[i] += m_data[i - 1]; } }

    // 区間 [0, k] の和を返す O(1)
    // 閉区間なので k が含まれることに注意
    T Query(int k) {
        if(k < 0) { return 0; }
        return (m_data[min(k, (int) m_data.size() - 1)]);
    }

    // 区間 [l, h] の和を返す O(1)
    // 閉区間なので k が含まれることに注意
    T Query(int l, int h) { return this->Query(h) - this->Query(l-1); }
};

int N;
int A[2][MAX_N] = {};

signed main()
{
    cin >> N;
    CumulativeSum<int> cs[2];
    REP(i, 2) {
        REP(j, N) {
            cin >> A[i][j];
            cs[i].Add(j, A[i][j]);
        }
        cs[i].Build();
    }
    int ans = 0;
    REP(i, N) {
        ans = max(ans, cs[0].Query(i) + cs[1].Query(i, N-1));
    }
    printf("%lld\n", ans);


    return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
def print_ans(A, B, C, D):
    """Test Case
    >>> print_ans(10, 9, 10, 10)
    No
    >>> print_ans(46, 4, 40, 5)
    Yes
    """
    while True:
        #Yes perttern
        C = C - B
        if(C <= 0):
            print("Yes")
            break
        #No perttern
        A = A - D
        if(A <= 0):
            print("No")
            break



if __name__ == '__main__':
    A, B, C, D = map(int, input().rstrip().split())
    print_ans(A,B, C, D)




Measured memory_bytes: 9220
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const ll mod = 1e9 + 7;
const ll MAX = 510000;
const ll MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(ll i = 2; i < MAX; i++) {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

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

int main() {
    ll n, k;
    cin >> n >> k;

    COMinit();

    for(ll i = 1; i < k + 1; i++) {
        if(n - k + 1 < i) {
            cout << 0 << "\n";
            continue;
        }
        cout << (COM(k - 1, k - i) * COM(n - k + 1, n - k - i + 1)) % MOD << "\n";
    }
    return 0;
}


Measured memory_bytes: 12160
using System;

namespace AtCoder.ABC094
{
    class a
    {
        static void Main(string[] args)
        {
            var line = Console.ReadLine().Trim();
            var spl = line.Split(' ');
            var A = int.Parse(spl[0]);
            var B = int.Parse(spl[1]);
            var X = int.Parse(spl[2]);
            if (A <= X && A + B >= X) Console.WriteLine("YES");
            else Console.WriteLine("NO");
        }
    }
}


Measured memory_bytes: 13140
n, k = map(int,input().split())
arr = list(map(int, input().split()))
kitai = 0
biglist = []
if k ==1:
    kitai = (max(arr)+1)/2
    print(kitai)
else:
    for i in range(n-k+1):
        if i == 0:
            big = 0
            for j in range(i+k):
                big = big + arr[j]
        else:
            big = biglist[i-1] - arr[i-1] + arr[i+k-1]
        biglist.append(big)
    max_value = max(biglist)
    max_index = biglist.index(max_value)
    for j in range(max_index,max_index+k):
        kitai = kitai + (arr[j]+1)/2
    print(kitai)

Measured memory_bytes: 25600
def gcd(a, b):
    """a, bの最大公約数(greatest common divisor:GCD)を求める"""
    if b == 0:
        return a
    return gcd(b, a%b)


def multi_lcm(array):
    """arrayのLCMを求める"""
    ans = array[0]
    for i in range(1, len(array)):
        ans = (ans * array[i]) // gcd(ans, array[i])
    return ans


n = int(input())
a = list(map(int, input().split()))
print(multi_lcm(a))


Measured memory_bytes: 5600
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//------------------------------------------------------------------------------
int MOD = 10;
struct ModInt {
    unsigned x; ModInt() : x(0) { }
    ModInt(signed sig) { x = sig < 0 ? sig % MOD + MOD : sig % MOD; }
    ModInt(signed long long sig) { x = sig < 0 ? sig % MOD + MOD : sig % MOD; }
    int get() const { return (int)x; }
    ModInt &operator+=(ModInt that) { if ((x += that.x) >= MOD) x -= MOD; return *this; }
    ModInt &operator-=(ModInt that) { if ((x += MOD - that.x) >= MOD) x -= MOD; return *this; }
    ModInt &operator*=(ModInt that) { x = (unsigned long long)x * that.x % MOD; return *this; }
    ModInt &operator/=(ModInt that) { return *this *= that.inverse(); }
    ModInt operator+(ModInt that) const { return ModInt(*this) += that; }
    ModInt operator-(ModInt that) const { return ModInt(*this) -= that; }
    ModInt operator*(ModInt that) const { return ModInt(*this) *= that; }
    ModInt operator/(ModInt that) const { return ModInt(*this) /= that; }
    ModInt inverse() const {
        long long a = x, b = MOD, u = 1, v = 0;
        while (b) { long long t = a / b; a -= t * b; std::swap(a, b); u -= t * v; std::swap(u, v); }
        return ModInt(u);
    }
    bool operator==(ModInt that) const { return x == that.x; }
    bool operator!=(ModInt that) const { return x != that.x; }
    ModInt operator-() const { ModInt t; t.x = x == 0 ? 0 : MOD - x; return t; }
};
typedef ModInt mint;
//------------------------------------------------------------------------------
int N;
vector<vector<int>> G;

mint dp[100010];

mint Solve(int curr, int prev = -1)
{
    dp[curr] = 1;
    for (const int next : G[curr])
    {
        if (next == prev) continue;

        dp[curr] *= Solve(next, curr) + 1;
    }
    return dp[curr];
}

mint ans[100010];

void Solve2(int curr, int prev = -1)
{
    ans[curr] = 1;
    for (const int next : G[curr])
    {
        ans[curr] *= dp[next] + 1;
    }

    int n = G[curr].size();
    vector<mint> lft(n), rht(n);
    rep(i, 0, n) lft[i] = rht[i] = dp[G[curr][i]] + 1;
    rep(i, 1, n) lft[i] *= lft[i - 1];
    rrep(i, n - 2, 0) rht[i] *= rht[i + 1];

    rep(i, 0, n) if (G[curr][i] != prev)
    {
        dp[curr] = 1;
        if (i) dp[curr] *= lft[i - 1];
        if (i + 1 < n) dp[curr] *= rht[i + 1];
        Solve2(G[curr][i], curr);
    }
}

void _main()
{
    cin >> N >> MOD;
    G.resize(N);
    rep(i, 0, N - 1)
    {
        int x, y;
        cin >> x >> y;
        --x; --y;
        G[x].push_back(y);
        G[y].push_back(x);
    }
    Solve(0);
    Solve2(0);

    rep(i, 0, N) cout << ans[i].get() << endl;
}


Measured memory_bytes: 18688
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;
int N;
int a,b,c,d;


int main(){
  cin >> a >> b >> c >> d;
  int  ans=0;
  if(a<c){
    if(c<b){
      if(b<d)ans=(b-c);
      else ans=(d-c);
    }
  }
  
  else{
    if(a<d){
      if(d<b)ans=(d-a);
      else ans=(b-a);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// M-SOL_2020_A
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int X = sc.nextInt();
		int ans = 8;
		if(600 <= X) {
			ans = 7;
		}
		if(800 <= X) {
			ans = 6;
		}
		if(1000 <= X) {
			ans = 5;
		}
		if(1200 <= X) {
			ans = 4;
		}
		if(1400 <= X) {
			ans = 3;
		}
		if(1600 <= X) {
			ans = 2;
		}
		if(1800 <= X) {
			ans = 1;
		}

		// 出力
		System.out.println(ans);
	    // Scannerクラスのインスタンスをクローズ
		sc.close();
	}
}


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

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

    string S;
    cin >> S;

    vector<int> count_white(N + 1, 0);
    vector<int> count_black(N + 1, 0);

    for (int i = 1; i <= N; i++)
    {
        if (S[i - 1] == '.')
        {
            count_white[i] = count_white[i - 1] + 1;
            count_black[i] = count_black[i - 1];
        }
        else
        {
            count_white[i] = count_white[i - 1];
            count_black[i] = count_black[i - 1] + 1;
        }
    }

    int ans = N;
    for (int i = 0; i <= N; i++)
    {
        ans = min(ans, count_black[i] + (count_white[N] - count_white[i]));
    }
    cout << ans << endl;
}


Measured memory_bytes: 2180
import java.util.*; 
 
class Main{
public static void main(String[] args){
	Scanner sc=new Scanner(System.in);
        int a=sc.nextInt();
        int b=sc.nextInt();
		int c=sc.nextInt();
		
    
 	if(a==b&&b==c){
    		System.out.println("No");
    	}else if(a==b){
     		System.out.println("Yes");
   	 }else if(b==c){
    	System.out.println("Yes");
    }else if(c==a){
 
    	System.out.println("Yes");
    }else{
    	System.out.println("No");
    }
    }
}


Measured memory_bytes: 21716
#include <stdio.h>
int main() {
	char n[5];
	scanf("%s", n);
	if ((n[0] == n[1] && n[1] == n[2]) || (n[1] == n[2] && n[2] == n[3])) {
		printf("Yes\n");
	} else {
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 128
#!/usr/bin/env python
# vim:fileencoding=utf-8

import sys

n = int(sys.stdin.readline().strip())

if n == 1:
    print("Hello World")
elif n == 2:
    i = int(sys.stdin.readline().strip())
    j = int(sys.stdin.readline().strip())
    print(i + j)




Measured memory_bytes: 2940
num = int(input())
dict = {}

for i in range(num):
        strList = input().split()
        if strList[0] == "insert":
                dict[strList[1]] = 1
        elif strList[0] == "find":
                if strList[1] in dict:
                        print("yes")
                else:
                        print("no")


Measured memory_bytes: 33116
import java.util.*;

public class Main{

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);
    int k = sc.nextInt();
    int x = sc.nextInt();
    long stone = 0;

    if(1<=k && k<=100 && 0<=x && x<=100){
      for(int i = x-(k-1);i < x+k;i++){
        System.out.print(i+" ");
      }
    }

  }

}


Measured memory_bytes: 21844
#![allow(
    non_snake_case,
    unused_variables,
    unused_assignments,
    unused_mut,
    dead_code
)]
//use permutohedron::LexicalPermutation as _;
use proconio::input;
use proconio::marker::Chars;
//use proconio::marker::Usize1;
//use std::collections::HashSet;
//use std::collections::HashMap;
//use std::collections::BTreeMap;
//use std::cmp::*;
//use std::num;

fn main() {
    input! {
        s:Chars
    }
    if s[2] == s[3] && s[4] == s[5] {
        println!("Yes");
    } else {
        println!("No");
    }
}


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

int main() {
//    freopen("test.txt", "r", stdin);
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int n; cin >> n;
    bitset<4000010> cur;
    cur[0] = 1;
    int val, sum = 0;
    for (int i = 0; i < n; i++) {
        cin >> val;
        cur |= cur<<val;
        sum += val;
    }
    for (int i = (sum+1)/2; i <= sum; i++) {
        if (cur[i]) {
            cout << i << endl;
            return 0;
        }
    }
    return 0;

}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using P = pair<int, int>;

int main() {
  int n, t;
  cin >> n >> t;
  vector<P> p(n);
  for (int i = 0; i < n; i++) {
    cin >> p[i].first >> p[i].second;
  }
  vector<int> a(n), b(n);
  sort(begin(p), end(p));
  for (int i = 0; i < n; i++) {
    tie(a[i], b[i]) = p[i];
  }
  int m = *max_element(begin(a), end(a));
  vector<vector<int>> dp(n + 1, vector<int>(t + m + 1, 0));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < t + m + 1; j++) {
      dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
      if (0 <= j - a[i] && j - a[i] < t) dp[i + 1][j] = max(dp[i + 1][j], dp[i][j - a[i]] + b[i]);
    }
  }
  int ans = 0;
  for (int i = 0; i < t + m + 1; i++) {
    ans = max(ans, dp[n][i]);
  }
  cout << ans << endl;
}


Measured memory_bytes: 70784
import itertools


def warshal_floyd(d):
    # d[i][j] := iからjへの最短距離
    global N
    for k in range(N):
        for i in range(N):
            for j in range(N):
                d[i][j] = min(d[i][j], d[i][k] + d[k][j])
    # "今現在求まっているiからjへの最短距離"と"今現在求まっているiからkへの最短距離 + 今現在求まっているkからjへの最短距離 の和"を比較する
    return d


N, M, R = map(int, input().split())  # N個の町, M本の道, R個の町を訪れることになった
town = list(map(lambda x: int(x)-1, input().split()))
distant = [[float('inf')]*N for _ in range(N)]
for _ in range(M):
    a, b, c = map(int, input().split())
    a -= 1
    b -= 1
    distant[a][b] = c
    distant[b][a] = c
for i in range(N):
    distant[i][i] = 0


warshal_floyd(distant)
ans = 10**9
for x in itertools.permutations(town):
    x = list(x)
    now = x[0]
    tmp = 0
    for i in range(1, len(x)):
        tmp += distant[now][x[i]]
        now = x[i]
    ans = min(ans, tmp)
print(int(ans))

Measured memory_bytes: 59608
#include <iostream>
#include <cstdio>
#include <algorithm>
#define N 55
using namespace std;

typedef long long ll;
ll n, mn, mx, s, a[N], c[N][N]{1};
int main()
{
	ll i, j, k;
	for (i = 1; i < N; i++) {
		c[i][0] = 1;
		for (j = 1; j < N; j++) c[i][j] = c[i - 1][j - 1] + c[i - 1][j];
	}
	cin >> n >> mn >> mx;
	for (i = 0; i < n; i++) scanf("%lld", &a[i]);
	sort(a, a + n);
	for (i = n - 1; i >= n - mn; i--) s += a[i];
    printf("%.9f\n", 1.0 * s / mn);
	for (i = n - mn - 1; a[i] == a[n - mn] && i >= 0; i--); i++;
	mx = min(mx, n - i);
	for (j = n - 1; a[j] > a[i]; j--); j++;
    if (j < n) cout << c[j - i][mn - n + j];
    else {
		for (k = mn, s = 0; k <= mx; k++) s += c[j - i][k];
		cout << s;
    }
    return 0;
}

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

int main()
{
  ll N;
  cin >> N;
  vector<ll> P(N);
  for (int i=0; i<N; i++){
    cin >> P[i];
  }
  vector<ll> Q(N);
  for (int i=0; i<N; i++){
    cin >> Q[i];
  }

  vector<ll> v(N, 0);
  for (int i=0; i<N; i++) {
    v[i] = i+1;
  }

  ll a = 0, b = 0;
  ll i = 0;
  do {
    i++;
    if (v == P) a = i;
    if (v == Q) b = i;
  } while (next_permutation(v.begin(), v.end()));
  cout << abs(a-b) << endl;

  return 0;
}


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

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> A(m);
  for(int& a : A)
    cin >> a;
  int play = accumulate(A.begin(), A.end(), -n);
  cout << ((play > 0) ? -1 : -play) << "\n";
  return 0;
}


Measured memory_bytes: 3224
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll n, a[100005], freq[100005], q, l, r, sum;


int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin >> n;
	sum = 0;
	for (int i=1; i<=n; i++) {
		cin >> a[i];
		sum += a[i];
		freq[a[i]]++;
	}
	cin >> q;
	while (q--) {
		cin >> l >> r;
		ll val = r-l;
		sum += val*freq[l];
		freq[r] += freq[l];
		freq[l] = 0;
		cout << sum << '\n';
	}
	return 0;
}

Measured memory_bytes: 5120
#include <bits/stdc++.h>
using namespace std;
int x,y,say[100005],k[100005],n,m,ans;
int main()
{
	scanf("%d %d",&n,&m);
	k[1]=1;
	for(int i=1;i<=n;i++)
	{
		say[i]=1;
	}
	for(int i=1;i<=m;i++)
	{
		scanf("%d %d",&x,&y);
		say[x]--;
		say[y]++;
		if(k[x]==1)
		{
			k[y]=1;
			if(say[x]<=0)
			{
				k[x]=0;
			}
		}
	}
	for(int i=1;i<=n;i++)
	{
		if(k[i]>0)
			ans++;
	}
	printf("%d",ans);
	
}


Measured memory_bytes: 1024
//二つの整数A,Bが与えられます。A+B,A-B,A*Bの中で最大の値を求めなさい。

#include <stdio.h>

int main(){

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

int sum1 = a + b;
int sum2 = a - b;
int sum3 = a * b;

if(sum1 >= sum2 && sum1>=sum3){
  printf("%d\n", sum1);
}else if(sum2 >= sum1 && sum2 >= sum3){
  printf("%d\n", sum2);
}else{
  printf("%d\n", sum3);
}
return 0;

}


Measured memory_bytes: 128
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <queue>
# define MOD 1000000000+7
# define INF 1000000000
#define rep(i,rept)	for(ll i = 0; i<rept;i++)
typedef long long ll;
using namespace std;
long long int a = 0, b = 0, c = 0, ans = 0, x = 0, y = 0, z = 0, n = 0, m = 0, maxy = 0, mini = 9999, counter = 0, counter2 = 0, endp = 0, checker = 0;

std::vector <char> vec{}, vecsec{}, vecth{};
long long int iremono[100001], sec[100001];
long long int iremono2[100001], check[100001];
std::vector<long long int>kinds{}, kaku{};
char maze[1000][1000];
int sx, sy;
int gx, gy;

bool relation[1000][1000];
int twod[1001][1001];
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
bool okada = false, okada2 = false;
std::string output, output2, input, input2, input3;
char rev[100001];


int ctoi(const char c) {
	if ('0' <= c && c <= '9') return (c - '0');
	return -1;
}
unsigned long long int LCM(unsigned long long int a, unsigned long long int b) {
	unsigned long long int i, j;
	i = a; j = b;
	while (true) {

		c = i % j;
		i = j;
		if (c != 0) {

			j = c;

		}
		else {
			break;
		}
	}
	return j * (a / j) * (b / j);
}
int kaizyo(int k) {
	int sum = 1;
	for (int i = 1; i <= k; ++i)
	{
		sum *= i;
	}
	return sum;
}

int N, M;//はんい
int bfs() {
	queue<pair<int, int>> que;
	for (int i = 0; i <= N; i++) {
		for (int j = 0; j <= M; j++) {
			twod[i][j] = INF;
		}
	}
	que.push(pair<int, int>(sx, sy));
	twod[sx][sy] = 1;
	while (que.size()) {
		pair<int, int> p = que.front();
		que.pop();
		if (p.first == gy && p.second == gx) {
			break;
		}
		for (int i = 0; i < 4; i++) {
			int nx = p.first + dx[i], ny = p.second + dy[i];
			if (1 <= nx && nx <= N && 1 <= ny && ny <= M && maze[nx][ny] != '#'&&twod[nx][ny] == INF) {
				que.push(pair<int, int>(nx, ny));
				twod[nx][ny] = twod[p.first][p.second] + 1;
			}
		}
	}
	return twod[gy][gx];
}
vector <int> g[100100];
int main()
{
	cin >> a >> b >> c;
	cout << (c+1/2)/ a * b << endl;

}


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

int main() {
    int N, X;
    cin >> N >> X;
    vector<int>L(N);
    for (int i = 0; i < N; ++i) {
      cin >> L[i];
    }
    int d = 0;
    for (int i = 0; i < N; ++i) {
        d += L[i];
        if(d > X){
            cout << i+1;
            return 0;
        }
    }
    cout << N+1;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define SIZE 1005



int N;
int table[SIZE][SIZE];
int loc[SIZE];


bool check(int node_id){

	if(loc[node_id] == N-1)return false;

	int next = table[node_id][loc[node_id]];

	if(loc[next] == N-1)return false;

	return table[next][loc[next]] == node_id;
}


int main(){

	scanf("%d",&N);

	for(int i = 0; i < N; i++){
		for(int k = 0; k < N-1; k++){

			scanf("%d",&table[i][k]);
			table[i][k]--;
		}
	}

	for(int i = 0; i < N; i++){

		loc[i] = 0;
	}

	int CURRENT = 0,NEXT = 1;

	vector<pair<int,int>> V[2];

	for(int i = 0; i < N; i++){
		if(check(i)){

			int next = table[i][loc[i]];
			V[CURRENT].push_back(make_pair(min(i,next),max(i,next)));
		}
	}

	int ans = -1;

	for(int day = 1; ;day++){

		if(V[CURRENT].size() == 0)break;
		ans = day;

		sort(V[CURRENT].begin(),V[CURRENT].end());
		V[CURRENT].erase(unique(V[CURRENT].begin(),V[CURRENT].end()),V[CURRENT].end());

		for(int i = 0; i < V[CURRENT].size(); i++){

			int a = V[CURRENT][i].first;
			int b = V[CURRENT][i].second;

			loc[a]++;
			loc[b]++;

			if(check(a)){
				int next = table[a][loc[a]];
				V[NEXT].push_back(make_pair(min(a,next),max(a,next)));
			}
			if(check(b)){
				int next = table[b][loc[b]];
				V[NEXT].push_back(make_pair(min(b,next),max(b,next)));
			}
		}
		V[CURRENT].clear();
		swap(CURRENT,NEXT);
	}

	for(int i = 0; i < N; i++){
		if(loc[i] != N-1){

			printf("-1\n");
			return 0;
		}
	}

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

	return 0;
}


Measured memory_bytes: 4224
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner stdIn = new Scanner(System.in);
		int N = stdIn.nextInt();
		int sum = 0;
		int A[] = new int[N];
		int B[] = new int[N];
		int C[] = new int[N];

		for(int i = 0; i < N; i++){
			A[i] = stdIn.nextInt();
		}

		for(int i = 0; i < N; i++){
			B[i] = stdIn.nextInt();
			sum = sum + B[i];
		}

		for(int i = 0; i < N - 1; i++){
			C[i] = stdIn.nextInt();
		}

		for(int i = 0; i < N - 1; i++){
			if(A[i]  == A[i+1] - 1){
				sum = sum + C[A[i] - 1];
			}
		}


		System.out.println(sum);
		stdIn.close();
	}
}

Measured memory_bytes: 35704
#include<bits/stdc++.h>
using namespace std;
int main()
{
    char a[20];
    for(int i=0;i<19;i++)
    {
        cin>>a[i];
    }
    a[5]=' ';
    a[13]=' ';
    for(int i=0;i<19;i++)
    {
        cout<<a[i];
    }
    cout<<endl;
    return 0;
}


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

string substring(string text, int low, int digit){
    string output = "";
    for(int i = low; i < low + digit; i++){
        output.push_back(text[i]);
    }
    return output;
}

int main(){
	string s;
	cin >> s;
	cout << substring(s, 0, 4) << " " << substring(s, 4, 8) << endl;
}

Measured memory_bytes: 768
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <cassert>
#include <random>
using namespace std;
using ll = long long;


int main() {
	int n, k; cin >> n >> k;
	vector<int> h(n);
	for (int i = 0; i < n; i++) cin >> h[i];
	sort(h.begin(), h.end());
	ll ans = 0;
	for (int i = 0; i < n - k; i++) ans += h[i];
	cout << ans << endl;
	return 0;
}


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

using namespace std;

const int MAXN = 100005;

int a[MAXN], p[MAXN], q[MAXN];

int n;

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

template<typename T> inline bool updmax(T &a, T b) { return (b > a ? a = b, 1 : 0); }

int main()
{
    ios::sync_with_stdio(false); cin.tie(0);
    cin >> n;
    for (int i = 1; i <= n; i++)
        cin >> a[i];
    for (int i = 1; i <= n; i++)
        p[i] = q[i] = a[i];
    for (int i = 2; i <= n; i++)
    	p[i] = gcd(p[i - 1], p[i]);
    for (int i = n - 1; i >= 1; i--)
    	q[i] = gcd(q[i], q[i + 1]);
	int res = 0;
	for (int i = 1; i <= n; i++)
		updmax(res, gcd(p[i - 1], q[i + 1]));
	cout << res << endl;
    return 0;
}


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

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

	int n;
	while(cin >> n && n != 0){

		int data[10] ={};

		string str;
		cin >> str;

		int now = 0;
		for(size_t i = 0; i < str.size(); ++i){
			data[i % n] ++;
			if(str[i] == 'S'){
				now += data[i % n];
				data[i % n] = 0;
			}
			if(str[i] == 'L'){
				data[i % n] += now;
				now = 0;
			}
		}

		sort(data, data + n);
		for(int i = 0; i < n; ++i){
			cout << data[i] << " ";
		}
		cout << now << endl;
	}

	return 0;
}

Measured memory_bytes: 1224
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define Graph vector<vector<ll>>
constexpr ll INF=(1ll<<60);
constexpr ll mod=1000000007;
constexpr double pi=3.14159265358979323846;
template<typename T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template<typename T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}

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

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

#define int long long 
#define pb push_back
#define S second
#define F first
#define f(i,n) for(int i=0;i<n;i++)
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define vi vector<int>
#define pii pair<int,int>

const int N = 1e5+10;
const int inf = 1e10;

int dp[N],a[N],n,k;


void solve()
{
  cin >> n >> k;
    
  f(i,n) cin >> a[i+1];
    
  dp[0] = dp[1] = 0;  
   
  for(int i=2;i<=n;i++)
  {
      dp[i] = inf;
      
      for(int j=1;j<=k;j++)
          if(i-j>=1) dp[i] = min(dp[i],dp[i-j] + abs(a[i-j]-a[i]));
          else break;
  }   
    
  cout << dp[n];  
}

signed main()
{
    fast;
    
    int t = 1;
    
//    cin >> t;
    
    while(t--)
        
    solve();
}

Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {

	public static void main(String[] args) 
	{
		Scanner sc = new Scanner(System.in);
		
		long n = sc.nextLong();
		long k = sc.nextLong();
		
		long MOD = 1000000007;
		long[] sum = new long[200002];
		long[] summax = new long[200002];
		
		sum[1] = 0;
		summax[1] = n;
		for(int i = 2; i < 200002; i++)
		{
			sum[i] = (sum[i-1] + (i-1))%MOD;
			while(sum[i]<0)sum[i]+=MOD;
			
			summax[i] = (summax[i-1] + ((n)-i+1))%MOD;
			while(summax[i]<0)summax[i]+=MOD;
		}
		
		for(int i = 0; i <= n+1; i++)
		{
//			System.out.println(sum[i] + " " + summax[i]);
		}
		
		long score = 0;
		for(int i = (int)k; i <= n+1; i++)
		{
			//try choosing i numbers
			score = (score +  (summax[i] - sum[i])+1)%MOD;
			while(score<0)score+=MOD;
			
		}
		if(score<0)score+=MOD;
		System.out.println(score);
	}

}


Measured memory_bytes: 39648
#include<cstdio>
#include<algorithm> 
#include<cstring>
#define LL long long
using namespace std;
const int N=2e3+5;
const int mod=1e9+7;
int n,m,fac[N*N],inv[N*N],f[N][N];
int read()
{
    int x=0,f=1;char c=getchar();
    while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
    return x*f;
}
void Mod(int& a,int b){a+=b;if(a>=mod)a-=mod;}
int power(int a,int b)
{
    int ans=1;
    while(b)
    {
        if(b&1)ans=1ll*ans*a%mod;
        a=1ll*a*a%mod;b>>=1;
    }
    return ans;
}
int C(int n,int m){return 1ll*fac[n]*inv[m]%mod*inv[n-m]%mod;}
int main()
{
    n=read();m=read();
    if(m==1){printf("1");return 0;}
    fac[0]=1;
    for(int i=1;i<=n*m;i++)fac[i]=1ll*fac[i-1]*i%mod;
    inv[n*m]=power(fac[n*m],mod-2);
    for(int i=n*m;i>=1;i--)inv[i-1]=1ll*inv[i]*i%mod;
    f[0][0]=1;
    for(int i=1;i<=n;i++)
        for(int j=0;j<=i;j++)
        {
            f[i][j]=f[i-1][j];
            if(!j)continue;
            Mod(f[i][j],1ll*f[i][j-1]*C(n-i+(n-j+1)*(m-1)-1,m-2)%mod);
        }
    printf("%d",1ll*f[n][n]*fac[n]%mod);
    return 0;
}

Measured memory_bytes: 46464
/*COMPETITIVE PROGRAMMING C++ TEMPLATE */

#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <string>
#include <cmath>
#include <iostream>
#include <stack>
#include <queue>
#include <climits>
#include <iomanip>
#include <ratio>

#define all(x) x.begin(), x.end()
#define debug(x) cout << #x << " = " << x << "\n"
#define MOD 998244353

const long double PI = 3.141592653589793236L;

typedef long long int ll;
typedef long double ld;

using namespace std;

void solve()
{

    ll a;
    cin >> a;

    cout << a + a * a + a * a * a << endl;

}

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

    int T = 1;
    //cin >> T;

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

    return 0;
}



Measured memory_bytes: 3608
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>

using namespace std;
using ll = long long int;
#define rep(i,n) for(int i = 0; i < n; i++)
#define FOR(i, a, b)  for(int i = (a); i < (b) ; i++)

#define pb push_back
#define SORT(v,n) sort(v, v+n)
#define ALL(x) (x).begin(),(x).end()
#define debug(x) cerr << #x << ": " << x << '\n'
#define elif else if
#define itn ll
#define int ll
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
///                →,↑,←,↓,↗,↖,↙,↘
int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };


signed main() {
	ios::sync_with_stdio(false);
	int n, a;
	cin >> n >> a;
	if (n % 500 <= a)
		cout << "Yes" << endl;
	else
		cout << "No\n";

	return 0;
}

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

int main(){
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  while (a > 0 || c > 0){
    c -= b;
    if (c <= 0){
      cout << "Yes" << endl;
      break;
    }
    a -= d;
    if (a <= 0){
      cout << "No" << endl;
      break;
    }
  }
  return 0;
}

Measured memory_bytes: 3636
#include <stdio.h>
#include <stdlib.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)

//セグ木ここから
//*
//↓ここを変える
typedef struct atai{ll a,c;}atai;
atai xx(atai x,atai y){
	atai r;
	r.a=x.a+y.a;
	r.c=x.c+y.c;
	return r;
}
atai aid={0,0};
//↑ここを変える

int segNUM;
atai *segN,*seg;
void seguse(int n){
	segN=(atai*)calloc(2*n,sizeof(atai));
	segNUM=n;
	seg=segN+segNUM;
	rep(i,1,2*segNUM)segN[i]=aid;
}
//seg[]に値を与えてから初期化
void seginit(){for(int node=segNUM-1;node;node--)segN[node]=xx(segN[node*2],segN[node*2+1]);}
void segupdate(int node,atai x){
	//seg[node]をxに更新
	node+=segNUM;
	segN[node]=x;
	while(node/=2)segN[node]=xx(segN[node*2],segN[node*2+1]);
}

atai segcalcsub(int l,int r,int k,int cl,int cr){
	if(l>=r)return aid;
	//完全に含むとき
	if(l<=cl&&cr<=r)return segN[k];

	int cm=(cl+cr)/2;
	//左側だけ
	if(r<=cm)return segcalcsub(l,r,2*k  ,cl,cm);
	//右側だけ
	if(cm<=l)return segcalcsub(l,r,2*k+1,cm,cr);
	//両方
	return xx(segcalcsub(l,r,2*k,cl,cm),segcalcsub(l,r,2*k+1,cm,cr));
}
atai segcalc(int l,int r){return segcalcsub(l,r,1,0,segNUM);}
//セグ木ここまで
//*/

int n,q;
int t[100010];
char s[100010][11];
int idx[100010];
int c(const void*x,const void*y){
	int i=*(int*)x,j=*(int*)y;
	if((t[i]-1)/q<(t[j]-1)/q)return -1;
	if((t[i]-1)/q>(t[j]-1)/q)return  1;
	if(i<j)return -1;
	return 1;
}

int main(){
	scanf("%d%d",&n,&q);
	rep(i,0,n)scanf("%s %d",s[i],t+i);
	rep(i,0,n)idx[i]=i;
	qsort(idx,n,sizeof(int),c);

	seguse(1<<17);
	rep(i,0,n){
		atai l=segcalc(0,idx[i]);
		atai r=segcalc(idx[i],1<<17);
		int cnt=(t[idx[i]]-1)/q;
									//左側					//右側						//自分
		printf("%s %d\n",s[idx[i]],(cnt+1)*q*(idx[i]-l.c)+l.a+cnt*q*(n-1-idx[i]-r.c)+r.a+t[idx[i]]);
		atai x={t[idx[i]],1};
		segupdate(idx[i],x);
	}
}




Measured memory_bytes: 6748
#!/usr/bin/env python3
import re

n = input()
n = re.split(" ",n)

A = int(n[0])
B = int(n[1])
t = 0
for i in range(1,4):
    save = A*B*i
    if(save % 2 == 1):
        t = 1

if(t == 1):
    print("Yes")
elif(t == 0):
    print("No")

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define LL long long
const int N = 300000;

int n;
int fa[N], c[N][2], pi[N]; LL res;
struct cp
{
    int operator () (int a, int b)
    {
        if (1ll * c[a][0] * c[b][1] != 1ll * c[b][0] * c[a][1])
            return (1ll * c[a][0] * c[b][1] > 1ll * c[b][0] * c[a][1]);
        return a < b;
    }
};
set <int, cp> S;
int get_f(int t)
{
    if (fa[t] == t) return t;
    else return fa[t] = get_f(fa[t]);
}
int main()
{
    scanf("%d", &n);
    for (int i = 2; i <= n; ++ i)
        scanf("%d", &pi[i]);
    for (int i = 1; i <= n; ++ i)
        fa[i] = i;
    for (int i = 1; i <= n; ++ i)
    {
        int v;
        scanf("%d", &v);
        c[i][v] = 1;
        S.insert(i);
    }
    while (!S.empty())
    {
        auto it = S.begin();
        int t = *it; S.erase(it);
        int p = get_f(pi[t]); fa[t] = p;
        if (p) S.erase(p);
        res += 1ll * c[p][1] * c[t][0];
        c[p][0] += c[t][0];
        c[p][1] += c[t][1];
        if (p) S.insert(p);
    }
    printf("%lld\n", res);
}


Measured memory_bytes: 13568
#include<bits/stdc++.h>
#define ll long long
#define mod 998244353
using namespace std;
const int N=200009;
int n,q,l,r,val,num[N<<3];
ll sum[N<<3],p[N],p1[10][N];
void build(int o,int left,int right)
{
    int lc=o*2,rc=o*2+1,mid=(left+right)/2;
    if(left==right)
        sum[o]=1;
    else
    {
        build(lc,left,mid);
        build(rc,mid+1,right);
        sum[o]=(sum[lc]*p[right-mid]%mod+sum[rc])%mod;
    }
}
void maintain(int o,int left,int right)
{
    int lc=o*2,rc=o*2+1,mid=(left+right)/2;
    if(left==right)
    {
        if(num[o])
        sum[o]=num[o];
    }
    else
    {
        sum[o]=(sum[lc]*p[right-mid]%mod+sum[rc])%mod;
        if(num[o])
        sum[o]=p1[num[o]][right-left+1];
    }
    //printf("%d %d %d %lld\n",left,right,num[o],sum[o]);
}
void pushdown(int o,int left,int right)
{
    int lc=o*2,rc=o*2+1,mid=(left+right)/2;
    if(!num[o])
        return;
    num[lc]=num[rc]=num[o];
    num[o]=0;
    //printf("%d %d %d %d %d %d\n",left,mid,mid+1,right,num[lc],num[rc]);
}
void update(int o,int left,int right)
{
    //printf("%d %d\n",left,right);
    int lc=o*2,rc=o*2+1,mid=(left+right)/2;
    if(l<=left&&r>=right)
        sum[o]=p1[val][right-left+1],num[o]=val;
    else
    {
        pushdown(o,left,right);
        if(l<=mid)
            update(lc,left,mid);
        else
            maintain(lc,left,mid);
        if(r>mid)
            update(rc,mid+1,right);
        else
            maintain(rc,mid+1,right);
    }
    //printf("sad\n");
    maintain(o,left,right);
}
ll query(int o,int left,int right)
{
    int lc=o*2,rc=o*2+1,mid=(left+right)/2;
    maintain(o,left,right);
    if(l<=left&&r>=right)
        return sum[o];
    pushdown(o,left,right);
    ll res=0,res1=0;
    if(l<=mid)
        res=query(lc,left,mid);
    else
        maintain(lc,left,mid);
    if(r>mid)
        res1=query(rc,mid+1,right);
    else
        maintain(rc,mid+1,right);
    maintain(o,left,right);
    return (res1+res)%mod;
}
int main()
{
    scanf("%d%d",&n,&q);
    p[0]=1;
    for(int i=1; i<=n; i++)
        p[i]=p[i-1]*10%mod;
    for(int i=1; i<=9; i++)
    {
        p1[i][0]=0;
        for(int j=1; j<=n; j++)
            p1[i][j]=(p1[i][j-1]*10%mod+i)%mod;
    }
    build(1,1,n);
    while(q--)
    {
        scanf("%d%d%d",&l,&r,&val);
        update(1,1,n);
        l=1,r=n;
        printf("%lld\n",query(1,1,n));
    }
    return 0;
}


Measured memory_bytes: 25616
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int ans = 0;
        for (int i=0;i<n;i++){
            if (sc.nextInt()>=k)ans++;
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 58608
import kotlin.math.*

fun main() {
  val reader = System.`in`.bufferedReader()
  val N = Integer.parseInt(reader.readLine())
  val abc = List(N, {
    reader.readLine().split(" ").map(Integer::parseInt)
  })

  if (N == 1) {
    println(abc[0].max())
    return
  }

  var dp = Array(N, {
    IntArray(3, { 0 })
  })

  val IA = 0
  val IB = 1
  val IC = 2
  
  dp[0][IA] = abc[0][IA]
  dp[0][IB] = abc[0][IB]
  dp[0][IC] = abc[0][IC]

  for (n in 1..N-1) {
    dp[n][IA] = max(dp[n-1][IB], dp[n-1][IC]) + abc[n][IA]
    dp[n][IB] = max(dp[n-1][IA], dp[n-1][IC]) + abc[n][IB]
    dp[n][IC] = max(dp[n-1][IA], dp[n-1][IB]) + abc[n][IC]
  }

  val ans = max(dp[N-1][IA], max(dp[N-1][IB], dp[N-1][IC]))
  println(ans)
}

Measured memory_bytes: 72364
#include<iostream>
using namespace std;
int main(){
	char a[20];
	cin>>a;
	cout<<a[0]<<a[1]<<a[2]<<a[3]<<" "<<a[4]<<a[5]<<a[6]<<a[7]<<a[8]<<a[9]<<a[10]<<a[11]<<endl;
	return 0;
} 

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define PB push_back
#define MP make_pair
#define REP(i,n) for(int i=0;i<(n);i++)
int N,M;
char A[50][50];
char B[50][50];
int main(){
    cin>>N>>M;
    REP(i,N)REP(j,N)cin>>A[j][i];
    REP(i,M)REP(j,M)cin>>B[j][i];
    REP(i,N-M+1)REP(j,N-M+1){
        bool f=true;
        REP(y,M)REP(x,M){
            if(A[i+y][j+x]!=B[y][x])f=false;
        }
        if(f){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <complex>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <algorithm>
#if __cplusplus >= 201103
#include <numeric>
#endif
using namespace std;

int main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    if(a*b >= c*d) cout << a*b << endl;
    else if(a*b <= c*d) cout << c*d <<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main ()
{
    int A,B,x,y,z,k;
    scanf("%d%d",&A,&B);
    x=A+B;
    y=A-B;
    z=A*B;

    if(x>=y){
      k=x;
    }
    else{
      k=y;
    }

    if(k>=z){
       printf("%d\n",k);
    }
    else{
       printf("%d\n",z);
    }
    return 0;
}



Measured memory_bytes: 128
/*
  Compete against Yourself.
  Author - Aryan Choudhary (@aryanc403)
*/

#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize ("-ffloat-store")

#include<iostream>
#include<bits/stdc++.h>
using namespace std;
#define fo(i,n)   for(i=0;i<(n);++i)
#define repA(i,j,n)   for(i=(j);i<=(n);++i)
#define repD(i,j,n)   for(i=(j);i>=(n);--i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define endl "\n"

typedef long long int lli;
typedef long double mytype;
typedef pair<lli,lli> ii;
typedef vector<ii> vii;
typedef vector<lli> vi;

clock_t time_p=clock();
void aryanc403()
{
#ifdef ARYANC403
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
#endif
}

#ifdef ARYANC403
#include "/home/aryan/codes/PastCodes/header.h"
#else
    #define dbg(args...)
#endif

const lli INF = 0xFFFFFFFFFFFFFFFL;

lli seed;
mt19937 rng(seed=chrono::steady_clock::now().time_since_epoch().count());
inline lli rnd(lli l=0,lli r=INF)
{return uniform_int_distribution<lli>(l,r)(rng);}

class CMP
{public:
bool operator()(ii a , ii b) //For min priority_queue .
{    return ! ( a.X < b.X || ( a.X==b.X && a.Y <= b.Y ));   }};

void add( map<lli,lli> &m, lli x,lli cnt=1)
{
    auto jt=m.find(x);
    if(jt==m.end())         m.insert({x,cnt});
    else                    jt->Y+=cnt;
}

void del( map<lli,lli> &m, lli x,lli cnt=1)
{
    auto jt=m.find(x);
    if(jt->Y<=cnt)            m.erase(jt);
    else                      jt->Y-=cnt;
}

bool cmp(const ii &a,const ii &b)
{
    return a.X<b.X||(a.X==b.X&&a.Y<b.Y);
}

const lli mod = 1000000007L;
// const lli maxN = 1000000007L;

    lli T,n,i,j,k,in,cnt,l,r,u,v,x,y;
    lli m;
    string s;
    vi a;
    //priority_queue < ii , vector < ii > , CMP > pq;// min priority_queue .

int main(void) {
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    // freopen("txt.in", "r", stdin);
    // freopen("txt.out", "w", stdout);
// cout<<std::fixed<<std::setprecision(35);
// cin>>T;while(T--)
{

    cin>>n>>k;
    a.clear();a.reserve(n);

    fo(i,n)
    {
        cin>>in;
        a.pb(in);
    }

    sort(all(a));
    n-=k;
    fo(i,n)
        cnt+=a[i];
    cout<<cnt<<endl;

}   aryanc403();
    return 0;
}


Measured memory_bytes: 1792