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

// begin fast read template by CYJian (source: https://www.luogu.com.cn/paste/i11c3ppx)

namespace io {
	const int __SIZE = (1 << 21) + 1;
	char ibuf[__SIZE], *iS, *iT, obuf[__SIZE], *oS = obuf, *oT = oS + __SIZE - 1, __c, qu[55]; int __f, qr, _eof;
	#define Gc() (iS == iT ? (iT = (iS = ibuf) + fread (ibuf, 1, __SIZE, stdin), (iS == iT ? EOF : *iS ++)) : *iS ++)
	inline void flush () { fwrite (obuf, 1, oS - obuf, stdout), oS = obuf; }
	inline void gc (char &x) { x = Gc(); }
	inline void pc (char x) { *oS ++ = x; if (oS == oT) flush (); }
	inline void pstr (const char *s) { int __len = strlen(s); for (__f = 0; __f < __len; ++__f) pc (s[__f]); }
	inline void gstr (char *s) { for(__c = Gc(); __c < 32 || __c > 126 || __c == ' ';)  __c = Gc();
		for(; __c > 31 && __c < 127 && __c != ' '; ++s, __c = Gc()) *s = __c; *s = 0; }
	template <class I> inline bool gi (I &x) { _eof = 0;
		for (__f = 1, __c = Gc(); (__c < '0' || __c > '9') && !_eof; __c = Gc()) { if (__c == '-') __f = -1; _eof |= __c == EOF; }
		for (x = 0; __c <= '9' && __c >= '0' && !_eof; __c = Gc()) x = x * 10 + (__c & 15), _eof |= __c == EOF; x *= __f; return !_eof; }
	template <class I> inline void print (I x) { if (!x) pc ('0'); if (x < 0) pc ('-'), x = -x;
		while (x) qu[++ qr] = x % 10 + '0',  x /= 10; while (qr) pc (qu[qr --]); }
	struct Flusher_ {~Flusher_(){flush();}}io_flusher_;
} using io::pc; using io::gc; using io::pstr; using io::gstr; using io::gi; using io::print;

// end fast read template by CYJian

#define iter(i, a, b) for(int i=(a); i<(b); i++)
#define rep(i, a) iter(i, 0, a)
#define rep1(i, a) iter(i, 1, (a)+1)
#define log(a) cerr<<"\033[32m[DEBUG] "<<#a<<'='<<(a)<<" @ line "<<__LINE__<<"\033[0m"<<endl
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define pb push_back
#define mp make_pair
 
using ll=long long;
using pii=pair<int, int>;
//#define int ll
const int MOD = 1000000007;

int tj[4005][3];
int seq[4005];

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int N; cin >> N;
	rep1(i, N) {
		char c; cin >> c;
		if(c == 'R') seq[i] = 1;
		else if(c == 'G') seq[i] = 2;
		else seq[i] = 3;
		tj[i][0] = tj[i-1][0] + (c == 'R');
		tj[i][1] = tj[i-1][1] + (c == 'G');
		tj[i][2] = tj[i-1][2] + (c == 'B');
	}
	ll ans = 0;
	rep1(i, N) {
		iter(j, i+1, N+1) {
			if(seq[i] == seq[j]) continue;
			int v = 5 - seq[i] - seq[j];
			ans += tj[N][v] - tj[j][v];
			if(2*j-i <= N && seq[2*j-i] == v+1) ans--;
		}
	}
	print(ans);
}


Measured memory_bytes: 3672
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
    out << "{" << p.first << ", " << p.second << "}";
    return out;
}

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


/* 曜日計算 (0日曜日 - 6土曜日)　*/
int Zeller(ll y, int m, int d){
  if(m <= 2){
    y--;
    m += 12;
  }
  return (y + y/4 - y/100 + y/400 + (13*m + 8)/5 + d) % 7;
}

char dayoftheweek[7][16] = {
  "Sunday",
  "Monday",
  "Tuesday",
  "Wednesday",
  "Thursday",
  "Friday",
  "Saturday"
};

int main(){
  while (1) {
    int y = 2004, m, d;

    scanf("%d%d", &m, &d);

    if (m == 0) break;

    puts(dayoftheweek[Zeller(y, m, d)]);
  }

  return 0;
}



Measured memory_bytes: 3048
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iomanip>
using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=(b-1);i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

ll dp[100001];

int main() {
  ll n;
  cin>>n;
  rep(i,0,100001){
    dp[i] = 1000000000;
  }
  dp[n] = 0;
  per(i,0,n+1){
    rep(j,1,20){
      ll a = pow(6,j);
      if(i-a>=0)dp[i-a] = min(dp[i-a],dp[i]+1);
    }
    rep(j,1,20){
      ll a = pow(9,j);
      if(i-a>=0)dp[i-a] = min(dp[i-a],dp[i]+1);
    }
  }
  ll mn = 1000000000;
  rep(i,0,100001){
    mn = min(mn,dp[i]+i);
  }
  cout << mn << endl;
  return 0;
}

Measured memory_bytes: 1280
using System;
using System.Collections.Generic;
using System.Linq;

namespace contest_Csharp
{
    class Program
    {
        static long power(long a, long b, long modulo)
        {
            long result = 1;
            long buff = a;
            for (long i = 1; i <= b; i *= 2)
            {
                result = result * ((b / i % (2) == 1) ? buff : 1) % modulo;
                buff = (buff * buff) % modulo;
            }
            return result % modulo;
        }
        static void Main(string[] args)
        {
            var vals = Console.ReadLine().Split(' ')
                .Select(x => int.Parse(x)).ToList();
            int N = vals[0];
            int M = vals[1];
            int Q = vals[2];
            var pairs = new List<(int a, int b,int c,int d)>();
            for (int i = 0; i < Q; i++)
            {
                var Qvals = Console.ReadLine().Split(' ')
                .Select(x => int.Parse(x)).ToList();
                pairs.Add((Qvals[0], Qvals[1], Qvals[2], Qvals[3]));
            }
            Func<IEnumerable<int>, int, int,int> dfs = null;

            dfs = (vec, last ,size) =>
            {
                if (size==N)
                {
                    var V = vec.ToList();
                    return pairs.Where(p => V[p.b - 1] - V[p.a-1] == p.c).Sum(p => p.d);
                }
                return Enumerable.Range(last,M-last+1).Max(x => dfs(vec.Concat(new int[]{ x }), x,size+1));
            };
            Console.WriteLine(dfs(new int[] { 1 }, 1, 1));
        }



    }


}


