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

using namespace std;
using ll = long long;
// #define int ll
using PII = pair<ll, ll>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()

template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type
fill_v(T &t, const V &v) { t=v; }
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t, const V &v ) { for(auto &e:t) fill_v(e,v); }

template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
    out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x: vec) {is >> x;} return is;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
    out<<'['; for(T i: a) {out<<i<<',';} out<<']'; return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;

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

    ll n;
    cin >> n;

    ll t = n;
    vector<ll> prime;
    for(ll i=2; i*i<=t; ++i) {
        if(t%i == 0) prime.push_back(i);
        while(t%i == 0) t /= i;
    }
    if(t != 1) prime.push_back(t);

    ll m = prime.size(), ans = 0;
    REP(mask, 1LL<<m) {
        ll tmp = 1;
        REP(i, m) if(mask&1<<i) tmp *= prime[i];
        if(__builtin_popcount(mask)%2) ans -= n / tmp;
        else ans += n / tmp;
    }
    cout << ans << endl;

    return 0;
}



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

using namespace std;

#define LL long long
#define ULL unsigned LL

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	LL n, k;
	cin>>n>>k;
	int a[n+1];
	for(int i=0; i<n; i++)
		cin>>a[i+1];
	bool vis[n+1] = {0}; // visited?
	LL time[n+1] = {-1}; // time of first visit
	int poz = 1;
	LL lr = 0;
	vis[1] = 1;
	time[1] = 0;
	LL pr = k;
	//bool kiedy = 0;
	while(pr > 0) {
		lr++;
		pr--;
		if(vis[a[poz]]) {
			//cerr<<"Wykrylem cykl: "<<a[poz]<<" - lr = "<<lr<<", time = "<<time[a[poz]]<<endl;
			LL dl = lr - time[a[poz]];
			pr%=dl;
			//kiedy = 1;
		}
		//cerr<<"Ide z poz = "<<poz<<", do "<<a[poz]<<endl;
		poz = a[poz];
		if(!vis[poz])
			time[poz] = lr;
		vis[poz] = 1;
	}
	cout<<poz;
}


Measured memory_bytes: 6192
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const int64_t LINF=8931145141919364364,LMOD=998244353;
// const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};

