akhauriyash/Code-Regression huggingface dataset:
#pragma region Template
#include <bits/stdc++.h>
using namespace std;

#define rep(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define rng(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define rbf(i, v) for (auto& (i) : (v))
#define All(x) (x).begin(),(x).end()
#define cAll(x) (x).cbegin(),(x).cend()
#define COL(x) cout << x << endl
#define CO(x) cout << x
#define int long long

using LL = long long;
using ULL = unsigned long long;
using PII = pair<int, int>;
using VI = vector<int>;
using VVI = vector<VI>;
using VS = vector<string>;
using VP = vector<PII>;

const double PI = 3.141592653589793;
const int MOD = 1000000007;
const LL INF64 = INT64_MAX >> 1;
const int INF = INT_MAX >> 1;

inline int sqr(int x) { return (x * x); }
inline void printd(double x) { printf("%.10lf\n", x); }
inline void upsort(VI& x) { sort((x).begin(), (x).end()); }
inline void downsort(VI& x) { sort((x).begin(), (x).end(), greater<int>()); }
inline int absdiff(int a, int b) {
	if (b > a) return absdiff(b, a);
	return (a - b);
}
int gcd(int a, int b) { // 最大公約数
	if (a < b) return gcd(b, a);
	int r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}
inline int lcm(int a, int b) { return a * b / gcd(a, b); } // 最小公倍数
#pragma endregion

signed main()
{	
	LL X, Y;
	cin >> X >> Y;

	LL a = X, cnt = 0;

	while (a <= Y) {
		a *= 2;
		cnt++;
	}

	COL(cnt);

	return 0;
}

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

//{ START
using namespace std;
#define int int64_t
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define reps(i, a, n) for (int i = (n - 1); i > (a - 1); --i)
#define arep(i, x) for (auto &&i : (x))
#define irep(i, x) for (auto i = (x).begin(); i != (x).end(); ++i)
#define rirep(i, x) for (auto i = (x).rbegin(); i != (x).rend(); ++i)
//降順はgreater<T>()
#define all(x) (x).begin(), (x).end()
#define rv(s) reverse((s).begin(), (s).end())
// gcd lcmはそのままok
#define gcd(a, b) __gcd(a, b)
#define bits(n) (1LL << (n))
#define pcnt(x) __builtin_popcountll(x)
//配列内等要素削除
#define Unique(x) (x).erase(unique((x).begin(), (x).end()), (x).end())
#define Fixed(n) fixed << setprecision(n)
//総和
#define sowa(n) (((n) * ((n) + 1)) / 2)
#define updiv(a, b) ((a + b - 1) / b)
#define cauto const auto &
using P = pair<int, int>;
using Graph = vector<vector<P>>;
template <class T>  //昇順
using min_heap = priority_queue<T, vector<T>, greater<T>>;
template <class T>  //降順
using max_heap = priority_queue<T>;
template <class A, class B>
using umap = unordered_map<A, B>;
template <class A>
using uset = unordered_set<A>;
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {  //多次元初期化
  std::fill((T *)array, (T *)(array + N), val);
}
template <class A, class B>
bool chmax(A &a, const B &b) {  //最大値更新 返り値はbool
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class A, class B>
bool chmin(A &a, const B &b) {  //最小値更新 返り値はbool
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, 1, 1, -1, -1};
constexpr int INF = 0x3f3f3f3f;
constexpr int LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9 + 7;
constexpr int mod2 = 998244353;
//} END

signed main(void) {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);

  string s;
  cin >> s;
  int cnt = 0;
  rep(i, 0, s.size()) cnt += s[i] - '0';
  cout << (cnt % 9 == 0 ? "Yes\n" : "No\n");
  return 0;
}

Measured memory_bytes: 3716
from collections import Counter
N, M = map(int,input().split())
A = list(map(int, input().split()))
ans = 0

S = [0 for k in range(N)]
S[0] = A[0]
for k in range(1,N):
    S[k] = S[k-1] + A[k]
S = [0] + S
for k in range(N+1):
    S[k] %= M

C = Counter(S)
for a in C:
    if C[a] >= 2:
        ans += (C[a]*(C[a]-1))//2
print(ans)

Measured memory_bytes: 17624
N,Y = map(int,input().split())
f = 0
for a in range(N+1):
    if f != 0:break
    for b in range(N+1-a):
        if a*10000+b*5000+(N-a-b)*1000 == Y:
            print(a,b,N-a-b)
            f = 1
            break
if f == 0:
    print(-1,-1,-1)

Measured memory_bytes: 3060
#include<stdio.h>
int main(void){
int P, Q, R;
scanf("%d%d%d", &P, &Q, &R);
if((P+Q)<=(Q+R)&&(P+Q)<=(P+R)){
    printf("%d\n", P+Q);
}else if((Q+R)<=(P+Q)&&(Q+R)<=(P+R)){
    printf("%d\n", Q+R);
}else{
    printf("%d\n", P+R);
}
return 0;
}

Measured memory_bytes: 128
#define NDEBUG
NDEBUG


#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cstring>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <memory>
#include <queue>
#include <random>


using namespace std;

template<class T>
using vec = std::vector<T>;


#define FOR(i, n) for (int i = 0; i < (n); ++i)


// TC_REMOVE_BEGIN
/// caide keep
bool __hack = std::ios::sync_with_stdio(false);
/// caide keep
auto __hack1 = cin.tie(nullptr);
// TC_REMOVE_END


// Section with adoption of array and vector algorithms.


//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//
//template <class T> using StdTree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;


namespace template_util {
    

    constexpr int bytecount(uint64_t x) {
        return x ? 1 + bytecount(x >> 8) : 0;
    }

    template<int N>
    struct bytetype {
        
    };

    
    /// caide keep
    template<uint64_t N>
    struct minimal_uint : bytetype<bytecount(N)> {
    };
}


template<class T>
T next(istream& in) {
    T ret;
    in >> ret;
    return ret;
}

template<class T>
vector<T> next_vec(istream& in, size_t n) {
  vector<T> ret(n);
  for (size_t i = 0; i < n; ++i) {
    ret[i] = next<T>(in);
  }
  return ret;
}


struct SegmentTree {
  vec<int64_t> tmax;
  int n;

  SegmentTree(int n_) {
    n = n_;
    tmax = vec<int64_t>(4 * n, 0);
  }

