akhauriyash/Code-Regression huggingface dataset:
#include<algorithm>/*{{{*/
#include<cctype>
#include<cassert>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<ctime>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<vector>
using namespace std;
typedef long long lld;
typedef long double lf;
typedef unsigned long long uld;
typedef pair<int,int> pii;
#define fi first
#define se second
#define pb push_back
#define mk make_pair
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define ROF(i,a,b) for(int i=(a);i>=(b);--i)
namespace RA{
    int r(int p){return 1ll*rand()*rand()%p;}
    int r(int L,int R){return r(R-L+1)+L;}
}
namespace IO{
    char nc(){ static char bf[100000],*p1=bf,*p2=bf; return p1==p2&&(p2=(p1=bf)+ fread(bf,1,100000,stdin),p1==p2)?EOF:*p1++; }
    int rd(){ int res=0; char c=getchar(); while(!isdigit(c))c=getchar(); while(isdigit(c))res=res*10+c-'0',c=getchar(); return res; }
}/*}}}*/
/******************heading******************/
#define int lld
using namespace RA;
const int N=11;

int w[N][N];
int a[]={0,1,2,4,7,12,20,29,38,52,73};

int getmax(int x){
    int p[N],res=0;
    FOR(i,1,x)p[i]=i;
    do{
        int s=0;
        FOR(i,1,x-1)s+=w[p[i]][p[i+1]];
        res=max(res,s);
    }while(next_permutation(p+1,p+x+1));
    return res;
}
void make(int k){
    int m=getmax(k-1);
    m++;
    FOR(i,1,k-1)w[i][k]=w[k][i]=a[i]*m;
}
int n;
signed main(){
    scanf("%lld",&n);
    FOR(i,2,n)make(i);
    FOR(i,1,n)FOR(j,1,n)printf("%lld%c",w[i][j]," \n"[j==n]);
    return 0;
}


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