int main(){
    int64_t r,d,x; cin>>r>>d>>x;
    for(int64_t i=1;i<=10;i++){
        x=r*x-d;
        cout<<x<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
package main

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

var (
	readString func() string
	readBytes  func() []byte
)

func init() {
	readString, readBytes = newReadString(os.Stdin)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Bytes()
	}
	return f1, f2
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func minInt64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func maxInt64(a, b int64) int64 {
	if a > b {
		return a
	}
	return b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func absInt64(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

func sum(a []int) int {
	var ret int
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumInt64(a []int64) int64 {
	var ret int64
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumFloat64(a []float64) float64 {
	var ret float64
	for i := range a {
		ret += a[i]
	}
	return ret
}

// sort ------------------------------------------------------------

type int64Array []int64

func (s int64Array) Len() int           { return len(s) }
func (s int64Array) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s int64Array) Less(i, j int) bool { return s[i] < s[j] }

type xxx struct {
	x int
}

type sortArray []xxx

func (s sortArray) Len() int           { return len(s) }
func (s sortArray) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s sortArray) Less(i, j int) bool { return s[i].x < s[j].x }

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

func main() {
	n := readInt()
	a := make([]int64, n)
	var cnt int
	for i := range a {
		t := readInt64()
		if t < 0 {
			cnt++
		}
		a[i] = absInt64(t)
	}
	if cnt%2 == 0 {
		fmt.Println(sumInt64(a))
	} else {
		sort.Sort(int64Array(a))
		ans := -a[0]
		for i := 1; i < n; i++ {
			ans += a[i]
		}
		fmt.Println(ans)
	}
}


Measured memory_bytes: 3072
#include <stdio.h>

long GCD(long a, long b){
  long dividend, divisor;
  if (a >= b) {
    dividend = a;
    divisor = b;
  } else {
    dividend = b;
    divisor = a;
  }
  long remainder;
  while (1) {
    if (divisor == 1) {
      return 1;
    }
    remainder = dividend % divisor;
    if (remainder == 0) {
      break;
    } else {
      dividend = divisor;
      divisor = remainder;
    }
  }
  return divisor;
}

int main(void){

  long a,b,c,d;
  scanf("%ld %ld %ld %ld", &a, &b, &c, &d);

	long lcm = c*d/GCD(c,d);
	long all = b-b/c-b/d+b/lcm;
	a--;
	long minus = a-a/c-a/d+a/lcm;
	long answer = all - minus;

	printf("%ld\n", answer);

  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <climits>
#include <cassert>
#include <algorithm>
#include <utility>

using namespace std;
using Int = long long int;
using UInt = unsigned long long int;
using VI = vector<long long int>;
using VVI = vector<vector<long long int> >;

// ビット演算
namespace Bits {
    // 整数 x を左に i ビットシフトした値を返す
    static Int LeftBitShift(Int x, Int i);
    // 整数 x を右に i ビットシフトした値を返す
    static Int RightBitShift(Int x, Int i);
    // 整数x の 下から i 桁目が1かどうかを返す
    static bool IsFlagUp(Int x, Int i);
    // 整数x の 下から i 桁目が0かどうかを返す
    static bool IsFlagDown(Int x, Int i);

    // 整数 x を左に i ビットシフトした値を返す
    Int LeftBitShift(Int x, Int i) {
        return (x << i);
    }
    // 整数 x を右に i ビットシフトした値を返す
    Int RightBitShift(Int x, Int i) {
        return (x >> i);
    }
    // 整数x の 下から i 桁目が1かどうかを返す
    bool IsFlagUp(Int x, Int i) {
        return ((x & (1 << i)) != 0);
    }
    // 整数x の 下から i 桁目が0かどうかを返す
    bool IsFlagDown(Int x, Int i) {
        return ((x & (1 << i)) == 0);
    }
}
using namespace Bits;

// 二つの値の最大値を求める関数
Int Max(const Int a, const Int b) {
    if (a >= b) {
        return a;
    } else {
        return b;
    }
}

struct Data {
    Int a;
    Int b;
    Int c;
    Int d;
};

void dfs(vector<Int>& v, Int value, Int zero, Int one) {
    //cout << value << " " << zero << " " << one << endl;
    if (zero == 0 && one == 0) {
        v.push_back(value);
    }
    if (zero != 0) {
        dfs(v, value * 2, zero - 1, one);
    } 
    if (one != 0) {
        dfs(v, value * 2 + 1, zero, one - 1);
    }
    return;
}

int main(void) {
    Int n, m, q;
    cin >> n >> m >> q;
    vector<Data> data(q);
    for (Int i = 0; i < q; ++i) {
        cin >> data[i].a >> data[i].b >> data[i].c >> data[i].d;
        data[i].a--;
        data[i].b--;
    }
    vector<Int> v;
    dfs(v, 0, n, m - 1);

    Int score_max = 0;

    for (Int i = 0; i < (Int)v.size(); ++i) {
        Int rank_one = 0;
        vector<Int> a;
        for (Int j = 0; j < n + m - 1; ++j) {
            if (IsFlagDown(v[i], j)) {
                a.push_back(rank_one);
            } else {
                ++rank_one;
            }
        }
        Int inner_score = 0;
        for (Int j = 0; j < q; ++j) {
            if (a[data[j].b] - a[data[j].a] == data[j].c) {
                inner_score += data[j].d;
            }
        }
        score_max = Max(score_max, inner_score);
        /*
        for (Int j = 0; j < a.size(); ++j) {
            cout << a[j] << " ";
        }
        cout << endl << "SCORE = " << inner_score << endl;
        */
    }
    cout << score_max << endl;
    return 0;
}


Measured memory_bytes: 4312
#include <iostream>
using namespace std;
int main()
{
    int num;
    cin >> num;
    
    int *a = new int[num];
    
    for (int i = 0; i < num; ++i)
    {
        cin >> a[i];
    }
    
    int min;
    for (int i = 0; i < num; ++i)
    {
        if(i == 0)
        {
            min = a[i];
        }
        else
        {
            if (min > a[i])
            {
                min = a[i];
            }
        }
    }
    
    int max;
    for (int i = 0; i < num; ++i)
    {
        if(i == 0)
        {
            max = a[i];
        }
        else
        {
            if (max < a[i])
            {
                max = a[i];
            }
        }
    }    
    
    long total = 0;
    for (int i = 0; i < num; ++i)
    {
        total += a[i];
    }    
    
    cout << min << " " << max << " " << total << endl;
    
    delete a;
 
    return 0;
}


Measured memory_bytes: 3156
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <string>

using namespace std;

int main()
{
    string s;
    getline(cin, s);
    while (s != "0")
    {
        int ans = 0;
        for (int i = 0; i < s.size(); i++)
        {
            ans += s[i] - 48;
        }
        cout << ans << endl;
        getline(cin, s);
    }
}


Measured memory_bytes: 3156
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
from bisect import bisect_left

N = int(input())
XD = [[int(i) for i in input().split()] for _ in range(N)]
XD.sort()
MOD = 998244353

def make():
    edge = [[] for _ in range(N)]
    parent = [-1] * N
    MAXIDX = N
    sorted_X = [X for X,_ in XD]
    for i in range(N-1, -1, -1):
        idx = bisect_left(sorted_X, XD[i][0] + XD[i][1])
        for j in range(i+1, min(idx, MAXIDX)):
            if parent[j] < 0:
                parent[j] = i
        if idx >= MAXIDX:
            MAXIDX = i + 1
    for i,par in enumerate(parent):
        if par < 0:
            continue
        edge[par].append(i)
    
    return parent, edge

parent, edge = make()

def cnt(node):
    if not edge[node]:
        return 2

    res = 1
    for v in edge[node]:
        res = (res * cnt(v)) % MOD
    res += 1

    return res % MOD

def main():
    ans = 1
    for i,par in enumerate(parent):
        if par < 0:
            ans = (ans * cnt(i)) % MOD

    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 253944
awk '$0=split($1,a,"")&&(a[1]a[2]==a[3]a[4]&&a[1]!=a[2])||(a[1]a[3]==a[2]a[4]&&a[1]!=a[3])||(a[1]a[2]==a[4]a[3]&&a[1]!=a[2])?"Yes":"No"'

Measured memory_bytes: 556
program ABC170_B
  integer(8)::X,Y
  read(*,*)X,Y
  if(Y/2*2/=Y .or. Y<2*X .or. 4*X<Y) then
     write(*,'(a)')'No'
  else
     write(*,'(a)')'Yes'
  end if
end program ABC170_B

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

int main() {
  int i,k;
  cin>>k;
  vector<int>su;
  su={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};
  cout << su.at(k-1) << endl;
}


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

int main(){
    int x, y = 0;
    
    while(std::cin >> x >> y){
        if(x==0 && y==0) break;
        if(x > y)  std::swap(x,y);
        std::cout << x << " " << y << std::endl;
    }
    return 0;
}



Measured memory_bytes: 2988
public class Main {

	public static void main(String[] args) {
		// System.out.print("社員の数を入力(2≤N≤2×10^5):");
		java.util.Scanner sc = new java.util.Scanner(System.in);
		int N = sc.nextInt();
		int[] count = new int[N];

		
		for(int i=1;i<N;i++){
			count[sc.nextInt()-1]++;
		}

		for(int i=0;i<N;i++){
			System.out.println(count[i]);
		}
	}

}


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

typedef long long ll;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll LINF = 1e18;
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define MP make_pair
#define F first
#define S second
#define PB push_back
#define dump(x)  cout << #x << " = " << (x) << endl;	// debug
#define SZ(x) ((ll)(x).size())
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define RFOR(i, a, b) for (ll i = (a); i >= (b); i--)
#define ps(s) cout << #s << endl;
#define pv(v) cout << (v) << endl;
#define pvd(v) cout << setprecision(16) << (v) << endl;
#define ALL(a)  (a).begin(),(a).end()
#define RANGE(a, left, right)  (a).begin()+(left),(a).begin()+(right)	// left to (right-1)


int main() {
	int m, d;
	cin >> m >> d;
	int res = 0;
	FOR(i, 1, m) {
		FOR(j, 1, d) {
			int d1 = j / 10;
			int d2 = j % 10;
			if (d1 >= 2 && d2 >= 2) {
				if (d1*d2 == i) {
					res++;
				}
			}
		}
	}
	pv(res)
	return 0;
}

Measured memory_bytes: 3572
#include <iostream>
#include <string>
using namespace std;
int main() {
  long t, a, k;
  cin >> t >> a >> k;
  if (t>=k) {
    t -= k;
  } else {
    k -= t;
    t = 0;
    if (a>=k) {
      a -= k;
    } else {
      k -= a;
      a = 0;
    }
  }
  cout << t << ' ' << a << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
	int a[] = { 1,3,5,7,8,10,12 };
	int b[] = { 4,6,9,11 };
	int c[] = { 2 };

	int x, y;
	cin >> x >> y;

	for (int i = 0; i < 7; i++) {
		if (a[i] == x) {
			x = -1;
		}
		if (a[i] == y) {
			y = -1;
		}
	}
	for (int i = 0; i < 4; i++) {
		if (b[i] == x) {
			x = -2;
		}
		if (b[i] == y) {
			y = -2;
		}
	}
	for (int i = 0; i < 1; i++) {
		if (c[i] == x) {
			x = -3;
		}
		if (c[i] == y) {
			y = -3;
		}
	}

	if (x == y) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <map>
#include <queue>
#include <vector>
#include <iostream>
#include <algorithm>

using namespace std;

int n;

vector<char> v, r;

vector<pair<vector<char>, int> > v1, v2;

inline int solve()
{
	r = v; sort(r.begin(), r.end());

	int ln = n / 2 - 1, rn = n - ln - 1;

	if (n == 10) { ln--; rn--; }

	map<vector<char>, int> d1; d1[v] = 1;

	queue<vector<char> > que1; que1.push(v);

	while (!que1.empty())
	{
		vector<char> v3 = que1.front(); que1.pop();

		v1.push_back(make_pair(v3, d1[v3] - 1));

		if (d1[v3] < ln + 1)
		{
			for (int i = 0; i < n; i++)
			{
				for (int j = i + 1; j < n; j++)
				{
					vector<char> v4(v3.begin(), v3.end());

					reverse(v4.begin() + i, v4.begin() + j + 1);

					if (!d1[v4])
					{
						d1[v4] = d1[v3] + 1;

						que1.push(v4);
					}
				}
			}
		}
	}

	map<vector<char>, int> d2; d2[r] = 1;

	queue<vector<char> > que2; que2.push(r);

	while (!que2.empty())
	{
		vector<char> v3 = que2.front(); que2.pop();

		v2.push_back(make_pair(v3, d2[v3] - 1));

		if (d2[v3] < rn + 1)
		{
			for (int i = 0; i < n; i++)
			{
				for (int j = i + 1; j < n; j++)
				{
					vector<char> v4(v3.begin(), v3.end());

					reverse(v4.begin() + i, v4.begin() + j + 1);

					if (!d2[v4])
					{
						d2[v4] = d2[v3] + 1;

						que2.push(v4);
					}
				}
			}
		}
	}

	sort(v2.begin(), v2.end());

	vector<vector<char> > v5; vector<int> v6;

	for (int i = 0; i < v2.size(); i++)
	{
		v5.push_back(v2[i].first);
		v6.push_back(v2[i].second);
	}

	int ret = 999999999;

	for (int i = 0; i < v1.size(); i++)
	{
		int l = distance(v5.begin(), lower_bound(v5.begin(), v5.end(), v1[i].first));
		int r = distance(v5.begin(), upper_bound(v5.begin(), v5.end(), v1[i].first));

		if (l != r)
		{
			ret = min(ret, v1[i].second + v6[l]);
		}
	}

	return ret == 999999999 ? 8 : ret;
}

int main()
{
	scanf("%d", &n);

	v = vector<char>(n); int k;

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

	vector<char> tokushu1 = { 3, 1, 5, 2, 7, 4, 9, 6, 10, 8 };
	vector<char> tokushu2 = { 2, 4, 1, 6, 3, 8, 5, 10, 7, 9 };

	if (v == tokushu1 || v == tokushu2)
	{
		printf("9\n");
	}
	else
	{
		printf("%d\n", solve());
	}

	return 0;
}

Measured memory_bytes: 68824
#include <iostream>

using namespace std;
int main()
{
	int n = 0;
	cin >> n;

	int s, l;
	cin >> s >> l;
	bool  is_found = false;
	for (int i = s; i <= l; i++)
	{
		if (i % n == 0)
		{
			is_found = true;
			break;
		}
	}
	cout << (is_found ? "OK" : "NG");

	return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++) 
#define FOR(i, a, b) for(int (i) = a; (i) < (int)b; i++)
#define RREP(i, n) for(int (i)=((int)(n)-1); (i)>=0; i--)
#define RFOR(i, a, b) for(int (i) =((int)(b)-1); (i)>=(int)a; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define NIL -1
#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define SZ(x)  (int)x.size()
#define SP(x)  setprecision((int)x)


using namespace std ;
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<string> vstr;
typedef pair<int, int> pii;
const int INF = 1e9;
const ll LINF = 1e18;
const double EPS = 1e-9;
ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;} //最大公約数
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;} //最小公倍数

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



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


int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n ;
  cin >> n ;
  vector<int> vec(n) ;
  int ans = 0 ;
  REP(i,n){
    cin >>vec.at(i) ;
    ans += vec.at(i) ;
  }
  sort(ALL(vec)) ;
  if(ans%10!=0){
    cout <<ans <<endl ;
    return 0 ;
  }
  else{
    REP(i,n){
      if(vec.at(i)%10!=0){
        ans -=vec.at(i) ;
        break ;
      }
    }
  }
  
    if(ans%10!=0){
    cout <<ans <<endl ;
    return 0 ;
  }
  else{
    cout << 0 <<endl ;
  }
  
  
  
  return 0 ;
}




Measured memory_bytes: 256
H = int(input())
A = [None] + list(map(int, input().split()))

def max_heapify(A, i):
	l = i * 2 
	r = i * 2 + 1
	largest = i
	if l <= H:
		if A[l] > A[largest]:
			largest = l
	if r <= H:
		if A[r] > A[largest]:
			largest = r
	if largest != i:
		A[i], A[largest] = A[largest], A[i]
		max_heapify(A, largest)

def build_max_heap(A):
	for i in range(int(H / 2), 0, -1):
		max_heapify(A, i)

build_max_heap(A)
print(" ", end = "")
print(*A[1:])

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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

const double EPS = 1e-9;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007;

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

int main(void){
    int N; cin >> N;
    vector<double> x(N);
    VS u(N);
    REP(i,N) cin >> x[i] >> u[i];
    double ans = 0;
    REP(i,N){
        if(u[i] == "JPY") ans += x[i];
        else ans += 380000*x[i];
    }
    cout << fixed << setprecision(8) << ans << endl;
    return 0;
}

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

void fnInput(vector<string>& rvsStr)
{
  int nStrSiz;
  cin >> nStrSiz;
  rvsStr.resize(nStrSiz);

  for (string& rsStr : rvsStr)
    cin >> rsStr;
}
  
int64_t fnAnagramCnt(const vector<string>& cnrvsStr)
{
  vector<string> vsSortStr(cnrvsStr);

  for (string& rsSortStr : vsSortStr)
    sort(begin(rsSortStr), end(rsSortStr));

  int64_t nAnagramCnt = 0;
  map<string, int> mpSortStr;

  for (string sSortStr : vsSortStr)
  {
    nAnagramCnt += mpSortStr[ sSortStr ];
    mpSortStr[ sSortStr ]++;
  }

  return nAnagramCnt;
}
  
int main()
{
  vector<string> vsStr;

  fnInput(vsStr);
  cout << fnAnagramCnt(vsStr) << endl;

  return 0;
}

Measured memory_bytes: 23680
#include <cstdio>
#include <algorithm>

typedef long long LL;
const int Mod = 1000000007;
const int MN = 305;

inline void Add(int &x, int y) { x -= (x += y) >= Mod ? Mod : 0; }

int N, Z, A[MN * 2], B[MN * 2], C[MN * 2], D[MN * 2];
int f[MN][MN], g[MN][MN];

int main() {
	scanf("%d", &N);
	for (int i = 1; i <= 2 * N; ++i) {
		scanf("%d", &A[i]);
		if (~i & 1 && ~A[i] && ~A[i - 1]) C[A[i - 1]] = C[A[i]] = 1;
	}
	for (int i = 1; i <= 2 * N; ++i) D[i] = D[i - 1] + !C[i];
	for (int i = 1; i <= 2 * N; ++i) if (~A[i] && !C[A[i]]) B[D[A[i]]] = 1, --Z;
	Z += N = D[2 * N] / 2;
	f[0][0] = 1;
	for (int i = 1; i <= Z; ++i) f[0][0] = (LL)f[0][0] * i % Mod;
	for (int i = 2 * N; i >= 1; --i) {
		for (int j = 0; j <= N; ++j)
			for (int k = 0; k <= N - j; ++k)
				g[j][k] = 0;
		for (int j = 0; j <= N; ++j)
			for (int k = 0; j + k <= N; ++k)
				if (B[i]) {
					if (j) Add(g[j - 1][k], f[j][k]);
					if (j + k < N) Add(g[j][k + 1], f[j][k]);
				} else {
					if (j) Add(g[j - 1][k], f[j][k]);
					if (k) g[j][k - 1] = (g[j][k - 1] + (LL)f[j][k] * k) % Mod;
					if (j + k < N) Add(g[j + 1][k], f[j][k]);
				}
		std::swap(f, g);
	}
	printf("%d\n", f[0][0]);
	return 0;
}

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

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

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

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 100010

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

    void Init(int sz) { m_Data.assign(sz, T(0)); }

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

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

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

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

ll N;
string S;

signed main()
{
    cin >> N >> S;

    CumulativeSum<ll> white(N);
    CumulativeSum<ll> black(N);

    REP(i, N) {
        if(S[i] == '.') { white.Add(i, 1); }
        else { black.Add(i, 1); }
    }
    white.Build();
    black.Build();

    ll ans = min(white.Query(0, N-1), black.Query(0, N-1));
    REP(i, N-1) {
        ans = min(ans, black.Query(0, i) + white.Query(i+1, N-1));
    }
    printf("%lld\n", ans);

    return 0;
}


Measured memory_bytes: 4224
#include<iostream>
#include<string>
#include<cstdio>

int main() {
	int A, B;
	std::cin >> A >>B ;

	if ((A%2 == 1) && (B% 2 == 1)) {
		std::cout << "Yes" <<std::endl;
	}
	else { std::cout << "No" << std::endl; }
	return 0;
}

Measured memory_bytes: 256
//Battlefield control establishing...
#include <iostream>
#include <cstdio>
//#include <bits/stdc++.h>
#include <iomanip>
#include <cstring>
#include <cmath>
//#include <minmax.h>
#include<queue>
#define MCV main
#define lldin(a) scanf("%lld",&a)
#define din(a) scanf("%d",&a)
#define reset(a,b) memset(a,b,sizeof(a))
const int INF=0x3f3f3f3f;
using namespace std;
typedef long long ll;
//Get ready? LET'S ROCK!
int MCV()
{
   int a,b,c;
   cin>>a>>b>>c;
   cout<<min(c,b/a)<<endl;
   return 0;
}


Measured memory_bytes: 256
"""
N = list(map(int,input().split()))
S = [str(input()) for _ in range(N)]
S = [list(map(int,list(input()))) for _ in range(h)] 
print(*S,sep="")
"""

import sys
sys.setrecursionlimit(10**6)
input = lambda: sys.stdin.readline().rstrip()
inf = float("inf") # 無限
n,k=map(int,input().split())
p = list(map(int,input().split()))
p.sort()

price = 0
for _ in range(k):
    price+=p[_]
print(price)

Measured memory_bytes: 9248
#include "bits/stdc++.h"
#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = (int)(n); i >= 0; i--)
#define FOR(i,n,m) for(int i = (int)(n); i < int(m); i++)
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
const int INF = 1e9 + 6;
const ll LLINF = 4e18;

int main() {
    string s, t;
    cin >> s >> t;
    vector<vector<int>> ind(26);
    int n = s.size(), m = t.size();
    REP(i, n) ind[s[i] - 'a'].push_back(i);
    REP(i, n) ind[s[i] - 'a'].push_back(i + n);
    ll ans = 0;
    int p = 0;
    REP(i, m) {
        int c = t[i] - 'a';
        auto itr = lower_bound(ALL(ind[c]), p);
        if (itr == ind[c].end()) {
            puts("-1");
            return 0;
        }
        ans += *itr - p + 1;
        p = (*itr + 1) % n;
    }
    cout << ans << endl;
    getchar(); getchar();
}

Measured memory_bytes: 1724
/*
* @Author: Samson
* @Date:   2018-06-11 12:09:01
* @Last Modified by:   Samson
* @Last Modified time: 2018-06-11 15:37:51
*/
//   @URL : http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_10_B
#include<bits/stdc++.h>
#include<algorithm>
#include <cstdlib>
#define INF 0x3f3f3f3f
using namespace std;
typedef long long LL;
const int MAXN = 1e5+10;

int p[205],f[105][105];

int main(void)
{
	ios::sync_with_stdio(false); 
	//cin.tie(0);
	int n;
	cin>>n;
	for(int i = 1; i <= n; ++i)
		cin>>p[i-1]>>p[i];
	memset(f,INF,sizeof f);
	for(int i = 1; i <= n; ++i)	f[i][i] = 0;
	for(int i = 2; i <= n; ++i)
	{
		for(int l = 1; l <= n-i+1; ++l)
		{
			int r = i+l-1;
			f[l][r] = INF;
			for(int k = l; k <= r-1; ++k)
				f[l][r] = min(f[l][r], f[l][k]+f[k+1][r]+p[l-1]*p[k]*p[r]);
		}
	}
	cout<<f[1][n]<<'\n';
	return 0;
}



Measured memory_bytes: 3216
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <functional>
#include <vector>
#include <queue>
#include <map>

using namespace std;

typedef long long ll;

#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--)

int A, B, C, X, Y;

int main() {
  scanf("%d %d %d %d %d", &A, &B, &C, &X, &Y);
  ll total = 0;
  total = A * X + B * Y;
  if (2 * C < A + B) {
    int x = (A + B) - 2 * C;
    total -= x * min(X, Y);
  }
  if (X > Y && A > 2 * C) {
    int d = A - 2 * C;
    total -= (X - Y) * d;
  } else if(Y > X && B > 2 * C) {
    int d = B - 2 * C;
    total -= (Y - X) * d;
  }
  printf("%lld\n", total);
}


Measured memory_bytes: 256
import java.util.*;

public class Main
{
	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);
		int[] mt = new int[10];
			for(int i=0; i<10; i++)
			{
				mt[i] = sc.nextInt();
			}
				Arrays.sort(mt);
					for(int i=0; i<3; i++)
					{
						System.out.println(mt[9-i]);
					}
	}
}

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

int main() {
	string s, t;
	cin >> s >> t;
	string ans = "No";
	if (s.length()+1 == t.length()) {
		for (int i = 0; i < s.length(); i++) {
			if (s.at(i) == t.at(i)) {
				ans = "Yes";
			} else {
				ans = "No";
				break;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3632
#include<algorithm>//everybody dies in their nightmares
#include<iostream>
#include<cstring>
#include<cstdio>
#include<set>
#include<map>
#include<queue>
#include<deque>
#include<string>
#include<vector>
#include<sstream>
#include<cmath>
#include<unordered_set>
#include<unordered_map>
#define f(i,a,b) for(register int i=a;i<=b;++i)
#define ff(i,a,b) for(register int i=a;i>=b;--i)
#define debug(x) cerr << #x << " : " << x << " " << endl
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
const ll mod = 1e18 + 7;
const double tiaohe = 0.57721566490153286060651209;
ll oula(ll x) { ll res = x;f(i, 2, x / i) { if (x % i == 0) { res = res / i * (i - 1);while (x % i == 0) x /= i; } }if (x > 1) res = res / x * (x - 1);return res; }
ll quickmod(ll a, ll n, ll m) { ll s = 1;while (n) { if (n & 1) { s = s * a % m; }a = (a*a) % m;n = n / 2; }return s; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
void ex_gcd(ll a, ll b, ll &x, ll &y, ll &d) { if (!b) { d = a, x = 1, y = 0; } else { ex_gcd(b, a % b, y, x, d);y -= x * (a / b); } }
ll inv(ll t, ll p) { ll d, x, y;ex_gcd(t, p, x, y, d);return d == 1 ? (x % p + p) % p : -1; }
bool isPrime(ll x) { if (x == 2)return true;if (x % 2 == 0)return false;for (ll i = 2;i*i <= x;i++) if (x % i == 0)return false; return true; }
//double a = log(n) +tiaohe + 1.0 / (2 * n);
double eqa = (1 + sqrt(5.0)) / 2.0;
const int N = 2e5 + 5;
int t;

int main()
{
	ll x;
	while (cin >> x)
	{
		ll ans = 0;
		ans += x / 500;
		ans *= 1000;
		x %= 500;
		ans += (x / 5) * 5;
		cout << ans << endl;
	}
	return 0;
}



Measured memory_bytes: 256
// --------------------<optimizations>--------------------
#pragma GCC optimize("O3")

//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)\
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)\
#pragma GCC optimize("unroll-loops")

// -------------------</optimizations>--------------------
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define d long double
#define pii pair<int,int>
#define pb push_back
#define pf push_front
#define cases int tc;cin>>tc;while(tc--)
#define N 100003
#define M 3003
#define inf LLONG_MAX
#define hahaha ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
//int mod=1e9+7;
//int mod=998244353;
vector<int> g[N];
int ans=0;
bool vis[N];
int dp[N];

int dfs(int i,int cnt)
{
    if(dp[i]!=-1)
        return dp[i];
    vis[i]=true;
    ++cnt;
    int ma=0;
    
    for(auto j:g[i])
        ma=max(ma,dfs(j,0));
    cnt+=ma;
    return dp[i]=cnt;
}

signed main()
{
    hahaha
    
    fill(dp,dp+N,-1);
    int n,m;
    cin>>n>>m;
    int i,j,x,y;
    for(i=1;i<=m;++i)
        cin>>x>>y,g[x].pb(y);
    
    for(i=1;i<=n;++i)
        if(!vis[i])
            ans=max(ans,dfs(i,0));
    
    cout<<ans-1;
    
    
    return 0;
}


Measured memory_bytes: 8192
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		while( sc.hasNext()) {
			judge_Orthogonal();
		}

	}

	private static void judge_Orthogonal() {
		double[] p = new double[8];

		for (int i = 0; i < 8; i++) {
			p[i] = sc.nextDouble();
		}

		double x_1 = p[2] - p [0];
		double x_2 = p[6] - p [4];

		double y_1 = p[3] - p [1];
		double y_2 = p[7] - p [5];

		if (Math.abs(x_1 * x_2 + y_1 * y_2) < 1e-12) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}

	}

}


Measured memory_bytes: 30188
#include<bits/stdc++.h>
using namespace std;
#pragma optimize("-O3")
#define int long long int
#define f first
#define s second
#define pb push_back

main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n, k;
	cin>>n>>k;
	int arr[n];
	for(int i=0; i<n; i++){
		cin>>arr[i];
	}
	for(int i=k; i<n; i++){
		if(arr[i]>arr[i-k]){
			cout<<"Yes"<<endl;
		}
		else{
			cout<<"No"<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 5212
// --------------------<optimizations>--------------------
#pragma GCC optimize("O3")
//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)\
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)\
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>

using namespace std;

#define ll long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pii pair<ll,ll>
#define vpii vector<pair<ll,ll> >
#define F first
#define S second
#define ld long double
#define built __builtin_popcountll
#define mst(a,i) memset(a,i,sizeof(a))
#define all(x) x.begin(),x.end()
#define itit(it,a) for(auto it=(a).begin(); it!=(a).end(); it++)
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define repr(i,a,b) for(ll i=a; i>b; i--)
#define reprr(i,a,b) for(ll i=a; i>=b; i--)
#define pi 3.14159265358979323846264338327950288419716939937510582097494459230
ll max3(ll x,ll y,ll z) {return max(max(x,y),z);}
ll min3(ll x,ll y,ll z) {return min(min(x,y),z);}
const ll M=1e5+10,M2=1e6+10,mod=1e9+7,inf=1e17+10;
void add(int& a, int b) {a+=b;if(a>=mod){a-=mod;}}
#define trace1(x)			 	 cerr<<#x<<": "<<x<<endl
#define trace2(x, y)		 	 cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)		 	 cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)	 	 cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)	 cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
int X[] = {0, 1, 0, -1};
int Y[] = {-1, 0, 1, 0};
ll power(ll x,ll n){ll result=1;while(n>0){if(n%2==1)result=(result*x)%mod; x=((x%mod)*(x%mod))%mod;n=n/2;}return result;}

vector<ll> adj[M];
ll vis[M];
ll indeg[M];
ll dis[M];
ll n,m;

void dfs(ll v){
	vis[v]=1;
	for(auto u: adj[v]){
		dis[u]=max(dis[u],dis[v]+1);
		indeg[u]--;
		if(!indeg[u]) dfs(u);
	}
}

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin >> n >> m;
	rep(i,0,m){
		ll x,y;
		cin >> x >> y;
		adj[x].push_back(y);
		indeg[y]++;
	}
	for(ll i=1; i<=n; i++){
		if(!vis[i] && indeg[i]==0) dfs(i);
	}
	ll maxi=0;
	for(ll i=1; i<=n; i++) maxi=max(maxi,dis[i]);
	cout << maxi;
	return 0;
}


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

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

const int INF = 1001001001;

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


int main() {
  vector<ll> v(2);
  vector<ll> d(2);
  cin>>v[0]>>v[1];
  if (v[0]>0)v[0]--;
//  vector<ll>v(b+1);
  rep(i,2){

    ll c=v[i]%4;
    ll now=0;
    if (c==0) now=v[i];
    if (c==1) now=1;
    if (c==2) now=(v[i] ^ 1);
    d[i]=now;
  //  cout<<now<<endl;
  }

  ll ans=d[1]^d[0];
  cout<<ans;
}


Measured memory_bytes: 256
use std::cmp::*;
use std::collections::HashMap;
use std::io::*;
use std::str::FromStr;
use std::string::String;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();

    token.parse().ok().expect("failed to parse token")
}

#[derive(Eq, PartialEq, Clone, Debug)]
pub struct Rev<T>(pub T);

impl<T: PartialOrd> PartialOrd for Rev<T> {
    fn partial_cmp(&self, other: &Rev<T>) -> Option<std::cmp::Ordering> {
        other.0.partial_cmp(&self.0)
    }
}

impl<T: Ord> Ord for Rev<T> {
    fn cmp(&self, other: &Rev<T>) -> std::cmp::Ordering {
        other.0.cmp(&self.0)
    }
}

use std::collections::BinaryHeap;

#[derive(Clone)]
struct Edge {
    to: usize,
    cost: i32,
}

fn dijkstra(graph: &Vec<Vec<Edge>>, start: usize) -> Vec<i32> {
    let n = graph.len();
    let mut distance: Vec<i32> = vec![1_000_000_000; n];
    let mut visited: Vec<bool> = vec![false; n];
    let mut heap: BinaryHeap<Rev<(i32, usize)>> = BinaryHeap::new();
    heap.push(Rev((0, start))); //(cost, from)

    while !heap.is_empty() {
        let Rev((cost, from)) = heap.pop().unwrap();
        if visited[from] == true {
            continue;
        }
        visited[from] = true;
        distance[from] = cost;

        for e in &graph[from] {
            if distance[e.to] <= cost + e.cost {
                continue;
            }

            heap.push(Rev((cost + e.cost, e.to)));
        }
    }

    return distance;
}

fn main() {
    let (v, e, r): (usize, usize, usize) = (read(), read(), read());
    let mut graph: Vec<Vec<Edge>> = vec![Vec::new(); v];

    for _ in 0..e {
        let (s, t, d): (usize, usize, i32) = (read(), read(), read());
        graph[s].push(Edge { to: t, cost: d });
    }

    for ans in dijkstra(&graph, r) {
        if ans == 1_000_000_000 {
            println!("INF");
        } else {
            println!("{}", ans);
        }
    }
}



Measured memory_bytes: 26008
def sort_key(end):
    if end[1]:
        return end[0]*2+1
    return end[0]*2

n = int(input())
a = [int(i) for i in input().split()]
a.append(0)

ends = []
top = 0
up = True
for i in range(0, n+1):
    if not up and (i == n or a[i+1] > a[i]):
        ends.append((a[i], True))
        ends.append((top, False))
        up = True
    elif i != n and up and a[i+1] < a[i]:
        top = a[i]
        up = False
ends.sort(key=sort_key)
max_overlaps = 0
overlaps = 0
for end in ends:
    if end[1]:
        overlaps += 1
        if overlaps > max_overlaps:
            max_overlaps = overlaps
    else:
        overlaps -= 1
print(max_overlaps)


Measured memory_bytes: 17712
/*	
TELL YOUR CODE TO START BELIEVING IN GOD!!
THEY HATE US BECAUSE THEY AIN'T US
	ARIJIT SUR 
	@duke_knight
	@surcode
	IIT ISM 
 WORK SO HARD THAT YOUR IDOL BECOMES YOUR COMPETITOR 
 */
#include<bits/stdc++.h>
#define SIZE 100008
#define mod (ll)(1e9+7)
#define INF 0x3f3f3f3f
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define abs(a) (a>0?a:-a)
#define all(a) a.begin(),a.end()
#define pb push_back
#define sort(a) sort(all(a))
#define reverse(a) reverse(all(a))
#define input(a) {for(int i=0;i<a.size();i++) cin>>a[i];}
#define display(a) {for(int i=0;i<a.size();i++) cout<<a[i]<<" "; cout<<endl;}
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
typedef long long ll;
ll dp[200][SIZE];
ll knap(ll value[], int w[], int W, int i){
    if(W==0) return 0;
    if(i==-1) return 0;
    if(dp[i][W]!=-1) return dp[i][W];
    if(w[i] > W) return dp[i][W] = knap(value,w,W,i-1);
    return dp[i][W] = max(knap(value,w,W-w[i],i-1)+value[i], knap(value,w,W,i-1));

}
void solve(){
	int n,W;
    cin>>n>>W;
    ll value[n]; int w[n];
    for(int i=0;i<n;i++) cin>>w[i]>>value[i];
    printf("%lld\n",knap(value,w,W,n-1));
}
int main()
{
    IOS
    int t=1;
    //cin>>t;
    while(t--){
        memset(dp,-1,sizeof(dp));
    	solve();
    }
    return 0;
}

Measured memory_bytes: 160056
import Control.Monad
import Control.Applicative
import Data.List

main = do
  xs <- input (map read . words) :: IO [[Int]]
  mapM_ putStrLn $ solve xs

solve :: [[Int]] -> [String]
solve xs = map whatday $ takeWhile (\[a,_] -> a /= 0) xs

whatday :: [Int] -> String
whatday xs | w == 0 = "Wednesday"
           | w == 1 = "Thursday"
           | w == 2 = "Friday"
           | w == 3 = "Saturday"
           | w == 4 = "Sunday"
           | w == 5 = "Monday"
           | w == 6 = "Tuesday"
           | otherwise = "Rainyday"
  where w = yday xs `mod` 7

yday :: [Int] -> Int
yday [m,d] = sum (take m mds) + d

mds :: [Int]
mds = [0,31,29,31,30,31,30,31,31,30,31,30]

input :: (String -> a) -> IO [a]
input f = map f . lines <$> getContents 

Measured memory_bytes: 4068
# AtCoder Beginner Contest 152: B (2020/01/19)
a, b = map(str, input().split())
x = ''
for i in range(int(b)):
    x = x + a
y = ''
for i in range(int(a)):
    y = y + b
if x < y:
    print(x)
else:
    print(y)

Measured memory_bytes: 3060
#include <iostream>
using namespace std;
int main(void){
    int N,D,X,ans=0;
    cin>>N>>D>>X;
    int a[N];
    for(int i=0;i<N;i++){
        cin>>a[i];
    }
    for(int i=0;i<N;i++){
        for(int j=0;j<100;j++){
            if(j*a[i]+1<=D){
                ans++;
            }
        }
    }
    cout<<ans+X<<endl;
}


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

int f(ll X, ll Y) {
	for(int i = 1; 2 * i <= X; i++) {
		if(-f(X - 2 * i, Y + i) == 1) return 1;
	}
	for(int i = 1; 2 * i <= Y; i++) {
		if(-f(X + i, Y - 2 * i) == 1) return 1;
	}
	return -1;
}

int dp[10][10];

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

	ll X, Y;
	cin >> X >> Y;

	if(abs(X - Y) <= 1) {
		cout << "Brown" << endl;
	}
	else {
		cout << "Alice" << endl;
	}
}

