akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long   signed int LL;
typedef long long unsigned int LU;
#define incID(i, l, r) for(LL i = (l)    ; i <  (r); ++i)
#define incII(i, l, r) for(LL i = (l)    ; i <= (r); ++i)
#define decID(i, l, r) for(LL i = (r) - 1; i >= (l); --i)
#define decII(i, l, r) for(LL i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec(i, n)  decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
template<typename T> bool setmin  (T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmax  (T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
LL mo(LL a, LL b) { assert(b > 0); a %= b; if(a < 0) { a += b; } return a; }
LL fl(LL a, LL b) { assert(b > 0); return (a > 0 ? a / b : (a - b + 1) / b); }
LL ce(LL a, LL b) { assert(b > 0); return (a < 0 ? a / b : (a + b - 1) / b); }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
#define bit(b, i) (((b) >> (i)) & 1)
#define BC __builtin_popcountll
#define SC static_cast
#define SI(v) SC<int>(v.size())
#define SL(v) SC<LL >(v.size())
#define RF(e, v) for(auto & e: v)
#define ef else if
#define UR assert(false)

// ---- ----

int n, ans[100001];

int main() {
	cin >> n;
	inc(i, n) {
		int a; cin >> a;
		ans[a] = i + 1;
	}
	
	inc1(i, n) {
		cout << ans[i] << (i == n ? "\n" : " ");
	}
	
	return 0;
}


Measured memory_bytes: 1152
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <fstream>
#include <string>
#include <math.h>
#include <cstdlib>
#include <istream>
#include <sstream>
#include <cctype>
#define fore(i,x,y) for(long long i=x;i<y;i++)
typedef long long ll;
using namespace std;
int main()
{
	string s;
	cin >> s;
	for(int i=0;i<s.size();i++){
		if(i%2==0){
			cout << s[i];
		}
	}
	cout << endl;
}

Measured memory_bytes: 512
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath> // 変数名にy1が使えなくなるかも…。
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <limits>
#include <functional>
#include <string>

typedef __int128_t int128_t;
std::istream &operator>>(std::istream& input, int128_t& value) { // int128_tの入力。入力が64bitに収まる前提。
    long long tmp; input >> tmp; value = tmp;
    return input;
}
std::ostream &operator<<(std::ostream& output, const int128_t value) { // int128_tの出力。出力が64bitに収まる前提。
    output << (long long)value;
    return output;
}

#define rep(i, begin, end) for(int64_t i = (begin); i <= (end); i++)
#define rev(i, begin, end) for(int64_t i = (begin); (end) <= i; i--)

void printvec(const std::vector<int>& vec) {
    for (int i = 0; i < vec.size(); i++) { std::cout << vec[i] << " "; } std::cout << std::endl;
}

int A, B, C;

int main(int argc, char **argv) {
    std::cin >> A >> B >> C;
    
    auto tmp = A - B;

    std::cout << std::max(0, C - tmp) << std::endl;
    
    return 0;
}

Measured memory_bytes: 256
S = input()

words = ["dream", "dreamer", "erase", "eraser"]

current = S
canEqual = False
while len(current) > 0:
  matchExists = False
  for w in words:
    last_index = -len(w)
    if(current[last_index:] == w):
      current = current[:last_index]
      matchExists = True
      break
  
  if(len(current) == 0):
    canEqual = True
    break
  
  if(matchExists == False):
    break

result = "YES" if canEqual == True else "NO"
print(result)

Measured memory_bytes: 135336
#include <bits/stdc++.h>
 
#pragma GCC optimize("O2")
#pragma GCC optimize("unroll-loops")
 
using namespace std;
#define ll long long
#define ull unsigned long long
#define rep(i,n,N) for(int i=n;i<=N;++i)
#define asd(i,n,N) for(int i=n;i< N;++i)
#define rap(i,n,N) for(int i=n;i>=N;--i)
#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define fi first
#define se second
#define ff fi.fi
#define fs fi.se
#define sf se.fi
#define ss se.se
#define lc (id<<1)
#define rc ((id<<1)|1)
#define db(x) cout << ">>>> " << #x << " -> " << x << endl
#define mems(x,y) memset(x,y,sizeof x)
#define all(x) x.begin(),x.end()
#define pii pair<int,int> 
#define pll pair<ll,ll>
#define plll pair<pll,ll>
#define piii pair<int,pii>
#define piiii pair<pii,pii>
#define psi pair<string,int>
#define endl '\n'
const int MAX = 1e6+5;
const ll MAX2 = 11;
const ll MOD = 1000000007;
const ll MOD2 = 1000005329;
const ll INF = 2e18;
const int dr[]={1,0,-1,0,1,1,-1,-1,0};
const int dc[]={0,1,0,-1,1,-1,1,-1,0};
const double pi = acos(-1);
const double EPS = 1e-9;
const int block = 555;

ll n,k,x[MAX],p[MAX],ans,id,y[MAX],sm,nw,rem;

int main(){
//	cout<<fixed<<setprecision(2);
//    freopen("input.txt", "r", stdin);
//	freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin>>n>>k;
    rep(i,1,n)cin>>p[i];
    ans = -INF;
    rep(i,1,n)cin>>x[i], ans = max(ans,x[i]);
    rep(i,1,n){
    	nw = i, id = 0;
    	do{
    		nw = p[nw], y[++id] = x[nw];
		}while(nw!=i);
		rep(j,1,id){
			y[j]+= y[j-1];
			if(j<=k)ans = max(ans,y[j]);
		}
		if(k>id && y[id]>0){
			sm = (k-id)/id;
			rem = k-sm*id, nw = sm*y[id];
			rep(j,1,id){
				--rem;
				if(rem<0)break;
				ans = max(ans,nw+y[j]);
			}
			nw+= y[id];
			rep(j,1,id){
				--rem;
				if(rem<0)break;
				ans = max(ans,nw+y[j]);
			}
		}
	}
	cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3780
#include<iostream>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)

#define LOSE 0
#define WIN  1
int table[20][(1<<14)];

int  solve(int n,int now,int *data,int num){
  if (table[now][num] != -1)return table[now][num];
  if (num == 0){
    return WIN;
  }
  
  int ret = LOSE;
  REP(i,1,1+data[now]){
    if (num-i<0)break;
    if (solve(n,(now+1)%n,data,num-i) == LOSE)ret =WIN;
  }
  return table[now][num]=ret;
}

main(){
  int n,num;
  int data[20];
  while(cin>>n>>num && n){
    n*=2;
    rep(i,n)rep(j,num+1)table[i][j]=-1;
    rep(i,n)cin>>data[i];
    cout << solve(n,0,data,num) << endl;
  }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,m;
    scanf("%d%d",&n,&m);
    multiset<int> ms;
    for (int i = 0; i < n; i++){
        int x;
        scanf("%d",&x);
        ms.insert(x);
    }

    while (ms.size() && m--){
        int x = *(--ms.end());
        ms.erase(--ms.end());
        x >>= 1;
        ms.insert(x);
    }
    long long ans = 0ll;
    for (auto x : ms){
        ans += x;
    }
    printf("%lld\n",ans);
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5;
int par[N], rnk[N], sz[N];
int findroot(int node) {
  if (par[node] == node)
    return node;
  else {
    par[node] = findroot(par[node]);
    return par[node];
  }
}
void dounion(int x, int y) {
  if (rnk[x] > rnk[y]) {
    par[y] = x;
    sz[x] += sz[y];
  }
  else if (rnk[x] < rnk[y]) {
    par[x] = y;
    sz[y] += sz[x];
  }
  else {
    par[x] = y;
    sz[y] += sz[x];
    rnk[y]++;
  }
}
int main() {
  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    sz[i] = 1;
    par[i] = i;
  }
  pair<int, int> edg[m];
  for (int i = 0; i < m; i++) {
    cin >> edg[i].first >> edg[i].second;
    edg[i].first--;
    edg[i].second--;
  }
  long long ans[m], cnt = (n - 1LL) * n / 2;
  for (int i = m - 1; i >= 0; i--) {
    ans[i] = cnt;
    int x = findroot(edg[i].first);
    int y = findroot(edg[i].second);
    if (x != y) {
      cnt -= 1LL * sz[x] * sz[y];
      dounion(x, y);
    }
  }
  for (int i = 0; i < m; i++)
    cout << ans[i] << ' ';
  return 0;
}

Measured memory_bytes: 6372
#include"bits/stdc++.h"
using namespace std;

int main()
{
	int v, n[50], a[50], b[50], c[49], ans = 0;
	cin >> v;
	for (int i = 0; i < v; i++)cin >> a[i];
	for (int i = 0; i < v; i++)cin >> b[i];
	for (int i = 0; i < v - 1; i++)cin >> c[i];

	if (v == 1)
	{
		ans = b[0];
	}
	else
	{
		for (int i = 0; i < v; i++)ans += b[i];

		for (int i = 0; i < v; i++)
		{
			if (a[i] + 1 == a[i + 1])
			{
				ans += c[a[i]-1];
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<string>
#include<string.h>
#include<algorithm>
#include<vector>
#include<map>
#include<queue>
#include<stack>
#include<set>
#include<climits>
#include<deque>
#include<tuple>
#include<iomanip>
using namespace std;
#define int                  int64_t
#define double               long double
#define ass_on_fire          ios_base::sync_with_stdio(false);cin.tie(0);
#define vi                   vector<int>
#define di                   deque<int>
#define si                   set<int>
#define vpii                 vector<pair<int,int>>
#define pi                   pair<int,int>
#define pub                  push_back
#define puf                  push_front
#define pob                  pop_back
#define pof                  pop_front
#define all(a)               a.begin(),a.end()
#define rall(a)              a.rbegin(),a.rend()
#define PI                   3.1415926535897932384626433832795
#define read(a)              for(auto& x:a) cin>>x
#define speak(a)             for(auto x:a) cout<<x<<' '
#define rep(i,s,n)           for(int i=s;i<n;++i)
#define repe(i,s,n)          for(int i=1;i<=n;++i)
#define repr(i,n,s)          for(int i=n;i>=s;--i)
#define endl                 '\n'
#define gap                  ' '
#define min3(a,b,c)          min(a, min(b, c))
#define max3(a,b,c)          max(a, max(b, c))
#define MOD                  1000000007
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
int ass[100005];
int32_t main()
{
    ass_on_fire
    int n,s=0,a;cin>>n;
    rep(i,0,n) cin>>a,s+=a,ass[a]++;
    int operations;cin>>operations;
    rep(tt,0,operations)
    {
        int x,y;cin>>x>>y;
        s+=(y-x)*ass[x];
        ass[y]+=ass[x];
        ass[x]=0;
        cout<<s<<endl;
    }
}


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

using namespace std;

int main(){
    int N;
    cin >> N;
    int A[N];
    int a = 0;
    int b = 0;
    for(int i = 0;i < N;i++){
        cin >> A[i];
        if(A[i] > a){
            a = A[i];
        }
        else{
            if(A[i] > b){
                b = A[i];
            }
        }
    }
    
    for(int i = 0;i < N;i++){
        if(A[i] != a){
            cout << a << endl;
        }
        else{
            cout << b << endl;
        }
    }
}


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

int main(){
  ll n,ans=0,a,num_m=0,mi=2*1e9;cin>>n;
  REP(i,n){
      cin>>a;
      if(a<0) num_m++;
      mi=min(mi,abs(a));
      ans+=abs(a);
  }
  cout<<((num_m%2)?ans-mi*2:ans);
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <climits>
#include <sstream>

int N, C[500], S[500], F[500];

using namespace std;

int main(){

    scanf ("%d", &N);
    for(int i = 0; i < N - 1; i++) scanf("%d%d%d", &C[i], &S[i], &F[i]);

    for(int i = 0; i < N; i++){
        int t = 0;
        for(int j = i; j < N - 1; j++){
            if(t < S [j]) t = S[j];
            else if (t % F[j] == 0);
            else t = t + F[j] - t % F[j];
            t += C[j];
        }

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

    }

    

    return 0;
}

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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

const int M = 200000;
int n, a[M], b[M];

int main() {
	scanf("%d", &n);
	inc(i, n) { scanf("%d", &a[i]); }
	inc(i, n) { scanf("%d", &b[i]); }
	
	int ans = 0;
	dec(k, 28 + 1) {
		inc(i, n) {
			a[i] &= (2 << k) - 1;
			b[i] &= (2 << k) - 1;
		}
		sort(a, a + n);
		sort(b, b + n, greater<>());
		
		int c = 0, p1 = 0, p2 = 0, p3 = 0;
		inc(i, n) {
			while(p1 < n && a[i] + b[p1] >= (1 << k)) { p1++; }
			while(p2 < n && a[i] + b[p2] >= (2 << k)) { p2++; }
			while(p3 < n && a[i] + b[p3] >= (3 << k)) { p3++; }
			c ^= (p1 - p2 + p3) & 1;
		}
		ans |= c << k;
	}
	
	printf("%d\n", ans);
	
	return 0;
}


Measured memory_bytes: 1664
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
using namespace std;
int main() {
	int n;
	int a[10000];
	int ans = 0;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		for (;;) {
			if (a[i] % 2 == 0) {
				ans++;
				a[i] = a[i] / 2;
			}
			else {
				break;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

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

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

  sort(d.begin(),d.end());
  cout << d[N/2]-d[(N/2)-1] << endl;
}

Measured memory_bytes: 640
package main

import (
	"fmt"
)

func main() {
	var n, d, x, a int

	fmt.Scan(&n)
	fmt.Scan(&d)
	fmt.Scan(&x)

	ans := 0
	ans += x

	for i := 0; i < n; i++ {
		fmt.Scan(&a)
		ans += 1 + (d-1)/a

	}

	fmt.Print(ans)
}

Measured memory_bytes: 512
function Main(input) {
    input = input.split("");
    // console.log(input);
	if (input[0]===input[1] && input[0]===input[2]){
	    return console.log("No")
	}else{
	    return console.log("Yes");
	}
}
 
 
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
N, K = map(int, input().split())

sunuke = [0]*N
for i in range(K):
    d = int(input())
    A = list(map(int, input().split()))
    for j in range(d):
        sunuke[A[j]-1] += 1

n = 0
for sunu in sunuke:
    if sunu == 0:
        n += 1
print(n)



Measured memory_bytes: 67532
#include <bits/stdc++.h>
#define INF 2147483647
#define INF_LL 9223372036854775807
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

int main() {
	ll N, X;
	cin >> N >> X;
	vector<ll> a(51), b(51); //a レベルnバーガーの大きさ bレベルnバーガーに含まれるパティ
	a[0] = 1; b[0] = 1;
	for (int i = 0; i < 50; i++) {
		a[i + 1] = a[i] * 2 + 3;
		b[i + 1] = b[i] * 2 + 1;
	}

	ll ans = 0;
	int i = N;
	while (X >= 0) {
		for (i ; i >= 0; i--) {
			if (X >= a[i]) {
				if (X == a[i]) {
					X -= a[i];
					ans += b[i];
				}
				else {
					X -= a[i] + 1;
					ans += b[i] + 1;
				}
				break;
			}
			X--;
			if (X == 0)break;
		}
	}
	cout << ans << endl;
	return 0;
}

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

#define endl '\n'
#define pi 3.1415926

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int R;
    cin >> R;
    cout << fixed << setprecision(6) << 2 * pi * R << endl;
    return 0;
}

Measured memory_bytes: 3796
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		String data = scn.nextLine();
		char[] datas = data.toCharArray();
		for (int i = 0; i < data.length(); i++) {
			if (Character.isLowerCase(datas[i])) {
				datas[i] = Character.toUpperCase(datas[i]);
			} else if (Character.isUpperCase(datas[i])) {
				datas[i] = Character.toLowerCase(datas[i]);
			}
		}
		String changedData = String.valueOf(datas);
		System.out.println(changedData);
	}
}



Measured memory_bytes: 25964
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <cmath>

using namespace std;

int main() {
    int a, b, c;
    int counter;
    cin >> a >> b >> c;
    for(int i = a; i <= b; ++i) {
        if(c % i == 0) {
            ++counter;
        }
    }

    cout << counter << endl;

    return 0;
}


Measured memory_bytes: 3116
#include <iostream>
#include <cstdlib>
#include <time.h>
#include <algorithm>
#include <map>
#include <queue>
#include <stack>
#include <vector>
#include <array>
#include <string>
using namespace std;

typedef long long int ll;

int main(){
	cin.sync_with_stdio(false);
	cin.tie(0);
	ll t;
	cin >> t;
	vector<ll> a(t);
	for(auto &x : a)
		cin >> x;
	if(t&1){
		for(ll i=t-1; i>=0; i-=2)
			cout << a[i] << " ";
		for(ll i=1; i<t; i+=2)
			cout << a[i] << " ";
	}
	else{
		for(ll i=t-1; i>=0; i-=2)
			cout << a[i] << " ";
		for(ll i=0; i<t; i+=2)
			cout << a[i] << " ";
	}
	return 0;
}

Measured memory_bytes: 4792
#include <bits/stdc++.h>
using namespace std;
// #define int long long
typedef long long ll;
typedef pair<int,int> pii;
#define ITR(v,c) for(auto v=begin(c);v!=end(c);v++)
#define FOR(v,a,n) for(int v=a;v<(int)(n);v++)
#define FORE(x,arr) for(auto &x:arr)
#define REP(v,n) FOR(v,0,n)
#define RREP(v,n) for(int v=(int)(n);v>=0;v--)
#define ALL(c) begin(c),end(c)
const int DX[4]={0,1,0,-1}, DY[4]={-1,0,1,0};
const int INF = 1e9;
const ll INFLL = 1e18;
template<class T,class U>ostream&operator<<(ostream &os,const pair<T,U> &p){
    os<<"("<<p.first<<","<<p.second<<")";return os;}
template<class T>ostream&operator<<(ostream &os,const vector<T> &v){
    ITR(i,v)os<<*i<<(i==end(v)-1?"":"\n");return os;}
//------------------------------------------------------------------------------

signed main() {
    int N,M;
    cin>>N>>M;
    vector<int> A(N);
    REP(i,N) cin>>A[i];

    FOR(i,1,M+1) {
        REP(j,N-1) {
            if(A[j]%i>A[j+1]%i) swap(A[j],A[j+1]);
        }
    }
    cout<<A<<endl;
    return 0;
}

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

int main() {
	ll n;
	cin >> n;
	vector<ll> a(n);
	map<ll,ll> cnt;
	rep(i,n){
		cin >> a[i];
		a[i]--;
		cnt[a[i]]++;
	}
	ll tot = 0;
	for(auto p : cnt){
		tot += p.second*(p.second-1)/2;
	}
	rep(i,n){
        ll minus = cnt[a[i]] * (cnt[a[i]] - 1) / 2;
        ll plus = (cnt[a[i]]-1) * (cnt[a[i]]-2) / 2;
		ll ans = tot - minus + plus;
		cout << ans << endl;
	}
}

Measured memory_bytes: 12416
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<vector>
#include <algorithm>
#include<deque>
#include<queue>
#include<set>
#include <functional>
#include <cmath>


//マクロ
/*動かない・・・
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define REP(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _roverload3(_1,_2,_3,name,...) name
#define _rrep(i,n) repi(i,0,n)
#define rrepi(i,a,b) for(int i=int(a);i<int(b);++i)
#define RREP(...) _roverload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
//*/
#define REP(i,n) for(int i=0; i<(int)(n); ++i)
#define REPS(i,n) for(int i=1; i<=(int)(n); ++i)
#define RREP(i,n) for(int i=(int)(n)-1; i>=0; --i)
#define RREPS(i,n) for(int i=(int)(n); i>0; --i)
#define FOR(i,s,e) for(int i=(int)(s); i<(int)(e); ++i)
#define RFOR(i,s,e) for(int i=(int)(e)-1; i>=(int)(s); --i)
//*/
#define All(a) (a).begin(),(a).end()
#define dump(x)  cerr << #x << " = " << (x) << endl;

//定数
#define INF 1e9
#define MOD (int)(1e9+7)

typedef long long ll;
typedef unsigned long long ull;
/*
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
//*/
using namespace std;

//とりあえず書いておく変数
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

//今回の変数
ll a, b, k;

//使用する関数
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 (a > b) { a = b; return 1; }
	return 0;
}

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

	cin >> a >> b >> k;
	cout << max((ll)0, a - k) << " " << max((ll)0,b - max((ll)0, k - a)) << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

double area2(const double x[][2]){
        double y[3][2];
        for(int i = 0; i < 3; i++){
                for(int j = 0; j < 2; j++){
                        y[i][j] = x[i][j];
                }   
        }   
        for(int i = 0; i < 3; i++){
                y[i][0] -= y[2][0];
                y[i][1] -= y[2][1];
        }   
        double s = y[0][0]*y[1][1]-y[0][1]*y[1][0];
        if(s < 0){ 
                s = -s; 
        }   
        return s;
}
bool isIn(double x[][2]){
        double x1[][2] = {{x[0][0], x[0][1]}, {x[1][0], x[1][1]}, {x[3][0], x[3][1]}};
        double x2[][2] = {{x[0][0], x[0][1]}, {x[2][0], x[2][1]}, {x[3][0], x[3][1]}};
        double s = area2(x) - area2(x+1) - area2(x1) - area2(x2);
        return !s; 
}
int main(){
        double x[4][2];
        while(cin >> x[0][0]){
                cin >> x[0][1];
                for(int i = 1; i < 4; i++){
                        for(int j = 0; j < 2; j++){
                                cin >> x[i][j];
                        }   
                }   
                if(isIn(x)){
                        cout << "YES" << endl;
                }else{
                        cout << "NO" << endl;
                }   
        }   
}

Measured memory_bytes: 0
#pragma region
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <iomanip>
#include <cstdint>
#include <bitset>
#include <fstream>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()

#pragma region UnionFind
struct UnionFind
{
	vector<int> par;

	UnionFind(int n) : par(n, -1) {}
	void init(int n) { par.assign(n, -1); }

	int root(int x)
	{
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}

	bool issame(int x, int y)
	{
		return root(x) == root(y);
	}

	bool merge(int x, int y)
	{
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x)
	{
		return -par[root(x)];
	}
};
#pragma endregion
#pragma region GCD
int gcd(int a, int b)
{
	if (a%b == 0)return b;
	return gcd(b, a%b);
}
#pragma endregion
#pragma region chmin
template<class T> inline bool chmin(T& a, T b)
{
	if (a > b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma region chmax
template<class T> inline bool chmax(T& a, T b)
{
	if (a < b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma endregion


int main()
{
	int n; cin >> n;
	string s; cin >> s;
	vector<vector<int>> dp(n + 1, vector<int>(n + 1));
	rep(i, n)for (int j = i + 1; j < n; ++j)
	{
		if (s[i] == s[j])dp[i + 1][j + 1] = dp[i][j] + 1;
	}
	int res = 0;
	rep(i, n)for (int j = i + 1; j <= n; ++j)
	{
		chmax(res, min(j - i, dp[i][j]));
	}
	cout << res << endl;
}

Measured memory_bytes: 101176
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <algorithm>
#include <stdio.h>
#include <cstring>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <numeric>
#include <regex>
#include <locale>
#include <fstream>
#include <stdlib.h>
#include <cctype>

//#include <map>

using namespace std;

int main()
{
	int n;
	vector<int> vx, vy;

	cin >> n;
	cin.ignore();

	string temp;
	{
		getline(cin, temp);
		istringstream iss(temp);
		while (!iss.eof())
		{
			int t;
			iss >> t;
			vx.push_back(t);
			iss.ignore();
		}
	}
	{
		getline(cin, temp);
		istringstream iss(temp);
		while (!iss.eof())
		{
			int t;
			iss >> t;
			vy.push_back(t);
			iss.ignore();
		}
	}

	double D = 0.0;
	double d = 0;
	for (double p = 1.0; p <= 3.0; p += 1.0)
	{
		d = 0.0;
		for (int i = 0; i < n; i++)
		{
			double dd = abs(vx.at(i) - vy.at(i));
			double ddd = pow(dd, p);
			d += pow(abs(vx.at(i) - vy.at(i)) * 1.0, p);
		}
		D = pow(d, 1.0 / p);
		cout << fixed << setprecision(8) << D << endl;
	}

	d = 0.0;
	for (int i = 0; i < n; i++)
	{
		d = max(d, abs(vx.at(i) - vy.at(i)) * 1.0);
	}
	cout << fixed << setprecision(8) << d << endl;
	return 0;
}

Measured memory_bytes: 3444
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n:usize,
        k:usize,
        x:usize,
        y:usize
    }
    let mut ans = 0;
    for i in 1..n + 1 {
        if i <= k {
            ans += x;
        } else {
            ans += y;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <stdio.h>
#include <stdlib.h>

int main()
{
  int N;
  scanf("%d", &N);
  
  char *S = NULL;
  S = (char *)malloc(sizeof(char) * N);
  scanf("%s", S);

  int cnt, cnt_min=0;

  for(int i=1; i<N; i++){
    if(S[i]=='E'){
      cnt_min++;
    }
  }
  cnt=cnt_min;
    
  for(int i=1; i<N; i++){
    if(S[i-1]=='W') cnt++;
    if(S[i]=='E') cnt--;
    
    if(cnt_min>cnt){
      cnt_min = cnt;
    }
  }

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

  free(S);
  
  return 0;
}

Measured memory_bytes: 512
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <cassert>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define EACH(t,i,c) for(t::iterator i=(c).begin(); i!=(c).end(); ++i)
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int main(){
	vi w(10),k(10);
	REP(i,10){
		cin>>w[i];
	}
	REP(i,10){
		cin>>k[i];
	}

	sort(RALL(w));
	sort(RALL(k));

	int ww=0,kk=0;
	REP(i,3){
		ww+=w[i];
		kk+=k[i];
	}

	cout<<ww<<" "<<kk<<endl;
}

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

using namespace std;

typedef long long ll;

#define MOD 1000000007

int main() {
    
    int n,k;
    cin >> n >> k;
    vector<int> A(n);
    for(int i = 0; i < n; i++)
    {
        cin >> A[i];
    }
    
    if(k == 0)
    {
        cout << 1 << '\n';
        return 0;
    }
    
    vector<vector<ll>> dp(n+1,vector<ll>(k+1));
    vector<ll> lastPrefixSum(k+1);
    for(int i = 0; i <= n; i++)
    {
        dp[i][0] = 1;
    }
    
    lastPrefixSum[0] = dp[n][0];
    for(int i = 1; i <= k; i++)
    {
        lastPrefixSum[i] = lastPrefixSum[i-1]+dp[n][i];
    }
    
    for(int i = n-1; i >= 0; i--)
    {
        vector<ll> prefixSum(k+1);
        prefixSum[0] = dp[i][0];
        for(int j = 1; j <= k; j++)
        {
            ll sum = lastPrefixSum[j];
            if(j-A[i]-1 >= 0)
            {
                sum -= lastPrefixSum[j-A[i]-1];
            }
            
            dp[i][j] = (sum+MOD)%MOD;
            prefixSum[j] = prefixSum[j-1]+dp[i][j];
        }
        lastPrefixSum = prefixSum;
    }
    
    cout << dp[0][k] << '\n';
    
    return 0;
}

Measured memory_bytes: 81008
import sys
import bisect
import itertools
import collections
import fractions
import heapq
import math
from operator import mul
from functools import reduce
from functools import lru_cache


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    D, T, S = map(int, input().split())
    if T*S >= D:
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    solve()

Measured memory_bytes: 77340
/*X に最も近いもの、つまり X との差の絶対値が最小のものを求めてください。そのような整数が複数存在する場合は、そのうち最も小さいものを答えてください*/
#include<stdio.h>

// サイズn の配列v にx が含まれているかどうかを判定する関数
// x が含まれる場合には1, 含まれない場合には 0 を返す
int has_in_array(int x, int v[], int n)
{
	int count = 0, i;

	for (i = 0; i < n; i++) {
		if (v[i] != x) {
			count++;
		}
	}

	if (count == n) {
		return 1;
	} else {
		return 0;
	}
}


int main(void) {

	int x = 0;
	int N = 0;
	int v[100] = { 0 };
	int ans = 0;
	int i = 0;
	int sa = 0;

	/*xを入力*/
	scanf("%d", &x);
	/*個数を入力*/
	scanf("%d", &N);

	int j = 0;


	for (i = 0; i < N; i++) {
		// printf("[%d]\n", i);
		scanf("%d", &v[i]);
	}



	/*優先順位が高い順に
	  x = 10
	  10, 9, 11, 8, 12, 7, 13, 6, 14, 5を表示。
	  x = 50 を入力すると
	  50, 49, 51, 48, 52, 47, 53, 46, 52, 45 */

	int a = x - 1;
	int b = x + 1;

	// x が配列v に含まれているかチェック
	// 含まれてなければ、x 自身が正答。printf して終了

	if (has_in_array(x, v, N) == 1) {
		printf("%d", x);
		return 0;
	}


	/*整数列にxがあるとき*/

	while (a >= 0) {
		// a が配列v に含まれているかチェック
		// 含まれてなければ、a が正答。printf して終了

		if (has_in_array(a, v, N) == 1) {
			printf("%d", a);
			return 0;
		}

		a--;

		// b が配列v に含まれているかチェック
		// 含まれてなければ、a が正答。printf して終了

		if (has_in_array(b, v, N) == 1) {
			printf("%d", b);
			return 0;
		}

		b++;
	}

	return 0;
}



Measured memory_bytes: 1736
a, b, c, x = [int(input()) for _ in range(4)]
ans = 0
for i in range(a + 1):
    for j in range(b + 1):
        for k in range(c + 1):
            if 500 * i + 100 * j + 50 * k == x:
                ans += 1
print(ans)

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

using ll = long long;
using ld = long double;
using vi = vector<int>;
using vll = vector<ll>;
using P = pair<int, int>;

const int INF = 1e9;
const ll INFLL = 1e18;
const int MOD = 1e9 + 7;
const int NIL = -1;
const ld PI = acosl(-1);

#define rep(i,n) for(int i=0; i<(n); ++i)
#define all(n) n.begin(),n.end()

int main() {
	ios::sync_with_stdio(false); cin.tie(nullptr);
	//cout << fixed << setprecision(6);
	int n; cin >> n;
	n %= 1000;

	if(n == 0) {
		cout << 0 << endl;
		return 0;
	}
	cout << 1000 - n << endl;
	return 0;
}

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

using namespace std;

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int N;
  cin >> N;
  vector<int> v(N);
  long long res = 0;
  for(int i=0; i<N; ++i){
     cin >> v[i];;
     res += v[i];
  } 
  cout << res-N << "\n";
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

static const int MAX = 500;

static const int INFTY = (1<<21);

int main(){
  int n,i,j,e,sum;


  int M[MAX][MAX];
  int u,v;
  int minv;
  int d[MAX];
  int p[MAX];
  int vis[MAX];

  scanf("%d", &n);

  for ( i = 0; i< n; i++ ){
    for ( j = 0; j < n; j++ ){
      scanf("%d", &e);
      if((M[i][j] = (e==-1))==1){
          M[i][j]=INFTY;
    }
    else {
        M[i][j]=e;
        }
    }
  }
  for ( i = 0; i < n; i++ ) {
    d[i] = INFTY;
    p[i] = -1;
    vis[i] = 0;
  }

  d[0] = 0;

  while(1){
    minv = INFTY;
    u = -1;
    for ( i = 0; i < n; i++ ){

      if ( minv > d[i] && !vis[i] ){
	u = i;
	minv = d[i];
      
      }
    }
    if ( u == -1 ) break;
    vis[u] = 1;
    for ( v = 0; v < n; v++ ){

      if ( !vis[v] && M[u][v] != INFTY ){
	if ( d[v] > M[u][v] ){
	  d[v] =  M[u][v];

	  p[v] = u;
	}
      }
    }
  }

  sum = 0;



  for ( i = 0; i < n; i++ ){
    if ( p[i] != -1 ) sum += M[i][p[i]];
  }

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

  return 0;
}


Measured memory_bytes: 2056
#include <iostream>
#include <deque>
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
/* run this program using the console pauser or add your own getch, system("pause") or input loop */

int main()
{
	bool a=0;
	int num;
	cin >>num;
	while(num!=0)
	{
		if(num%10==7)
		{			
			a=1;
		}
					num/=10;
	
	}
	if(a==1)
		cout << "Yes" << endl;
	else
		cout << "No";
	return 0;
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std ;
 
int main() 
{
    long long int  d , n , m = 10000 ;
    cin >> d >> n ;
    if ( d == 0 )
    {
        if ( n < 100)
        cout << n << endl ;
        else cout << 101 << endl ;
    }
    else if ( d == 1 )
    {
        if ( n < 100 )
        {
        cout << (100 * n) << endl ;
        }
        else cout << (10100) ;
    }
    else if ( d == 2 )
    {
        if ( n < 100)
        {
        cout << 100*100*n << endl ;
        }
        else
        {
            cout << (1010000)<<endl ;
        }
    }
     return 0 ;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ld long double
using namespace std;
const int mod=1e9+7,N=100007;
int n;
int grid[N][3];
int ans[N][3];
int main()
{
    cin>>n;
    for(int i=0; i<n; ++i)
        for(int j=0; j<3; ++j)
            cin>>grid[i][j];
    ans[0][0]=grid[0][0];
    ans[0][1]=grid[0][1];
    ans[0][2]=grid[0][2];
    for(int i=1; i<n; ++i)
        for(int j=0; j<3; ++j)
        {
            int x=0;
            for(int k=0; k<3; ++k)
            {
                if(j==k)
                    continue;
                x=max(x,ans[i-1][k]);
            }
            ans[i][j]+=(x+grid[i][j]);
        }
    cout<<max(ans[n-1][0],max(ans[n-1][1],ans[n-1][2]));


    return 0;
}


Measured memory_bytes: 2560
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <numeric>
#include <queue>
#include <map> 
#include <set>
#include <string>
#include <functional>
#include <list>
#include <random>
#include <time.h>
#include <iomanip>
#include <assert.h>
#include <numeric>
#define int long long
#define double long double
#define mod 1000000007
#define MAXN (int)1e+5 * 2+1
#define LL_MAX 9223372036854775807	//ない環境用
#define LL_HALFMAX 9223372036854775807 / 2	//ない環境用

using namespace std;
using namespace std;

std::mt19937 mt((int)time(0));

int dx[4] = { 0, 1, 0, -1 }; // x軸方向への変位
int dy[4] = { 1, 0, -1, 0 }; // y軸方向への変位

bool flag[1919];

signed main() {
	int N1, N2, N3, N4;
	cin >> N1 >> N2 >> N3 >> N4;
	flag[N1] = flag[N2] = flag[N3] = flag[N4] = true;
	if (flag[1] && flag[7] && flag[9] && flag[4]) cout << "YES\n";
	else cout << "NO\n";

	return 0;
}

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

int main() {
	int n, tmp;
	cin >> n;
	
	long long ans = 0;
	vector<int> v(n);
	for (auto &x : v) cin >> x;
	
	for (int i = 0; i < n; ++i) {
		for (int j = i+1; j < n; ++j) {
			for (int k = j+1; k < n; ++k) {
				ans += (v[i] + v[j] + v[k] - 2 * max({v[i], v[j], v[k]}) > 0);
			}
		}
	}
	
	cout << ans << "\n";
	
	/*
	vector<long long> v(1005, 0);
	for (int i = 0; i < n; ++i) {
		cin >> tmp;
		++v[tmp];
	}
	
	long long ans = 0;
	for (long long i = 1; i <= 1000; ++i) {
		ans += v[i] * (v[i] - 1) * (v[i] - 2) / 6;
		for (long long j = i+1; j <= 1000; ++j) {
			if (i + i > j) ans += v[i] * (v[i] - 1) * v[j] / 2;
			ans += v[i] * v[j] * (v[j] - 1) / 2;
			for (long long k = j+1; k < j+i and k <= 1000; ++k) {
				ans += v[i] * v[j] * v[k];
			}
		}
	}
	
	cout << ans << "\n";
	*/
	
	return 0;
}

Measured memory_bytes: 256
a,b,k = map(int,input().split())
ans = []
flag = 0
for i in range(k):
    temp_a = i+a
    temp_b = b-i
    ans.append(temp_a)
    ans.append(temp_b)
    if(temp_a >= b or temp_b <= a):
        break

ans = list(set(ans))
ans.sort()
for a in ans:
    print(a)


Measured memory_bytes: 3060
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define INF 1000000000000000000

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

    string s;
    cin >> s;
    char prev = '?';
    if (s.size() == 2) {
        if (s[0] == s[1]) {
            cout << 1 << " " << 2 << endl;
        } else {
            cout << -1 << " " << -1 << endl;
        }
        return 0;
    }
    rep(i, s.size()) {
        if (prev == s[i]) {
            if (i == 1) {
                cout << 1 << " " << 3 << endl;
            } else if (i == s.size() - 1) {
                cout << s.size() - 2 << " " << s.size() << endl;
            } else {
                cout << i - 1 << " " << i + 1 << endl;
            }
            return 0;
        }
        prev = s[i];
    }

    for (int i = 2; i < s.size(); i++) {
        if (s[i] == s[i - 2]) {
            cout << i - 1 << " " << i + 1 << endl;
            return 0;
        }
    }

    cout << -1 << " " << -1 << endl;
    return 0;
}

Measured memory_bytes: 3736
#include <stdio.h>

int main(){
  int a[5];
  for(int i = 0; i<5;i++){
  scanf("%d", &a[i]);
}
  for(int i = 0;i < 5; i++){
    if(a[i]==0){
    printf("%d", ++i);
    return 0;
  }
  }
  return 0;
  }


Measured memory_bytes: 1708
n=int(input())
if n==1:print('0'); exit()
h=list(map(int,input().split()))
ans=0
step=0
for i in range(n):
    cnt=0
    for j in range(n):
        if h[step]<h[step+1]: step+=1; break
        cnt+=1; step+=1
        if step+1==n: break
    ans=max(ans,cnt)
    if step+1==n: break
print(ans)

Measured memory_bytes: 14252
#include <iostream>
#include <iterator>
#include <string>
#include <algorithm>
#include <locale>

using namespace std;

int main()
{
  string line;
  getline(cin, line);
  for (char c : line) {
    if (islower(c)) cout << toupper(c, locale());
    else if (isupper(c)) cout << tolower(c, locale());
    else cout << c;
  }
cout << endl;
}


Measured memory_bytes: 3204
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int arr[3];
  cin>>arr[0]>>arr[1]>>arr[2];
  sort(arr,arr+3);
    if(arr[0]==5 && arr[1]==5 && arr[2]==7)
    {
      cout<<"YES"<<endl;
    }
  else
  {
    cout<<"NO"<<endl;
  }
  return 0;
}

Measured memory_bytes: 3644
// Created by ...Lusifer
#include<bits/stdc++.h>
using namespace std;
 
#define pb 		push_back
#define mp 		make_pair
#define prior   priority_queue
#define MOD 	1000000007
#define INF64 	(long long)1e18
#define INF 	(int)1e9
#define PI 		3.1415926535897932384626433832795 
#define ll      long long
#define ld		long double
#define ret     return
#define NUM 	1000001
const int SIZE = 2e5+4;
void fastio(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
}

void solveTest(){
	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());
	int ans = INT_MAX;
	for(int i=0;i<=n-k;i++){
		int diff = abs(h[i]-h[i+k-1]);
		//cout<<diff<<endl;
		ans = min(diff,ans);
	}
	cout<<ans<<endl;

	
	return ;
}
 
int main(){
	fastio();

	int t=1;
	//cin>>t;
	while(t--){
		solveTest();
 
	}
	return 0;
}

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

int main() {
  int N; cin >> N;
  vector<long long> A(N);
  for (int i = 0; i < N; i++) cin >> A.at(i);
  vector<long long> S(N+1);
  map<long long, long long> M;
  for (int i = 0; i < N; i++) S.at(i+1) = S.at(i) + A.at(i);
  for (long long v : S) {
    if (M.count(v)) M[v]++;
    else M[v] = 1;
  }
  long long ans = 0;
  for (auto p : M) ans += p.second * (p.second - 1) / 2;
  cout << ans << endl;
}

Measured memory_bytes: 15872
x=input()

ans1,ans2=0,0

for n,i in enumerate(x):
    if n%2==0: gg='0'
    else: gg='1'
    if i!=gg: ans1+=1

for n,i in enumerate(x):
    if n%2==1: gg='0'
    else: gg='1'
    if i!=gg: ans2+=1

print(min(ans1,ans2))

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define ll long long
#define be(v) v.begin(), v.end()

int main() {
	int n; cin >> n;
	int v[n]{};
  	rep(i,n) cin >> v[i];
	int ma = 0; int count = 0;
	rep(i,n) {
		if(v[i]>=ma) count ++;
		ma = max(ma,v[i]);
	}
	cout << count << endl;
}

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

int main() {
  int n;
  cin>>n;
  map<string,int> cnt;
  rep(i,n){
    string s;
    cin>>s;
    cnt[s]++;
  } 
  int max_cnt=0;
  for(auto x:cnt){
    max_cnt=max(max_cnt,x.second);
  }
  for(auto x:cnt){
    if(max_cnt==x.second){
      cout<<x.first<<endl;
    }
  }
}

Measured memory_bytes: 26368
n = int(input())
d_list = [int(i) for i in input().split()]

count = 0
ans = 0

for i in d_list:
    count += 1
    sum_temp = 0
    for m in range(count, n):
        sum_temp += i*d_list[m]
    ans += sum_temp

print(ans)


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

int main() {
  int n; cin >>n;
  vector<int> x(n);
  vector<int> y(n);
  for (int i=0; i<n; i++){
    cin >>x.at(i); y.at(i)=x.at(i);
  }
  sort(y.begin(), y.end());
  int medianl = y.at(n/2), medians = y.at(n/2-1);
  
  for (int i=0; i<n; i++){
    if (x.at(i) <= medians) cout <<medianl;
    else cout <<medians;
    cout <<endl;
  }
  
  /*
  for (int i=0; i<n; i++){
    if (i<n/2) cout <<x.at(n/2);
    else cout <<x.at(n/2-1);
    cout <<endl;
  }
  */
  //cout <<ans;
  //cout <<endl;
}


Measured memory_bytes: 3712
#! /usr/bin/env python3
# -*- coding: utf-8 -*-
import math

N = int(input())
ls = []
for _ in range(5):
    ls.append(int(input()))

if N <= min(ls):
    print(5)
else:
    mint = min(ls)
    ans = 4 + math.ceil(N/mint) 
    print(ans)

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

using namespace std;

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

	vector < int >k(M);
	vector < vector < int >>s(M);
	for (int i = 0; i < M; i++) {
		cin >> k[i];
		s[i] = vector < int >(k[i]);
		for (int j = 0; j < k[i]; j++) {
			cin >> s[i][j];
			s[i][j]--;
		}
	}

	vector < int >p(M);
	for (int i = 0; i < M; i++) {
		cin >> p[i];
	}

	int ans = 0;
	for (int bits = 0; bits < (1 << N); bits++) {
		bool isOk = true;
		for (int i = 0; i < M; i++) {
			int onCount = 0;
			for (int j = 0; j < k[i]; j++) {
				bool isOn = (bits >> s[i][j]) & 1;
				if (isOn) {
					onCount++;
				}
			}
			if (onCount % 2 != p[i]) {
				isOk = false;
			}
		}
		if (isOk) {
			ans++;
		}
	}

	cout << ans << endl;

	return 0;
}


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

using namespace std;

#define all(v)				((v).begin()), ((v).end())
#define allr(v)				((v).rbegin()), ((v).rend())
#define sz(v)				((int)((v).size()))
#define ll long long
#define pb					push_back
#define fIO ios_base::sync_with_stdio(0);cin.tie(0);

const ll oo = 1e8;
const double pi = 3.1415926535897;


const double EPS = (1e-7);
int dcmp(double x, double y) {	return fabs(x-y) <= EPS ? 0 : x < y ? -1 : 1;	}


typedef vector<int>                vi;
typedef vector<pair<int,int>>      vii;
typedef vector<ll>                 vll;
typedef vector<double>             vd;
typedef vector< vi >               vvi;
typedef vector< vd >               vvd;
typedef vector<string>             vs;
typedef pair<int, int>             pii;

/**
    * PLEASEEE READDD PROBLEEEM CARFULLY ****
    * Always check for OVERFLOW ll vs int
    * Always check for array bounds
    * Check for function return
    * READ OUTPUT SECTION AGAIN!!!
**/

struct edge{
    int from, to, w;

    edge(){}
    edge(int x, int y, int we): from(x), to(y), w(we){}

    bool operator < (const edge &rhs) const{
        return w > rhs.w;
    }

};

int main(){
    fIO
//    freopen("", "r", stdin);
//    freopen("", "w", stdout);

    string s, t;
    cin >> s >> t;

    int n = s.length(), m = t.length();
    int ans = n;

    for(int i = 0; i + m - 1 < n; i++) {
        int cnt = 0;
        for(int j = 0; j < m; j++) {
            cnt += (s[i + j] != t[j]);
        }
        //cout << i << " " << cnt << "\n";
        ans = min(ans, cnt);
    }

    cout << ans;
}








Measured memory_bytes: 3592
#include <iostream>
#include <algorithm>
#include <vector>
#include <iterator>
#include <numeric>

using namespace std;

int main(){
    int n, k;
    vector<int> a, num;
    cin >> n >> k;
    a.resize(n);
    copy_n(istream_iterator<int>(cin), n, a.begin());
    sort(a.begin(), a.end());

    vector<int>::iterator i = a.begin(), num_i;

    num.resize(n);
    num_i = num.begin();
    fill(num.begin(), num.end(), 0);
    while(i < a.end()){
        vector<int>::iterator j = find_if(i, a.end(), [i](int a){ return a != *i; });
        *num_i = distance(i, j);
        num_i++;
        i = j;
    }
    sort(num.begin(), num.end());
    find_if(num.begin(), num.end(), [](int a){ return a != 0; });
    i = num.begin();
    vector<int>::iterator j = find_if(num.begin(), num.end(), [](int a){ return a != 0; });
    while(j < num.end()){
        *i = *j;
        j++;
        i++;
    }
    
    num.resize(distance(num.begin(), i));
    
    cout  << (num.size() < k ? 0 : accumulate(num.begin(), num.begin() + (num.size() - k), 0)) << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N;
    cin >> N;
    vector<int> vec(N);
    for(int i=0; i<N; i++){
        cin >> vec.at(i);
    }

    int count =0;
    for(int i=0; i<N-2; i++){
        if (vec.at(i+2) > vec.at(i+1) && vec.at(i+1) > vec.at(i)) count++;
        else if(vec.at(i) > vec.at(i+1) && vec.at(i+1) > vec.at(i+2)) count++;
    }

    cout << count << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1001001001
#define LINF 1001001001001001001
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define bit(n) (1LL<<(n))
using namespace std;

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

int main() {

    int N, Z, W;
    cin >> N >> Z >> W;
    vector<int> a(N);
    rep(i,N) cin >> a[i];

    if (N == 1) cout << abs(a[N - 1] - W) << endl;
    else cout << max(abs(a[N - 1] - W), abs(a[N - 2] - a[N - 1])) << endl;
    
    return 0;
}

Measured memory_bytes: 256