int main() {
	string s;
	cin >> s;

	int topping=0;
	for(int i=0;i<3;i++) {
		if(s.at(i)=='o') topping++;
	}

	cout << 700 + 100*topping << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define N 1000005
using namespace std;

int n, m, say[27], mn[27];
char s[N];

int main() {
	// freopen("in.txt", "r", stdin);
	// freopen("out.txt", "w", stdout);
	scanf("%d",&n);
	for(int i = 'a'; i <= 'z'; i++)
		mn[i - 'a'] = N;
	for(int i = 1; i <= n; i++){
		memset(say, 0, sizeof say);
		scanf("%s",s + 1);
		m = strlen(s + 1);
		for(int i = 1; i <= m; i++)
			say[s[i] - 'a']++;
		for(int i = 'a'; i <= 'z'; i++)
			mn[i - 'a'] = min(mn[i - 'a'], say[i - 'a']);
	}
	for(int i = 'a'; i <= 'z'; i++)
		while(mn[i - 'a']--)
			printf("%c", i);
	return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <iostream>
using namespace std;
 
int main(){
    int n;
    cin >> n;
 
	vector<int> A(n+1);
	vector<int> B(n);
 
    for (int i = 0; i < n + 1;i++){
        cin >> A[i];
    }
    for (int i = 0; i < n;i++){
        cin >> B[i];
    }
    long sum = 0;
 
    for (int i = 0; i < n;i++){
        for (int j = 0; j < 2;j++){
            if(B[i] >= A[j+i]){
                B[i] -= A[j+i];
                sum += A[j+i];
                A[j+i] = 0;
            }else{
                sum += B[i];
                A[j+i] -= B[i];
                B[i] = 0;
            }
        }
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 1024
# coding: utf-8

import sys
import math

import array
import bisect
import collections
from collections import Counter, defaultdict
import fractions
import heapq
import re

sys.setrecursionlimit(1000000)


def array2d(dim1, dim2, init=None):
    return [[init for _ in range(dim2)] for _ in range(dim1)]

def argsort(l, reverse=False):
    return sorted(range(len(l)), key=lambda i: l[i], reverse=reverse)

def argmin(l):
    return l.index(min(l))

def YESNO(ans, yes="YES", no="NO"):
    print([no, yes][ans])

II = lambda: int(input())
MI = lambda: map(int, input().split())
MIL = lambda: list(MI())
MIS = lambda: input().split()


def bfs(nm, N):
    color = [None] * N
    visited = [False] * N
    q = collections.deque()

    def _bfs(node, before):
        if visited[node]: return
        visited[node] = True
        if before is None:
            color[node] = 0
        else:
            if nm[node][before] % 2 == 0:
                color[node] = color[before]
            else:
                color[node] = 0 if color[before] == 1 else 1
        for k in nm[node].keys():
            q.append((k, node))
        while(q):
            n, b = q.pop()
            _bfs(n, b)

    _bfs(0, None)
    return color


def main():
    N = II()
    nm = {i: {} for i in range(N)}
    for i in range(N-1):
        u, v, w = MI()
        nm[u-1][v-1] = nm[v-1][u-1] = w
    for c in bfs(nm, N):
        print(c)


if __name__ == "__main__":
    main()


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

using namespace std;

typedef long long ll;

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

  ll ans1 = 0;
  ll ans2 = 0;
  ll sum1 = 0;
  ll sum2 = 0;

  for(int i = 0; i < n; i++) {
    sum1 += a[i];
    if(i % 2 == 0 && sum1 <= 0) {
      ans1 += 1 - sum1;
      sum1 = 1;
    }
    
    if(i % 2 == 1 && sum1 >= 0) {
      ans1 += 1 + sum1;
      sum1 = -1;
    }
    //   cout << ans1 << endl;
  }

  for(int i = 0; i < n; i++) {
    sum2 += a[i];
    if(i % 2 == 0 && sum2 >= 0) {
      ans2 += 1 + sum2;
      sum2 = -1;
    }

    if(i % 2 == 1 && sum2 <= 0) {
    ans2 += 1 - sum2;
    sum2 = 1;
  }
    // cout << ans2 << endl;
  }

  cout << min(ans1,ans2) << endl;
}

  
  
  


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int long long
#define endl '\n'
#define pb push_back
#define fi first
#define se second
#define PI acos(-1)
#define all(c) (c).begin(),(c).end()
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define TRACE
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

int modpow(int x, int n, int m) {
	x %= m;
	int res = 1;
	while(n > 0) {
		if(n & 1)
			res = res * x % m;
		x = x * x % m;
		n >>= 1;
	}
	return res;
}

const ll inf = 2e18;
const int mod = 1e9 + 7;
const int N = 2e5 + 10;

signed main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	srand(chrono::steady_clock::now().time_since_epoch().count());
	#ifndef ONLINE_JUDGE
		// freopen("input.txt", "r", stdin);
		// freopen("output.txt", "w", stdout);
	#endif

	int n, m;
	cin >> n >> m;
	if(n == m) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}

	return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"strconv"

	// Reader
	"bufio"
	"os"
	"strings"
)

func main() {




	l := nextLine()

	nc, _ := strconv.Atoi(l[0])
	mc, _ := strconv.Atoi(l[1])
	dx, _ := strconv.Atoi(l[2])
	
	books := make([][]int, nc)
	for n := 0; n < nc; n++ {
		books[n] = make([]int, mc + 1)

		bl := nextLine()
		c, _ := strconv.Atoi(bl[0])
		books[n][0] = c
		for m := 1; m <= mc; m++ {
			x, _ := strconv.Atoi(bl[m])
			books[n][m] = x
		}
	}

	fmt.Printf("%d\n", exec(books, nc, mc, dx))
}

func exec(books [][]int, nc int, mc int, dx int) int {
	var patterns [][]int
	patterns = append(patterns, make([]int, nc))
	patterns = append(patterns, make([]int, nc))
	patterns[len(patterns) - 1][0] = 1

	for n := 1; n < len(books); n++ {
		tmp := patterns
		for _, p := range(tmp) {
			tp := append([]int{}, p...)
			tp[n] = 1
			patterns = append(patterns, tp)
		}
	}

	minCost := -1
	for _, pattern := range(patterns) {
		ret := checkBooks(pattern, books, mc, dx)
		if ret == -1 {
			continue
		}
		if minCost == -1 || ret < minCost {
			minCost = ret
		}
	}
	return minCost
}


func checkBooks(pattern []int, books [][]int, mc int, dx int) int {
	totals := make([]int, mc + 1)
	for key, book := range(books) {
		if pattern[key] == 0 {
			continue
		}

		for k, v := range(book) {
			totals[k] += v
		}
	}

	for m := 1; m <= mc; m++ {
		if totals[m] < dx {
			return -1
		}
	}

	return totals[0]
}

func remove(books [][]int, search int) [][]int {
    result := [][]int{}
    for k, v := range books {
        if k != search {
            result = append(result, v)
        }
    }
    return result
}

func contains(s []int, e int) bool {
	for _, v := range s {
		if e == v {
			return true
		}
	}
	return false
}

// Reader
var limit int = 10000000
var rdr = bufio.NewReaderSize(os.Stdin, limit)

func nextLine() []string {
	return parseLine(readLine())
}

func readLine() string {
	buf := make([]byte, 0, limit)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func parseLine(s string) []string {
	slice := strings.Split(s, " ")
	return slice
}


Measured memory_bytes: 32672
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
const int N=3e3+10;
int n,m,dp[N][N],pre[N][N][2],nows,nowt,cnt;
char s[N],t[N],store[N];
int main(){
	scanf("%s%s",s+1,t+1);
	n=strlen(s+1);m=strlen(t+1);
	for(register int i=1;i<=n;i++)
		for(register int j=1;j<=m;j++)
			if(s[i]==t[j]){
				dp[i][j]=dp[i-1][j-1]+1;
				pre[i][j][0]=i-1;pre[i][j][1]=j-1;
			}
			else{
				if(dp[i][j-1]<=dp[i-1][j])dp[i][j]=dp[i-1][j],pre[i][j][0]=i-1,pre[i][j][1]=j;
				else dp[i][j]=dp[i][j-1],pre[i][j][0]=i,pre[i][j][1]=j-1;
			}
	nows=n;nowt=m;
	while(nows&&nowt){
		if(s[nows]==t[nowt])store[++cnt]=s[nows];
		int x=pre[nows][nowt][0],y=pre[nows][nowt][1];
		nows=x;nowt=y;
	}
	for(register int i=cnt;i>=1;i--)printf("%c",store[i]);
	printf("\n");return 0;
}

Measured memory_bytes: 106368
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

#define int long long

#define override_rep(i, l, r, mes, ...) mes
#define rep1(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = l; i < r; i++)
#define rep(...) override_rep(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)

using namespace std;
using P = pair<int, int>;
using ll = long long;
using ld = double;

using bint = boost::multiprecision::cpp_int;

constexpr int MOD = 1e9 + 7;

template<typename T, typename U>
istream& operator>>(istream& in, pair<T, U>& p) {
    in >> p.first >> p.second;
    return in;
}

// https://twitter.com/vane11ope ←フォローしましょう
// (ノ)>◡<(ヾ)ﾓﾁﾓﾁ
signed main(signed argc, char* argv[]) {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    int a,b,c,d;
    cin>>a>>b>>c>>d;
    cout<<max({a*c,a*d,b*c,b*d})<<endl;
}


Measured memory_bytes: 3688
S = input()
N = len(S)
if not S == S[::-1]:
    print('No')
    exit()

S2 = S[:(N-1)//2]
if not S2 == S2[::-1]:
    print('No')
    exit()

S3 = S[(N + 3) // 2 - 1: ]
if not S3 == S3[::-1]:
    print('No')
    exit()

print('Yes')

Measured memory_bytes: 38576
package main

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

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

// Sort
type Val struct {
	id, num int
}
type ByNum []Val

func (a ByNum) Len() int           { return len(a) }
func (a ByNum) Less(i, j int) bool { return a[i].num < a[j].num }
func (a ByNum) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

type Info struct {
	x, y, h int
}

type ByH []Info

func (a ByH) Len() int           { return len(a) }
func (a ByH) Less(i, j int) bool { return a[i].h > a[j].h }
func (a ByH) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	N := sc.nextInt()
	info := make([]Info, N)
	for i := 0; i < N; i++ {
		info[i] = Info{sc.nextInt(), sc.nextInt(), sc.nextInt()}
	}
	sort.Sort(ByH(info))
	for x := 0; x <= 100; x++ {
		for y := 0; y <= 100; y++ {
			hDecided := false
			var H int
			flag := true
			for i := 0; i < N; i++ {
				in := info[i]
				h, ok := f(x, y, in.x, in.y, in.h)
				if ok {
					if !hDecided {
						hDecided = true
						H = h
					}
					if h != H || h < 1 {
						flag = false
						break
					}
				} else {
					if H-abs(x-in.x)-abs(y-in.y) <= 0 {
						continue
					} else {
						flag = false
						break
					}
				}
			}
			if flag {
				fmt.Fprintln(wtr, x, y, H)
				wtr.Flush()
				return
			}
		}
	}
}

func f(X, Y, cx, cy, ch int) (int, bool) {
	if ch == 0 {
		return 0, false
	}
	return (ch + abs(X-cx) + abs(Y-cy)), true
}


Measured memory_bytes: 640
//#pragma warning disable
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System;
using System.Threading.Tasks;
using static System.Math;
using static System.Console;
public class Program
{
    public static void Main()
    {
        int[] n = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        int N = n[0];
        int K = n[1];

        int[] l = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();

        Array.Sort(l);
        Array.Reverse(l);
        int ans = 0;
        for (int i = 0;i < K; ++i)
        {
            ans += l[i];
        }
        
        Console.WriteLine(ans);
    }
}

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

int	main()
{
	int	N;
	cin >> N;
	priority_queue<int64_t, vector<int64_t>, greater<int64_t>>	min_que;
	priority_queue<int64_t, vector<int64_t>, less<int64_t>>		max_que;
	vector<int64_t>	a_vec(N);
	int64_t	a;
	int64_t	lhs = 0, rhs = 0;
	for (int i = 0; i < N; ++i) {
		cin >> a;
		lhs += a;
		min_que.push(a);
	}
	for (int i = 0; i < N; ++i)
		cin >> a_vec.at(i);
	for (int i = 0; i < N; ++i) {
		cin >> a;
		rhs += a;
		max_que.push(a);
	}
	vector<int64_t>	lhs_vec(N + 1, 0);
	vector<int64_t>	rhs_vec(N + 1, 0);
	int64_t	l_diff; 
	int64_t	r_diff;
	lhs_vec.at(0) = lhs;
	for (int i = 1; i < N + 1; ++i) {
		lhs_vec.at(i) = lhs_vec.at(i - 1);
		l_diff = a_vec.at(i - 1) - min_que.top();
		if (l_diff > 0) {
			lhs_vec.at(i) += l_diff;
			min_que.pop();
			min_que.push(a_vec.at(i - 1));
		}
	}
	rhs_vec.at(0) = rhs;
	for (int i = 1; i < N + 1; ++i) {
		rhs_vec.at(i) = rhs_vec.at(i - 1);
		r_diff = a_vec.at(N - i) - max_que.top();
		if (r_diff < 0) {
			rhs_vec.at(i) += r_diff;
			max_que.pop();
			max_que.push(a_vec.at(N - i));
		}
	}
	int64_t	max_score = lhs_vec.at(0) - rhs_vec.at(N);	
	int64_t	score;
	for (int i = 1; i < N + 1; ++i) {
		score = lhs_vec.at(i) - rhs_vec.at(N - i);
		if (max_score < score)
			max_score = score;
	}
	cout << max_score << endl;
}


Measured memory_bytes: 4340
#include <bits/stdc++.h>
using namespace std;
 
 
int main(){
  int N;
  cin >>N;
  vector<tuple<string,int,int>> a(0);
  for(int i =0;i<N;i++){
   string x;
    int y;
    cin >>x>> y;
    tuple<string,int,int> ato;
   ato= make_tuple(x,100-y,i+1);
    a.push_back(ato);
  }
  sort(a.begin(),a.end());
  for(int i =0;i<N;i++)
  cout<< get<2>(a.at(i)) <<endl;
  
  
}


Measured memory_bytes: 256
#pragma GCC optimize "-O3"
#pragma GCC optimize("Ofast")
#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define LSOne(S) (S & (-S))
#define ll long long
#define two pair<int,int>
#define twoll pair<ll,ll>
#define four pair<two,two>
#define pb push_back
#define eb emplace_back
#define mk make_pair
#define y1 y1922
#define INF 1000000000000000000
#define P 1000000007
#define lmax 1000000000
#define nn 1000003
#define ff first.first
#define fs first.second
#define sf second.first
#define ss second.second
#define f first
#define s second
#define vi vector<int>
#define vll vector<ll>
#define vtwo vector<two>
#define ALL(container) (container).begin(), (container).end()
#define sz(container) (int)(container.size())
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define mid(a,b) (a+b>>1)
#define minN 0
#define maxN 10000000
#define na(x) ((x)<P?(x):(x)-P)
#define ab(a) (-(a)<(a)?(a):-(a))
#define FAST std::ios::sync_with_stdio(false)
#define xRand mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define rnd rng
#define IT iterator
typedef
tree<
  int,// aq pair<int,int> shegidzlia
  null_type,
  less/*_equal*/<int>,// aqac
  rb_tree_tag,
  tree_order_statistics_node_update>
ordered_set;
// '_equal' mashin ginda roca multiset gchirdeba
template<class key, class value,class cmp = std::less<key>>
using ordered_map = tree<key, value, cmp, rb_tree_tag, tree_order_statistics_node_update>;
ordered_map<int, int> my_map;
inline int rin(){
	int x=0,w=1;char ch=getchar();
	while ((ch<'0'||ch>'9')&&ch!='-') ch=getchar();
	if (ch=='-') w=0,ch=getchar();
	while (ch>='0'&&ch<='9') x=(x<<3)+(x<<1)+ch-'0',ch=getchar();
	return w?x:-x;
}
inline int bin(){
	int x=0;char ch=getchar();
	while (ch<'0'||ch>'9') ch=getchar();
	while (ch>='0'&&ch<='9') x=(x<<3)+(x<<1)+ch-'0',ch=getchar();
	return x;
}
bitset<4000004>s;
int n,sm,a;
int main(){FAST;xRand;
cin>>n;
s.set(0);
while(n--){
	cin>>a;
	sm+=a;
	s|=(s<<a);
}
for(int i=(sm+1)/2;;i++){
	if(s[i]){
		cout<<i<<endl;
		return 0;
	}
}

}
/*

                   *         *
                  * *       * *
                 *   *     *   *
                *     *   *     *
                 *   *   * *   *
                  *   *   *   *
                   *   * *   *
                     *  *   *
					   *  *


*/



Measured memory_bytes: 1792
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

alias B = Tuple!(int, "in_cnt", int, "out_cnt");

void main()
{
    auto N = readln.chomp.to!int;
    B[] as, bs;
    foreach (_; 0..N) {
        bool fst;
        int cnt, min_cnt;
        foreach (c; readln.chomp) {
            if (c == ')') {
                --cnt;
            } else {
                ++cnt;
            }
            min_cnt = min(min_cnt, cnt);
        }
        if (cnt > 0) {
            as ~= B(min_cnt, cnt - min_cnt);
        } else {
            bs ~= B(min_cnt, cnt - min_cnt);
        }
    }
    sort!"a.in_cnt == b.in_cnt ? a.out_cnt > b.out_cnt : a.in_cnt > b.in_cnt"(as);
    sort!"a.out_cnt == b.out_cnt ? a.in_cnt > b.in_cnt : a.out_cnt > b.out_cnt"(bs);

    int x;
    foreach (a; as) {
        if (x + a.in_cnt < 0) {
            writeln("No");
            return;
        }
        x = x + a.in_cnt + a.out_cnt;
    }
    foreach (b; bs) {
        if (x + b.in_cnt < 0) {
            writeln("No");
            return;
        }
        x = x + b.in_cnt + b.out_cnt;
    }

    writeln(x == 0 ? "Yes" : "No");
}

Measured memory_bytes: 15528
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		String ans = "Three";

		for (int i = 0; i < n; i++) {
			String s = sc.next();
			if (s.equals("Y")) {
				ans = "Four";
				break;
			}
		}

		System.out.println(ans);

		sc.close();
	}

}


Measured memory_bytes: 22996
from collections import Counter
n, k = map(int,input().split())
a = sorted(list(map(int,input().split())))

a = sorted(Counter(a).items(), key=lambda x: -x[1])
if len(a) <= k:
    print(0)
else:
    ans = 0
    for l in range(k,len(a)):
        ans += a[l][1]
    print(ans)


Measured memory_bytes: 103624
H,W = 150,150
dp = [[0 for w in range(W+1)] for h in range(H+1)]
for h in range(1,H+1):
  for w in range(1,W+1):
    if h<w:
      dp[h][w] = h*h + w*w
while True:
  h,w = map(int,input().split())
  if h+w==0:
    break
  #####h<w#####
  l = dp[h][w]
  a,b = h,w
  for i in range(1,H+1):
    for j in range(1,W+1):
      if dp[i][j]==l and a<i:
        a,b = i,j
        break
    if a!=h or b!=w:
      break
  if a!=h or b!=w:
    print(a,b)
  else:
    m = 10**10
    for i in range(1,H+1):
      for j in range(1,W+1):
        if dp[i][j]>l and dp[i][j]<m:
          m = dp[i][j]
          a,b = i,j
    print(a,b)


Measured memory_bytes: 6052
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define in insert
#define mp make_pair
#define F first
#define pb push_back
#define pf push_front
#define speed ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define test ll t; cin>>t; while(t--)
ll exp(ll x,ll y,ll p){ ll res=1; while(y) {if(y%2) res=(res*x%p)%p; x=(x*x)%p; y/=2; } return res;}
ll exp(ll x,ll y){ ll res=1; while(y) {if(y%2) res=(res*x); x=(x*x); y/=2; } return res;}

ll a[200006];
ll n;
int main(){
    speed
    string s; cin>>s;
    ll q; cin>>q;
    deque<char> dq;
    for(ll i=0;i<s.length();i++){
        dq.pb(s[i]);
    }
    bool reversee=false;
    while(q--){
        ll x; cin>>x;
        if(x==1){
            reversee=!reversee;
        }
        else{
            ll f; char c; cin>>f>>c;
            if(f==1){
                if(reversee==false)
                    dq.pf(c);
                else dq.pb(c);
            }
            else{
                if(reversee==false)
                    dq.pb(c);
                else dq.pf(c);
            }
            
        }
    }
    if(reversee){
        reverse(dq.begin(),dq.end());
        for(auto x:dq) cout<<x;
    }
    else {
        for(auto x:dq) cout<<x;
    }
    return 0;
}


Measured memory_bytes: 976
import collections
n = int(input())
a = list(map(int,input().split()))
q = int(input())
suma = sum(a)
count = collections.Counter(a)

for i in range(q):
    b,c = map(int,input().split())
    suma += (c*count[b] - b*count[b])
    count[c] = count[b] + count[c]
    count[b] = 0
    print(suma)

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

public class Main {

	public static void main(String[] args) {
	    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String input = null;
		    try {
			    input = br.readLine();
		        
		    } catch (IOException e) {
	    	}
		    double r = Double.parseDouble(input) ;
		    System.out.printf("%f %f\n", r * r * Math.PI , r * 2 * Math.PI);
		    // %fはdoubleの時にprintf内の小数を表示したいときに使う。
		    // 使いたい個数分書いて、空白を入れたいときは%fとか%dとかの間に空白入れるだけ
	}
}


Measured memory_bytes: 24880
def combi(n,k)
  k=n-k if 2*k > n
  return 1 if k == 0
  ((n-k+1)..n).reduce(&:*)/((1..k).reduce(&:*))
end

n = gets.to_i
items = Hash.new(0)
n.times do |i|
  s = Hash.new(0)
  gets.chomp.chars{|ch| s[ch] += 1}
  items[s] += 1
end

ans = 0
items.each do |k, v|
  ans += combi(v, 2) if v >= 2
end
puts ans


Measured memory_bytes: 135676
d=3;a=[]
n=int(input());s=n**.5
while n%2==0 and n>3:a+=[2];n//=2
while s>d and n>d:
 if n%d>0:d+=2
 else:a+=[d];n//=d
a+=[n];p=1
for f in set(a):
 p*=f**a.count(f)*(1-1/f)
print(int(p))


Measured memory_bytes: 5636
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scan() string {
	sc.Scan()
	return sc.Text()
}

func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}

