akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll= long long;
using vi= vector<int>;
using vvi= vector<vi>;
using vd= vector<double>;
using vvd= vector<vd>;
using vc= vector<char>;
using vb= vector<bool>;
using vl= vector<ll>;
#define rep(i,x,n) for(int i=x; i<n; i++)
#define all(x) x.begin(), x.end()

int main(void){
  int a,b,c;
  cin >> a >> b >> c;
  cout << c << " " << a << " " << b;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define per(i, a, b) for (int i = b - 1; i >= a; i--)
#define int long long
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int dxx[8] = {1, 1, 1, 0, 0, -1, -1, -1}, dyy[8] = {-1, 0, 1, -1, 1, -1, 0, 1};

const int mod = 1e9 + 7;
int modpow (int n, int m) {
    int ans = 1;
    while (n > 0) {
        if (n & 1) ans = ans * m % mod;
        m = m * m % mod;
        n >>= 1;
    }
    return ans;
}

signed main() {
    int n, m;
    cin >> m >> n;
    cout << modpow (n, m) << "\n";
}


Measured memory_bytes: 3088
import sys
import random
input = sys.stdin.readline

################################################################################

def dist(x, y):
    d = 0
    for i in range(len(x)):
        d += (x[i]-y[i])**2

    return d

def check(x, y):
    d = dist(x, y)
    rt = int(d**0.5+1e-6)
    return rt*rt == d


n, d = map(int, input().split())
pts = [list(map(int, input().split())) for _ in range(n)]

res = 0
for i in range(n):
    for j in range(i+1, n):
        res += check(pts[i], pts[j])

print(res)

Measured memory_bytes: 4208
#include<bits/stdc++.h>
#define rep(i,N) for(ll i=0; i<N; i++)
using namespace std;
using ll = long long;
const ll MOD = 1000000007;

int main(){
    string S; cin >> S;
    if(S[0] == 'S') cout << "Cloudy";
    else if(S[0] == 'C') cout << "Rainy";
    else cout << "Sunny";
}


Measured memory_bytes: 256
import sys

read = sys.stdin.buffer.read
input = sys.stdin.buffer.readline
inputs = sys.stdin.buffer.readlines


#mod=10**9+7
# rstrip().decode('utf-8')
# map(int,input().split())
#import numpy as np

from collections import deque

def main():
	h,w=map(int,input().split())
	s=[list("#"+input().rstrip().decode('utf-8')+"#") for _ in [0]*h]
	s=[list("#"*(w+2))]+s+[list("#"*(w+2))]
	
	ans=0
	
	for i in range(1,h+1):
		for j in range(1,w+1):
			cnt = ccnt=0
			
			if s[i][j]==".":
				sumi=set()
				Q=deque()
				Q.append((i, j, cnt))
				while Q:
					x,y,cnt=Q.popleft()
					ccnt=max(cnt,ccnt)
					if (x,y) not in sumi:
						sumi.add((x, y))
						if s[x-1][y]==".":
							if (x-1,y) not in sumi:
								Q.append((x-1,y,cnt+1))
						if s[x+1][y]==".":
							if (x+1,y) not in sumi:
								Q.append((x+1,y,cnt+1))
						if s[x][y-1]==".":
							if (x,y-1) not in sumi:
								Q.append((x,y-1,cnt+1))
						if s[x][y+1]==".":
							if (x,y+1) not in sumi:
								Q.append((x,y+1,cnt+1))
							
			ans=max(ans,ccnt)
	
	print(ans)
	
	

if __name__ == "__main__":
	main()


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

int main()
{
    string s;
    int year, month, day;
    bool flg = false;
    cin >> s;
    year = stoi(s.substr(0, 4));
    month = stoi(s.substr(5, 2));
    day = stoi(s.substr(8, 2));
    if (year <= 2019)
    {
        if (month <= 4)
        {
            if (day <= 30)
            {
                cout << "Heisei" << endl;
                flg = true;
            }
        }
    }

    if (!flg)
    {
        cout << "TBD" << endl;
    }
    return 0;
}

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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define ALL(v) (v).begin(), (v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x, n) bitset<n>(x)
#define PI 3.14159265358979323846

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

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

int n, k;
int ls[] = {10, 7, 4, 1, 9, 6, 3, 0, 8, 5, 2};
int cnt[11];
int sum;

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

	cin >> n >> k;
    REP(i, 11) {
		REP(j, 5) {
            if ((ls[i] + 9 * j) % 11 == k) cnt[i]++;
		}
		sum += cnt[i];
	}
	int ans = 0;
	ans += sum * (n / 11);
	ans -= cnt[0] + cnt[1];
	REP(i, n % 11) ans += cnt[i];
	cout << ans << endl;

    return 0;
}




Measured memory_bytes: 892
import collections
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

n = int(input())
c = collections.Counter(prime_factorize(n))
ans=0
for i in c:
    tmp=1
    while 1:
        c[i]-=tmp
        if c[i]>=0:
            ans+=1
        else:
            break
        if c[i]==0:
            break
        tmp+=1
print(ans)

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef complex<double> P;
typedef pair<int,int> pii;
#define REP(i,n) for(ll i=0;i<n;++i)
#define REPR(i,n) for(ll i=1;i<n;++i)
#define FOR(i,a,b) for(ll i=a;i<b;++i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define MOD (ll)(1e9+7)
#define ADD(a,b) a=((a)+(b))%MOD
#define FIX(a) ((a)%MOD+MOD)%MOD

int main(){
  int w,n;
  cin>>w>>n;
  vi a(w);
  REP(i,w)a[i]=i+1;
  REP(i,n){
    int x,y;
    scanf("%d,%d",&x,&y);
    --x;--y;
    swap(a[x],a[y]);
  }
  REP(i,w)cout<<a[i]<<endl;
  return 0;
}

Measured memory_bytes: 1240
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for i2 in range(j)] for i3 in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from collections import Counter # a = Counter(A).most_common()
#from itertools import accumulate #list(accumulate(A))

