akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <vector>
#include <algorithm>
using namespace std;
pair<int,int> vx[100001],vy[100001];
int par[100001];
int fnd(int k)
{
	return par[k]==k?k:par[k]=fnd(par[k]);
}
int main()
{
	int n;
	scanf("%d",&n);
	for (int i=1;i<=n;++i)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		vx[i]=make_pair(x,i);
		vy[i]=make_pair(y,i);
	}
	sort(vx+1,vx+n+1);
	sort(vy+1,vy+n+1);
	vector<pair<int,pair<int,int>>> diff;
	for (int i=1;i<n;++i)
	{
		diff.push_back(make_pair(vx[i+1].first-vx[i].first,make_pair(vx[i].second,vx[i+1].second)));
		diff.push_back(make_pair(vy[i+1].first-vy[i].first,make_pair(vy[i].second,vy[i+1].second)));
	}
	sort(diff.begin(),diff.end());
	long long ans=0;
	for (int i=1;i<=n;++i)
		par[i]=i;
	for (size_t i=0;i<diff.size();++i)
		if (fnd(diff[i].second.first)!=fnd(diff[i].second.second))
		{
			ans+=diff[i].first;
			par[fnd(diff[i].second.first)]=fnd(diff[i].second.second);
		}
	printf("%lld",ans);
	return 0;
}


Measured memory_bytes: 6388
#include <iostream>
#include <string>
#include <string.h>
using namespace std;
int main(int argc, char* argv[])
{
	string S,T;
	cin>>S;
	cin>>T;
	int sLen=S.length();
	for (int i=0;i<sLen;i++){
		const char *pStr=S.c_str();
		if (!strcmp(pStr,(char*)T.c_str())){
			cout<<"Yes"<<endl;
			return 0;
		}
		char ch[2];
		ch[0]=S[sLen-1];
		ch[1]='\0';
		S.insert(0,ch);
		S[sLen]='\0';
	}
	cout<<"No"<<endl;
	return 0;
}

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

void solve(long long N)
{
    long long tmax = 0, ans = 0;
    for (int i = 1; i <= N; i++)
    {
        long long i_max = 0;
        long long x = i;
        while (true)
        {
            if (x % 2 == 0)
            {
                i_max++;
                x = x / 2;
            }
            else
            {
                break;
            }
        }
        tmax = max(tmax, i_max);
        if (tmax == i_max)
        {
            ans = i;
        }
    }
    cout << ans << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    long long N;
    scanf("%lld", &N);
    solve(N);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
#include<algorithm>
using namespace std;
#define _GLIBCXX_DEBUG
#define pq priority_queue
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define pii pair<long long,long long>
#define ppii pair<long long,pair<long long,long long>>
#define all(x) (x).begin(),(x).end()
#define rep(x) for(int i = 0;i < (x);i++)
#define repj(x) for(int j = 0;j < (x);j++)
#define REP(i,x) for(int (i) = 0;(i) < (x);(i)++)
#define rrep(x) for(int i = (x);i >= 0;i--)
#define mod 1000000007
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
typedef vector<vector<long long>> vii;
typedef long long lint;
typedef long long ll;
lint qp(int a, ll b) { int ans = 1; do { if (b & 1)ans = 1ll * ans*a; a = 1ll * a*a; } while (b >>= 1); return ans; }
lint qp(int a, ll b, int mo) { int ans = 1; do { if (b & 1)ans = 1ll * ans*a%mo; a = 1ll * a*a%mo; } while (b >>= 1); return ans; }
lint gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };
long long INF = 1e14;
const int MAX_N = 1 << 17;
const int cf = 100010;
///////////////////////////////////////////////////////////////////////////////
int L[100000];
int main(void) {
	int n, x; cin >> n >> x;
	rep(n) cin >> L[i];
	int c = 0;
	int lyn = 0;
	while (lyn <= x) {
		lyn += L[c];
		c++;
		if (c == n + 1) break;
	}
	cout << c << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;

using namespace std;


int inputValue(){
    int a;
    cin >> a;
    return a;
};

long long inputValueLongLong(){
    long long a;
    cin >> a;
    return a;
};

void inputArray(int * p, int a){
    rep(i, a){
        cin >> p[i];
    }
};

void inputVector(vector<int> * p, int a){
    rep(i, a){
        int input;
        cin >> input;
        p -> push_back(input);
    }
}

template <typename T>
void output(T a, int precision) {
    if(precision > 0){
        cout << setprecision(precision)  << a << "\n";
    }
    else{
        cout << a << "\n";
    }
}

int main(int argc, const char * argv[]) {
    // source code
    int N = inputValue();
    char S[N];
    scanf("%s",S);
    if(N%2!=0){
        cout << "No" <<endl;
        return 0;
    }
    char T[N/2];
    int i=0;
    for(i=0;i<N/2;i++){
        T[i] = S[i];
        if(T[i] != S[i+N/2]){
            cout << "No" << endl;
            return 0;
        }
    }

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

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

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

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

// Self settings
// clang-format off
#define MAX_N 100000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
ll fact(ll n) { ll res = 1; for(ll i=2;i<=n;++i) res = res * i; return res;}
ll nCr(ll n, ll r) {return (fact(n)/fact(n-r)*fact(r)) ;}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const int inf = 1 << 30;
// clang-format on

int N;
int A[MAX_N];

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> N;
  REP(i, N) cin >> A[i];

  map<int, int> mp;
  REP(i, N) mp[A[i]]++;

  int cnt = 0;
  priority_queue<P> q;
  for (auto m : mp) {
    if (m.second >= 2) {
      q.push(m);
      cnt++;
    }
  }
  if (cnt < 2) {
    cout << 0 << endl;
    return 0;
  }

  if (q.top().second >= 4) {
    cout << (ll)q.top().first * (ll)q.top().first << endl;
    return 0;
  }

  ll w = q.top().first;
  q.pop();
  ll h = q.top().first;
  q.pop();

  cout << (ll)w * h << endl;

  return 0;
}


Measured memory_bytes: 5376
#include<stdio.h>

int main(){
int a,b;
scanf("%d%d",&a,&b);
if(a!=1&&b!=1){
if(a>b)puts("Alice");
if(a<b)puts("Bob");
if(a==b)puts("Draw");
}
else {
if(a==1&&b!=1)puts("Alice");
if(a!=1&&b==1)puts("Bob");
if(a==b)puts("Draw");
}
return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <stdio.h>
using namespace std;
int main(void){
    double A[2][3];
    while(cin >> A[0][0] >> A[0][1] >> A[0][2] >> A[1][0] >> A[1][1] >> A[1][2]){
        for(int i = 1; i < 3; i++){
            A[0][i] /= A[0][0];
        }
        A[0][0] /= A[0][0];
        for(int i = 1; i < 3; i++){
            A[1][i] -= A[0][i] * A[1][0];
        }
        A[1][0] -= A[0][0] * A[1][0];
        for(int i = 0; i < 3; i++){
            if(i != 1)
                A[1][i] /= A[1][1];
        }
        A[1][1] /= A[1][1];
        for(int i = 0; i < 3; i++){
            if(i != 1)
                A[0][i] -= A[1][i] * A[0][1];
        }
        A[0][1] -= A[1][1] * A[0][1];
        
        printf("%.3f %.3f\n", A[0][2], A[1][2]);
    }
}



Measured memory_bytes: 3188
#include <stdio.h>
int main(void)
{
	int n;
	scanf("%d",&n);
	if(n>=65 && n<=90){
		printf("1\n");
	}
	else if(n>=97 && n<=122){
		printf("2\n");
	}
	else{
		printf("0\n");
	}
	return 0;
}


Measured memory_bytes: 2112
#C
N, M = map(int, input().split())
flags = [0] * (N+1)
submit_count = [0] * (N+1)
true_answer = 0
penalty = 0

for _ in range(M):
    pi, Si = input().split()
    pi = int(pi)
    if Si == "AC":
        if flags[pi] == 0:
            flags[pi] = 1
            true_answer += 1
            penalty += submit_count[pi]
        else:#すでにAC済みの場合
            pass
    else:#Si == "WA"の場合
        if flags[pi] == 0:
            submit_count[pi] += 1
        else:#すでにAC済みの場合
            pass
        
print(true_answer, penalty)

Measured memory_bytes: 4596
import math

n, x = list(map(int, input().split()))
m_list = []

for _ in range(n):
    m_list.append(int(input().split()[0]))

nokori_x = x - sum(m_list)
min_m = min(m_list)
ans = math.floor(nokori_x / min_m + n)

print(ans)


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

using namespace std;

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,n) for(int i=1;i<=(int)(n);i++)
#define rep3(i,n) for(int i=0;i<=(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
#define repll(i,n) for(ll i=0;i<(ll)(n);i++)
#define repll2(i,n) for(ll i=1;i<=(ll)(n);i++)
#define REPLL(i,m,n) for(ll i=m;i<(ll)(n);i++)
#define INF (int)1e9  //
#define LINF (ll)4e18  //
#define MOD (int)(1e9)+7
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define PI 3.1415926535898

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

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << max(a * b, c * d) << endl;
    return 0;
}