func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	n := iScan()
	ans := 0.
	for i := 0; i < n; i++ {
		x := fScan()
		if Scan() == "JPY" {
			ans += x
		} else {
			ans += x * 380000.
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 1744
#include<iostream>

using namespace std;

long long n,t,a[100009];


void solve(){
    long long cur_mn=a[0], cur_mx=a[0], mx=0;
    for(int i=0;i<n;i++){
        if(a[i]<cur_mn){
            cur_mn=a[i];
            cur_mx=a[i];
        }
        cur_mx=max(cur_mx, a[i]);
        mx = max(mx, cur_mx-cur_mn);
    }

    long long cur_low=a[0],cur_upp=a[0], low_cnt=0, upp_cnt=0, ans=0;
    for(int i=0;i<n;i++){
        cur_upp = max(cur_upp, a[i]);
        if(a[i]<cur_low){
            ans += min(low_cnt, upp_cnt);
            low_cnt=0;
            upp_cnt=0;
            cur_upp=a[i];
            cur_low=a[i];
        }
        if(a[i]==cur_low){
            low_cnt++;
        }
        if(cur_upp-cur_low==mx && a[i]==cur_upp){
            upp_cnt++;
        }
    }
    ans += min(low_cnt, upp_cnt);
    cout << ans << endl;
}

int main(){
    cin >> n >> t;
    for(int i=0;i<n;i++){
        cin >> a[i];
    } 
    solve();
}

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

int main() {
	int n;cin>>n;
	cout<<n<<":";
	while(n%2==0)
	{
		cout<<" "<<2;
		n/=2;
	}
	for(int i=3;i*i<=n;i+=2)
	{
		while(n%i==0)
		{
			cout<<" "<<i;
			n/=i;
		}
	}
	if(n!=1)cout<<" "<<n;
	cout<<endl;
	return 0;
}

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

int main() {
  int D, G;
  vector<int> p(10);
  vector<int> c(10);
  vector<int> complete_score(10);
  
  int count = 0;
  int score = 0;
  int res = 0;

  cin >> D >> G;
  rep(i,D){
    cin >> p.at(i) >> c.at(i);
    complete_score.at(i) = (i+1)*100*p.at(i)+c.at(i);
    res += p.at(i);
  }

  rep(tmp,1 << D){
    bitset<10> index(tmp);
    bool finished = false;

    score = 0;
    count = 0;
    rep(i,D){
      if(index.test(i) == 1){
        score += complete_score.at(D-i-1);
        count += p.at(D-i-1);
      }
    }
    
    if(G <= score){
      res = min(res, count);
    }
    else{
      rep(i,D){
        if(index.test(i) == 1){
          continue;
        }
        rep(j,p.at(D-i-1)){
          score += 100*(D-i);
          count++;
         
          if(G <= score){
            res = min(res, count);
            finished = true;
            break;
          }
        }
        if(finished){
          break;
        }
      }
    }
  }

  cout << res << endl;
  return 0;
}

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

using namespace std;


int main() {

	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);

	string s;
	cin >> s;
	sort(s.begin(), s.end());
	cout << (s[0] == s[1] && s[1] != s[2] && s[2] == s[3] ? "Yes\n" : "No\n");
	return 0;
}

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

int main() {
    int n;
    cin >> n;
    vector<int> a1(n), a2(n);
    for(int i = 0; i < n; i++)
    {
        cin >> a1.at(i);
    }
    for(int i = 0; i < n; i++)
    {
        cin >> a2.at(i);
    }
    
    vector<int> sum1(n + 1), sum2(n + 1);
    for(int i = 0; i < n; i++)
    {
        sum1.at(i + 1) = sum1.at(i) + a1.at(i);
        sum2.at(i + 1) = sum2.at(i) + a2.at(i);
    }
    
    int maximum = 0;
    for(int i = 1; i <= n; i++)
    {
        maximum = max(maximum, sum1.at(i) + (sum2.at(n) - sum2.at(i - 1)));
    }
    cout << maximum << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;


class Program
{
    static void Main(string[] args)
    {
        var p = new Program();
        var N = int.Parse(Console.ReadLine());
        var result = "Yes";
        if(N == 1)
        {
            Console.WriteLine("Yes");
        }
        else
        {
            var array = p.ConvertIntArray(p.ReadInput());
            var val = array[0];
            for (var i = 1; i < N; i++)
            { 
                if(val < array[i])
                {
                    val = array[i] - 1;
                }
                else if(val > array[i])
                {
                    result = "No";
                    break;
                }
            }

            Console.WriteLine(result);
        }

    }

    public string[] ReadInput()
    {
        return Console.ReadLine().Split(' ');
    }

    public int[] ConvertIntArray(string[] x)
    {
        var convertedArray = new int[x.Length];
        for (var i = 0; i < x.Length; i++)
        {
            convertedArray[i] = int.Parse(x[i]);
        }

        return convertedArray;
    }
}



Measured memory_bytes: 28764
N = int(input())

if N == 0:
    print(0)
    exit()

ans = []
while N != 0:
    d = len(ans)
    if N % 2 == 1:
        ans.append('1')
        N -= pow(-1, d)
        N //= 2
    else:
        ans.append('0')
        N //= 2

print(''.join(ans[::-1]))


Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long int lli;

int main(){
    string s;
    lli k;
    cin >> s >> k;
    int n = s.length();
    // len, num;
    vector<vector<pair<int, lli>>> dp(n, vector<pair<int, lli>>(n+1));
    for(int i=0; i<n; i++){
        dp[i][i] = {0, 1LL};
        dp[i][i+1] = {1, 1LL};
    }
    for(int w=2; w<n+1; w++){
        for(int i=0; i+w<n+1; i++){
            if(s[i] == s[i+w-1]){
                auto tmp = dp[i+1][i+w-1];
                dp[i][i+w] = {tmp.first +2, tmp.second};
            }else{
                auto tmp1 = dp[i][i+w-1];
                auto tmp2 = dp[i+1][i+w];
                if(tmp1.first > tmp2.first) swap(tmp1, tmp2);
                if(tmp1.first == tmp2.first){
                    dp[i][i+w] = {tmp1.first +2, min(tmp1.second +tmp2.second, k+1)};
                }else{
                    dp[i][i+w] = {tmp1.first +2, tmp1.second};
                }
            }
        }
    }
    if(dp[0][n].second < k){
        cout << "NONE" << endl;
        return 0;
    }
    int i=0,j=n;
    string front="",mid="";
    while(1){
        if(i == j) break;
        if(i+1 == j){
            mid += s[i];
            break;
        }
        if(s[i] == s[j-1]){
            front += s[i];
            i++; j--;
        }else if(dp[i+1][j].first < dp[i][j-1].first){
            front += s[i];
            i++;
        }else if(dp[i+1][j].first > dp[i][j-1].first){
            front += s[j-1];
            j--;
        }else if(s[i] < s[j-1]){
            if(dp[i+1][j].second >= k){
                front += s[i];
                i++;
            }else{
                k -= dp[i+1][j].second;
                front += s[j-1];
                j--;
            }
        }else{
            if(dp[i][j-1].second >= k){
                front += s[j-1];
                j--;
            }else{
                k -= dp[i][j-1].second;
                front += s[i];
                i++;
            }
        }
    }
    string back = front;
    reverse(back.begin(), back.end());
    cout << front << mid << back << endl;
    return 0;
}



Measured memory_bytes: 65508
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<vector>
#include<map>
#include<set>
using namespace std;
#define ll long long
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)
#define fi first
#define se second
#define pr(x) cerr<<#x<<"="<<(x)<<endl
#define pri(x,lo) {cerr<<#x<<"={";for (int ol=0;ol<=lo;ol++)cerr<<x[ol]<<("},"[ol<lo]);cerr<<endl;}
#define inf 100000000
#define N 11000
char ch[N];
int a[N],b[N],f[2010][2010],g[2010][2010],dp[2010][2010],i,j,n,pos[3][2010];
int main()
{
	scanf("%d",&n);
	for (i=1;i<=2*n;i++)
	{
		scanf("%s",ch);
		a[i]=ch[0]=='W'?0:1;
		scanf("%d",&b[i]);
		pos[a[i]][b[i]]=i;
	}
	for (i=1;i<=n;i++)
	{
		for (j=1;j<=2*n;j++) 
		{
			if (a[j]==0&&b[j]==i) break;
			if (a[j]==0&&b[j]<i) continue;else f[i][0]++;
		}
		for (j=1;j<=n;j++)
			f[i][j]=f[i][j-1]-(pos[1][j]<pos[0][i]);
	}
	for (j=1;j<=n;j++)
	{
		for (i=1;i<=2*n;i++) 
		{
			if (a[i]==1&&b[i]==j) break;
			if (a[i]==1&&b[i]<j) continue;else g[0][j]++;
		}
		for (i=1;i<=n;i++)
			g[i][j]=g[i-1][j]-(pos[0][i]<pos[1][j]);
	}
//	for (i=1;i<=n;i++) pri(f[i],n);
//	for (i=1;i<=n;i++) pri(g[i],n);
	memset(dp,0x7f,sizeof(dp));
	dp[0][0]=0;
	for (i=0;i<=n;i++) for (j=0;j<=n;j++)
	{
		if (i!=0) dp[i][j]=min(dp[i][j],dp[i-1][j]+f[i][j]);
		if (j!=0) dp[i][j]=min(dp[i][j],dp[i][j-1]+g[i][j]);
	}
	printf("%d\n",dp[n][n]);
}
	
		

Measured memory_bytes: 47616
import java.util.*;

public class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int[] score = new int[3];
		int m = 0;
		int f = 0;
		int r = 0;
		String ans = null;
		
		while(true){
			m = sc.nextInt();
			f = sc.nextInt();
			r = sc.nextInt();
			if(m + f + r == -3){
				break;
			}
			if(m == -1 || f == -1){
				ans = "F";
			}else if(m + f >= 80){
				ans = "A";
			}else if(m + f >= 65){
				ans = "B";
			}else if(m + f >= 50){
				ans = "C";
			}else if(m+ f >= 30){
				if(r >= 50){
					ans = "C";
				}else{
					ans = "D";
				}
			}else if(m + f < 30){
				ans = "F";
			}
			System.out.println(ans);
		}
	}
}