N, M, Q = mi()
abcd = li2(Q)

'''
a = '0' * N
m = str(M-1)
l = [a]

while True:
    i = N-1
    while i >= 0 and a[i] == m:
        i -= 1
    if i == -1:
        break
    a = list(a)
    num = str(int(a[i]) + 1)
    a[i] = num
    if i != N-1:
        for j in range(i+1, N):
            a[j] = num
    tmp = ''.join(a)
    l.append(tmp)
'''

def dfs(num, length):
    if length == N:
        l.append(num)
        return
    last = int(num[-1])
    for i in range(last, M):
        dfs(num + str(i), length+1)

#l = []
#dfs('0', 1)

from collections import deque
keta_list = [str(i) for i in range(M)]
l = deque([str(i) for i in range(M)])

while len(l[0]) <= N:
    num = l.popleft()
    last = int(num[-1])
    for tail in keta_list[last:]:
        l.append(num + tail)

ans = 0
for num in l:
    cnt = 0
    num = list(map(int, list(num)))
    for i in range(Q):
        if num[abcd[i][1]-1] - num[abcd[i][0]-1] == abcd[i][2]:
            cnt += abcd[i][3]
    ans = max(ans, cnt)

print(ans)

Measured memory_bytes: 100776
n,m=map(int,input().split())
count=0
s=[]
for i in range(m):
    a,b=map(int,input().split())
    if n>a:
        count+=1
        s.append(n-a)
if count<m-1:
    z=max(s)
    s.remove(z)
    print(sum(s))
else:
    print("0")
        


Measured memory_bytes: 5608
/*
AizuOnline A0076
Treasure Hunt II
*/
#include <stdio.h>
#include <math.h>
#include <float.h>

main()
{
  int i,n;
  double angle,shahen,x,y;

  while(EOF != scanf("%d",&n) && n>0)
    {
      angle = 0.0;
      for(i=1;i<n;i++)
          angle += atan(sqrt(1/(double)i));
      shahen = sqrt(1+(double)n-1);

      x = shahen*cos(angle);
      y = shahen*sin(angle);

      printf("%.2f\n",x);
      printf("%.2f\n",y);
    }
return(0);
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
//#define int long long

using namespace std;

const int N = 1e6 + 9;
vector <int> prime;
bool used[N];


void calc() {
    for (int i = 4; i < N; i += 2) used[i] = 1;
    for (int i = 3; i * i < N; i += 2) {
        if (used[i]) continue;
        for (int j = i * i; j < N; j += i) used[j] = 1;
    }
    prime.push_back(2);
    for (int i = 3; i < N; i += 2) {
        if (!used[i]) prime.push_back(i);
    }
}

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    int data[n];
    for (int i = 0; i < n; ++i) cin >> data[i];
    calc();
    vector <int> cnt(N, 0);
    int fl = 1;
    for (int i = 0; i < n; ++i) {
        int tmp = data[i];
        for (auto a : prime) {
            if (a * a > tmp) break;
            if (tmp % a == 0) {
                ++cnt[a];
                while (tmp % a == 0) tmp /= a;
            }
        }
        if (tmp > 1) ++cnt[tmp];
    }
    for (int i = 0; i < N; ++i) {
        if (cnt[i] > 1) fl = 0;
    }
    if (fl) {
        cout << "pairwise coprime";
        return 0;
    }
    int b = data[0];
    for (int i = 1; i < n; ++i) b = __gcd(b, data[i]);
    if (b == 1) {
        cout << "setwise coprime";
        return 0;
    }
    cout << "not coprime";
    return 0;
}


Measured memory_bytes: 12580
#include <numeric>
#include <bits/stdc++.h>
#include <utility>
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <math.h>
#include <string>
#define ll long long
#define ull unsigned long long
#define make(type,x) type x; cin>>x
#define make2(type,x,y) type x,y; cin>>x>>y
#define fr(x,y) for(long long x=0;x<y;x++)
#define makevec(x,y,n) vector <x> y(n); for(ll i=0;i<n;i++) cin>>y[i]
#define M (ll)1000000007
#define MM (ll) 1e8
#define INF (ll) 1e18

# define IOS ios_base::sync_with_stdio(false); cin.tie(NULL)

using namespace std;

template <typename T>
T modpow(T base, T exp, T modulus) {
  base %= modulus;
  T result = 1;
  while (exp > 0) {
    if (exp & 1) result = (result * base) % modulus;
    base = (base * base) % modulus;
    exp >>= 1;
  }
  return result;
}
bool sortbysec(const pair <ll,ll> &a,const pair <ll,ll> &b){
    return a.second<b.second;
}

struct cmp {
	bool operator() (const pair<int, int> &a, const pair<int, int> &b) const {
		int lena = a.second - a.first + 1;
		int lenb = b.second - b.first + 1;
		if (lena == lenb) return a.first < b.first;
		return lena > lenb;
	}
};


struct c_h {
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        x ^= FIXED_RANDOM;
        return x ^ (x >> 16);
    }
};

ll calcpow(ll x, ll y)
{
    ll temp;
    if(y == 0)
        return 1;
    temp = calcpow(x, y / 2);
    if (y % 2 == 0)
        return temp * temp;
    else
    {
        if(y > 0)
            return x * temp * temp;
        else
            return (temp * temp) / x;
    }
}
ll gcd(ll a, ll b){
    if(b==0) return a;
    return gcd(b,a%b);

}
ll egcd(ll a, ll b, ll &x,ll &y){
    if(b==0){
        x=1;
        y=0;
        return a;
    }
    ll x1;
    ll y1;
    ll g=egcd(b,a%b,x1,y1);
    x=y1;
    y=x1-y1*(a/b);
    return g;
}


bool isprime(ll a){
bool flag=1;
for(ll i=2;i*i<=a;i++){
    if(a%i==0) {flag=0; break;}
}
return flag;
}
ll dx[2]={1,0};
ll dy[2]={0,1};