Measured memory_bytes: 41172
from collections import deque
import sys
sys.setrecursionlimit(10 ** 9)

N, M = map(int, input().split())
path = [list(map(int, input().split())) for i in range(M)]

edges = [[] for j in range(N+1)]
for p in path:
    x, y = p
    edges[x].append(y)
    edges[y].append(x)

que = deque([])
dic = {1: 0}
def bfs(now):
    e = edges[now]
    for q in e:
        if not q in dic:
            dic[q] = now
            que.append(q)
    try:
        n = que.popleft()
        bfs(n)
    except IndexError:
        pass

bfs(1)

if len(dic) != N:
    print("No")
else:
    print('Yes')
    dic_sort = sorted(dic.items())
    for elem in dic_sort:
        if elem[0] != 1:
            print(elem[1])



Measured memory_bytes: 146016
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <numeric>
typedef long long Int;
#define rep(i,a,b) for(Int i=a;i<b;++i)
#define rrep(i,a,b) for(Int i=a;i>=b;--i)
using namespace std;

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

    int N, D, X; cin >> N >> D >> X;
    int res = X;
    rep(i, 0, N) {
      int A; cin >> A;
      res += 1 + (D-1)/A;
    }
  
    cout << res << endl;
}


Measured memory_bytes: 256
var fs = require("fs");
var line = fs.readFileSync("/dev/stdin");
var N = Number(line);
var res = 0;

for (let i = 1; i <= N; i++) {
  let n = Math.floor(N / i);
  res += (i * n * (n + 1)) / 2;
}

console.log(res);


Measured memory_bytes: 33220
import sys
input = sys.stdin.readline

N, M, Q = map(int, input().split())
abcd = [tuple(map(int, input().split())) for _ in range(Q)]

def dfs(i, A):
    if i == N:
        # calc score
        score = 0
        for a, b, c, d in abcd:
            if A[b-1] - A[a-1] == c:
                score += d
        return score

    ret = 0
    for n in range(A[-1], M+1):
        ret = max(ret, dfs(i + 1, A + [n]))
    return ret

ans = 0
for i in range(1, M+1):
    ans = max(ans, dfs(0, [i]))

print(ans)


Measured memory_bytes: 75936
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <limits>
#include <climits>
#include <utility>
#include <algorithm>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

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

    int R, S, P;
    cin >> R >> S >> P;

    string T;
    cin >> T;

    vector<vector<ll>> dp(N, vector<ll>(3, 0));

    for (int i = 0; i < K; ++i) {
        if (T[i] == 'r') {
            dp[i][2] = P;
        }
        if (T[i] == 's') {
            dp[i][0] = R;
        }
        if (T[i] == 'p') {
            dp[i][1] = S;
        }
    }

    for (int i = K; i < N; ++i) {
        dp[i][2] = max(dp[i-K][0], dp[i-K][1]);
        if (T[i] == 'r') {
            dp[i][2] += P;
        }

        dp[i][0] = max(dp[i-K][1], dp[i-K][2]);
        if (T[i] == 's') {
            dp[i][0] += R;
        }

        dp[i][1] = max(dp[i-K][2], dp[i-K][0]);
        if (T[i] == 'p') {
            dp[i][1] += S;
        }
    }

    ll ans = 0;
    for (int i = N-K; i < N; ++i) {
        ans += max(max(dp[i][0], dp[i][1]), dp[i][2]);
    }

    cout << ans << endl;

    return 0;
}


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

int main() {
    string s;
    cin >> s;
    int32_t l = s.size();

    if (l > 1) {
        int32_t answer = 0;
        for (int32_t i = 1; i <= l - 1; i++) {
            if (s.at(i - 1) != s.at(i)) {
                answer++;
            }
        }
        cout << answer << endl;
    } else {
        cout << 0 << endl;
    }
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>
#include <iomanip>
#include <random>

#define FOR_LT(i, beg, end) for (int i = (int)(beg); i < (int)(end); i++)
#define FOR_LE(i, beg, end) for (int i = (int)(beg); i <= (int)(end); i++)
#define FOR_DW(i, beg, end) for (int i = (int)(beg); (int)(end) <= i; i--)
#define REP(n)              for (int repeat_index = 0; repeat_index < (int)n; repeat_index++)

using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(20);

	int64_t n; cin >> n;

	vector<vector<int>> map(n + 1);
	vector<vector<int>> map2(n + 1);

	FOR_LT(i, 0, n - 1) {
		int a, b; cin >> a >> b;
		if (a > b) swap(a, b);
		map[a].push_back(b);
		map2[b].push_back(a);
	}

	int64_t ans = 0;
	vector<int64_t> pro(n + 1);
	int64_t t = 0;
	FOR_LE(i, 1, n) {
		//cout << t << " " << i << " " << pro[i] << endl;
		t += i;
		t -= pro[i];
		ans += t;
		//cout << ans << " " << t << endl;
		for (auto b : map[i]) {
			pro[b] += i;
		}
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 26544
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int a, b;
    cin >> a >> b;
    printf("%.10lf\n", a*b/3.305785);
    return 0;
}


Measured memory_bytes: 3224
_, *A = map(lambda x: int(x) - 1, open(0).read().split())
A = list(A)
pos = 0
cnt = 1
for i in range(10 ** 5 + 1):
    pos = A[pos]
    if pos == 1:
        print(cnt)
        break
    cnt += 1
else:
    print(-1)


Measured memory_bytes: 14068
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.Set;
import java.util.HashMap;
import java.util.TreeSet;
import java.util.ArrayList;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ABC_113_C solver = new ABC_113_C();
        solver.solve(1, in, out);
        out.close();
    }

    static class ABC_113_C {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int m = in.nextInt();

            List<Integer> years = new ArrayList<Integer>();

            String[] answerList = new String[m];
            Map<Integer, Integer> map = new HashMap<Integer, Integer>();
            Set<Integer> sortedYears = new TreeSet<Integer>();
            int[] townCity = new int[m];
            int[] city = new int[n];

            for (int i = 0; i < m; i++) {
                int p = in.nextInt();
                int year = in.nextInt();
                answerList[i] = String.format("%06d", p);
                townCity[i] = p;
                map.put(year, i);
//            years.add(year);
                sortedYears.add(year);
            }


            for (int year : sortedYears) {
                int pNumber = map.get(year);
//            int pNumber = years.indexOf(year);
                answerList[pNumber] += String.format("%06d", city[townCity[pNumber] - 1] + 1);
                city[townCity[pNumber] - 1]++;
            }

            for (String answer : answerList) {
                out.println(answer);
            }

        }

    }
}