Measured memory_bytes: 26532
roadcnt,money = (int(n) for n in input().split(" "))
while True:
    road = []
    for r in range(roadcnt):
        road.append([int(n) for n in input().split(" ")])
    road = sorted(road,key=lambda x:x[1])
    while money > 0 and len(road) > 0:
        if road[-1][0] - money < 0:
            money -= road[-1][0]
            road.pop()
        else:
            road[-1][0] -= money
            break
    ans = 0
    for ro in road:
        ans += ro[0] * ro[1]
    print(ans)
    roadcnt,money = (int(n) for n in input().split(" "))
    if roadcnt == 0 and money == 0:
        break

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

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

    while(k--){
        if(2*a<b)   a=2*a;
        else if(2*b<c)  b = 2*b;
        else    c=2*c; 
    }

    if(a<b && b<c)  cout <<"Yes"<<endl;
    else    cout <<"No"<<endl;

    return 0;
}

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

using namespace std;

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

  int n, m;
  cin >> n;
  map<string, int> hash;
  string in;
  for (int i = 0; i < n; ++i) {
    cin >> in;
    hash[in]++;
  }
  cin >> m;
  for (int i = 0; i < m; ++i) {
    cin >> in;
    hash[in]--;
  }
  int res = 0;
  for (auto &h : hash) {
    if (h.second > res) 
      res = h.second;
  }
  cout << res << endl;

  return 0;
}



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

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int a;
    string s;
    cin >> a >> s;
    if( a >= 3200) {
        cout << s << '\n';
    } else {
        cout << "red\n";
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
using namespace std;
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORD(i, a, b) for (int i = (a); i >= (b); i--)
#define endl "\n"
inline bool EQ(double a, double b)
{
    return fabs(a - b) < 1e-9;
}
const int INF = 1 << 29;
typedef long long int ll;
inline int two(int n) { return 1 << n; }

inline int test(int n, int b) { return (n >> b) & 1; }
inline void set_bit(int &n, int b) { n |= two(b); }
inline void unset_bit(int &n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n)
{
    int res = 0;
    while (n && ++res)
        n -= n & (-n);
    return res;
}
template <class T>
void chmax(T &a, const T &b) { a = max(a, b); }
template <class T>
void chmin(T &a, const T &b) { a = min(a, b); }

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n;
    cin >> n;
    int a = 0, b = 0, c = 0, d = 0;
    string s;
    REP(i, n)
    {
        cin >> s;
        if (s[0] == 'A')
            a++;
        else if (s[0] == 'W')
            b++;
        else if (s[0] == 'T')
            c++;
        else if (s[0] == 'R')
            d++;
    }
    cout << "AC x " << a << endl;
    cout << "WA x " << b << endl;
    cout << "TLE x " << c << endl;
    cout << "RE x " << d << endl;
    return 0;
}