int main(){
    IOS;
    make(string,s);
    ll n=s.length();
    vector <ll> left(n+1);
    vector <ll> right(n+1);
    ll c=0;
    for(ll i=0;i<n;i++){
        if(s[i]=='<') c++;
        else c=0;
        left[i+1]=c;
    }
    c=0;
    for(ll i=n-1;i>=0;i--){
        if(s[i]=='>') c++;
        else c=0;
        right[i]=c;
    }
    ll ans=0;
    fr(i,n+1) ans+=max(left[i],right[i]);
    cout<<ans<<endl;


    return 0;
}


Measured memory_bytes: 11652
import sys
readline = sys.stdin.readline
H, W, K = map(int, readline().split())
Cake = [[1 if s == '#' else 0 for s in readline().strip()] for _ in range(H)]
Cd = [sum(c) for c in Cake]

Ans = [[None]*W for _ in range(H)]

cnt = 0
for h in range(H):
    if not Cd[h]:
        continue
    else:
        pc = cnt
        for w in range(W):
            if Cake[h][w]:
                cnt += 1
            Ans[h][w] = max(pc+1, cnt)

kf = False

for h in range(H):
    if Cd[h]:
        kf = True
    else:
        if not kf:
            continue
        Ans[h] = Ans[h-1][:]

kf = False
for h in range(H-1, -1, -1):
    if Cd[h]:
        kf = True
    else:
        if not kf:
            continue
        Ans[h] = Ans[h+1][:]
for a in Ans:
    print(*a)

Measured memory_bytes: 50396
#include <iostream>

int bubbleSort(int* a, int n) {
    int swap_count{};
    bool flag{true};
    while(flag) {
        flag = false;
        for(auto i=n-1; i>0; i--) {
            if(a[i]<a[i-1]) {
                std::swap(a[i],a[i-1]);
                swap_count++;
                flag = true;
            }
        }
    }
    return swap_count;
}

int main() {
    int n{}; std::cin >> n;
    int a[n]{}; for(auto i=0; i<n; i++) std::cin >> a[i];
    int swap_count = bubbleSort(a, n);
    for(auto i=0; i<n; i++) std::cout << a[i] << ((i<n-1) ? " " : "");
    std::cout << std::endl << swap_count << std::endl;
}



Measured memory_bytes: 3124
def minas2zero(n):
    if(n<=0):return 0
    return n
a, b, k = map(int, input().split())
a1, a2 = 0, 0
if(k >= a):
    a1 = 0
    a2 = minas2zero(b - (k-a))
else:
    a1 = a-k
    a2 = b

print(a1, a2)


Measured memory_bytes: 38256
// 22
/****************************************************
https://searleser97.gitlab.io/algorithms/template.cpp
****************************************************/

#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define fors(_, x, n, s) for (int _ = x; _ < n; _ += s)
#define forn(_, x, n) fors(_, x, n, 1)
#define rep(_, n) forn(_, 0, n)
#define forrs(_, x, n, s) for (int _ = x; _ > n; _ -= s)
#define forrn(_, x, n) forrs(_, x, n, 1)
#define rrep(_, n) forrn(_, n - 1, -1)
#define fi first
#define se second
#define pb push_back
#define pairii pair<int, int>
#define all(x) x.begin(), x.end()
#define cerr(s) cerr << "\033[48;5;196m\033[38;5;15m" << s << "\033[0m"
// typedef __int128_t lli;
typedef long long int li;
typedef long double ld;
// 12
void _main(int tc) {
  int n, k;
  cin >> n >> k;
  assert(n >= 2);
  vector<li> h(n);
  rep(i, n) cin >> h[i];
  vector<li> mem(n, -1);
  mem[n - 1] = 0;
  mem[n - 2] = abs(h[n - 2] - h[n - 1]);
  rrep(i, n - 2) {
    mem[i] = (1 << 30);
    forn(j, i + 1, (i + 1) + min(k, n - 1 - i)) {
      mem[i] = min(mem[i], abs(h[i] - h[j]) + mem[j]);
    }
  }
  cout << mem[0] << endl;
}

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  _main(0);
  return 0;
  int tc;
  cin >> tc;
  rep(i, tc) _main(i + 1);
}

Measured memory_bytes: 1920
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <numeric>
#include <cmath>
#include <cassert>

using namespace std;

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

#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main()
{
	int r,g;
	cin>>r>>g;
	cout<<2*g-r<<endl;
	return 0;
}

Measured memory_bytes: 256
s=input()
n=len(s)
if s[0]!='A' or 'C' not in s[2:n-1] or s.count('C')!=1:
  print('WA')
else:
  s=s.replace('A','')
  s=s.replace('C','')
  if s.islower()==1:
    print('AC')
  else:
    print('WA')

Measured memory_bytes: 3060
ans = []

loop{
	m = gets.to_i
	if m==0
		break
	end
	money = 1000 - m
	num = 0
	list = [500,100,50,10,5,1]
	list.each do |coin|
		num += money/coin
		money %= coin
	end

	ans << num
}

ans.each do |a|
	puts a
end

Measured memory_bytes: 8484
def countingSort(A,k):
    C = {}
    for ai in A:
        C[ai] = C.get(ai,0) + 1
    for i in range(1,k+1):
        C[i] = C.get(i,0) + C.get(i-1,0)
    B = A[:]
    for ai in A:
        B[C[ai]-1] = ai
        C[ai] -= 1
    return B

if __name__=='__main__':
    n=int(input())
    print(*countingSort(list(map(int,input().split())),10000))