Measured memory_bytes: 256
N, M = map(int, input().split())
A = sorted(list(map(int, input().split())), reverse = True)
x = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]
dp = [0 for i in range(N+1)]
INF = float('inf')
for i in range(1, N+1):
    t = -INF
    for a in A:
        if i >= x[a]:
            t = max(dp[i-x[a]] + 1, t)
    dp[i] = t

K = N
k = dp[N]
ans = ""
while k > 0:
    for a in A:
        xa = x[a]
        if K >= xa and k == dp[K-xa] + 1:
            ans += str(a)
            K -= xa
            k -= 1
            break
print(ans)

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

int main()
{
  int a, b, c;
  cin >> a >> b >> c;
  int k1 = a+b, k2 = b+c, k3 = a+c;
  cout << min( min(k1, k2), k3)   << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long N, ans=0, tate=0, yoko=0;
    cin >> N;	
    vector<long long> a(N);
    for(int i=0; i<N; i++){
	cin >> a[i];
    }
    sort(a.begin(), a.end(), greater<long long>());

    for(int i=0; i<N-1; i++){
	if(a[i] == a[i+1]){
	    if(tate == 0){
		tate = a[i];
		i++;
	    }else{
		yoko =a[i];
		break;
	    }
	}
    }

    cout << tate*yoko << endl;

}



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