Measured memory_bytes: 3660
A,B,C,D = map(int,input().split())
X = max(C,D)
Y = min(C,D)
def gcd(a,b):
  while b!= 0:
    a,b = b,a%b
  return a
l = int(C*D/ gcd(X,Y))
def f(x):
  return x - (x//C + x//D - x//l)
ans = f(B) - f(A-1)
print(int(ans))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define int long long
using namespace std;
string s,substr[25000+10]={};
int K;
signed main(){
  cin >> s >> K;
  int t=0;
  for(int i=0;i<s.size();i++){
    substr[t]=s[i];
    //cout << "a" << endl;
    for(int j=0;j<K;j++){
      if(i+j>=s.size()) break;
      if(j==0){
        t++;
        substr[t]=substr[t-1];
      }
      else{
        substr[t]+=s[i+j];
        t++;
        substr[t]=substr[t-1];
      }
    }
  }
  sort(substr,substr+t);
  /*for(int i=0;i<t;i++){
    cout << substr[i] << endl;
  }*/
  //cout << t << endl;
  //if(substr[1]!=substr[2]) cout << "a" << endl;;
  //cout << substr[1+1]+'0' << endl;
  //cout << substr[1]+'0' << endl;
  for(int i=0;i<t-1;i++){
    if(substr[i]==substr[i+1]) substr[i]="zzzzz";
    //else substr[i]="zzz";
  }
  /*for(int i=0;i<t-1;i++){
    cout << substr[i] << endl;
  }*/
  sort(substr,substr+t);
  //cout << "--------------------" << endl;
  /*for(int i=0;i<t;i++){
    cout << substr[i] << endl;
  }*/
  cout << substr[K-1] << endl;
  return 0;
}


Measured memory_bytes: 1664
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include<cstdio>
#include <iomanip>
#include <math.h>

using namespace std;

typedef long long int ll;
typedef vector<int> vi;
typedef vector<ll> vl;

const int  INF = 1e9;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
const int SIZE = 100;

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

	sort(a, a + n);

	ll t = a[n - 1] / 2;

	ll ans = 0;
	ll than = MOD;
	for (int i = 0; i < n - 1; i++)
	{
		ll x = abs(a[i] - t);
		
		if (than >= x) {
			ans = a[i];
			than = x;
		}
	}

	cout << a[n - 1] << " " << ans << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
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;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    ll N,M,X;
    cin >>N>>M>>X;
    vector<ll>sum(N+1);
    vector<ll>A(N+1);
    rep(i,M){
        ll a;
        cin>>a;
        A[a]=1;
    }

    rep(i,N){
        sum[i+1]=sum[i]+A[i];
    }


    cout << min(sum[X],sum[N]-sum[X]) << endl;


    return 0;
    

}