  void update(int pos, int64_t value) {
    int v = 1, le = 0, ri = n;
    while (le + 1 < ri) {
      int e = (le + ri) / 2;
      v *= 2;
      if (pos >= e) {
        ++v;
        le = e;
      } else {
        ri = e;
      }
    }
    tmax[v] = max(tmax[v], value);
    v /= 2;
    while (v) {
      tmax[v] = max(tmax[2 * v], tmax[2 * v + 1]);
      v /= 2;
    }
  }

  int64_t internalGetMax(int v, int left, int right, int rangeLeft, int rangeRight) {
    if (left >= rangeRight || right <= rangeLeft) {
      return 0;
    }
    if (rangeLeft >= left && rangeRight <= right) {
      return tmax[v];
    }
    int e = (rangeLeft + rangeRight) / 2;
    int64_t res = internalGetMax(2 * v, left, right, rangeLeft, e);
    res = max(res, internalGetMax(2 * v + 1, left, right, e, rangeRight));
    return res;
  }

  int64_t getMax(int from, int to) {
    return internalGetMax(1, from, to + 1, 0, n);
  }
};

void solve(istream& in, ostream& out) {
  auto n = next<int>(in);
  auto h = next_vec<int>(in, n);
  auto b = next_vec<int>(in, n);

  SegmentTree stree(n + 1);
  FOR(i, n) {
    int64_t bestLeft = stree.getMax(1, h[i] - 1);
    stree.update(h[i], bestLeft + b[i]);
  }
  out << stree.getMax(1, n) << "\n";
}

//#include <fstream>


int main() {
//  ifstream fin("bridges.in");
//  ofstream fout("bridges.out");
    solve(cin, cout);
//  solve(fin, fout);
    return 0;
}



Measured memory_bytes: 8064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define sz(v) (ll((v).size()))
#define forn(i,n) for(ll i=0;i<(n);i++)
#define forr(i,n) for(ll i=(n)-1;i>=0;i--)
#define forv(i,v) forn(i,sz(v))
#define fors(i,s) for(auto i=(s).begin();i!=(s).end();++i)
#define all(v) (v).begin(),(v).end()
#define clr(x) memset(x,0,sizeof(x))

const ll N =1e5+5;
const ll inf=1e15;
ll h[N],dp[N],n;


int main()
{
    ios_base::sync_with_stdio(false);

	cin>>n;forn(i,n){cin>>h[i];dp[i]=inf;}
	dp[0]=0;dp[1]=abs(h[1]-h[0]);
	for(int i=2;i<n;i++)dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
	cout<<dp[n-1]<<endl;

}


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

int key=0;

int binarySearch(int A[],int n){
  int left=0;
  int right=n;
  int mid=0;
  
  while(left<right){
    mid=(left+right)/2;
    if(A[mid]==key)return 1;
    else if(key<A[mid])right=mid;
    else left=mid+1;
  }
  return 0;
}

int main(){
  int n=0,q=0;
  int S[100000];
  int T[100000];
  int count=0;
  cin>>n;
  for(int i=0;i<n;i++)cin>>S[i];
  cin>>q;
  for(int i=0;i<q;i++)cin>>T[i];
  for(int i=0;i<q;i++){
    key=T[i];
    //cin>>key;
    if(binarySearch(S,n)==1)count++;
  }
  cout<<count<<endl;
  return 0;
}



Measured memory_bytes: 3604
$N=($K=38)*($P=$K-1)+1;
for(0..$P){
	$_[$_]=[$N-1,$P*$_..$P*$_+$P-1]
}
for$i(0..$P-1){
	for$j(0..$P-1){
		$_[@_]=[$N-$K+$i,map$P*$_+($j+$i*$_)%$P,0..$P-1]
	}
}
$,=$";$\=$/;
print$N,$K;
print map$_+1,@$_ for@_[0..$N-1]


Measured memory_bytes: 2688
from collections import deque

def main():

    inf = 1000000007
    n = int(input())
    e = [[] for _ in range(n)]
    d = [inf]*n

    for i in range(n):
        m = list(map(int,input().split()))
        for j in range(2,len(m)):
            e[m[0]-1].append(m[j]-1)

    d[0] = 0
    dq = deque([])
    dq.append([0,0])
    while dq:
        c,v = dq.popleft()
        for u in e[v]:
            if d[u]==inf:
                d[u] = c+1
                dq.append([c+1,u])

    for i in range(n):
        if d[i]==inf:print (i+1,-1)
        else        :print (i+1,d[i])

if __name__ == '__main__':
    main()




Measured memory_bytes: 6036
N = int(input())
pts = [(list(map(int,input().split()))) for _ in range(0,N)]

from itertools import permutations
def f(x1,y1,x2,y2):
    dx = x2 - x1
    dy = y2 - y1
    return (dx**2+dy**2)**0.5

l = 0
dst = 0
for i,j in permutations(range(0,N),2):
    dst += f(pts[i][0], pts[i][1], pts[j][0], pts[j][1])
    l += 1
print(dst / l * (N-1))

Measured memory_bytes: 3064
N = int(input())
a = input().split()
b = [int(n) for n in a]


for i in range(N):
    v = b[i]
    j = i-1
    while j>=0 and b[j]>v:
        b[j+1] = b[j]
        j = j-1
        b[j+1] = v
    print(" ".join([str(n) for n in b]))