Measured memory_bytes: 256
#!/usr/bin/env python3
import copy
 
N, Ma, Mb = map(int, input().split())
a = []
b = []
c = []
for i in range(N):
    ai, bi, ci = map(int, input().split())
    a.append(ai)
    b.append(bi)
    c.append(ci)
 
def update(mincosti, a_b, c):
    if a_b not in mincosti:
        mincosti[a_b] = c
        return
    if mincosti[a_b] > c:
        mincosti[a_b] = c
        return
 
mincost = [{(a[0],b[0]): c[0]}]
 
for i in range(1,N):
    mincost.append(copy.deepcopy(mincost[i-1]))
    update(mincost[i], (a[i],b[i]), c[i])
    for a_, b_ in mincost[i-1].keys():
        a_b = (a_+a[i], b_+b[i])
        update(mincost[i], a_b, mincost[i-1][(a_,b_)]+c[i])
 
Na = Ma
Nb = Mb
 
ans = None
 
while (Na <= 400) and (Nb <= 400):
    if (Na, Nb) in mincost[N-1].keys():
        if ans == None:
            ans = mincost[N-1][(Na, Nb)]
        else:
            ans = min(ans, mincost[N-1][(Na, Nb)])
    Na += Ma
    Nb += Mb
 
if ans == None:
    print(-1)
else:
    print(ans)

Measured memory_bytes: 119516
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a, b;
    cin >> a >> b;
    if(a + b == 15)
    {
       cout << "+" << endl;
    }
    else if(a * b == 15)
    {
      cout << "*" << endl;
    }
    else cout << "x" << endl;
}

Measured memory_bytes: 384
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author champon
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for(ll i=0; i<n; i++)
#define repr(i, s, e) for(ll i=s; i>=e; i--)
#define reps(i, s, e) for(ll i=s; i<=e; i++)
#define inf 1e18
#define all(v) v.begin(),v.end()
#define ceill(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
void ans(bool b){ cout << (b ? "Yes" : "No") << endl; }
void ans2(bool b){ cout << (b ? "YES" : "NO") << endl; }
template<typename T> inline bool chmax(T &a, T b){ if(a<b) a=b; return a<b; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a) a=b; return b<a; }
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    fill((T*)array, (T*)(array+N), val);
}
template<typename T> void vdeb(T v){
    cout << "#vector set debug" << endl;
    for(auto vv : v) cout << vv << " ";
    cout << endl;
}
template<typename T1, typename T2> void adeb(T1 arr[], T2 n){
    cout << "#adebug" << endl;
    for(int i=0; i<=n; i++) cout << arr[i] << " ";
    cout << endl;
}
template<typename T1> void mdeb(T1 mp){
    cout << "#map pair debug" << endl;
    for(auto const& m : mp) cout << m.first sp m.second << endl;
}
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};