Measured memory_bytes: 226488
n = "1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51".split(',')
k = int(input())
print(n[k-1])

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(int i = 0; i < (int)n; i++)
vector<ll > d;
ll euclidean_gcd(ll a, ll b){
  if(a < b) return euclidean_gcd(b, a);
  ll r;
  while((r = a%b)){
    a = b;
    b = r;
  }
  return b;
}
bool is_prime(ll n){
  switch(n){
    case 0: return true;
    case 1: return false;
    case 2: return true;
    case 3: return true;
  }
  
  if(n%2 == 0) return false;
  if(n%3 == 0) return false;
  if(n%6 != 1&&n%6 != 5) return false;
  
  for(ll i = 5; i*i <= n;i += 6){
    if(n%i == 0) return false;
    if(n%(i + 2) == 0) return false;
  }
  return true;
}
bool isnotind(ll n){
  ll size = d.size();
  for(ll i = 0;i < size; i++){
    if(n%d[i] == 0){
      return false;
    }
  }
  return true;
}
int main()
{
  ll a,b;
  cin >> a >> b;
  ll g;
  g = euclidean_gcd(a, b);
  // cout << g<< endl;
  ll num = 1;
  // for(ll i = 1; i <= g; i++){
  //   if(g%i == 0 ){
  //     if(isnotind(i)){
  //       if(is_prime(i)){
  //         // cout << i << endl;
  //         num ++;
  //         g/= i;
  //         d.push_back(i);
  //       }
  //     }
  //   }
  // }
  for (int i = 2;i <= sqrt(g); i++){
    // cout << "g = "<< g << " i = "<< i << endl;
    if(g % i == 0){
      // cout << "gi == 0" << endl;
      // cout << "g = "<< g << " i = "<< i << endl;
      num++;

      while(g%i == 0){
        g/= i;
      }
      // cout << "g = "<< g << " i = "<< i << endl;
    }
  }
  if(g > 1) num ++;
  cout << num << endl;
}



Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:https://arc060.contest.atcoder.jp/tasks/arc060_c>
 問題文============================================================
 N 軒のホテルが一直線上に並んでいます。i (1≤i≤N) 番目のホテルは、座標 xi に位置しています。
 
 旅行者である高橋君には、次の 2 つの信念があります。
 
 高橋君の 1 日の移動距離は L を超えない。
 高橋君は野宿をしない。すなわち、1 日の終わりには必ずいずれかのホテルにいなければならない。
 
 Q 個のクエリが与えられます。j (1≤j≤Q) 番目のクエリとして、異なる 2 つの整数 aj, bj が与えられます。
 各クエリについて、前述の信念をともに守った上で、
 高橋君が aj 番目のホテルから bj 番目のホテルに移動するために必要な最小日数を求めてください。
 なお、高橋君が aj 番目のホテルから bj 番目のホテルに移動できることは保証されます。
 =================================================================
 解説=============================================================
 ================================================================
 */

ll check(ll i,ll d,vector<vector<ll>>& next){
    if(d == 0) return i;
    ll k = 0;
    while(d >= (1<<k)) k++;
    return check(next[k-1][i],d - (1<<(k-1)),next);
}
void solve(){
    ll N; cin >> N;
    vector<ll> x(N); for(auto& in:x) cin >> in;
    ll L; cin >> L;
    ll Q; cin >> Q;
    vector<ll> a(Q),b(Q);
    for(int i = 0; i < Q;i++){
        cin >> a[i] >> b[i];
        a[i]--; b[i]--;
        if(a[i] > b[i]) swap(a[i],b[i]);
    }
    
    ll LOG_N = 0;
    while(N >= (1<<LOG_N)) LOG_N++;
    vector<vector<ll>> next(LOG_N+1,vector<ll>(N));
    for(int i = 0; i < N;i++){
        next[0][i] = upper_bound(x.begin(), x.end(), x[i]+L) - x.begin() - 1;
    }
    for(int k = 0; k < LOG_N; k++){
        for(int i = 0; i < N;i++){
            next[k+1][i] = next[k][next[k][i]];
        }
    }
    for(int i = 0; i < Q;i++){
        ll _a = a[i], _b = b[i];
        ll l = 0, r = N;
        while(r-l>1){
            ll m = (l+r)/2;
            
//            // a番目の要素のm個次の要素を求める
//            ll p = _a;
//            for(ll k = LOG_N-1; k>=0; k--){
//                if((m>>k)&1){
//                    p = next[k][p];
//                }
//            }
//            if(p >= _b){
//                r = m;
//            }else{
//                l = m;
//            }
            if(check(_a,m,next) >= _b) r = m;
            else l = m;
        }
        cout << r << endl;
    }
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    solve();
    return 0;
}


Measured memory_bytes: 17536
import math
from copy import copy
di = {}
di[0] = 0
for i in range(1, 2*(10**5)+1):
    di[i] = 0
for i in range(1, 2*(10**5)+1):
    count = 0
    for j in range(int(math.log2(i))+4):
        if (i>>j)&1:
            count += 1
    di[i] = di[i%count] + 1
n = int(input())
x = list(input())
x.reverse()
count = 0
for i in x:
    if i =='1':
        count += 1
mod_p = count + 1
mod_m = count - 1
di_p = {}
di_m = {}
for i in range(n):
    di_p[i] = pow(2, i, mod_p)
    if mod_m >= 1:
        di_m[i] = pow(2, i, mod_m)
s_p = 0
s_m = 0
for i in range(n):
    if x[i] == '1':
        s_p += di_p[i]
        if mod_m >= 1:
            s_m += di_m[i]
    else:
        continue
for i in range(n-1, -1, -1):
    sm = copy(s_m)
    sp = copy(s_p)
    if x[i] == '1' and (mod_m == 0 or mod_m == -1):
        print(0)
    elif x[i] == '1':
        sm -= di_m[i]
        sm %= mod_m 
        print(di[sm]+1)
    else:
        sp += di_p[i]
        sp %= mod_p
        print(di[sp]+1)


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



int lcs(string X,string Y){
	int dp[1001][1001];
  	int maxl=0; 
  	int m=X.size();int n=Y.size();
  	rep(i,m+1){dp[i][0]=0;}
  	rep(i,n+1){dp[0][i]=0;}
  	X=' '+X;Y=' '+Y;
  	for(int i=1;i<=m;i++){
    	for(int j=1;j<=n;j++){
        	if(X[i]==Y[j]){
            	dp[i][j]=dp[i-1][j-1]+1;            	
            }
        	else {
            dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
            }   
          maxl=max(maxl,dp[i][j]);
          
        }
    } 
  return maxl;
}