Measured memory_bytes: 184200
package main

import (
	"fmt"
	"os"
	"strings"
	"sync"
	"bufio"

)

var h,w int

func main() {
	fmt.Scanf("%d %d", &h, &w)

	reader := bufio.NewScanner(os.Stdin)

	grid := make([][]string, h)
	for i := 0; i<h; i++ {
		reader.Scan()
		grid[i] = strings.Split(reader.Text(), "")
	}


	left := [2000][2000]int{}
	right := [2000][2000]int{}
	up := [2000][2000]int{}
	down := [2000][2000]int{}

	wg := sync.WaitGroup{}
	wg.Add(4)

	go func() {
		for i := 0; i < h; i++ {
			cnt := 0
			for j := 0; j < w; j++ {
				if grid[i][j] == "#" {
					cnt = 0
					left[i][j] = 0
					continue
				}
				cnt++
				left[i][j] = cnt
			}
		}
		wg.Done()
	}()

	go func() {
		for i := 0; i < h; i++ {
			cnt := 0
			for j := w - 1; j >= 0; j-- {
				if grid[i][j] == "#" {
					cnt = 0
					right[i][j] = 0
					continue
				}
				cnt++
				right[i][j] = cnt
			}
		}
		wg.Done()
	}()

	go func() {
		for j := 0; j < w; j++ {
			cnt := 0
			for i := 0; i < h; i++ {
				if grid[i][j] == "#" {
					cnt = 0
					up[i][j] = 0
					continue
				}
				cnt++
				up[i][j] = cnt
			}
		}
		wg.Done()
	}()

	go func() {
		for j := 0; j < w; j++ {
			cnt := 0
			for i := h - 1; i >= 0; i-- {
				if grid[i][j] == "#" {
					cnt = 0
					down[i][j] = 0
					continue
				}
				cnt++
				down[i][j] = cnt
			}
		}
		wg.Done()
	}()

	wg.Wait()

	max := 0
	for i := 0; i<h; i++ {
		for j := 0; j<w; j++ {
			if grid[i][j] != "#" {
				current := left[i][j] +right[i][j]+up[i][j]+down[i][j]-3
				if current > max {
					max = current
				}
			}
		}
	}

	fmt.Println(max)
}



Measured memory_bytes: 200192
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define size_of_array(array) (sizeof(array)/sizeof(array[0]))
#define MAX 100005
#define DEBUG 0 
using ll =long long;
using namespace std;
using Graph=vector<vector<int>>;

int main(){
    int l;
    cin>>l;
    cout<<fixed<<setprecision(6)<<pow(l,3)/27<<endl;
}


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

int main() {
	int n, num;
	double p;

	cin >> n;

	if(n%2 == 0) {
		num = n/2;
	}else{
		num = n/2+1;
	}
	p = (double)num/(double)n;
	cout << fixed << setprecision(10) << p << endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main(int argc, const char * argv[])
{

    char sent[200];
    long len;
    long halflen;
    int i;
    int cnt = 0;
    int pal = 0;
    while (~scanf("%s", sent)) {
        len = strlen(sent);
        halflen = len / 2;
        for (i = 0; i < halflen; i++) {
            if (sent[i] == sent[len - i - 1]) {
                cnt++;
            }
            else break;
        }
        if (halflen == cnt) {
            pal++;
        }
        cnt = 0;
    }
    printf("%d\n", pal);
    return 0;
}

Measured memory_bytes: 540
A=[int(input()) for i in range(5)]
from itertools import permutations, combinations,combinations_with_replacement,product
L = list(permutations(range(5), 5))
ans = sum(A)+100
for i in L:
  time = 0
  for j in i:
    if time%10 !=0:
      time += (10-time%10)
    time += A[j]
  ans = min(ans ,time)
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main(){
int a,s,d,f,g;
cin>>a>>s>>d>>f>>g;
if(d-g>=0 && d+g<=a && f-g>=0 && f+g<=s){
cout<<"Yes"<<endl;
}
else{
cout<<"No"<<endl;
}
}


Measured memory_bytes: 3096
#include<iostream>
#include<vector>
#include<utility>
#include<string>
#include<map> // pair
#include<algorithm>
using namespace std;
using ll = long long;
ll func(ll a,ll b){
  ll r = a % b;
  if(r==0)return b;
  return func(b,r);
}
int main(){
  ll n,x,y;
  cin >> n;
  pair<ll,ll> p[n];
  for(ll i=0;i<n;i++){
    cin >> x >> y;
    p[i] = make_pair(y,x);
  }
  sort(p,p+n);
  ll sum=0;
  bool can = true;
  for(ll i=0;i<n;i++){
    sum += p[i].second;
    if(sum > p[i].first){
      can = false;
      break;
    }
  }
  if(can){
    cout << "Yes";
  }else{
    cout << "No";
  }
}


Measured memory_bytes: 3328
#include <stdio.h>

int main(void) {

	int n;
	scanf("%d",&n);
	int max = -1e19;

	int min = 1e19;

	long long int sum = 0;

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

		int temp;

		scanf("%d",&temp);

		max = (max<temp)?temp:max;

		min = (min>temp)?temp:min;

		sum += temp;

	}

	printf("%d %d %lld\n",min,max,sum);

	return 0;

}



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