Measured memory_bytes: 3596
#include <chrono>
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std::chrono;
using namespace std;
using namespace __gnu_pbds;
#define  st first
#define  nd second
void debug_out() { cerr << endl; }
template<class T> ostream& prnt(ostream& out, T v) { out << v.size() << '\n'; for(auto e : v) out << e << ' '; return out;}
template<class T> ostream& operator<<(ostream& out, vector <T> v) { return prnt(out, v); }
template<class T> ostream& operator<<(ostream& out, set <T> v) { return prnt(out, v); }
template<class T1, class T2> ostream& operator<<(ostream& out, map <T1, T2> v) { return prnt(out, v); }
template<class T1, class T2> ostream& operator<<(ostream& out, pair<T1, T2> p) { return out << '(' << p.st << ' ' << p.nd << ')'; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << " " << H; debug_out(T...);}
#define dbg(...) cerr << #__VA_ARGS__ << " ->", debug_out(__VA_ARGS__)
#define dbg_v(x, n) do{cerr<<#x"[]: ";for(int _=0;_<n;++_)cerr<<x[_]<<" ";cerr<<'\n';}while(0)
#define dbg_ok cerr<<"OK!\n"
#define maxn 300001
#define M   1000000007
#define int long long
#define inf 1e18
#define ninf -1e17
template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
typedef cc_hash_table<int, int, hash<int > > ht;