int main() {
	int q;
  	cin >>q;
  	rep(k,q){
    	string x,y;
    	cin >>x>>y;
      	cout <<lcs(x,y)<<endl;
      	
    }  
}




Measured memory_bytes: 7024
#include <bits/stdc++.h> 
using namespace std;
#define rep(i, N) for(int i=0; i<N; i++)
typedef long long ll;
#define dump(x) cerr<<#x<<"="<<x<<endl
using P = pair<int, int>;

int main() {
    int a, b;
    cin >> a >> b;

    cout << (a + b) % 24 << endl;
    return 0;
}


Measured memory_bytes: 256
/*

Coded by peyha X

*/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

ll x,y;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	cin >> x >> y;
	
	ll actuel=x;
	int compteur=1;
	
	while(2*actuel<=y){
		actuel*=2,
		compteur++;
	}
	
	cout << compteur << endl;
	
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pl;
#define all(a) (a).begin(),(a).end()
#define overload4(_1, _2, _3, _4, name, ...) name
#define rep1(n) for(ll i = 0;i < (n);i++)
#define rep2(i,n) for(ll i = 0;i < (n);i++)
#define rep3(i,a,b) for(ll i = (a);i < (b);i++)
#define rep4(i,a,b,c) for(ll i = (a);i < (b);i += (c))
#define rep(...) overload4(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rrep1(n) for(ll i = (n)-1;i >= 0;i--)
#define rrep2(i,n) for(ll i = (n)-1;i >= 0;i--)
#define rrep3(i,a,b) for(ll i = (a)-1;i >= (b);i--)
#define rrep4(i,a,b,c) for(ll i = (a)-1;i >= (b);i -= (c))
#define rrep(...) overload4(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__)
#define SHOW(x) cout << #x << ": " << x << endl;
template<class T> ll sumArr(const T& a){ return accumulate(all(a), 0LL);}
template<class T> auto minArr(const T& a){ return *min_element(all(a));}
template<class T> auto maxArr(const T& a){ return *max_element(all(a));}
template<class T> void DEBUG_PRINT(T tmp){cout<<tmp<<endl;}
template<class T1,class... T2> void DEBUG_PRINT(T1 tmp,T2... tmp2){cout<<tmp<<" ";DEBUG_PRINT(tmp2...);}
ll gcd(ll a, ll b){ while(b){ ll c = b; b = a % b; a = c; } return a; }
const ll INF=1e18,MOD = 1e9+7;
const int iINF = 1e9;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    double p = 6.28318530717958623200;

    int r;
    cin>>r;
    printf("%.9f\n",p*r);


    return 0;
}

Measured memory_bytes: 3792
#include <stdio.h>
#include <stdlib.h>
long long Lucas(int n);
long long Lucas(int n)
{
    int i;
    long long s[90];
    s[0] = 2;
    s[1] = 1;
    for (i=2;i<=90;i++)
    {
        s[i] = s[i-1] + s[i-2];
    }
    return s[n];
}

int main()
{
    int n;
    scanf("%d",&n);
    printf("%lld\n",Lucas(n));
    return 0;
}


Measured memory_bytes: 128
#include <stdio.h>

int main(){
  
  int a,b,c,d,ans = 0;
  scanf("%d%d%d%d",&a,&b,&c,&d);
  
  ans += (a > b) ? b : a;
  ans += (c > d) ? d : c;
  printf("%d",ans);
  
  return 0;
  }

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(var, begin, end) for (int var = (begin); var <= (end); var++)
#define RFOR(var, begin, end) for (int var = (begin); var >= (end); var--)
#define REP(var, length) FOR(var, 0, length - 1)
#define RREP(var, length) RFOR(var, length - 1, 0)
#define EACH(value, var) for (auto value : var)
#define SORT(var) sort(var.begin(), var.end())
#define REVERSE(var) reverse(var.begin(), var.end())
#define RSORT(var) SORT(var); REVERSE(var)
#define OPTIMIZE_STDIO ios::sync_with_stdio(false);cin.tie(0);cout.precision(10);cout << fixed
#define endl '\n'

const ll MOD = 1e9 + 7;
struct mint {
    ll x;
    mint() : x(0) {}
    mint(ll x) : x((x % MOD + MOD) % MOD) {}
    mint& operator+=(const mint& r) { if ((x += r.x) >= MOD) { x -= MOD; } return *this; }
    mint& operator-=(const mint& r) { if ((x -= r.x) < 0) { x += MOD; } return *this; }
    mint& operator*=(const mint& r) { if ((x *= r.x) > MOD) { x %= MOD; } return *this; }
    mint& operator++() { if ((++x) >= MOD) { x -= MOD; } return *this; }
    mint operator++(int) { mint ret = x; if ((++x) >= MOD) { x-= MOD; } return ret; }
    mint& operator--() { if ((--x) < 0) { x += MOD; } return *this; }
    mint operator--(int) { mint ret = x; if ((--x) < 0) { x += MOD; } return ret; }
    mint operator+(const mint& r) { mint ret; return ret = x + r.x; }
    mint operator-(const mint& r) { mint ret; return ret = x - r.x; }
    mint operator*(const mint& r) { mint ret; return ret = x * r.x; }
    mint operator-() { return mint() - *this; }
    bool operator<(const mint& a) { return x < a.x; }
    bool operator>(const mint& a) { return x > a.x; }
    bool operator<=(const mint& a) { return x <= a.x; }
    bool operator>=(const mint& a) { return x >= a.x; }
    bool operator==(const mint& a) { return x == a.x; }
    bool operator!=(const mint& a) { return x != a.x; }
};
ostream& operator<<(ostream& os, const mint& r) { os << r.x; return os; }
ostream& operator>>(ostream& os, const mint& r) { os >> r.x; return os; }