int main(){
	int x,a;
	cin >> x >> a;
	
	if (x < a){
		cout << 0 << endl;
	}else{
		cout << 10 << endl;
	}
	
	
}



Measured memory_bytes: 256
import math
import numpy as np
def main(N, S):
    e_cum_list = []
    w_cum_list = []
    e_sum = 0
    w_sum = 0
    for char in S:
        if char == 'E':
            e_sum +=1
        else:
            w_sum +=1
        e_cum_list.append(e_sum)
        w_cum_list.append(w_sum)

    min_val = 10**6
    for i in range(N):
        
        if i - 1 < 0:
            w_cum = 0
        else:
            w_cum = w_cum_list[i - 1]
        
        e_cum = e_cum_list[-1] - e_cum_list[i]

        ew_sum = e_cum + w_cum
        if ew_sum < min_val:
            min_val = ew_sum

    print(min_val)




if __name__ == "__main__":
    N = int(input())
    S = input()
    
    main(N, S)


Measured memory_bytes: 28632
import sys
input = sys.stdin.readline

A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ans = min(a) + min(b)
for i in range(M):
    x, y, c = map(int, input().split())
    ans = min(ans, a[x-1] + b[y-1] - c)
print(ans)




Measured memory_bytes: 64800
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define inf 1e9
#define mod 1000000007
#define ff first
#define ss second

void solve()
{
	int n, m, k;
	cin >> n >> m >> k;
	vector<int> A(n + 1, 0), B(m + 1, 0);
	for (int i = 1; i <= n; i++)
	{
		cin >> A[i];
		A[i] += A[i - 1];
	}
	for (int i = 1; i <= m; i++)
	{
		cin >> B[i];
		B[i] += B[i - 1];
	}

	int ans = 0;
	for (int i = 0; i <= n; i++)
	{
		int rem = k - A[i];
		if (rem < 0)
			continue;

		int idx = lower_bound(B.begin(), B.end(), rem) - B.begin();
		if (idx > m or B[idx] > rem)
			idx--;
		ans = max(ans, i + idx);
	}
	cout << ans << "\n";

}

signed main()
{
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	solve();
	return 0;
}


Measured memory_bytes: 6364
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws Exception {

//    	File file = new File("test.txt");
//    	Scanner sc = new Scanner(file);
    	Scanner sc = new Scanner(System.in);
    	String S = sc.next();
    	sc.close();
    	boolean ans = false;
    	char[] chars = S.toCharArray();
    	if(chars[2] == chars[3] && chars[4] == chars[5]){
    		ans = true;
    	}
    	System.out.println(ans?"Yes":"No");
    }

}

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

typedef vector<double> vd;
#define rep(i, n) for(int i=0; i<n; i++)

static const double INF = 1E8;
struct Edge{int x, y; double d, c;};
int n, m;
int s, g;
int x, y;
double dd, c;
double d[33][33][33];
vector<Edge> G[33];
vd tmp(4);

int main()
{
  while(cin >> n >> m, n){
    cin >> s >> g;
    rep(i, 33) G[i].clear();
    rep(i, m){
      cin >> x >> y >> dd >> c;
      G[x].push_back((Edge){x, y, dd, c});
      G[y].push_back((Edge){y, x, dd, c});
    }
    rep(i, 33) rep(j, 33) rep(k, 33) d[i][j][k] = INF;    
    priority_queue<vd, vector<vd>, greater<vd> > que;
    tmp[0] = 0;  tmp[1] = 0;  tmp[2] = s;  tmp[3] = 0;
    que.push(tmp);
    while(!que.empty()){
      vd top = que.top();
      double cost = top[0];
      int v = top[1];
      int hx = top[2];
      int px = top[3];
      tmp[3] = hx;
      if(hx == g && v == 1){
        printf("%.15f\n", cost);
        break;
      }
      que.pop();
      if(d[hx][px][v] < cost) continue;
      rep(i, G[hx].size()) if(G[hx][i].y != px){
        Edge e = G[hx][i];
        tmp[2] = e.y;
        for(int k = -1; k <= 1; k++){
          if(v + k > 0 && v + k <= e.c && d[e.y][hx][v + k] > cost + e.d / (v + k)){
            d[e.y][hx][v + k] = cost + e.d / (v + k);
            tmp[1] = v + k;
            tmp[0] = d[e.y][hx][v + k];
            que.push(tmp);
          }
        }
      }
    }
    if(que.empty()) puts("unreachable");
  }

  return 0;
}

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

#define ALL(v) (v).begin(),(v).end()

using namespace std ;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;




int main()
{
  string s ;
  cin >> s ;
  
  int n = s.size() ;
  vector<char> vec(n) ;
    
  rep(i, n){
    vec.at(i) = s.at(i) ;
  }
  sort(vec.begin(),vec.end()) ;
  
  if(vec.at(0)=='a' && vec.at(1)=='b' && vec.at(2)=='c'){
    cout <<"Yes"<<endl ;
  }
  else{
    cout <<"No"<<endl ;
  }
    
    return 0 ;
}

/*　吾輩はやれば出来る子である。 
　　　　∩∩ 
　　　（´･ω･） 
　　 ＿|　⊃／(＿＿_ 
　／　└-(＿＿＿_／ 
　￣￣￣￣￣￣￣ 
　やる気はまだない 

　　 ⊂⌒／ヽ-、＿_ 
　／⊂_/＿＿＿＿ ／ 
　￣￣￣￣￣￣￣　　*/



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