Measured memory_bytes: 5608
#include <bits/stdc++.h>
#define inf 0x3f3f3f3f
#define m_k make_pair
using namespace std;
int x,y,z;
signed main()
{
	scanf("%d%d%d",&x,&y,&z);
	swap(x,y);
	swap(x,z);
	printf("%d %d %d\n",x,y,z);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=100005;
int dp[N];
int height[N];
int n;
int main()
{
	cin>>n;
	for(int i=0;i<n;i++)
	cin>>height[i];
	
	dp[0]=0;
	dp[1]=abs(height[1]-height[0]);
	for(int i=2;i<n;i++)
	{
		dp[i]=min(dp[i-1]+abs(height[i]-height[i-1]),dp[i-2]+abs(height[i]-height[i-2]));
	}
	cout<<dp[n-1]<<endl;
	
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#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 ALL(x) (x).begin(),(x).end()
typedef long long ll;

#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev

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

  ll ans = 0;
  REP(i,1,N+1){
    if(i % 3 != 0 && i % 5 != 0){ ans += i; }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3624
#!/usr/local/gnu/bin/bash
max=1000000000000000000
read n
read -a a
a=(`echo ${a[@]} | tr ' ' '\n' | sort -nr`)
if((a[n-1]==0))
then
    echo 0
    exit
fi
m=1
for x in ${a[@]}
do
    if((max/m<x))
    then
        echo -1
        exit
    else
        m=$((m*x))
    fi
done
echo $m


Measured memory_bytes: 44488
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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


int main() {
    int a,b;
    cin>>a>>b;
    if(a<=8&&b<=8) cout<<"Yay!"<<endl;
    else cout<<":("<<endl;
}



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

#define EPS (1e-10)
#define equals(a, b) (fabs((a) - (b)) < EPS)
#define pb push_back
#define rep(i, n) for(int i = 0; i < (n); i++)
#define INF (1 << 29)

using namespace std;
typedef long long ll;

const int nc = 26;
int D;
ll c[40], t[400];
ll s[400][40];

ll scoring(){
	vector<int> last(nc+10, -1);

	long long sat = 0;

	for(ll d = 0; d < D; d++){
		last[t[d]] = d;

		for(int i = 0; i < nc; i++){
			sat -= c[i] * (d - last[i]);
		}
		sat += s[d][t[d]];
		//cout << sat << endl;
	}

	return sat;
}


ll calc_score(ll &score, int d, int q){
	int p = t[d]; // p -> q
	int prev_q = 0, prev_p = 0, next_q = D - 1 ,next_p = D - 1;

	if(p == q){
		return score;
	}

	for(int i = d-1; i >= 0; i--){
		if(prev_p == 0){
			if(t[i] == p){
				prev_p = i;
			}
		}
		if(prev_q == 0){
			if(t[i] == q){
				prev_q = i;
			}
		}
	}

	for(int i = d+1; i < D; i++){
		if(next_p == D-1){
			if(t[i] == p){
				next_p = i;
			}
		}
		if(next_q == D-1){
			if(t[i] == q){
				next_q = i;
			}
		}
	}

	//cout << "next_p:" << next_p << ", next_q:" << next_q << endl;
	//cout << "prev_p:" << prev_p << ", prev_q:" << prev_q << endl;

	score = score + s[d][q] - s[d][p];

	for(int i = d; i <= next_p; i++){
		//score += c[p] * (i-d);
		score -= c[p] * (i - prev_p);
	}

	for(int i = d; i <= next_q; i++){
		//score += c[q] * (i - prev_q);
		score -= c[q] * (i - d);
	}

	t[d] = q;
	return score;
}

void ans_query(ll &score){
	int M;
	cin >> M;

	for(int i = 0; i < M; i++){
		int d, q, old;
		cin >> d >> q;
		d--; q--;
		old = t[d];
		t[d] = q;
		ll new_score = scoring();
		cout << new_score << endl;
		/*if(score > new_score){
			t[d] = old;
		}*/
	}
}


int main(){
	cin >> D;

	for(int i = 0; i < nc; i++){
		cin >> c[i];
	}

	for(int i = 0; i < D; i++){
		for(int j = 0; j < nc; j++){
			cin >> s[i][j];
		}
	}

		for(int i = 0; i < D; i++){
		cin >> t[i];
		t[i]--;
	}

	ll score = scoring();

	ans_query(score);

	return 0;
}


Measured memory_bytes: 3716
from collections import defaultdict

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

d = defaultdict(int)

for a in A:
    d[a] += 1

L = len(d.keys())
if L <= K:
    print(0)
    exit()

diff = L - K
ans = 0
for k, v in sorted([x for x in d.items()], key=lambda x: x[1])[:diff]:
    ans += v

print(ans)


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

#include <math.h>
#include <stdlib.h>


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

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    ll n, k; cin >> n >> k;
    ll r, s, p; cin >> r >> s >> p;
    string t; cin >> t;

    ll ans = 0;
    for(int i = 0; i < k; i++){
        int pos = i;
        char pre = 'a';
        while(pos < n){
            if(t[pos] == pre){
                pre = 'a';
                pos += k;
                continue;
            }
            if(t[pos] == 'r') ans += p;
            if(t[pos] == 's') ans += r;
            if(t[pos] == 'p') ans += s;
            pre = t[pos];
            pos += k;
            continue;
        }
    }
    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 512
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

int main(){
  int N;
  cin >> N;
  ll a[N];
  for(int i = 0; i < N; i++) cin >> a[i];

  ll b = 0LL;
  for(int i = 0; i < N; i++) b ^= a[i];

  if(b == 0){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1024
M,D = list(map(int,input().split()))
a = 0

if D<=21:
  print(0)
else:
  for i in range(1,M+1):
    for j in range(22,D+1):
      d01 = j//10
      d10 = j%10
      if d01>=2 and d10>=2 and i==d01*d10:
        a+=1
  print(a)

Measured memory_bytes: 3060
s = input()

idx_a = 200000
idx_z = 0
for i in range(len(s)):
	if s[i] == "A":
		idx_a = min(idx_a,i)
		#print(idx_a)
	if s[i] == "Z":
		idx_z = max(idx_z,i)
		#print(idx_z)

print(len(s[idx_a:idx_z])+1)

Measured memory_bytes: 3516
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


import numpy as np
from numba import njit, b1, i4, i8, f8
from heapq import heappop as hpp, heappush as hp

h,w = map(int, input().split())
ch,cw = map(int, input().split())
dh,dw = map(int, input().split())
ch -= 1
cw -= 1
dh -= 1
dw -= 1
rows,cols = h,w

OK = "."
NG = "#"

ss = np.array([[c=="#" for c in input()] for _ in range(h)])


@njit((b1[:, :],i8,i8,i8,i8), cache=True)
def main(ss,ch,cw,dh,dw):
    inf = 1<<30
    h,w = ss.shape
    start = ch*w+cw
    goal = dh*w+dw
    n = h*w
    seen = np.full(n, inf, np.int64)
    seen[start] = 0
    q = [(0, start)] # ワープ回数, 現在位置, 最後の道の位置
    while q:
        pnum,pu = hpp(q)
        ux,uy = divmod(pu,w)
        if pu==goal:
            break
        for xx in range(-2, 3):
            for yy in range(-2, 3):
                if xx==yy==0:
                    continue
                if abs(xx)+abs(yy)<=1:
                    vv = 0
                else:
                    vv = 1
                x,y = ux+xx, uy+yy
                u = x*w + y
                num = pnum+vv
                if x<0 or y<0 or x>=h or y>=w or ss[x][y]:
                    continue
        #         print(x,y)
                if seen[u]>num:
                    seen[u] = num
                    hp(q,(num, u))
                
    val = seen[goal]
    if val==inf:
        return -1
    else:
        return val

print(main(ss,ch,cw,dh,dw))

Measured memory_bytes: 124720
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
const int INFTY =2147483647;
int main(){
    int a,b;
    cin>>a>>b;
    cout<<a*b<<endl;
}

Measured memory_bytes: 3628
#include<stdio.h>
int main()
{
  int i,num,N;i=scanf("%d",&N)+1;long ans=1l*N*(N+1)-1;
  while(i*i<=N){num=N/i;ans+=i*(1l*num*num-i*i+num);i++;}
  return printf("%ld\n",ans),0;
}

Measured memory_bytes: 1688
#include <utility>
#include <vector>
#include <iostream>
#include <algorithm>
#include <set>
#include <climits>
#include <cmath>
#include <limits.h>
#include <ios>
#include <iomanip>
#include <map> // pair
#define REP(i,n) for(int i=0;i<n;i++)
typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
using namespace std;
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() {
	cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  int B[N-1];
  int A[N];
  for(int i = 0; i < N-1; i++){
    cin >> B[i];
  }

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

  int ret = 0;
  for(int i = 0; i < N; i++){
    ret += A[i];
  }
  cout << ret << endl;

  return 0;
}

Measured memory_bytes: 256
//自分の梅は任意の地点でかおるとする。→間違い。
//EPSはつけない。
//扇形と家は接しないので、距離はsqrtで求めた。

#include<iostream>
#include<cmath>
#include<vector>
#define rep(i,n) for(i = 0;i < n;i++)
#define PI 3.14159265358979
using namespace std;

typedef pair<double,double> P;

int H,R;				//家数,日数
int hx[100],hy[100];	//家の座標
int U,M,S;				//梅、桃、桜の数
int du,dm,ds;			//梅、桃、桜の扇形の中心角
int ux[100],uy[100];	//梅の座標
int mx[100],my[100];	//桃の座標
int sx[100],sy[100];	//桜の座標
int w[100],a[100];		//扇形の方向(角度),風の強さ

//半径,角度の順で格納し、返す
//rotateは角度補正( 補正 = rotate*360 )
P POLAR( int treex,int treey,int housex,int housey,int rotate )
{
	P ans;
	ans.first = (housex-treex)*(housex-treex) + (housey-treey)*(housey-treey);
	ans.first = sqrt( ans.first );
	ans.second = atan2( (double)housey - treey, (double)housex - treex ) * 180 / PI;
	ans.second += 360*rotate;
	return ans;
}

int main()
{
	int i,j,k,l;
	while( cin >> H >> R )
	{
		int day[100] = {0};		//i番目の家において、他の木の香りが届かなかった日数

		if( H == 0 && R == 0 )
			break;
		rep(i,H)
			cin >> hx[i] >> hy[i];
		cin >> U >> M >> S >> du >> dm >> ds;
		rep(i,U)
			cin >> ux[i] >> uy[i];
		rep(i,M)
			cin >> mx[i] >> my[i];
		rep(i,S)
			cin >> sx[i] >> sy[i];
		rep(i,R)
			cin >> w[i] >> a[i];
		//ここから探索
		rep(i,R){
			rep(j,H){
				rep(k,U){
					rep(l,3){
						P t = POLAR( ux[k],uy[k],hx[j],hy[j],l-1 );
						//判定
						if( t.first <= a[i] && fabs( (double)w[i] - t.second ) <= (double)du/2.0 )
							break;
					}
					if(l < 3)
						break;
				}
				if(k < U)
					continue;
				rep(k,M){
					rep(l,3){
						P t = POLAR( mx[k],my[k],hx[j],hy[j],l-1 );
						//判定
						if( t.first <= a[i] && fabs( (double)w[i] - t.second ) <= (double)dm/2.0 )
							break;
					}
					if(l < 3)
						break;
				}
				if(k < M)
					continue;
				rep(k,S){
					rep(l,3){
						P t = POLAR( sx[k],sy[k],hx[j],hy[j],l-1 );
						//判定
						if( t.first <= a[i] && fabs( (double)w[i] - t.second ) <= (double)ds/2.0 )
							break;
					}
					if(l < 3)
						break;
				}
				if(k < S)
					continue;

				//私の梅の香りは届くのか！！
				rep(l,3){
					P t = POLAR( 0,0,hx[j],hy[j],l-1 );
					//判定
					if( t.first <= a[i] && fabs( (double)w[i] - t.second ) <= du/2.0 )
						break;
				}
				if( l < 3 )
					day[j]++;
			}
		}
		int maxday = 0;
		rep(i,H){
			maxday = max( maxday,day[i] );
		}
		if( maxday == 0 ){
			cout << "NA" << endl;
			continue;
		}

		int lasthouse = 0; 
		rep(i,H){
			if( day[i] == maxday ){
				lasthouse = i;
			}
		}
		rep(i,H){
			if( day[i] == maxday ){
				cout << i+1;
				if( i < lasthouse )
					cout << ' ';
				else
					cout << endl;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1256
#include<iostream>
#include<string>
#include<vector>
#include<stdbool.h>
#include<math.h>
typedef long long ll;
using namespace std;
#define N (1000000000+7);


int main() {
	ll n;
	cin >> n;
	bool prime[1010] = { false };
	ll p = 2;
	ll ans = 1, sum = 0;
	while (p <= n) {
		ll q = 2;
		while (q <= sqrt(p) && !prime[p]) {
			if (p%q == 0) {
				prime[p] = true;
			}
			else q++;
		}
		ll z = 2;
		while (!prime[p]) {
			if (p*z <= n) {
				prime[p*z] = true;
				z++;
			}
			else break;
		}
		p++;
	}
	ll i = 0;
	for (ll i = 2;i <= n;i++) {
		ll j = 1;
		sum = 0;
		while (!prime[i]&&pow(i,j)<=n) {
			sum += (ll)n / pow(i, j);
			j++;
		}
		ans = ans*(sum + 1) % N;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 512
M, D = map(int, input().split())

res = 0

for m in range(1, M + 1):
    for d in range(22, D + 1):
        d1 = int(str(d)[0])
        d10 = int(str(d)[1])
        if d1 >= 2 and d10 >= 2 and d1 * d10 == m:
            res += 1

print(res)


Measured memory_bytes: 2940
#include <iostream>
#include <string>

using namespace std;

int main() {
    int h,w,n,i = 0;
    cin >> h >> w >> n;
    
    while(true){
        i++;
        if(h > w) {
            if(n <= h*i)
                break;
        }
        if(h <= w) {
            if(n <= w*i)
                break;
        }
    }
    cout << i;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO 自動生成されたメソッド・スタブ
		BufferedReader bReader = new BufferedReader(new InputStreamReader(System.in));

		int n = Integer.parseInt(bReader.readLine());

		int[] S = new int[n];
		String[] strArray = bReader.readLine().split(" ");

		for (int i = 0; i < n; i++) {
			S[i] = Integer.parseInt(strArray[i]);
		}
		int q = Integer.parseInt(bReader.readLine());

		int[] T = new int[q];
		String[] strArray2 = bReader.readLine().split(" ");

		for (int i = 0; i < q; i++) {
			T[i] = Integer.parseInt(strArray2[i]);
		}
		int count = 0;
		for (int i = 0; i < T.length; i++) {
			if (linearSeach(S, T[i]) != -1) {
				count++;
			}
		}
		System.out.println(count);

	}

	static int linearSeach(int[] array, int key) {
		int result = -1;
		for (int i = 0; i < array.length; i++) {
			if(array[i] == key){
				return i;
			}
		}
		return result;
	}
}


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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  
  int sum=0;
  
  rep(i,n-1)
    rep2(j,i+1,n){
    sum += a[i]*a[j];
  }
  
  cout << sum << endl;
}

Measured memory_bytes: 256
#include<algorithm>
#include<iomanip>
#include<iostream>
#include<queue>
#include<string>
#include<unordered_set>
#include<vector>
using namespace std;
typedef long long ll;
const ll INF = 1000000000000000000;

ll a, b;

int main(){
    cin >> a >> b;
    ll min_ab = min(a, b);
    ll max_ab = max(a, b);
    for(int i = 0; i < max_ab; i++){
        cout << min_ab;
    }
    cout << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int int64_t
int ceilDiv(int x,int y){
  return 1+((x-1)/y);
}
main(){
  int N;
  cin>>N;
  int A=1,B=1;
  for(int i=1;i<=N;++i){
    int x,y;
    cin>>x>>y;
    const int n=max(ceilDiv(A,x),ceilDiv(B,y));
    A=n*x;
    B=n*y;
  }
  cout<<(A+B)<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
const int MOD=(int)1e9+7;
using namespace std;
int main(){
    string n;
    cin>>n;
    if(n[0]==n[1]&&n[1]==n[2]) cout<<"Yes"<<endl;
    else if(n[1]==n[2]&&n[2]==n[3]) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))

from collections import deque
B = deque([])

rev = False

for i in range(N):
  if rev:
    B.appendleft(A[i])
  else:
    B.append(A[i])
  rev ^= True
  
if rev:
  B = list(B)[::-1]
    
print(*B)


Measured memory_bytes: 30812
N,K = list(map(int, input().split(" ")))
H = sorted(list(map(int, input().split(" "))), reverse=True)
Z = 0
R = 0
for n,e in enumerate(H):
  if (n == K):
    Z = n
    break
  elif (K >= len(H)):
    Z = len(H)
    break
for i in H[Z:]:
  R += i
print(R)

Measured memory_bytes: 26180
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	int n;
	cin>>n;
	char s[n+1]={};
	cin>>s;
	if(n%2==1){
		cout<<"No"<<endl;
	}else{
		int k=n/2;
		bool c=true;
		for(int i=0; i<k; i++){
			if(s[i]!=s[k+i]){
				c=false;
			}
		}
		if(c){
			cout<<"Yes"<<endl;
		}else{
			cout<<"No"<<endl;
		}
	}
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
#include <string.h>
#include <ctype.h>
#include <math.h>
#include <float.h>
#include <iomanip>
#include <iostream>
using namespace std;
 
int gcd(int x,int y){
    if(y==0)return x;

    return gcd(y,x%y);
}
int lcm(int x,int y){
    return x*y/gcd(x,y);
}

int main(){

    int c[5]={0,0,0,0,0},a;

    for(int i=0;i<6;i++){
        cin>>a;
        c[a]++;
    }

    for(int i=1;i<=4;i++){
        if(c[i]>2){
            cout<<"NO"<<endl;
            return 0;
        }
    }

    cout<<"YES"<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define cout16 cout << setprecision(16) 
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define SORT(A) sort(A.begin(),A.end())
#define REV(A) reverse(A.begin(),A.end())
typedef long long int ll;
using vi = std::vector<int>;
using vvi = std::vector<std::vector<int>>;
using vll = std::vector<ll>;
using vvll = std::vector<std::vector<ll>>;
using P = std::pair<int,int>;
using vp = std::vector<P>;
using namespace std;
#define INF 1001001001
#define LL_INF 1001001001001001001
#define fi first
#define se second
// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
//const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
int main(void) {
	ll n,k; cin >> n >> k;
	mint ans = 0;
	for(ll i=k; i<=n+1; i++){
		ll mn = i*(i-1)/2;
		ll mx = n*(n+1)/2 - (n-i)*(n-i+1)/2;
		ans = ans+mx-mn+1;
	}
	cout << ans << endl;
}


Measured memory_bytes: 3636
def con(s):
    li = list(s)
    out=[0]*len(li)
    cnt=0
    t={}
    for i in range(len(li)):
        if li[i] in t.keys():
            out[i] = t[li[i]]
        else:
            out[i] = cnt 
            t[li[i]] = cnt
            cnt += 1
    return out

s = input()
t = input()

if con(s)==con(t):
    print("Yes")
else:
    print("No")

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

int main() {
    int n; cin >> n;
    int a = 25-n;
    cout << "Christmas";
    rep(i,a) cout << " Eve";
    cout << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18+7)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define mkt make_tuple
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x > 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod;
		}
		x = x * x % mod;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2) % mod;
}
/*--------Library Zone!--------*/

struct BIT {
	int n;
	vector<int>bit;
	BIT(int x) {
		n = x;
		rep(i, n)bit.push_back(0);
	}
	int sum(int x) {
		int s = 0;
		while (x > 0) {
			s += bit[x];
			x -= x & -x;
		}
		return s;
	}
	void add(int x, int y) {
		while (x <= n) {
			bit[x] += y;
			x += x & -x;
		}
	}
};
void compress(vector<int>& x) {
	vector<int>v1;
	rep(i, x.size())v1.push_back(x[i]);
	sort(all(v1));
	rep(i, x.size()) {
		int index = lower_bound(all(v1), x[i]) - v1.begin();
		x[i] = index + 1;
	}
}
int n, m, ans;
int a[222222];
signed main() {
	cin >> n >> m;
	vector<int>sum(n + 1);
	sum[0] = 0;
	rep(i, n) {
		cin >> a[i]; a[i] -= m;
		sum[i + 1] += a[i];
		sum[i + 1] += sum[i];
	}
	compress(sum);
	BIT bit(200010);
	rep(i, sum.size()) {
		ans += bit.sum(sum[i]);
		bit.add(sum[i], 1);
	}
	cout << ans << endl;
}

Measured memory_bytes: 7508
#include<iostream>
#include<algorithm>
#include<vector>
#include<cstdio>
using namespace std;
int N,Q;
long long L,R;
long long A[2<<17],q[2<<17],x[2<<17],s[2<<17],t[2<<17];
int f(long long X)
{
    int l=-1,r=N;
    while(r-l>1)
    {
        int m=(l+r)/2;
        long long now=A[m];
        for(int i=0;i<Q;i++)
        {
            if(q[i]==1&&now>=x[i])
            {
                now=t[i]*(now+s[i]);
            }
            else if(q[i]==2&&now<=x[i])
            {
                now=(now-s[i])/t[i];
            }
        }
        if(now>=X)r=m;
        else l=m;
    }
    return N-l-1;
}
int main()
{
    cin>>N>>Q>>L>>R;
    for(int i=0;i<N;i++)scanf("%lld",&A[i]);
    sort(A,A+N);
    for(int i=0;i<Q;i++)scanf("%lld%lld%lld%lld",&q[i],&x[i],&s[i],&t[i]);
    printf("%d\n",f(L)-(R==(1uLL<<63)-1?0:f(R+1)));
}



Measured memory_bytes: 10852
#include <cstdio>
#include <cstring>
#include <string>
#include <iostream>

using namespace std;

const int N = 3'009;

char s[2 * N];
int w[2 * N];
int pa[N];
int pb[N];
string f[2 * N];

int main() {
  int n;
  scanf("%d %s", &n, s);
  for (int i = 0, cnta = 0; i < 2 * n; ++i) {
    if (s[i] == 'a') {
      w[i] = cnta;
      pa[cnta] = i;
      ++cnta;
    } else {
      w[i] = i - cnta;
      pb[i - cnta] = i;
    }
  }
  f[2 * n] = "";
  for (int i = 2 * n - 1; i >= 0; --i) {
    f[i] = f[i + 1];
    if (s[i] == 'a') {
      if (pb[w[i]] > i) {
        f[i] = max(f[i], "ab" + f[pb[w[i]] + 1]);
      }
    } else {
      if (pa[w[i]] > i) {
        string cur = "b";
        int l = w[i], r = w[i];
        int j = i + 1;
        while (l <= r) {
          if (s[j] == 'a') {
            if (w[j] == l) {
              cur += "a";
              ++l;
            }
          } else {
            cur += "b";
            ++r;
          }
          ++j;
        }
        f[i] = max(f[i], cur + f[j]);
      }
    }
  }
  puts(f[0].c_str());
}


Measured memory_bytes: 14720
K = int(input())
S = input()

# 英小文字からなる文字列 S があります。
# S の長さが K 以下であれば、 S をそのまま出力してください。
# S の長さが K を上回っているならば、先頭 K文字 だけを切り出し、末尾に ... を付加して出力してください。

if len(S) <= K:
    print(S)
else:
    print(S[0: K] + "...")

Measured memory_bytes: 9108
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#include <algorithm>
#include <functional>
#include <iterator>
#include <locale>
#include <memory>
#include <stdexcept>
#include <utility>
#include <string>
#include <fstream>
#include <ios>
#include <iostream>
#include <iosfwd>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <streambuf>
#include <complex>
#include <numeric>
#include <valarray>
#include <exception>
#include <limits>
#include <new>
#include <typeinfo>
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <climits>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdlib>
#include <cstddef>
#include <cstdarg>
#include <ctime>
#include <cstdio>
#include <cstring>
#include <cwchar>
#include <cwctype>
using namespace std;
static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const double PI2 = 8.0 * atan(1.0);
using ll = long long;
using ull = unsigned long long;

#define ALL(c) (c).begin(), (c).end()
#define CLEAR(v) memset(v,0,sizeof(v))
#define MP(a,b) make_pair((a),(b))
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ABS(a) ((a)>0?(a):-(a))
template<class T> T MIN(const T& a, const T& b) { return a < b ? a : b; }
template<class T> T MAX(const T& a, const T& b) { return a > b ? a : b; }
template<class T> void MIN_UPDATE(T& a, const T& b) { if (a > b) a = b; }
template<class T> void MAX_UPDATE(T& a, const T& b) { if (a < b) a = b; }

constexpr int mo = 1000000007;
int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

bool IsPrime(ll x) {
	for (int i = 2; i * i <= x; ++i) {
		if (x % i == 0) {
			return false;
		}
	}
	return true;
}

int main() {
	std::ios::sync_with_stdio(false);

	ll X;
	cin >> X;
	while (!IsPrime(X)) {
		++X;
	}
	cout << X << endl;
}


Measured memory_bytes: 384
import bisect
n, m = map(int, input().split())

# 県ごとに誕生した市を格納
block = [[] for _ in range(n)]
# 入力される市の順序を保持
input_list = []

for i in range(m):
    p, y = map(int, input().split())
    block[p-1].append(y)
    input_list.append([p-1, y])

# 座標圧縮
for j in range(n):
    block[j] = sorted(list(set(block[j])))

for i in range(m):
    p, y = input_list[i]
    est_num = bisect.bisect_left(block[p], y)
    print(str(p+1).zfill(6), str(est_num+1).zfill(6), sep='')


Measured memory_bytes: 86176
#include<iostream>
#include<iomanip>
#include<string>
using namespace std;
int main(){
	int H = 0;
	int W = 0;
	while (1)
	{
		cin >> H >> W;
		if (H == 0 && W == 0)
		{
			break;
		}
		for (int i = 0; i < H; i++)
		{
			for (int j = 0; j < W;j++)
			{
				cout << "#";
			}
			cout << "\n";
		}
		cout << "\n";
	}
	return 0;
}


Measured memory_bytes: 3068
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int lld;

const lld mod = 1e9+7;
const lld INF = 1e9;
const lld MAXN = 50;

int main()
{
    int n;
    lld a[MAXN+1] = {0};

    cin >> n;
    for(int i = 1; i <= n; i++)
    {
        cin >> a[i];
    }

    lld max = 0;
    int num = 0;
    for(int i = 1; i <= n; i++)
    {
        if (abs(a[i]) > max)
        {
            max = abs(a[i]);
            num = i;
        }
    }

    max = a[num];


    vector<pair<int,int> > change;

    for(int i = 1; i <= n; i++)
    {
        pair<int,int> p;
        p.first = num;
        p.second = i;
        change.push_back(p);
    }
    if (max == 0)
    {
        cout << 0 << endl;
        return 0;
    }else if (max > 0)
    {
        for(int i = 2; i <= n; i++)
        {
            pair<int,int> p;
            p.first = i-1;
            p.second = i;
            change.push_back(p);
        }
    }else
    {
        for(int i = n-1; i >= 1; i--)
        {
            pair<int,int> p;
            p.first = i+1;
            p.second = i;
            change.push_back(p);
        }
    }

    cout << change.size() << endl;
    for(int i = 0; i < change.size(); i++)
    {
        cout << change[i].first << " " << change[i].second << endl;
    }
    return 0;
}

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

int now,n,k;

int main(){
  int ans=0;
  cin >> n ;
  vector<int> a(n);
  REP(i,n) cin>>a[i];

  sort(a.begin(), a.end());
  
  ans=a[n/2]-a[n/2-1];
  if (a[n/2]==a[n/2-1])ans=0;

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

Measured memory_bytes: 640
import java.io.*;

public class Main{
	public static void main(String[] args)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str = br.readLine();
		String[] starray = str.split(" ");	
		int a = Integer.parseInt(starray[0]);
		int b = Integer.parseInt(starray[1]);	
	System.out.println(a/b+" "+a%b+" "+String.format("%.5f",(double) a /(double) b));
	}
}

Measured memory_bytes: 24716
#include <stdio.h>

int main()
{
	int N, M;
	scanf("%d%d", &N,&M);
	int a[M + 1],b[M + 1];
	int n[N + 1];
	int i = 0;
	while (i < M)
	{
		scanf("%d",&a[i]);
		scanf("%d", &b[i]);
		i++;
	}
	int j;
	i = 1;
	int count = 0;
	while (i <= N)
	{
		j = 0;
		count = 0;
		while (j < M)
		{
			if (i == a[j] || i == b[j])
				count += 1;
			j++;
		}
		printf("%d\n", count);
		i++;
	}
	return (0);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define int long long
#define pii pair<int,int>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define FINF(a) memset(a,0x3f,sizeof(a))
#define POW(n) (1LL<<(n))
#define IN(i,a,b) (a <= i && i <= b)
using namespace std;
template <typename T> inline bool CHMIN(T& a,T b) { if(a>b) { a=b; return 1; } return 0; }
template <typename T> inline bool CHMAX(T& a,T b) { if(a<b) { a=b; return 1; } return 0; }
template <typename T> inline void SORT(T& a) { sort(ALL(a)); }
template <typename T> inline void REV(T& a) { reverse(ALL(a)); }
template <typename T> inline void UNI(T& a) { sort(ALL(a)); a.erase(unique(ALL(a)),a.end()); }
const int MOD = 1000000007;
const int INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-10;
/* ---------------------------------------------------------------------------------------------------- */

struct edge {
  int to, cap, rev;
  edge() {}
  edge(int to, int cap, int rev) : to(to), cap(cap), rev(rev) {}
};

const int MAX_V = 310;
vector<edge> G[MAX_V];
int level[MAX_V];
int iter[MAX_V];

void add_edge(int from, int to, int cap) {
  G[from].emplace_back(to, cap, G[to].size());
  G[to].emplace_back(from, 0, G[from].size()-1);
}

void bfs(int s) {
  memset(level, -1, sizeof(level));
  queue<int> que;
  level[s] = 0;
  que.push(s);
  while (!que.empty()) {
    int v = que.front(); que.pop();
    for (int i = 0; i < G[v].size(); i++) {
      edge &e = G[v][i];
      if (e.cap > 0 && level[e.to] < 0) {
        level[e.to] = level[v] + 1;
        que.push(e.to);
      }
    }
  }
}

int dfs(int v, int t, int f) {
  if (v == t) return f;
  for (int &i = iter[v]; i < G[v].size(); i++) {
    edge &e = G[v][i];
    if (e.cap > 0 && level[v] < level[e.to]) {
      int d = dfs(e.to, t, min(f,e.cap));
      if (d > 0) {
        e.cap -= d;
        G[e.to][e.rev].cap += d;
        return d;
      }
    }
  }
  return 0;
}

int max_flow(int s, int t) {
  int flow = 0;
  for (;;) {
    bfs(s);
    if (level[t] < 0) return flow;
    memset(iter, 0, sizeof(iter));
    int f;
    while ((f = dfs(s, t, INF)) > 0) {
      flow += f;
    }
  }
}

int N,M;
int X[1010],Y[1010];
int S,T;
int idx[1010];

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

  cin >> N >> M;
  REP(i,M) {
    cin >> X[i] >> Y[i];
    X[i]--; Y[i]--;
    idx[i] = G[X[i]].size();
    add_edge(X[i],Y[i],1);
    add_edge(Y[i],X[i],1);
  }
  cin >> S >> T;
  S--; T--;
  int flow = max_flow(S,T);
  vector<int> ans;
  REP(i,M) {
    if (G[X[i]][idx[i]].cap == 1) ans.push_back(i+1);
  }
  cout << flow << endl;
  cout << ans.size() << endl;
  for (int v : ans) cout << v << endl;

  return 0;
}


Measured memory_bytes: 3392
main :: IO ()
main = do
  s <- getContents
  let nums1 = map read $ words s
  let (n:nums2) = nums1
  let (d:x:as) = nums2
  putStrLn $ show $ solve n d x as

solve :: Int -> Int -> Int -> [Int] -> Int
solve n d x as = x + asum
  where
    asum = sum $ do
      ai <- as
      return $ length  $ filter (\a -> mod (a - 1) ai == 0) [1..d]
  
  

Measured memory_bytes: 1020
#include <stdio.h>

#define MIN_INPUT_NUM	(3)
#define MAX_INPUT_NUM	(100)

static int search_number_of_pattern(int inputNum, int destinationNum);

int main(int argc, char *argv[])
{
	int inputNum;
	int destinationNum;
	int patternNum;

	while(1){

		/* ??\??? : inputNum = 0 and destinationNum = 0?????´????????????*/
		scanf("%d %d", &inputNum, &destinationNum);
		if(inputNum == 0 && destinationNum == 0){
			break;
		}else if(inputNum < MIN_INPUT_NUM || MAX_INPUT_NUM < inputNum){
			fprintf(stderr, "Invalid Input...\n");
		}else{
			/* do nothing */
		}

		/* ??????????????°????????? */
		patternNum = search_number_of_pattern(inputNum, destinationNum);

		/* ??????????????°?????¨??? */
		printf("%d\n", patternNum);

	}

	return 0;
}

static int search_number_of_pattern(int inputNum, int destinationNum)
{
	int i;
	int ii;
	int iii;
	int countPattern;

	countPattern = 0;
	for(i = 1; i <= inputNum; i++){
		for(ii = i + 1; ii <= inputNum; ii++){
			for(iii = ii+ 1; iii <= inputNum; iii++){
				if(destinationNum == i + ii + iii){
					countPattern++;
				}
			}
		}
	}

	return countPattern;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
#define rep(i,n) for(int i=1; i<=n; i++)
using namespace std;
int main(){
  int y,m,d;
  string s;
  while(1){
    cin >> s;
    if(s == "#") break;
    cin >> y >> m >> d;
    if(y>=31){
     if(y==31 && m<5){
     }
     else {
       s = "?";
       y -= 30;
     }
    }
    cout << s << " " << y << " " << m << " " << d << endl;
  }
  return 0;
}


Measured memory_bytes: 3128
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
using namespace std;
typedef long long int ll;
typedef long double ld;

#define MOD 998244353

int main(){
    ll n;
    cin >> n;
    string s[n];
    for (ll i=0;i<n;i++){
        cin >> s[i];
    }
    for (ll i=0;i<n;i++){
        for (ll j=0;j<n;j++){
            if (i==j)continue;
            if (s[i]==s[j]){
                cout << "No" << endl;
                return 0;
            }
        }
    }
    for (ll i=1;i<n;i++){
        if (s[i-1][s[i-1].size()-1]!=s[i][0]){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}




Measured memory_bytes: 256
#include <iostream>


using namespace std;

int main(){
 int a,b,c,d;
 int A,B,ans;

 cin >> a >> b >> c >> d;
 A = a*b;
 B = c*d;

 if (A >= B){
     cout << A << endl;
 }else{
     cout << B << endl;
 }

    return 0;
}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
int main()
{
    string s;
    cin >> s;
    int n = s.size();
    stack<char> st;
    for(int i = 0; i < n; i++)
    {
        if(s[i] == 'S') st.push('S');
        else
        {
            if(st.size() == 0 || st.top() == 'T') st.push('T');
            else st.pop();
        }
    }
    cout << st.size() << endl;
}


Measured memory_bytes: 3800
#include <stdio.h>
#include <vector>
#include <queue>
using namespace std;

vector<int> in[200200];
int k[200200], l[200200], r[200200];

int main()
{
	int Test; scanf ("%d", &Test); while (Test--){
		int n, x = 0; scanf ("%d", &n);
		long long base = 0;
		for (int i = 0; i < n; i++){
			scanf ("%d %d %d", &k[i], &l[i], &r[i]);
			if (l[i] >= r[i]) x++;
		}

		for (int i = 0; i < n; i++){
			if (l[i] >= r[i]){
				base += r[i];
				if (k[i] > x) k[i] = x;
				in[k[i]].push_back(l[i] - r[i]);
			}
			else{
				if (k[i] <= x){
					base += r[i];
					continue;
				}
				in[k[i] + 1].push_back(r[i] - l[i]);
				base += l[i];
			}
		}

		priority_queue<int> Q;
		for (int i = x; i >= 1; i--){
			for (auto &v : in[i]) Q.push(v);
			if (!Q.empty()) base += Q.top(), Q.pop();
			in[i].clear();
		}
		while (!Q.empty()) Q.pop();
		for (int i = x + 1; i <= n; i++){
			for (auto &v : in[i]) Q.push(v);
			if (!Q.empty()) base += Q.top(), Q.pop();
			in[i].clear();
		}
		in[n + 1].clear();

		printf ("%lld\n", base);
	}
	return 0;
}

Measured memory_bytes: 13052
a = Array.new(5) { gets.to_i }
k = gets.to_i
ans = true
a.each_with_index { |x, i|
  a.each_with_index{ |y, j|
    next if i >= j
    if y - x > k
      ans = false
      break
    end
  }
  break unless ans
}

puts (ans ? "Yay!" : ":(")

Measured memory_bytes: 14328
#include <stdio.h>
#include <stdlib.h>
long i,j,n,l,l2;
int main(){
  l=0; l2=0;
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    scanf("%d",&j);
    //if((n==1)&&(j==2)){printf("No"); exit(0);}
    if (j%2==1) {l++;}
    if (j%4==0) {l2++;}
  }
  //printf("%d %d",l,l2);
  if((l==0)){printf("Yes"); exit(0);}
  if((l2==0)&&(l>0)){printf("No"); exit(0);}
  if((l2==l-1)&&(l2+l<n)){printf("No"); exit(0);}
  if(l2>=(l-1)){printf("Yes");}
  if(l2<(l-1)){printf("No");}
  //else printf("No");
}


Measured memory_bytes: 128