void solve(istream& cin, ostream& cout) {
  int k, x;
  cin >> k >> x;
  if (k * 500 >= x) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

#ifndef TEST
int main() {
  OPTIMIZE_STDIO;
  solve(cin, cout);
}
#endif


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
int main(void){
    ll h,n;
    cin>>h>>n;
    ll sum=0;
    rep(0,i,n){
        ll a;
        cin>>a;
        sum+=a;
    }
    if(h-sum<=0){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 256
macro_rules! input {
     (source = $s:expr, $($r:tt)*) => {
         let mut iter = $s.split_whitespace();
         input_inner!{iter, $($r)*}
     };
     ($($r:tt)*) => {
         let s = {
             use std::io::Read;
         let mut s = String::new();
         std::io::stdin().read_to_string(&mut s).unwrap();
         s
     };
     let mut iter = s.split_whitespace();
     input_inner!{iter, $($r)*}
     };
}
     
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
 
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}
 
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
 
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
 
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
 
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
 
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::io::{stdout, Write, BufWriter};
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
//#[allow(unused_imports)]
//use proconio::marker::{Isize1, Usize1, Bytes, Chars};
//#[proconio::fastout]
fn main() {
    input!{
        n: usize,
        bricks: [i32; n],
    }
    if ! bricks.contains(&1) {
        println!("-1");
        return;
    }
    let mut ans = 0;
    let mut k = 1;
    for brick in bricks {
        if brick == k { k += 1; }
        else { ans += 1; }
    }
    println!("{}", ans);
}


Measured memory_bytes: 6524
#include <bits/stdc++.h>
using namespace std;
int main()
{
 int a,b,c,t;
 c=0;
 t=1;
 cin >> a >> b;
 while(t<b)
 {
  t--;
  t+=a;
  c++;
 }
 cout << c;
 return 0;
}

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

int main() {
	int N, a, count = 0;
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> a;
		while (a % 2 == 0) {
			count++;
			a /= 2;
		}
	}
	cout << count;
}

Measured memory_bytes: 256
from collections import deque
N, M = map(int, input().split())
G0 = [set([i]) for i in range(N)]

A = set(range(N))

for i in range(M):
    a, b = map(int, input().split())
    G0[a-1].add(b-1)
    G0[b-1].add(a-1)

G = [A - g for g in G0]

b = 1
c = [-1]*N
for i in range(N):
    if c[i] != -1:
        continue
    p = 0; s = 0
    que = deque([i])
    c[i] = 0
    while que:
        v = que.popleft()
        s += 1
        if c[v] == 0:
            p += 1
        for w in G[v]:
            if c[w] == -1:
                c[w] = c[v]^1
                que.append(w)
            elif c[w] == c[v]:
                print(-1)
                exit(0)
    b = (b << p) | (b << (s-p))

ans = 10**18
for i in range(N+1):
    if (b >> i) & 1:
        ans = min(ans, i*(i-1)//2 + (N-i)*(N-i-1)//2)
print(ans)

Measured memory_bytes: 38208
#include <bits/stdc++.h>
using namespace std;
int main(){
   int n,n2=0,n4=0;
   cin >> n;
   for(int i=0;i<n;i++){
       int a;
       cin >> a;
       if(a%4==0) n4++;
       else if(a%2==0) n2++;
   }
   if(n<=n2+2*n4+(n2==0)) cout << "Yes" << endl;
   else cout << "No" << endl;
}

Measured memory_bytes: 3596
package main

import (
  "bufio"
  "fmt"
  "os"
  "strconv"
  "strings"
)

const size = 1000000
var reader = bufio.NewReaderSize(os.Stdin,size)
func NextLine() string {
  var line,buffer []byte
  var isPrefix bool = true
  var err error
  for ;isPrefix; {
    line,isPrefix,err = reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer,line...)
  }
  return string(buffer)
}
func NextInt() int {
  var n int
  n,_ = strconv.Atoi(NextLine())
  return n
}
func NextIntArray() []int {
  var s []string = strings.Split(NextLine()," ")
  var n int = len(s)
  var a []int = make([]int,n+2)
  for i:=1;i<n+1;i++ {
    a[i],_ = strconv.Atoi(s[i-1])
  }
  return a
}

func main() {
  var n int = NextInt()
  var a []int = NextIntArray()
  var s,t int
  s = 0
  for i:=0;i<n+1;i++ { s += abs(a[i+1]-a[i]) }
  for i:=1;i<n+1;i++ {
    t = s-abs(a[i]-a[i-1])-abs(a[i+1]-a[i])+abs(a[i+1]-a[i-1])
    fmt.Println(t)
  }
}
func abs(n int) int {
  if n < 0 { return -n }
  return n
}

Measured memory_bytes: 5888
//#define _GLIBCXX_DEBUG
//#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
//using namespace atcoder;
#define rep(i,n) for (int i = 0;i < (int)(n);i++)
using ll = long long;
const ll MOD=1000000007;
//const ll MOD=998244353;
const long long INF = 1LL << 60;
const double pi=acos(-1.0);
int dx[9] = {1, 0, -1, 0, 1, 1, -1, -1, 0};
int dy[9] = {0, 1, 0, -1, 1, -1, -1, 1, 0};

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



int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  // cout << fixed << setprecision(15);

  string S; cin>>S;
  ll N=S.size();
  cout<<S<<(S[N-1]=='s'?"es":"s")<<'\n';
  
  return 0;
}


Measured memory_bytes: 3664
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> ans(n);
  for(int i = 1, temp; i <= n; ++i){
    cin >> temp;
    ans[temp - 1] = i;
  }
  for(int i = 0; i < n; ++i){
    cout << (i ? " " : "") << ans[i];
  }
  cout << endl;
}

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

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

  lint ans = 0;
  const lint MOD = 1e9 + 7;
  int n;
  cin >> n;
  lint sum = 0;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    ans += 1ll * sum * a;
    sum += a;
    ans %= MOD;
    sum %= MOD;
  }
  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <numeric>
#include <iomanip>
#include <tuple>

using namespace std;
typedef long long ll;
const ll mod=1e9+7;
const ll INF=1LL<<60;