int main(){
	int N;
	int K;
	cin>>N>>K;
	long long ans;
	ans=pow(N/K,3);
	if(K%2==0){
		ans+=pow((N+K/2)/K,3);
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 768
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Map;
import java.util.TreeMap;

public class Main {

    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

    public static void main(String... args) throws IOException {
        String[] params = br.readLine().split(" ");
        int n = Integer.parseInt(params[0]);
        long k = Long.parseLong(params[1]);

        Map<Integer, Long> inData = new TreeMap<>();
        for (int i = 0; i < n; i++) {
            String[] data = br.readLine().split(" ");
            int key = Integer.parseInt(data[0]);
            long val = Long.parseLong(data[1]);
            if (inData.get(key) == null) {
                inData.put(key, val);
            } else {
                inData.put(key, inData.get(key) + val);
            }
        }
        long curCount = 0;
        for (Map.Entry<Integer, Long> entry : inData.entrySet()) {
            curCount += entry.getValue();
            if (k <= curCount) {
                System.out.println(entry.getKey());
                break;
            }
        }
    }
}

Measured memory_bytes: 47604
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define N 100005
#define MOD 1000000007
#define dd double
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;



int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
//ios_base& scientific (ios_base& str);
ll n;
cin >> n;
string arr[n];
map<string, int> map1;
for(int i =0; i<n; i++){
	string str;
	cin >> str;
	sort(str.begin(), str.end());
	map1[str]++;
}
ll sum =0;
for(auto i : map1){
	ll num = i.second;
	sum+=(num*(num-1))/2;
}
cout << sum << endl;
return 0;
}



Measured memory_bytes: 12032
#include <stdio.h>
#include <stdlib.h>
int compare(const void *a,const void *b){
    if(*(int *)a>*(int *)b)return 1;
    return -1;
}
int main()
{
    int n;
    scanf("%d",&n);
    int d[n];
    for(int i=0;i<n;i++){
        scanf("%d",&d[i]);
    }
    qsort(d,n,sizeof(int),compare);
    int m;
    scanf("%d",&m);
    int t[m];
    for(int i=0;i<m;i++){
        scanf("%d",&t[i]);
    }
    qsort(t,m,sizeof(int),compare);
    int k=0;
    for(int i=0;i<m;i++){
        for(;k<n;k++){
            if(t[i]==d[k]){
                //printf("t[%d] found@d[%d]\n",i,k);
                k++;
                break;
            }
            if(d[k]>t[i]||n-1-k<m-1-i){
                printf("NO");
                return 0;
            }
        }
    }
    printf("YES");

    return 0;
}


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

namespace ABC_Training
{

    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var h = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

            var result = true;
            for (int i = 0; i < n - 1; i++)
            {
                var right = n - i - 1;
                var left = right - 1;
                var diff = h[right] - h[left];
                if(diff >= 0)
                {
                    continue;
                }else if (diff == -1)
                {
                    h[left] -= 1;
                }
                else
                {
                    result = false;
                }
            }
            Console.WriteLine(result ? "Yes" : "No");
        }
    }
}


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

# define C continue;
# define R return

# define D double
# define I insert
# define ll long long
# define ld long double

# define ull unsigned long long
# define ui unsigned int

# define pb push_back
# define pf push_front

# define vi vector < int >
# define vc vector < char >
# define vs vector < string >
# define vb vector < bool >
# define vd vector < D >
# define vll vector < ll >
# define vull vector < ull >
# define vld vector < ld >
# define PQ priority_queue

# define vvi vector < vector < int > >
# define vvb vector < vector < bool > >
# define vvc vector < vector < char > >
# define vvs vector < vs >
# define vvll vector < vector < ll > >
# define vvd vector < vector < D > >
# define vvld vector < vector < ld > >

# define all(v) (v).begin() , (v).end()
# define allrev(v) (v).rbegin() , (v).rend()
# define allcomp(v) v.begin() , v.end() , comp
# define allrevcomp(v) v.rbegin() , v.rend() , comp

# define pii pair < int , int >
# define pll pair < ll , ll >
# define pld pair < ld , ld >
# define pDD pair < D , D >

# define vpld vector < pld >
# define vpii vector < pii >
# define vpll vector < pll >
# define vpDD vector < pDD >

# define vvpii vector < vector < pii > >
# define F first
# define S second
# define mp make_pair

# define dist(a,b,p,q) sqrt((p-a)*(p-a) + (q-b)*(q-b))

# define pp(n) printf("%.10Lf",n);
# define line cout<<"\n";
# define fast ios_base::sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0);