int32_t main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  int n;
  cin>>n;
  int a[n];
  for(int i=0;i<n;i++)
    cin>>a[i];
  float k=0.0;
  for(int i=0;i<n;i++){
    k+=1.0/a[i];
  }
  cout<<1.0/k;
}


Measured memory_bytes: 256
import numpy as np

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

# XOR和と加算和が等しくなるのは、二進数にしたときの各ビットの1の数が高々ひとつのとき
# → ある集合が条件を満たすとき、その部分集合も条件を満たす
# しゃくとり法
r = 0 # 右端の初期値
temp = 0
ans = 0 # 答えの初期値
for l in range(N): # 左端を動かしていく
    while r < N and temp ^ A[r] == temp + A[r]: # 右端を動かしても条件を満たすなら
        temp += A[r]
        r += 1
    # 条件を満たさなくなったら
    ans += r - l # 答えを更新
    # 左端を動かす準備
    if r == l:
        r += 1 # すでに重なっている場合は右端も動かす
        temp = 0
    else:
        temp -= A[l]
print(ans)

Measured memory_bytes: 50128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  int N, M;
  cin >> N >> M;
  int a[M];
  int b[M];
  int f[M]{};
  int t = 0;
  int flag[N]{};
  for (int i = 0; i < M; i++) {
    cin >> a[i] >> b[i];
    for (int j = 0; j < b[i]; j++) {
      cin >> t;
      t--;
      flag[t] = 1;
      f[i] += (1<<t);
    }
  }
  // 全ての宝箱を開けることができるかをチェック
  for (int i = 0; i < N; i++) {
    if (flag[i] == 0) {
      cout << "-1\n";
      return 0;
    }
  }
  int l = (1<<N);
  int dp[l];
  int inf = 100000000;
  fill(dp, dp + l, inf);
  dp[0] = 0;

  for (int i = 0; i < M; i++) {
    for (int k = 0; k < l; k++) {
      int idx = k | f[i];
      dp[idx] = min(dp[idx], dp[k] + a[i]);
    }
  }
  cout << dp[l - 1] << "\n";
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <algorithm>
using namespace std;
int main(void){
    unsigned long n,min,ans;
    unsigned long a[5];
    cin>>n;
    for (int i=0;i<5;i++) cin>>a[i];
    sort(a,a+5);
    min=a[0];
    if (n%min==0) ans=n/min+4;
    else ans=n/min+5;
    cout<<ans<<endl;
    
}


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