int main(){
    ll n;
    cin>>n;
    vector<ll> a(n),b(n);
    for(ll i=0;i<n;i++)cin>>a[i]>>b[i];
    reverse(a.begin(),a.end());
    reverse(b.begin(),b.end());

    ll ans=0;
    for(ll i=0;i<n;i++){
        if((a[i]+ans)%b[i]==0)continue;
        ans+=b[i]-(a[i]+ans)%b[i];
    }
    cout<<ans<<endl;
}
 
   

Measured memory_bytes: 1792
N = int(input())
S = [0]*N
for i in range(N):
    S[i] = ''.join(sorted(str(input())))
answer = 0
numdic = {}
for i in range(N):
    if S[i] in numdic:
        answer += numdic[S[i]]
        numdic[S[i]] +=1
        
    else:
        numdic[S[i]] = 1
    
print(answer)

Measured memory_bytes: 104968
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define WHATIS(x) cout << #x << " is " << x << endl;
#define ERROR(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<ll, II> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << *it << " = " << a << endl;
    err(++it, args...);
}

const ll MODBASE = 1000000007LL;
const int MAXN = 100010;

int n, a[MAXN], l[MAXN], r[MAXN];

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

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin >> n;
    FOR(i,1,n) cin >> a[i];
    FOR(i,1,n)
        if (i == 1) l[i] = a[i];
        else l[i] = gcd(a[i], l[i-1]);
    FORE(i,n,1)
        if (i == n) r[i] = a[i];
        else r[i] = gcd(r[i+1], a[i]);
    int res = 0;
    FOR(i,1,n) {
        if (i == 1) {
            res = max(res, r[i+1]);
        }
        else if (i == n) {
            res = max(res, l[i-1]);
        }
        else {
            res = max(res, gcd(l[i-1], r[i+1]));
        }
    }
    cout << res;
    return 0; 
}

Measured memory_bytes: 1408
from collections import deque


def poland_calc(chars):
    stack = deque()
    for char in chars:
        if char == "+":
            res = stack.pop() + stack.pop()
            stack.append(res)
        elif char == "*":
            res = stack.pop() * stack.pop()
            stack.append(res)
        elif char == "-":
            res = - stack.pop() + stack.pop()
            stack.append(res)
        else:
            stack.append(int(char))
    return stack.pop()


def main():
    chars = input().split()
    print(poland_calc(chars))


if __name__ == "__main__":
    main()



Measured memory_bytes: 6000
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
typedef pair<int, int> P;
const int INF=10000000;

int main() {
    int n, k;
    cin >> n >> k;
    int a[n];
    for(int i=0;i<n;++i) {
        cin >> a[i];
    }
    int ans=k;
    int cnt=1;
    while(ans<n) {
        ans+=k-1;
        ++cnt;
    }
    cout << cnt << endl;
}



Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <vector>
#include <stack>
#include <math.h>
#include <queue>

using namespace std;

typedef long long int ll;
typedef long double ld;

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define vsort(a) sort(a.begin(), a.end())
#define rev(a) reverse(a.begin(), a.end())

const int MOD = 1000000007;
const int INF = INT_MAX;


// a,bの最小公倍数
ll lcm(ll a, ll b){ll lcm = a * b; ll r = a % b;while(r != 0){a = b; b = r; r = a % b;}return lcm /= b;}
// a,bの最大公約数
ll gcd(ll a, ll b){ll r = a % b;while(r != 0){a = b; b = r; r = a % b;}return b;}
// MOD
ll modadd(ll a, ll b){return (a%MOD+b%MOD+MOD)%MOD;}
ll modmul(ll a, ll b){return a%MOD*b%MOD%MOD;}
ll modexp(ll a, ll n){if(n==0)return 1; if(n%2==0){ll e=modexp(a,n/2); return modmul(e,e);} return modexp(a,n-1)*a%MOD;}
ll modinv(ll n){return modexp(n%MOD,MOD-2);}
ll modfact(ll n){ll res=1; for (int i=1; i <= n; ++i){res *= i; res %= MOD;} return res;}
ll modncr(ll n, ll r){ll numer=1;ll denom=1;for(int i=1;i<=r;++i){numer=modmul(numer,n-r+i);denom=modmul(denom,i);}return modmul(numer, modinv(denom));}


int main(){


    string s;
    cin >> s;

    if ((s[5] - '0') * 10 + (s[6] - '0') <= 4) cout << "Heisei" << endl;
    else cout << "TBD" << endl;





}



//              g++ -std=c++1z


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

#define GO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int

const int maxr = 1e5 + 5;


int32_t main()
{
	GO;
	int n;
	cin >> n;
	for (int i = 1; i <= 9; i++) {
		for (int j = 1; j <= 9; j++) {
			if (i * j == n) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
	return 0;
}

//!

Measured memory_bytes: 3488
#include <bits/stdc++.h>
#define maxn 100001
#define maxa 1000005
#define MOD 1000000007
#define INF 1000000000000000000

using namespace std;

#define ll long long
#define pii pair<ll, ll>
#define piii pair<pii, ll>
#define ft first
#define sd second
#define rep(i, a, n) for(ll i = a; i < n; i++)
#define repr(i, a, n) for(ll i = n-1; i >= a; i--)
#define meme(a, b) memset(a, b, sizeof(a))

void fast(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
}
ll ceil(ll a, ll b){if((a%b) != 0) return a/b+1; return a/b;}
void flaged(bool flag){
    if(flag) cout << "YES\n";
    else cout << "NO\n";
}
ll power(ll a, ll b = MOD-2){
    if(b == 0) return 1;
    ll r = power(a, b/2);
    r = (r*r)%MOD;
    if(b%2 == 1) r = (r*a)%MOD;
    return r;
}

void solve(){
    ll n, k; cin >> n >> k;
    ll a[n];
    for(ll i = 0 ; i< n; i++) cin >> a[i];
    cout << setprecision(10);

    double dp[n+1], ans = 0;
    meme(dp, 0);
    for(ll i = 0; i < n; i++){
        dp[i+1] = dp[i] + (double)(a[i]+1)/2;
        if(i+1 >= k) ans = max(ans, dp[i+1] - dp[i+1-k]);
    }
    cout << ans;
 }

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


Measured memory_bytes: 3328
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC126
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] nk = Console.ReadLine().Split().Select(int.Parse).ToArray();
            string S = Console.ReadLine();
            char[] s = new char[nk[0]];
            for (int i = 0; i < nk[0]; i++)
            {
                s[i]=S[i];
            }
            
            s[nk[1] - 1] += (char)32;
            Console.WriteLine(s);
        }
    }
}