string vow = "aeiou";
int month[] = {-1, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

const int dxhorse[] = {-2, -2, -1, -1, 1, 1, 2, 2};
const int dyhorse[] = {1, -1, 2, -2, 2, -2, 1, -1};

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

const ld pie = 3.1415926535897932384626 ;
const ll mod = 1e9 + 7 ;

/// Tip : If a and b are positive integers ; we may say - ceil (a/b) = 1 + floor ( (a-1)/b ) .

void solve ( int test_case )
{
    ld L ;
    cin >> L ;

    ld den = 27 ;
    ld ans = L * L * L ;
    ans /= den ;

    pp ( ans ) ;
}

int main()
{
    int t = 1;
    // cin >> t;

    for ( int i=1 ; i <= t ; i ++ ) solve ( i ) ;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, pair<ll, ll> > P3;
const ll MOD = 1000000007;
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;
const int MAX_N = int(1e5 + 5);
const double EPS = 1e-10;
const int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define ALL(v) (v).begin(), (v).end()


int main() {
    int n, h, w;
    cin >> n >> h >> w;
    cout << (n-h+1)*(n-w+1) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
#define int long long int
const int INF = 1001001001001001LL;
const int MOD = 1000000007;

int di[] = {-1, 0, 1, 0, -1, 1, 1, -1};
int dj[] = {0, 1, 0, -1, 1, 1, -1, -1};

signed main(){
    
    while(1){
        int n; cin >> n;
        if(!n) break;
        vector<int> r(n);
        vector<int> w(n);
        vector<pair<int, int>> vec(n);
        for(int i = 0; i < n; i++){
            cin >> r[i] >> w[i];
            vec[i] = pair<int, int>(r[i], w[i]);
        }

        sort(vec.begin(), vec.end());
    
        int longest = vec[n - 1].first;
        int sumOfOthers = 0;
        for(int i = 0; i < n - 1; i++) sumOfOthers += vec[i].first;

        int ans = 0;
        for(int i = 0; i < n; i++) ans += vec[i].first + vec[i].second;
        
        if(longest <= sumOfOthers){
            // みっちりやる
        }else{
            int rest = longest - sumOfOthers;
            vector<int> v(n - 1);
            for(int i = 0; i < n - 1; i++) v[i] = vec[i].second;

            ans += rest;

            vector<vector<bool>> dp(n, vector<bool> (rest + 1, false));
            dp[0][0] = true;
            for(int i = 0; i < n - 1; i++){
                for(int j = 0; j <= rest; j++){
                    if(!dp[i][j]) continue;
                    int nj = j + v[i];
                    dp[i + 1][j] = true;
                    if(nj <= rest) dp[i + 1][nj] = true;
                }
            }

            int val = 0;
            for(int j = 0; j <= rest; j++) if(dp[n - 1][j]) val = j;
            ans -= val;
        }
        cout << ans << endl;
        
    }
    return 0;
}



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

int main() {
    int N,X,Y;
    cin >> N >> X >> Y;
    --X,--Y;
    vector<int> ans(N+1,0);
    rep(i,N)for(int j=i+1;j<N;j++){
        int d1 = j-i;
        int d2 = 10000000;
        if(i<=X&&Y<=j){
            d2 = X-i + j-Y + 1;
        } else if(X<i&&Y<=j){
            d2 = i-X + j-Y + 1;
        } else if(i<=X&&j<Y){
            d2 = X-i + Y-j + 1;
        } else if(X<i&&j<Y){
            d2 = i-X + Y-j + 1;
        }
        ++ans[min(d1,d2)];
    }
    for(int i=1;i<=N-1;i++)cout << ans[i] << endl; 
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
    ll n, k;
    cin>>n>>k;
    int a[n];
    rep(i,n)cin>>a[i];
    ll ans = 0;
    rep(i,n){
        ll cnt1 = 0, cnt2 = 0;
        rep(j,i){
            if(a[j]>a[i])++cnt1;
        }
        rep(j,n){
            if(a[j]>a[i])++cnt2;
        }
        ans += cnt1 * k +(k*(k-1)/2)%mod*cnt2%mod;
        ans %=mod;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 384
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
class Simple {
    readonly int[] dirY = new int[] { 0, 1, 1, 1, 0, -1, -1, -1 };
    readonly int[] dirX = new int[] { 1, 1, 0, -1, -1, -1, 0, 1 };
    int H, W;
    string[] S;
    void Solve() {
        //input
        H = io.Int;
        W = io.Int;
        S = new string[H];
        for (int i = 0; i < H; ++i)
            S[i] = io.String ;
        //cal
        var ans = new int[H, W];
        for(int i = 0; i < H; ++i) {
            for(int j = 0; j < W; ++j) {
                var cy = i;
                var cx = j;
                if (S[cy][cx] == '#') {
                    ans[cy, cx] = -1;
                    continue;
                }
                for(int k = 0; k < 8; ++k) {
                    var ny = cy + dirY[k];
                    var nx = cx + dirX[k];
                    if (0 <= ny && ny < H && 0 <= nx && nx < W) 
                        if (S[ny][nx] == '#') 
                            ans[cy, cx]++;
                }
            }
        }
        //ret
        for(int i = 0; i < H; ++i) {
            for(int j = 0; j < W; ++j) 
                Console.Write(ans[i, j] >= 0 ? ans[i, j].ToString() : "#");            
            Console.WriteLine();
        }
    }
    SimpleIO io = new SimpleIO();
    public static void Main(string[] args) { new Simple().Stream(); }
    void Stream() {
        Solve();
        io.writeFlush();
    }
}
class SimpleIO {
    SimpleIO(bool isAutoFlush = false) { this.isAutoFlush = isAutoFlush; }
    string[] nextBuffer;
    int BufferCnt;
    char[] cs = new char[] { ' ' };
    public bool isAutoFlush;
    StreamWriter sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
    public SimpleIO() {
        nextBuffer = new string[0];
        BufferCnt = 0;
        if (!isAutoFlush) Console.SetOut(sw);
    }
    public string Next() {
        if (BufferCnt < nextBuffer.Length) return nextBuffer[BufferCnt++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        nextBuffer = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        BufferCnt = 0;
        return nextBuffer[BufferCnt++];
    }
    public string String => Next();
    public char Char => char.Parse(String);
    public int Int => int.Parse(String);
    public long Long => long.Parse(String);
    public double Double => double.Parse(String);
    public void writeFlush() { Console.Out.Flush(); }
}


Measured memory_bytes: 11220
//from PKU1125
#define M 299
double dist[M][M],d;
next[M][M],x[M],y[M];
main(){
	int a,b,k,n,i,j;
	for(;scanf("%d",&n),n;){
		/*initialize*/
		for(i=1;i<=n;i++)scanf("%d",&a),scanf("%d%d",x+a,y+a);
		for(i=1;i<=n;i++)for(j=1;j<=n;next[i][j]=j,j++)
			dist[i][j]=(d=hypot(x[i]-x[j],y[i]-y[j]))<50.1?d:M;

		{/*warshall-floyd*/
			int k,i,j;
			for(k=1;k<=n;k++)
				for(i=1;i<=n;i++)
					for(j=1;j<=n;j++){
						if(dist[i][j]>dist[i][k]+dist[k][j])
							dist[i][j]=dist[i][k]+dist[k][j],next[i][j]=next[i][k];
					}
		}

		{/*query*/
			for(scanf("%d",&k);k;k--){
				scanf("%d%d",&a,&b);
				if(dist[a][b]>=M)puts("NA");
				else{
					for(j=a;j!=b;j=next[j][b])printf("%d ",j);
					printf("%d\n",b);
				}
			}
		}
	}exit(0);
}

Measured memory_bytes: 980
#include <iostream>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <fstream>
#include <bitset>
#include <queue>
#include <stack>
#include <deque>
#include <complex>
#include <iomanip>
#include <stdio.h>
#include <string.h>
#include <random>
#include <functional>

using std::cin;
using std::cout;
using std::cerr;
using std::endl;

using std::map;
using std::set;
using std::bitset;
using std::vector;
using std::string;
using std::multimap;
using std::multiset;
using std::deque;
using std::queue;
using std::stack;
using std::pair;
using std::iterator;

using std::sort;
using std::stable_sort;
using std::reverse;
using std::max_element;
using std::min_element;
using std::unique;
using std::ios_base;
using std::swap;
using std::fill;

using std::setprecision;
using std::fixed;

long long min(long long a, long long b) {return a < b ? a : b;}
long long min(int a, long long b) {return a < b ? a : b;}
long long min(long long a, int b) {return a < b ? a : b;}
long long min(int a, int b) {return a < b ? a : b;}

long long max(long long a, long long b) {return a > b ? a : b;}
long long max(int a, long long b) {return a > b ? a : b;}
long long max(long long a, int b) {return a > b ? a : b;}
long long max(int a, int b) {return a > b ? a : b;}

#define int long long

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef string S;

#define F(i, n) for (int (i) = 0; (i) != (n); (i)++)
#define fi first
#define se second
#define re return
#define all(x) (x).begin(), (x).end()

const int N = 1522220;
const int MOD = 1e9 + 7;
const double eps = 1e-8;
const int K = 5;

ll inq(ll x, ll y)
{
    if (y == 0) return 1;
    ll l = inq(x, y / 2);
    if (y % 2) return l * l % MOD * x % MOD;
    return l * l % MOD;
}

int n;
vector<int> graph[N];
int sz[N];

void dfs(int v, int p)
{
    sz[v] = 1;
    for (auto u : graph[v]) if (u != p)
    {
        dfs(u, v);
        sz[v] += sz[u];
    }
}

long long ans = 0;

signed main()
{
    srand(time(NULL));
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n;
    for (int i = 0; i < n - 1; i++)
    {
        int v, u;
        cin >> v >> u;
        graph[v].push_back(u);
        graph[u].push_back(v);
    }
    dfs(1, 0);
    for (int i = 1; i <= n; i++)
    {
        if (graph[i].size() != 1)
        {
            ans = (ans + inq(2, n - 1) - 1) % MOD;
            for (auto u : graph[i])
            {
                int x = sz[u];
                if (sz[u] > sz[i]) x = n - sz[i];
                ans = (ans + MOD - inq(2, x) + 1) % MOD;
                //cout << i << " " << u << " " << x << "\n";
            }
        }
    }
    cout << ans * inq(inq(2, n), MOD - 2) % MOD;
}


Measured memory_bytes: 52352
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <string>
#include <cstring>
#include <complex>
#define rep(i,b,n) for(int i=b;i<n;i++)
#define Rrep(i,b,n) for(int i=n-1;i>=b;i--)
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define NCLR(mat) memset(mat, -1, sizeof(mat))
#define EPS (1e-10)
#define EQ(a,b) (abs((a)-(b)) < EPS)
using namespace std;
typedef complex<double> point;
typedef pair<int, int> paii;
typedef long long ll;
double cross(point va, point vb){
    return real(va) * imag(vb) - imag(va) * real(vb);
}
int is_parallel(point a1, point a2, point b1, point b2) {
  return EQ( cross(a1-a2, b1-b2), 0.0 );
}
int main(){
    int n;
    cin >> n;
    rep(i, 0, n){
        double x, y;
        point pt[4];
        rep(j, 0, 4){
            cin >> x >> y;
            pt[j] = point(x, y);
        }
        if( is_parallel(pt[0], pt[1], pt[2], pt[3]) )
            cout << "YES" << endl;
        else
            cout << "NO" << endl;
    }
}

Measured memory_bytes: 1224
N,M = map(int,input().split())
A,B = [],[]
for i in range(M):
    a,b = map(int,input().split())
    if a==1:
        A.append(b)
    if b==N:
        B.append(a)
if set(A)&set(B):
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Measured memory_bytes: 21836
package main

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

var stdin = bufio.NewScanner(os.Stdin)

func main() {
	a := scanArrayInt()
	switch a[0] * a[1] % 2 {
	case 0:
		fmt.Println("Even")
	default:
		fmt.Println("Odd")
	}
}

func scanArrayInt() []int {
	var ret = []int{}
	stdin.Scan()
	for _, s := range strings.Split(stdin.Text(), " ") {
		i, _ := strconv.Atoi(s)
		ret = append(ret, i)
	}
	return ret
}


Measured memory_bytes: 640
#include<stdio.h>
#include<algorithm>
using namespace std;
const int mod=1e9+7;
int num[100005],a[100005];
void init(int x)
{
	if(x%2==0)
		for(int i=1;i<=x;i+=2) 
		{
			a[i]=i;
			a[i+1]=a[i];
		}
	else
		for(int i=2;i<=x;i+=2)
		{
			a[i]=i;
			a[i+1]=a[i];
		}
		
}
int main()
{
	int n,k=1;
	scanf("%d",&n);
	init(n);
	for(int i=1;i<=n;i++)
		scanf("%d",&num[i]);
	sort(num+1,num+1+n);
	for(int i=1;i<=n;i++)
		if(a[i]!=num[i])
		{
			printf("0");
			return 0; 
		}
			
	long long ans=1;
	n/=2;
	while(n--)
		ans=ans*2%mod;
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 896
N = int(input())
red = []
blue = []
for i in range(N):
    in1, in2 = list(map(int,input().split()))
    red.append([in1, in2])
for i in range(N):
    in1, in2 = list(map(int,input().split()))
    blue.append([in1, in2])
    
red = sorted(red, key=lambda x: x[0])[::-1]
ans = 0
INF = 10 ** 9 + 7
for i in range(N):
    min_ = INF
    ind = -1
    for j in range(N):
        if red[i][0] <= blue[j][0] and red[i][1] <= blue[j][1] and blue[j][1] < min_:
            ind = j
            min_ = blue[j][1]
    if ind != -1:
        blue[ind][0] = -1
        ans += 1
print(ans)

Measured memory_bytes: 38896
#include<bits/stdc++.h>
using namespace std;
#define FASTIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
void solve(){
	ll k,count=1;
	cin>>k;
	ll p=7;
	while(1){
		p%=k;
		if(p==0){
			cout<<count<<"\n";
			return;
		}
		if(count>=k){
			cout<<"-1\n";
			return;
		}
		p=p*10+7;
		count++;
	}
}
int main(){
	FASTIO
	solve();
	return 0;
}


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

int main(){
    int n;cin>>n;
    vector<P> lst(n);
    rep(i,n){
        cin>>lst[i].first.first>>lst[i].first.second;
        lst[i].first.second=0-lst[i].first.second;
        lst[i].second = i+1;
    }
    sort(lst.begin(),lst.end());
    rep(i,n){
        cout<<lst[i].second<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <map>
#include <set>
#include <sstream>
#include <stdio.h>
#include <cstdio>
#include <cstring>
#include <math.h>

using namespace std;

#define Rep(i,a,b) for(int i = a; i < b; i++)
#define rep(i,b) Rep(i,0,b)
#define rrep(i,a) for(int i = a; i >= 0; i--)
#define allof(a) (a).begin(), (a).end()

typedef long long ll;
const int inf = 1e9 + 7;
const ll infll = 1ll << 60ll;
const ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

/*
// 最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

// 最小公倍数
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}*/

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

	int n, k;
	cin >> n >> k;

	ll ans = 0;

	// 1からnまですべてのありえるペアの数を探す
	// 逆だ、後ろの数字を先に決める
	Rep(i, k + 1, n + 1) {
		if (i == 1) {
			ans += n;
			continue;
		}

		int tmp = n / i;
		tmp *= (i - k);
		ll fraction = max(0, n % i - k + 1);

		//cout << i << " " << tmp << " " <<  fraction << endl;
		if (k == 0) tmp--;
		ans += tmp + fraction;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
      	//データ取り込み
		Scanner sc = new Scanner(System.in);
		int hen[] = new int[3];
		hen[0] = sc.nextInt();
		hen[1] = sc.nextInt();
		hen[2] = sc.nextInt();
		
		int temp;
        for(int k = 0; k < 2; k++){
            for(int l = 0; l< 2-k; l++){
               if(hen[l] > hen[l + 1]){
                    	temp = hen[l];
                    	hen[l] = hen[l + 1];
                    	hen[l + 1] = temp;
               	}
            }
        }
		System.out.println(hen[0]*hen[1]/2);
		
    }
}

Measured memory_bytes: 23764
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <utility>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <istream>
#include <ostream>

#include <cstdlib>
#include <cmath>
#include <cstdio>

using namespace std;

#define fi first
#define se second
#define mkp make_pair
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define rep(i,n) for(ll i=0; i < (n); ++i)
#define rrep(i,n) for(ll i=((n)-1); i >= 0; --i)

#define OPLT(T) bool operator<(const T & lop_, const T & rop_)
#define OPEQ(T) bool operator==(const T & lop_, const T & rop_)

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

istream& operator>>(istream& istr, __float128& obj) { double d; istr >> d; obj = d; return istr; };
ostream& operator<<(ostream& ostr, __float128& obj) { ostr << static_cast<double>(obj); return ostr; };

int main() {
	int N, C, K;
	cin >> N >> C >> K;
	vector<int> T(N);
	rep(i,N) cin >> T[i];
	priority_queue<int> q;
	sort(all(T));
	int res = 0;
	rep(i,N) {
		if(q.size() && -q.top() < T[i]) {
			int cnt = 0;
			while(q.size() && -q.top() < T[i]) {cnt++; q.pop(); }
			res += cnt / C + !!(cnt % C);
			for(int j = 0; cnt % C && q.size() && j < C - (cnt % C); j++) {
				q.pop();
			}
		}
		q.push(-(T[i]+K));
	}
	res += q.size() / C + !!(q.size() % C);
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 640
# 入力
N = int(input())
p = [float(x) for x in input().split()]

# DPテーブルを初期化
dp = [[0 for x in range(N+1)] for n in range(N+1)]
dp[0][0] = 1

# ループを回す
for i in range(N):
    for x in range(N):
        dp[i+1][x+1] += dp[i][x]*p[i]
        dp[i+1][x] += dp[i][x]*(1-p[i])

# 答えを得て出力
print(sum(dp[N][N//2+1:]))


Measured memory_bytes: 258952
/*|In The Name Of Allah|*/

#include <bits/stdc++.h>

using namespace std;

const int N = 2e2+5;

int main(){
    string s;
    cin >> s;
    for(int i = 0; i < s.size(); i++){
        s[i] -= '0';
    }
    int best = 1e9;
    for(int i = 0; i < s.size() - 2; i++){
        int ac = s[i] * 100 + s[i + 1] * 10 + s[i + 2];
        best = min(best , abs(ac - 753));
    }
    cout << best << endl;
}





Measured memory_bytes: 256