class DRecording {
public:
	void solve(std::istream& in, std::ostream& out) {
        int n, C;
        int s[100010], t[100010], c[100010];
        in >> n >> C;
        rep(i, n){
            in >> s[i] >> t[i] >> c[i];
        }

        vector<int> start[100010];
        vector<int> end[100010];
        rep(i, n){
            start[s[i]].push_back(c[i]);
            end[t[i]].push_back(c[i]);
        }

        ll bit = 0LL;
        ll bitflg = 0LL;
        int res = 0;
        for(auto const& e : start[1]){
            bit |= 1<<e;
        }
        reps(i, 2, 100000){
            for(auto const& e : end[i-1]){
                if(!(bitflg & 1<<e)) bit &= ~(1<<e);
            }
            for(auto const& e : start[i]){
                bit |= 1<<e;
            }
            chmax(res, __builtin_popcount(bit));

            bitflg = 0LL;
            for(auto const& e : end[i]){
                int ind = distance(start[i].begin(), lower_bound(all(start[i]), e));
                if(ind == start[i].size()) continue;
                if(start[i][ind] != e) continue;
                bitflg |= 1<<e;
            }
        }

        out << res << endl;
	}
};


int main() {
	DRecording solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

int isPrime(int x){
    if(x==2){
        //cout << "Prime:" << 2 << endl;
        return 1;
    }else if(x%2==0){
        return 0;
    }else{
        int ans = 1;
        for(int j=2; j<=(int)sqrt((double)x); j++){
            if(x%j==0){
               ans = 0; 
               break;
            }
        }
        //if(ans==1) cout << "Prime:" << x << endl;
        return ans;
    }
}

int main(){
    int n;
    cin >> n;
    int nums;
    int ans = 0;
    for(int i=0; i<n; i++){
        cin >> nums;
        ans += isPrime(nums);
    }
    cout << ans << endl;
    
}

Measured memory_bytes: 3088
input_line = raw_input().split(" ")
a = input_line[0]
b = input_line[1]
if a == "H":
	if b == "H":
		print "H"
	elif b == "D":
		print "D"
elif a == "D":
	if b == "H":
		print "D"
	elif b == "D":
		print "H"

Measured memory_bytes: 2568
X, N = map(int, input().split())
# p = list(map(int, input().split()))

if N == 0:
    input()
    print(X)
    exit(0)
else:
    p = list(map(int, input().split()))
    for i in range(10000):
        if X - i not in p:
            print(X - i)
            exit(0)
        elif X + i not in p:
            print(X + i)
            exit(0)

Measured memory_bytes: 9176
N = int(input())
h = list(map(int, input().split()))

dp = [100000] * N
dp[0] = 0
dp[1] = abs(h[1] - h[0])

for i in range(2,N):
    dp[i] = min(dp[i-2] + abs(h[i-2] - h[i]), dp[i-1] + abs(h[i-1] - h[i]))




print(dp[N-1])


Measured memory_bytes: 13976
#include <cstdio>
#include <algorithm>
using namespace std;

int main()
{
	char s[8];
	scanf("%s", s);

	sort(s, s + 4);

	if(s[0] == s[1] && s[2] == s[3] && s[1] != s[2]) {
		printf("Yes\n");
	} else {
		printf("No\n");
	}

	return 0;
}


Measured memory_bytes: 128
#!/usr/bin/env python3
import sys

def factor_iter(n):
    from itertools import takewhile
    m = n
    for p in range(2, int(n**0.5)+2):
        while m % p == 0:
            yield p
            m //= p
        if m == 1:
            return
    if m != 1:
        yield m

def f(c):
    ret = 0
    tmp = 1
    while c >= tmp:
        c -= tmp
        ret += 1
        tmp += 1
    return ret

def solve(N: int):
    from collections import Counter
    p = Counter(factor_iter(N))
    return sum(map(f, p.values()))

# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    print(solve(N))

def test():
    import doctest
    doctest.testmod()

if __name__ == '__main__':
    #test()
    main()


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

int main(){
	int i;
	i = 1;
	int x;
	while(1){
		cin >> x;
		if(x==0){
			break;
		}

			cout << "Case"<<" "<<i<<":"<<" "<<x<<endl;
			i += 1;
	}
}




Measured memory_bytes: 3084
#include <stdio.h>

void heapify(int s[],int h,int i){
    int l,r,max,tmp;
    l=i*2;
    r=i*2+1;
    max=i;

    if(l<=h&&s[l-1]>s[max-1])max=l;
    if(r<=h&&s[r-1]>s[max-1])max=r;
    
    if(max!=i){
        tmp=s[max-1];
        s[max-1]=s[i-1];
        s[i-1]=tmp;
        
        heapify(s,h,max);
    }
    
    return;
}

void output(int s[],int h){
    int i;
    for(i=0;i<h;i++)printf(" %d",s[i]);
    printf("\n");
}

int main(void){
    int i;
    
    int h;
    scanf("%d\n",&h);
    
    int s[h];
    for(i=0;i<h;i++)scanf("%d \n",&s[i]);
    
    for(i=h/2;i>0;i--){
        heapify(s,h,i);
    }
    
    output(s,h);
    
    return 0;    
}



Measured memory_bytes: 3688
package main

import (
	"fmt"
)

func main() {
	var H, W int
	fmt.Scan(&H, &W)
	c := make([][]int, 10)
	for i := 0; i < 10; i++ {
		c[i] = make([]int, 10)
		for j := 0; j < 10; j++ {
			fmt.Scan(&c[i][j])
		}
	}

	minCosts := make([]int, 10)
	for i := 0; i < 10; i++ {
		minCosts[i] = solve(c, i)
	}

	ans := 0
	for i := 0; i < H; i++ {
		for j := 0; j < W; j++ {
			A := 0
			fmt.Scan(&A)
			if A == -1 || A == 1 {
				continue
			}
			ans += minCosts[A]
		}
	}

	fmt.Println(ans)
}

/** Return minimum cost from start to 1 */
func solve(c [][]int, start int) int {
	if start == 1 {
		return 0
	}
	const Big = 999999

	unfixed := make([]int, 10)
	fixed := make([]int, 10)
	for i := 0; i < 10; i++ {
		fixed[i] = Big
		unfixed[i] = Big
	}
	cur := start
	fixed[cur] = 0
	unfixed[cur] = 0

	// iterate 9 times
	for i := 0; i < 9; i++ {
		// calc unfixed costs.
		for j := 0; j < 10; j++ {
			// cur -> j
			if fixed[j] != Big {
				continue
			}
			x := fixed[cur] + c[cur][j]
			if unfixed[j] > x {
				unfixed[j] = x
			}
		}
		// find minimum unfixed costs.
		muc := Big
		for j := 0; j < 10; j++ {
			if fixed[j] == Big && unfixed[j] < muc {
				muc = unfixed[j]
				cur = j
			}
		}
		fixed[cur] = unfixed[cur]
	}
	return fixed[1]
}


Measured memory_bytes: 3072
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int n;
    cin >> n;
    vector<int> p(n);
    for (int i=0;i<n;i++) cin >> p[i];

    int ans=0;
    for (int i=1;i<n-1;i++) {
        int maxp=max(p[i-1],max(p[i],p[i+1]));
        int minp=min(p[i-1],min(p[i],p[i+1]));
        if (p[i]!=maxp && p[i]!=minp) ans++;
    }
    cout << ans << endl;
}

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