Measured memory_bytes: 11348
#include<iostream>
#include<stdlib.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
using namespace std;

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

Measured memory_bytes: 1792
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
constexpr int kMax = 2e5 + 1;
typedef long long LL;

int dfs(int v) {
  int cnt = 0;
  while (v > 0) {
    int popcount = __builtin_popcount(v);
    v %= popcount;
    ++cnt;
  }
  return cnt;
}

int main() {
  int N; cin >> N;
  string S; cin >> S;
  int popcount = 0;
  for (int i = 0; i < N; ++i) if (S[i] == '1') ++popcount;
  int pp = popcount + 1, pn = popcount - 1;

  int Xp = 0, Xn = 0;
  for (int i = 0; i < N; ++i) {
    Xp = (Xp * 2) % pp;
    Xn = (pn <= 0) ? 0 : (Xn * 2) % pn;
    if (S[i] == '1') {++Xp; ++Xn;}
  }

  reverse(S.begin(), S.end());
  vector<int> v(N);
  int kp = 1, kn = 1;
  for (int i = 0; i < N; ++i) {

    if (S[i] == '1') {
      if (pn <= 0) v[i] = 0;
      else         v[i] = dfs((pn + Xn - kn) % pn) + 1;
    } else {
      v[i] = dfs((Xp + kp) % pp) + 1;
    }

    kp = (2 * kp) % pp;
    kn = (pn <= 0) ? 0 : (2 * kn) % pn;
  }

  for (auto it = v.rbegin(); it != v.rend(); ++it) cout << *it << endl;
}


Measured memory_bytes: 4324
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

H, W = MAP()
cost = [LIST() for _ in range(10)]
wall = [LIST() for _ in range(H)]

for k in range(10):
    for i in range(10):
        for j in range(10):
            cost[i][j] = min(cost[i][j], cost[i][k] + cost[k][j])

magic = 0
for i in range(H):
	for j in range(W):
		if wall[i][j] == -1:
			pass
		else:
			magic += cost[wall[i][j]][1]

print(magic)

Measured memory_bytes: 61796
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
void statusSummary(vector <string> const& vect) {
	long num1 = 0;
	long num2 = 0;
	long num3 = 0;
	long num4 = 0;
	for (long i = 0; i < vect.size(); i++) {
		if (vect[i] == "AC") num1++;
		else if (vect[i] == "WA") num2++;
		else if (vect[i] == "TLE") num3++;
		else num4++;
	}
	cout << "AC x " << num1 << endl;
	cout << "WA x " << num2 << endl;
	cout << "TLE x " << num3 << endl;
	cout << "RE x " << num4 << endl;
}
int main() {
	long size;
	cin >> size;
	vector <string> codes(size);
	for (long i = 0; i < size; i++) {
		cin >> codes[i];
	}
	statusSummary(codes);
	return 0;
}

Measured memory_bytes: 6392
import bisect
n = int(input())
l = list(map(int, input().split()))

a = [l[i] + l[j] for i in range(n) for j in range(i+1, n)]

len_a = n*(n-1)//2

a.sort()

ans = 0
for ll in l:
    x =  bisect.bisect(a, ll)
    ans += x

print(n*(n-1)*(n-2)//6 - ans)


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

vector<int> par;
vector<int> rnk;

void makeSets(int n) {
    par.resize(n);
    rnk.resize(n);
    for(int i=0; i<n; i++) {
        par[i] = i;
        rnk[i] = 0;
    }
}

int find(int x) {
    if(x != par[x]) par[x] = find(par[x]);
    return par[x];
}

void unite(int xp, int yp) {
    int x = find(xp);
    int y = find(yp);
    if(x == y) return;
    if(rnk[x] > rnk[y]) {
        par[y] = x;
    } else {
        par[x] = y;
        if(rnk[x] == rnk[y]) rnk[y]++;
    }
}

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

    for(int i=0; i<M; ++i) {
        int x,y,z;
        cin >> x >> y >> z;
        unite(x-1, y-1);
    }

    map<int, bool> K;
    int res = 0;
    for(int i=0; i<N; ++i) {
        if(!K[find(i)]) {
            ++res;
            K[find(i)] = true;
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 5760
#include <stdio.h>
#define N 100

int main(){

  int i, j;
  int n, minv, tmp, a[N];
  int count = 0;

  scanf("%d", &n);

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

  for(i = 0; i < n; i++){
    minv = i;

    for(j = i; j < n; j++){
      if(a[j] < a[minv]){
	minv = j;
      }
    }

    if(i != minv){
      tmp = a[i];
      a[i] = a[minv];
      a[minv] = tmp;
      count++;
    }

  }

   for(i = 0; i < n; i++){
    printf("%d", a[i]);
    if(i < n - 1) printf(" ");
  }

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

   return 0;
}

Measured memory_bytes: 604
#include <functional>
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

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

  priority_queue<double, vector<double>, greater<double>> q;
  for (int i = 0; i < n; i++) {
    double n;
    cin >> n;
    q.push(n);
  }

  while (q.size() > 1) {
    double fst = q.top();
    q.pop();
    double snd = q.top();
    q.pop();
    q.push((fst + snd) / 2);
  }
  
  cout << q.top() << "\n";
  
  return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Scan()
	n, _ := strconv.Atoi(sc.Text())
	switch n % 10 {
	case 2, 4, 5, 7, 9:
		fmt.Println("hon")
	case 0, 1, 6, 8:
		fmt.Println("pon")
	case 3:
		fmt.Println("bon")
	}
}


Measured memory_bytes: 1756