using namespace std;
#define int long long
#define maxn 666666
int n,m;
int  arr[maxn];
int cnt;
void bfs(){
	queue<int> q;map<int,int> vis;
	for(int i=1;i<=9;i++) q.push(i);
	while(!q.empty()){
		int t=q.front();q.pop();
		if(vis[t]) continue;
		else{
			arr[cnt++]=t;
			vis[t]=1;
		}
		if(cnt>200000) break;
		int yushu=t%10;
		q.push(t*10+yushu);
		if((yushu+1)<=9){
			q.push(t*10+yushu+1);
		}
		if((yushu-1)>=0){
			q.push(t*10+yushu-1);
		}
	}
	return ;
}
signed main(){
	cnt=1;
	bfs();
	sort(arr+1,arr+cnt+1);
	//for(int i=1;i<=16;i++) cout<<arr[i]<<" ";
	cin>>n;
	cout<<arr[n+1];
	return 0;
}

/*
3
1 3 4
6 7 9
1 1 2 3

*/

Measured memory_bytes: 17536
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

/* typedef */

typedef set<string> ss;

/* global variables */

/* subroutines */

/* main */

int main() {
  int gen = 0;
  ss used;
  string q("a"), ans;

  for (;;) {
    used.insert(q);
    cout << "?" + q << endl; cout.flush();
    
    cin >> ans;

    if (ans[0] != q[q.size() - 1] || used.find(ans) != used.end())
      break;
    used.insert(ans);

    char ch0 = 'a' + (gen / 26);
    char ch1 = 'a' + (gen % 26);

    q.assign(1, ans[ans.size() - 1]);
    q.append(1, ch0);
    q.append(1, ch1);
    q.append(1, 'a');

    gen++;
  }

  cout << "!OUT" << endl; cout.flush();
  
  return 0;
}

Measured memory_bytes: 1260
#include <stdio.h>
#pragma warning(disable : 4996)
long long n, ret;
int main() {
	while (true) {
		scanf("%lld", &n);
		if (n == 0) break;
		ret = 0;
		for (long long i = 1; i < n; i++) {
			int l = 0;
			int r = n;
			while (r - l > 1) {
				int m = (l + r) / 2;
				long long p = i * i * i + m * m * m;
				if (p <= n * n * n) {
					l = m;
				}
				else {
					r = m;
				}
			}
			ret = ret > i * i * i + l * l * l ? ret : i * i * i + l * l * l;
		}
		printf("%lld\n", n * n * n - ret);
	}
	return 0;
}

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

int main(){
  int a,b,c,d;cin>>a>>b>>c>>d;
  
  while(a){
    c-=b;a-=d;
    if(c<=0){cout<<"Yes"<<endl;return 0;}
    else if(a<=0){cout<<"No"<<endl;return 0;}
  }
  return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <stdio.h>
using namespace std;

int main() {
	string s, p;
	cin >> s >> p;
	bool flag = false;
	int s_size = s.size();
	int p_size = p.size();
	for(int i = 0; i < s_size; i++) {
		if(p[0] == s[i]) {
			for(int j = 0; j < p_size; j++) {
				// printf("%d ok\n",j%s_size);
				if(p[j] != s[(i+j)%s_size]) {
					break;
				}
				if(j == p_size-1) {
					flag = true;
				}
			}
			if(flag == true) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	if(flag == false) {
		cout << "No" << endl;
	}
}


Measured memory_bytes: 3204
#include<bits/stdc++.h>
using namespace std;
#define hackcyborg shresth_walia
#define ll long long int
#define ld long double
#define FOR(i,a,b) for (auto i = (a); i != (b); i = (a)<(b)? i+1 : i-1)
#define pb push_back
#define mod 1000000007
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n;
    cin>>n;
    string s;
    cin>>s;
    ll su[n+1][3]={0};
    if(s[0]=='R')
            ++su[0][0];
        else if(s[0]=='B')
        ++su[0][1];
        else
            ++su[0][2];
    for(int x=1;x<n;x++)
    {    su[x][0]=su[x-1][0];
         su[x][1]=su[x-1][1];
         su[x][2]=su[x-1][2];
        if(s[x]=='R')
            ++su[x][0];
        else if(s[x]=='B')
        ++su[x][1];
        else
            ++su[x][2];
    }
    ll ans=su[n-1][1]*su[n-1][0]*su[n-1][2];
    for(int x=1;x<=n/2;x++)
    {
        for(int y=0;y<n;y++)
        {
            if(y+x<n && y+2*x<n)
            {
                if(s[y]!=s[x+y] && s[y]!=s[2*x+y] && s[y+x]!=s[y+2*x])
                    --ans;
            }
        }
    }
    cout<<ans;
 
}

Measured memory_bytes: 3708