using namespace std;

int main(){
    string s;
    cin >> s;
    int cnt = 0;
    for (int i = 0; i < s.size(); i++)
        if (s[i] == '1')
            cnt ++;
    cout << cnt << endl;
}


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

int main() {
  int n;
  ll ans = 0;
  cin >> n;
  vector<vector<ll>>data(10,vector<ll>(10,0));
  rep(i,0,10) rep(j,0,10){
    rep(k,1,n+1){
      string s = to_string(k);
      if(s[0]-'0' == i && s[s.size()-1]-'0' == j) data[i][j]++;
    }
  }
  rep(i,0,10) rep(j,0,10) ans += data[i][j]*data[j][i];
  cout << ans << endl;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,d,a;
    cin>>n>>d>>a;
    int ans=0;
    while(n--)
    {
        int x;
        cin>>x;
        if(d%x==0)
            ans+=d/x;
        else
            ans+=d/x+1;
    }
    cout<<ans+a;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>

using namespace std;

int main(){
    int N;
    cin >> N;
    int count = 0;
    for(int i = 1; i <= N; i++){
        stringstream ss;
        ss << i;
        string s = ss.str();
        if(s.size() % 2 != 0){
            count++;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define sz(x) int(x.size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define INF 2e9
#define LINF 1e18
template<class T> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> P;
 
int main() {
    int n, k; cin >> n >> k;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    ll sum = 0;
    rep(i, n) sum += a[i];
    set<ll> candidates;
    //GCDはsumの約数なのでそれを調べるため約数列挙
    for (int i=1; i*i<=sum; i++) {
        if (sum%i == 0) {
            candidates.insert(i);
            candidates.insert(sum/i);
        }
    }
    ll ans = 1;
    for (ll x : candidates) {
        ll need = 0;
        vector<ll> r(n);
        rep(i, n) r[i] = a[i]%x;
        sort(all(r));
        ll tot = 0;
        rep(i, n) tot += r[i];
        //マイナスする側の個数
        int l = n-tot/x; //totはxで割り切れることに注意
        rep(i, l) need += r[i];
        if (need <= k) chmax(ans, x);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
# coding: utf-8
import sys

n = input()
seq = [int(x) for x in sys.stdin.read().rstrip().split("\n")]
seq_max = max(seq)

# seq_max と同じ値を持つindexを探査
seq_max_indices = []
for i in range(0, len(seq)):
    if seq[i] == seq_max:
        seq_max_indices.append(i)

if len(seq_max_indices) == 1:
    seq_second_max = sorted(seq, reverse=True)[1]
    result = [str(seq_max) for x in range(len(seq))]
    result[seq_max_indices[0]] = str(seq_second_max)
    print("\n".join([str(x) for x in result]))
else:
    print("\n".join([str(seq_max) for x in range(len(seq))]))

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

int main(){
  long long n,i,j,flag=0;
  cin >> n;
  vector<long long> a(n),b(31);
  for(i=0; i<n; i++){
    cin >> a[i];
    if(a[i]!=0) flag++;
  }
  if(!(flag)){
    cout << "Yes"; return 0;
  }
  if(n%3!=0){
    cout << "No"; return 0;
  }
  for(j=0; j<31; j++){
    for(i=0; i<n; i++){
      b[j]+=a[i]%2;
      a[i]/=2;
    }
    if((b[j]%2)){
      cout << "No"; return 0;
    }
  }
  
  cout << "Yes"; 

}

Measured memory_bytes: 1024
import java.util.*;
class Main{
    public static void main(String[] args){
	Scanner stdIn=new Scanner(System.in);
	int N = stdIn.nextInt();
	int A = stdIn.nextInt();
	int o = N%500;
	if(o<=A){
	    System.out.println("Yes");
	}else{
	    System.out.println("No");
	}
    }
}


Measured memory_bytes: 21972
n = int(input())

def findL(n):
    if n==0: return 2
    if n==1: return 1
    i2, i1 = 2, 1
    Luca = 0
    for i in range(2,n+1):
        Luca = i1 + i2
        i2 = i1
        i1 = Luca
    return Luca

print(findL(n))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
        using namespace std;
   #define int long long
const int MAX = 510000;
const int MOD =  998244353;
const int  Inv2 = (MOD+1)/2;
stack<int> que;
     signed main(){
int n,a;
cin>>n;
multiset<int> s;
vector<int> x;
for(int i=0;i<(1<<n);i++){
   cin>>a;
   s.insert(-1*a);
}
auto it=s.begin();
x.push_back(*it);
s.erase(it++);
for(int i=0;i<n;i++){
   it=s.begin();
    sort(x.begin(),x.end());
   for(int j=0;j<(1<<i);j++){
      //cerr<<*it<<' '<<x[j]<<' ';
      while(it!=s.end()&&(*it)<=x[j])it++;
      if(it==s.end()){
         cout<<"No";
         return 0;
      }
      x.push_back(*it);
      s.erase(it++);
   }
  
}
cout<<"Yes";
      }

        


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

int main(){
  int K,X;
  cin >> K >> X;
  for (int i = X-(K-1); i<=X+(K-1); i++){
    if(i==X+(K-1)){
      cout << i<< endl;
    }
    else{
      cout << i<<" ";
    }
  }
}

Measured memory_bytes: 256
import sys
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
def resolve():
    A = [[] for _ in range(3)]
    for i in range(3):
        A[i] = lr()
    N = ir()
    card = [[False, False, False] for _ in range(3)]
    for i in range(N):
        b = ir()
        for j in range(3):
            for k in range(3):
                if A[j][k] == b:
                    card[j][k] = True
    for i in range(3):
        if card[i] == [True, True, True]:
            print('Yes')
            return
    for i in range(3):
        if card[0][i] == True and card[1][i] == True and card[2][i] == True:
            print('Yes')
            return
    if card[0][0] == True and card[1][1] == True and card[2][2] == True:
        print('Yes')
        return
    if card[2][0] == True and card[1][1] == True and card[0][2] == True:
        print('Yes')
        return
    print('No')
resolve()

Measured memory_bytes: 3064
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repn(i,x) for(int i = 1; i <= x; i++)
#define SORT(x) sort(x.begin(),x.end())
#define dupl(s) s.erase(unique(s.begin(), s.end()), s.end());//重複取り除き
#include <bits/stdc++.h>
using namespace std;
int sum(vector<int> s){return accumulate(s.begin(),s.end(),0);}
void p(vector<int> A){rep(i,A.size()){cout << A[i] << " ";}cout << "\n";}

int main(){
    long long k,a,b;
    cin >> k >> a >> b;
    if(b - a <= 2 || k < a - 1)cout << k + 1;
    else{
        long long ans = a;
        k -= a - 1; 
        if(k % 2 == 1)k--,ans++;
        ans += (b - a)*(k/2);
        cout << ans;
    }
}

Measured memory_bytes: 3596
N, M = map(int, input().split())
SC = list(tuple(map(int, input().split())) for _ in range(M))

for i in range(10**N):
    if len(str(i)) == N and all(str(i)[s-1] == str(c) for s, c, in SC):
        print(i)
        break
else:
    print(-1)


Measured memory_bytes: 9116
x=int(input())
for i in range(1000):
  for j in range(1000):
    if i**5-j**5==x:
      a,b=i,j
      break
else:
  for k in range(1000):
    for l in range(1000):
      if k**5+l**5==x:
        a,b=k,(-1)*l
        break
        
print(a,b)

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

using namespace std;

const int maxn = 5005,maxm = 205;

typedef long long ll;

ll s[maxn][maxn],a[maxn];
int v[maxm][maxn],n,m;

void mark(int l,int r,int x,int y,int v)
{
	if (l > r || x > y) return;
	s[l][x] += v,s[r + 1][x] -= v,s[l][y + 1] -= v,s[r + 1][y + 1] += v;
}

int main()
{
	scanf("%d%d", &n, &m);
	for(int i = 2;i <= n;i ++) scanf("%d", &a[i]),a[i] += a[i - 1];
	for(int i = 1;i <= n;i ++)
		for(int j = 1;j <= m;j ++)
			scanf("%d", &v[j][i]);
	for(int j = 1;j <= m;j ++)
	{
		static int stk[maxn],l[maxn],r[maxn];
		int  top = 0;
		for(int i = 1;i <= n;i ++) l[i] = 1,r[i] = n;
		for(int i = 1;i <= n;i ++)
		{
			for(;top && v[j][i] > v[j][stk[top]];top --) r[stk[top]] = i - 1;
			l[i] = stk[top] + 1;
			stk[++ top] = i;
		}
		for(int i = 1;i <= n;i ++) mark(l[i],i,i,r[i],v[j][i]);
	}
	for(int i = 0;i <= n;i ++)
		for(int j = 0;j <= n;j ++)
		{
			if (i - 1 >= 0) s[i][j] += s[i - 1][j];
			if (j - 1 >= 0) s[i][j] += s[i][j - 1];
			if (i - 1 >= 0 && j - 1 >= 0) s[i][j] -= s[i - 1][j - 1];
		}
	ll ans = 0;
	for(int i = 1;i <= n;i ++)
		for(int j = i;j <= n;j ++) ans = max(ans,s[i][j] - (a[j] - a[i]));
	printf("%lld\n", ans);
	return 0;
}

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

char tolower(char ch){
    if('A'<=ch&&ch<='Z'){
        return ch-'A'+'a';
    }else{
        return ch;
    }
}

int main(){
    
    string word;
    string greeting;
    int count=0;
    
    cin>>word;
    
    while(true){
        
        cin >> greeting;
        if(greeting=="END_OF_TEXT"){
            break;
        }
        
        
        for(int i=0;i<(int)greeting.size();i++){
            greeting[i]=tolower(greeting[i]);
        }
        
        if(greeting==word){
            count++;
        }
        
    }
    
    cout<<count<<endl;
    
    
  return 0;
}


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

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

#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define sqrep(i,cc,n) for(long long i=cc;i*i<=n;++i)
#define rrep(i,cc,n) for(long i=cc;i>n;--i)
#define pii pair<int, int>
#define pll pair<long long, long long>
 
using ll = long long;

const vector<int> dx = {1, 0, -1, 0};
const vector<int> dy = {0, 1, 0, -1};
const ll inf = 1001001001;
const ll e9  = 1000000000;
const ll mod = 1000000007;


int main() {
 int n;
 cin >> n;
 vector<ll>a(n);
 map<int, ll>mp;
 ll ans = 0;
 rep(i, 0, n){
     ll a;
     cin >> a;
     mp[a+i]++;
     ans += mp[i-a];
 }
 cout << ans << endl;
}

Measured memory_bytes: 27392
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>

using namespace std;

int main() {
	string s;
	cin >> s;
	int k;
	cin >> k;
	set<string> ss;
	for (int i = 0; i < s.size(); i++) {
		for (int j = 1; j <= 5; j++) {
			if (i + j <= s.size()) {
				ss.insert(s.substr(i, j));
			}
		}
	}
	string ans;
	for (set<string>::iterator ite = ss.begin(); ite != ss.end(); ite++) {
		ans = *(ite);
		k--;
		if (k == 0) {
			break;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1664
#include <algorithm>
#include <cfloat>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define int long long
#define ll long long
#define eps LDBL_EPSILON
#define mod 1000000007
#define int long long
#define double long double
#define INF INT_MAX
#define P pair<int,int>
#define prique priority_queue
using namespace std;
int n, m, a, b;
vector<int> vec[100010];
int d[100010];
bool dfs(int node, bool f) {
	if (!f)d[node] = 1;
	else d[node] = 2;
	for (int i : vec[node]) {
		if (d[node] == d[i])return false;
		if (!d[i] && !dfs(i, !f))return false;
	}
	return true;
}
signed main() {
	cin >> n >> m;
	rep(i, m) {
		cin >> a >> b;
		vec[a].push_back(b);
		vec[b].push_back(a);
	}
	if (!dfs(1, 0))cout << n * (n - 1) / 2 - m << endl;
	else {
		int cnt = 0;
		REP(i, n)if (d[i] == 1)cnt++;
		cout << cnt * (n - cnt) - m << endl;
	}
}

Measured memory_bytes: 7424
// https://atcoder.jp/contests/dp/tasks/dp_g

#include <iostream>
#include <vector>
#include <array>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <algorithm>
#include <iomanip>

using namespace std;

long long longest_path(const vector<vector<long long>>& edges, vector<long long>& dp, long long id) {
	if (dp[id] >= 0) return dp[id];
	long long length = 0;
	for (long long next_id : edges[id]) {
		length = max(length, longest_path(edges, dp, next_id) + 1);
	}
	dp[id] = length;
	return length;
}

int main (int argc, char* argv[]) {
	long long n, m;
	cin >> n >> m;

	vector<vector<long long>> edges(n);
	for (int i = 0; i < m; i++) {
		long long from, to;
		cin >> from >> to;
		from--;
		to--;
		edges[from].push_back(to);
	}

	long long length = 0;
	vector<long long> dp(n, -1);
	for (long long i = 0; i < n; i++) {
		length = max(length, longest_path(edges, dp, i));
	}

	cout << length << endl;
}


Measured memory_bytes: 9216
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <iostream>
using namespace std;
const int MaxN = 2e5 + 4;
int a[MaxN],b[MaxN];
int main ()
{
	int n;
	scanf("%d",&n);
	for (int i = 1; i <= n; i++)
	{
		scanf("%d",&a[i]);
		b[i] = a[i];
	}
	sort(b+1,b+1+n);
	int x,y;
	x = b[n/2],y = b[n/2+1];
	for (int i = 1; i <= n; i++)
	{
		if (a[i] <= x) printf("%d\n",y);
		else printf("%d\n",x);
	}
	return 0;
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using P = pair<lint, lint>;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
void yes(bool expr) {
  cout << (expr ? "Yes" : "No") << "\n";
}
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int N;
  cin >> N;
  vector<lint> a(N);
  REP(i, N) cin >> a[i];
  map<lint, lint> minidx;
  map<lint, lint> cnt;
  minidx[0] = 0;
  cnt[0] = 0;
  REP(i, N) {
    if(minidx.find(a[i]) == minidx.end()) {
      minidx[a[i]] = i;
      cnt[a[i]] = 1;
    } else {
      cnt[a[i]]++;
    }
  }
  vector<lint> ans(N);
  auto itr = prev(minidx.end());
  lint idx = INF;
  lint cntsum = 0;
  lint lastkey = -1;
  while(true) {
    lint key = itr->first;
    if(lastkey != -1) ans[idx] += (lastkey-key) * cntsum;
    if(itr == minidx.begin()) break;
    cntsum += cnt[key];
    if(itr->second < idx) idx = itr->second;
    lastkey = key;
    itr = prev(itr);
  }
  REP(i, N) cout << ans[i] << "\n";
}

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

const long double PI = acos(-1);
constexpr long double EPS = 1e-15;
constexpr int inf = 2e9;
constexpr ll INF = 2e18;
constexpr ll MOD = 1e9+7;
constexpr ll MOD1 = 998244353;
typedef pair<ll,ll> P;

//#define all(v) (v).begin(), (v).end()
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
//#define mp make_pair

struct Tree{
  int num = 0;
  Tree *left;
  Tree *right;
  Tree() {
    num = 0;
    left = NULL;
    right = NULL;
  }
  Tree(Tree *l,int m,Tree *r) {
    num = m;
    left = l;
    right = r;
  }
};

// void findroot(string s, int &k) {
//   int cnt = 1;
//   for (int i = 1; i < sz(s); i++) {
//     if (s[i] == '(') cnt++;
//     else if (s[i] == ')') cnt--;

//     if (cnt == 0) {
//       i+=2;
//       int num = 0;
//       while ('0' <= s[i] && s[i] <= '9') {
//         num *= 10;
//         num += (s[i] - '0');
//         i++;
//       }
//       k = num;
//       return;
//     }
//   }
// }

int k;
Tree *maketree(Tree *t, string s) {
  Tree *tmp = new Tree();

  int middle = 0;
  k++;
  if (s[k] == ')') ;
  else tmp->left = maketree(t, s);
  k += 2;

  while ('0' <= s[k] && s[k] <= '9') {
    middle *= 10;
    middle += (s[k] - '0');
    k++;
  }
  
  k+=2;
  if (s[k] == ')') ;
  else tmp->right = maketree(t, s);
  k++;

  tmp->num = middle;
  return tmp;
}

void dfs(Tree *t1, Tree *t2) {
  cout << '(';
  if (t1->left != NULL && t2->left != NULL) {
    dfs(t1->left, t2->left);
  }
  cout << ')';
  cout << '[';
  cout << t1->num + t2->num;
  cout << ']';
  cout << '(';
  if (t1->right != NULL && t2->right != NULL) {
    dfs(t1->right, t2->right);
  }
  cout << ')';
}

void solve() {
  string a,b;
  int r1,r2;
  cin >> a >> b;
  Tree *t1 = new Tree();
  Tree *t2 = new Tree();
  k = 0;
  t1 = maketree(t1,a);
  k = 0;
  t2 = maketree(t2,b);
  dfs(t1,t2);
  cout << endl;
}

int main(){
  // int n;
  // cin >> n;
  // REP(i,n) {
  //   solve();
  // }
  solve();
  return 0;
}



Measured memory_bytes: 3308
from collections import Counter

N = int(input())
A = list(map(int, input().split()))

cum = [0, A[0]]
for i in range(1,N):
    cum.append(cum[-1] + A[i])

c = Counter(cum)

ans = 0
for v in c.values():
    ans += (v*(v-1))//2

print(ans)

Measured memory_bytes: 41696
#include <bits/stdc++.h>
using namespace std;
#define BE(x) x.begin(), x.end()

int main() {
    long long l, r;
    cin >> l >> r;

    long long ans = 2019;
    int icnt = 0;
    for (long long i = l; i < r; i++) {
        int jcnt = 0;
        for (long long j = i+1; j <= r; j++) {
            ans = min(ans, i*j%2019);
            jcnt++;
            if (jcnt == 2020) break;
        }
        icnt++;
        if (icnt == 2020) break;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3592
l = list(map(int, input().split() ))
if(((0 <= l[2] - l[4]) and (l[2] + l[4] <= l[0])) and ((0 <= l[3] - l[4]) and (l[3] + l[4] <= l[1]))):
    print("Yes")
else:
    print("No")


Measured memory_bytes: 5600
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
#include <limits>
using namespace std;
// 素因数分解
typedef pair<long long, long long> P;
vector<P> prime_factorize(long long n)
{
vector<P> res;
for (long long p = 2; p * p <= n; ++p)
{
if (n % p != 0)
continue;
int num = 0;
while (n % p == 0)
{
++num;
n /= p;
}
res.push_back(make_pair(p, num));
}
if (n != 1)
res.push_back(make_pair(n, 1));
return res;
}
// 因数分解
long long gcd(long long x, long long y)
{
  if (y == 0)
  {
    return x;
  }
  else
  {
    return gcd(y, x % y);
  }
}
const int MOD = 1000000007;
typedef long long int ll;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i, n) for (int i = 0; i < (n); i++)
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; }

int main()
{
    int n;
    cin >> n;
    vector<int> P(n);
    rep(i,n){
        cin >> P[i];
    }
    int Min = P[0];
    int ans = 1;
    for (int i = 0; i < n-1; i++)
    {
        chmin(Min, P[i]);
        if(P[i+1]<=Min){
            ans++;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3988
#include <algorithm>
#include <array>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
using ll=long long int;
using vi=vector<int>;
using vl=vector<ll>;
using vs=vector<string>;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define RANGE(i,a,b) for(int i=(a);i<=(b);i++)
#define RANGER(i,a,b) for(int i=(b);i>=(a);i--)
#define REP(i,n) FOR(i,0,n)
#define REPR(i,n) FORR(i,0,n)

#define EVALe 1

#ifdef EVAL
#define LOG(i) 0
#else
#define LOG(i) cerr<<#i<<": "<<i<<endl
#endif

void solve(){
	ll N,K,ans;
	cin>>N>>K;
	ll H[200000];
	REP(i,N)scanf("%lld",&H[i]);
	sort(&H[0],&H[N]);
	REP(i,N-K)ans+=H[i];
	cout<<ans<<endl;
	//cout<<(H<=0?"Yes":"No")<<endl;
}
int main(){
	solve();
	return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>

int main() {
  int n;
  int a[50], b[50], c[50];
  int temp = 0;
  int k, l, m;
  scanf("%d", &n);
  for(int i=0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  for(int i=0; i < n; i++) {
    scanf("%d", &b[i]);
  }
  for(int i=0; i < n -1; i++) {
    scanf("%d", &c[i]);
  }
  for(int i=0; i < n; i++) {
    k = a[i] - 1;
    if(temp == a[i]) {
      l = a[i] - 2;
      m += c[l];
    }
    m += b[k];
    temp = a[i] + 1;
  }
  printf("%d", m);
}

Measured memory_bytes: 128
#include <iostream>
#include<bits/stdc++.h>
#define ll long long int
#define lld long double
#define F first
#define S second
#define f(i,a,b) for(int i=a;i<=b;i++)
#define g(i,a,b) for(int i=a;i>=b;i--)
#define pb push_back
#define mh make_heap
#define ph push_heap
#define pq priority_queue
#define bits(x) __builtin_popcountll(x)
#define op(x) cout<<"Case #"<<x<<": "
#define op1(x) cout<<"Scenario #"<<x<<": "
#define endl "\n"
using namespace std;
const ll mod = 1000000007;
const ll INF = 1e18;
const int N = 20;



void solve(int t)
{

	ll n, k;
	cin >> n >> k;
	ll a[n];

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

	ll p = 0;
	ll q = k - 1;

	while (q < n - 1)
	{

		ll c = a[p];
		p++;
		q++;
		ll d = a[q];
		//cout<<c<<" "<<d<<endl;

		if (d > c)
		{
			cout << "Yes" << endl;
		}
		else
		{
			cout << "No" << endl;
		}
	}

}




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


	int t = 1;
	//cin >> t;

	for (int i = 1; i <= t; i++)
	{
		solve(i);

	}
}

Measured memory_bytes: 5216
#include <iostream>
#include <vector>

using ll = long long;

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

    std::vector<ll> h(N);
    for (auto& e : h) std::cin >> e;
    h.push_back(0);

    ll ans = 0;
    std::vector<std::pair<ll, int>> stack;
    for (int i = 0; i <= N; ++i) {
        int pos = i;
        while (!stack.empty() && stack.back().first > h[i]) {
            auto p = stack.back();
            stack.pop_back();
            ans = std::max(ans, p.first * (i - p.second));
            pos = p.second;
        }
        if (stack.empty() || stack.back().first < h[i]) {
            stack.emplace_back(h[i], pos);
        }
    }

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



Measured memory_bytes: 6464
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
ull nax=1e18;
ll n,m;
ll valid(ll i,ll j)
{
 if(i>=0 && i<n && j>=0 && j<m)
 return true;
 return false;
 //return 0;
}
int main()
{ 
    int n;
    ull k=1;
    cin>>n;
   
    vector<ull> v;
    bool zero=false;
    for(ll i=0;i<n;i++)
    {
        ull x;
        cin>>x;
        v.push_back(x);
   
         if(x==0)
         zero=true;

    }
    if(zero)
    {
        cout<<0;
        return 0;
    }
   // sort(v.begin(),v.end());
    for(ll i=0;i<n;i++)
    { 
        //ull x=v[i];
        
        if(v[i]>1000000000000000000/ k)
        {
            cout<<-1;
            return 0;
        }
        else
         k*=v[i];
    }
    cout<<k;
    return 0;
}


Measured memory_bytes: 4316
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int n;
    cin >> n;
 
    pair <pair<string,int>,int> p[n];
 
    for (int i=0;i<n;i++){
        string s;
        int t;
        cin >> s >> t;
        p[i] = make_pair(make_pair(s,-t),i+1);
    }
    sort(p,p+n);
    for (int i=0;i<n;i++){
        cout << p[i].second << endl;
    }
}

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

bool isSmaller(int ah,int aw,int bh,int bw){
    if((bh*bh+bw*bw)<(ah*ah+aw*aw)){
        return true;
    }else{
        if((bh*bh+bw*bw)==(ah*ah+aw*aw)&&bh<ah){
            return true;
        }
    }
    return false;
}

int main() {
    int h,w;

    while(true){
        cin>>h>>w;
        if(h==0 && w==0){
            break;
        }

        int answ=200,ansh=200;

        for(int i=1;i<151;i++){
            for(int j=i+1;j<151;j++){
                if(isSmaller(i,j,h,w)){
                    if(isSmaller(ansh,answ,i,j)){
                        ansh=i;
                        answ=j;
                    }
                }
            }
        }
        cout<<ansh<<" "<<answ<<endl;
    }
    return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
 
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define F               first
#define S               second
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18 + 1
#define endl            '\n'
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define forI(i,a,n)     for(int i=a;i<=n;i++)
#define forD(i,a,n)     for(int i=n;i>=a;i--)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());
 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
 
void init(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
}

double dp[301][301][301];

double compute(int x, int y, int z, int n){
    if(x < 0 || y < 0 || z < 0)  return 0;
    if(x == 0 && y == 0 && z == 0)  return 0;

    if(dp[x][y][z] > -0.9)  return dp[x][y][z];

    double nr = n + x*compute(x-1, y, z, n) + y*compute(x+1, y-1, z, n) + z*compute(x, y+1, z-1, n);
    return dp[x][y][z] = nr/(x+y+z);

}

void solve(){
    int n, x=0, y=0, z=0, s;  cin>>n;
    memset(dp, -1, sizeof dp);
    forI(i, 1, n){
        cin>>s;
        if(s == 1)  x++;
        else if(s == 2)  y++;
        else if(s == 3)  z++;
    }

    cout<<ps(compute(x, y, z, n), 10);

}

int32_t main(){
    init();
    // w(t) 
    solve();
    return 0;
}

Measured memory_bytes: 216856
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int M = sc.nextInt();
    HashMap<Integer, List<Integer>> nodeToNexts = new HashMap<>(), nodesFromPrev = new HashMap<>();
    for (int i = 0; i < M; i++) {
      int from = sc.nextInt() - 1; // 0-indexed.
      int to = sc.nextInt() - 1;
      nodeToNexts.computeIfAbsent(from, k -> new LinkedList<>()).add(to);
      nodesFromPrev.computeIfAbsent(to, k -> new LinkedList<>()).add(from);
    }

    double[] dpExp = new double[N]; // dpExp[v]:= Expectation(v->N)
    for (int i = N - 2; i >= 0; i--) {
      for (int next : nodeToNexts.get(i)) {
        dpExp[i] += dpExp[next];
      }
      dpExp[i] /= nodeToNexts.get(i).size();
      dpExp[i] += 1;
    }
    double[] dpReachProb = new double[N]; // dpReachProb[v]:= probReach(0->v)
    dpReachProb[0] = 1;
    for (int idxNext = 1; idxNext < N; idxNext++) {
      for (int prev : nodesFromPrev.getOrDefault(idxNext, Collections.emptyList())) {
        int sz =  nodeToNexts.get(prev).size();
        dpReachProb[idxNext] += dpReachProb[prev] / sz;
      }
    }


    double improve = 0;
    for (int i = 0; i < N - 1; i++) {
      List<Integer> nexts = nodeToNexts.get(i);
      int preCutOutNum = nexts.size();
      if (preCutOutNum <= 1) continue;
      double maxExp = 0;
      double nextExps = 0;
      for (Integer next : nexts) {
        maxExp = Math.max(dpExp[next], maxExp);
        nextExps += dpExp[next];
      }
      double expPreCut = dpExp[i];
      double expPostCut = (nextExps - maxExp) / (preCutOutNum  - 1) + 1;
      double tmpImprove = (expPreCut - expPostCut) * dpReachProb[i]; // ?
      if (improve < tmpImprove)
        improve = tmpImprove;
    }

    System.out.println(dpExp[0] - improve);
  }
}


Measured memory_bytes: 103332
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<ll, ll>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'
#define all(a) a.begin(), a.end()
#define rev(a) reverse(all(a)
#define ld long double
const ll mod=1e9+7;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); 
int main() {
        ll n,m;
        cin >> n >> m;
        ll a[n]; 
        ll sum=0;
        for(int i=0; i<n; i++){
            cin >> a[i];
            sum+=a[i];
        }
        sort(a,a+n,greater<ll>());
        if(a[m-1]*4*m>=sum) puts("Yes");
        else puts("No");
        
	return 0;
}

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

typedef long long ll;
vector<ll>v;

int main()
{
	ll n;
	scanf("%lld",&n);
	while(n)
	{
		v.push_back(n);
		n/=2;
	}
	ll ans = 1;
	reverse(v.begin(),v.end());
	int sz = v.size();
	for(int i=1;i<sz;i++){
		ans = ans*2+1;
	}
	printf("%lld\n",ans);
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
static const int MAX=200000;

int main(){
    int R[MAX],n;
    cin>>n;
    for(int i=0;i<n;i++)cin>>R[i];
    int maxv=-2000000000;
    int minv=R[0];
    for(int i=1;i<n;i++){
        maxv=max(maxv,R[i]-minv);
        minv=min(R[i],minv);
    }
    cout<<maxv<<endl;
    return 0;
}


Measured memory_bytes: 3868