using lli = long long int;

template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

template <class T>ostream &operator<<(ostream &o,const pair<T, T>&p)
{o<<"("<<p.first<<", "<<p.second<<")";return o;}

#define rep(i, n) for(lli i = 0; i < (lli)(n); i++)

const lli MOD = 1000000007LL;

lli modpow(lli a, lli n){
    lli res = 1;

    for(lli ai = a; n; n>>=1){
        if(1&n) res = (res*ai)%MOD;
        ai=(ai*ai)%MOD;
    }
    return res;
}

lli inv(lli n){
    return modpow(n, MOD-2);
}

lli modperm(lli n, lli k){
    lli res = 1;
    rep(i, k){
        res = (res*(n-i))%MOD;
    }
    return res;
}

lli modcomb(lli n, lli k){
    return (modperm(n, k)*inv(modperm(k, k)))%MOD;
}

lli posmod(lli n){
    lli res = n;
    res %= MOD;
    if(res < 0) res += MOD;
    return res;
}
#define MAX_N 100100
int n;
vector<pair<int, int>> p;
int x, l;

int main(void){
    cin >> n;
    rep(i, n){
        pair<int, int> pi;
        cin >> x >> l;
        pi.first = x-l;
        pi.second = x+l;
        p.push_back(pi);
    }
    sort(p.begin(), p.end(), [](auto const& a, auto const& b){
        if(a.second <= b.second) return true;
        else return false;
    });
    int res = 0;
    int t = -INT_MAX;
    rep(i, n){
        if(t <= p[i].first){
            t = p[i].second;
            res++;
        }
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 1400
#include <stdio.h>

int a[200010][30];

int after[200010][30];

int an = 0;

void con(long int z,long int x,int c){
    long int s;
    long int q;

    s = z/x;
    q = z%x;

    a[an][c]  = s;

    if(x != 1)
        con(q,x/2,c+1);
}

void xor(int a1[30], int a2[30],int a3[30]){
    int i;
    for(i=0;i<30;i++)
        a3[i] = (a1[i] + a2[i])%2; 
}

long int ans(int f[30])
{
    int x = 1;

    int i = 29;

    long int num = 0;

    while(i >= 0)
    {
        num += x*f[i];
        i--;
        x *= 2;
    }

    return num;
}


int main(){
    int n;
    scanf("%d",&n);

    int i,j; long int b;

    for(i=0;i<n;i++){
        scanf("%ld",&b);
        con(b,1024*1024*1024/2,0);
        an++;
    }

    for(i=1;i<n;i++)
        xor(a[i],after[0],after[0]);

    for(i=1;i<n;i++){
        xor(after[i],after[i-1],after[i]);
        xor(a[i],after[i],after[i]);
        xor(a[i-1],after[i],after[i]);
        }

    printf("%ld",ans(after[0]));
    for(i=1;i<n;i++)
        printf(" %ld",ans(after[i]));
    printf("\n");

    return 0;

}

Measured memory_bytes: 49400
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define zep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(ll i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

const ll MAX = 2e5+10;
long long fac[MAX], finv[MAX], inv[MAX];

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

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

ll f(ll x){
	if(x == 0){
		return 1;
	}
	ll res = f(x/2);
	if(x%2 == 0){
		return res*res%MOD;
	}
	return res*res*2%MOD;
}

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	ll n, a, b;
	cin >> n >> a >> b;
	
	ll ans = (f(n)+MOD-1)%MOD;
	
	COMinit();
	
	ll tmp = 1;
	rrep(i, n, n-b+1){
		tmp *= i;
		tmp %= MOD;
	}
	tmp *= finv[b];
	tmp %= MOD;
	ans += MOD-tmp;
	ans %= MOD;
	
	tmp = 1;
	rrep(i, n, n-a+1){
		tmp *= i;
		tmp %= MOD;
	}
	tmp *= finv[a];
	tmp %= MOD;
	ans += MOD-tmp;
	ans %= MOD;
	
	print(ans)
	return 0;
}

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

#define REP(i,n) for(int i=0;i<(n);i++)
#define REAP(i,a,n) for(int i=(a);i<(n);i++)
#define YES cout<<"Yes"<<endl
#define NO cout<<"No"<<endl
#define fr first
#define sc second
#define pb push_back
#define All(v) v.begin(),v.end()
typedef long long ll;

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

    int n,a,b;
    cin >> n >> a >> b;
    cout << ((n*a>b)?b:(n*a)) << endl;
    return 0;
}


Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <string>
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <utility>

using namespace std;
using ll=long long;

void solve(){
  int a,b;
  cin >> a >> b;
  if(a==b)
    {cout << "Draw" << endl;}
  else if(a==1)
    cout << "Alice" << endl;
  else if(b==1)
    cout << "Bob" << endl;
  else
    cout << (a>b?"Alice":"Bob")<<endl;
}

int main(){
  solve();
  return 0;
}


Measured memory_bytes: 256