akhauriyash/Code-Regression huggingface dataset:
N,X,Y = map(int,input().split())
result = [0 for x in range(N-1)]

for p in range(1,N) :
    #print("--------- p =",p)
    for q in range(p+1,N+1) :
        #print("--- q=",q)
        if (p < X) :
            if (q <= X) :
                result[(q-p)-1] += 1
            elif (X < q <= Y) :
                result[min(q-p,1+(Y-q)+(X-p)) - 1] += 1
            elif (Y < q) :
                result[((X-p)+1+(q-Y))-1] += 1
            else :
                print("error1")
        elif (X <= p <= Y) :
            if Y < q :
                result[min(q-p,(p-X)+1+(q-Y))-1] += 1
            elif (q <= Y) :
                result[min(q-p,(p-X)+1+(Y-q))-1]+=1
            else :
                print("error2")
        elif (Y < p) :
            result[q-p-1] += 1
        else :
            print("error3")
        #print(result)

#print(result)
for k in range(N-1) :
    print(result[k])

Measured memory_bytes: 3444
#include<cmath>
#include<cstdio>
#include<algorithm>
using namespace std;
int a,b,c,d;double e;
int main()
{
	scanf("%d %d",&a,&b);
	c=b;while(c){d++;c=c/10;}
	a=a*int(pow(10,d)+0.5)+b;
	e=sqrt(a);b=sqrt(a);
	if(b==e)printf("Yes\n");
	else printf("No\n");
}

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

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<pair<int, int>, int> PP;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;

int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
bool comp(P a, P b){
    if (a.second == b.second) return a.first >= b.first;
    return a.second >= b.second;
}

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

int main(void) { 
    int N;
    cin >> N;
    vector<int> rev(N + 1);
    for (int i = 1; i <= N; i++) {
        int a;
        cin >> a;
        rev[a] = i;
    }
    for(int i = 1; i <= N; i++) {
        cout << rev[i] << ' ';
    }
}


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

#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n,s) for(int i=(s);i<(n);i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
#define rreps(i,n,s) for(int i=s;i>=n;i--)
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 (a>b) { a=b; return 1; } return 0; }

using ll = long long;
using namespace std;
constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int MOD = 1000000007;

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
int n;
cin >> n;
map<ll, int> a;
rep(i, n){
    ll tmp;
    cin >> tmp;
    a[tmp]++;
}
vector<ll>c;
for(auto v:a){
    int num=v.second;
    if(num>=2){
        rep(i,(int)(num/2)){
            c.pb(v.first);
        }
    }
}
sort(c.begin(),c.end(),greater<ll>());
ll ans=0;
if(c.size()>0){
    ans=c[0]*c[1];
}
cout<<ans<<endl;
return 0;
}

Measured memory_bytes: 6528
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <map>
using namespace std;
char s[100010];
map <int,int>ma;
int x,y,n,m;
main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
{
		scanf("%d",&x);
ma[x]++;
}
	scanf("%d",&m);
	for (int i=1;i<=m;i++)
	{
		scanf("%d",&x);
		if (ma[x]>0)
		{
			ma[x]--;
		}
		else
		{
			puts("NO");
			return 0;
		}
	}
	puts("YES");
        return 0;
}

Measured memory_bytes: 9600
#include<cstdio>
#include<vector>
//#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

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


	int N = getint(), M = getint();

	int E[200010], ne[200010], H[100010] = {};
	int k = 1;
	rep(i, M) {
		int a = getint(), b = getint();
		E[k] = b;
		ne[k] = H[a];
		H[a] = k++;
		E[k] = a;
		ne[k] = H[b];
		H[b] = k++;
	}

	bool S[100010] = {};
	S[1] = 1; 
	S[E[H[1]]] = 1;
	vector<int> kotae1, kotae2;
	kotae1.pb(1);
	kotae2.pb(E[H[1]]);

	int ima = 1;
	while (true) {
		int nakatta = 1;
		for (int i = H[ima]; i; i = ne[i]) {
			int to = E[i];
			if (!S[to]) {
				kotae1.pb(to);
				ima = to;
				S[to] = 1;
				nakatta = 0;
				break;
			}
		}
		if (nakatta) break;
	}
	ima = E[H[1]];
	while (true) {
		int nakatta = 1;
		for (int i = H[ima]; i; i = ne[i]) {
			int to = E[i];
			if (!S[to]) {
				kotae2.pb(to);
				ima = to;
				S[to] = 1;
				nakatta = 0;
				break;
			}
		}
		if (nakatta) break;
	}

	printf("%d\n", kotae1.size() + kotae2.size());
	rep(i, kotae1.size()) {
		printf("%d ", kotae1[kotae1.size() - i - 1]);
	}
	rep(i, kotae2.size()) {
		printf("%d ", kotae2[i]);
	}

	Would you please return 0;
}

Measured memory_bytes: 3448
import sys
## io
IS = lambda: sys.stdin.readline().rstrip()
II = lambda: int(IS())
MII = lambda: list(map(int, IS().split()))
MIIZ = lambda: list(map(lambda x: x-1, MII()))
## dp
INIT_VAL = 0
DP2 = lambda d1, d2: [[INIT_VAL]*d2 for _ in range(d1)]
DP3 = lambda d1, d2, d3: [[[INIT_VAL]*d3 for _ in range(d2)] for _ in range(d1)]
## math
DIVC = lambda x, y: -(-x//y)
DIVF = lambda x, y: x//y

def main():
    n = II()
    maxv = 0
    res = -1
    for i in range(1,n+1):
        cnt = 0
        x = i
        while x//2 > 0:
            if x%2 == 0:
                cnt += 1
                x //= 2
            else:
                break
        if cnt >= maxv:
            maxv = cnt
            res = i
    print(res)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define ios ios_base::sync_with_stdio(0);cin.tie(0);
#define F first
#define S second
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
char grid[50][50], mat[50][50];
int main(){
  int n, m;
  cin >> n >> m;
  for(int i = 0 ;i < n ; i++)
    cin >> grid[i];
  for(int i = 0 ;i < m ; i++)
    cin >> mat[i];
  bool flag = false;
  for(int i = 0; i < n; i++){
    for(int j = 0; j < n; j++){
      if(i + m <= n && j + m <= n){
        bool chk = true;
        for(int f1 = 0; f1 < m; f1++){
          for(int f2 = 0; f2 < m; f2++){
            if(mat[f1][f2] != grid[f1 + i][f2 + j])
              chk = false;
          }
        }
      flag |= chk;
      }

    }
  }
  puts(flag ? "Yes" : "No" );

  return 0;
}


Measured memory_bytes: 256
A = int(input())
B = int(input())
C = int(input())
X = int(input())
XS = str(X)
hantei = False
count = 0

for a in range(A + 1):
    for b in range(B + 1):
        for c in range(C + 1):
            if (500*a)+(100*b)+(50*c) == X:
                count += 1
print(count)


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

public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        System.out.println(n * n * n);
    }

}

Measured memory_bytes: 24304
#include <string>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i = 0;i<(n);i++)
typedef unsigned long long ull;
using namespace std;

int main(){
    int T;
    cin >> T;
    rep(_t,T){
        int gx,gy;
        cin >> gx >> gy;
        int p;
        cin >> p;
        bool matatabi[25][25][2];
        ull dp[25][25];
        rep(i,20)rep(j,20)rep(k,2){
            matatabi[i][j][k] = false;
        }
        rep(i,20)rep(j,20){
            dp[i][j] = 0;
        }
        dp[0][0] = 1;
        rep(_p,p){
            int x1,x2,y1,y2;
            cin >> x1 >> y1 >> x2 >> y2;
            if(max(y1,y2) == min(y1,y2) + 1){
                matatabi[x1][min(y1,y2)][0] = true;
                //tate
            }
            if(max(x1,x2) == min(x1,x2) + 1){
                matatabi[min(x1,x2)][y1][1] = true;
                //yoko
            }
        }
        rep(i,20)rep(j,20){
            if(!matatabi[i][j][0]){
                dp[i][j+1] += dp[i][j];
            }
            if(!matatabi[i][j][1]){
                dp[i+1][j] += dp[i][j];
            }
        }
        if(dp[gx][gy] == 0){
            cout << "Miserable Hokusai!" << endl;
        }else {
            cout << dp[gx][gy] << endl;
        }
    }
    return 0;
}

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

int main(int argc, char const *argv[])
{
	int n,k;
	cin>>n>>k;
	long long v[n];
	int cnt=0;
	for (int i = 0; i < n; ++i)
	{
		cin>>v[i];
		if (v[i]<0LL)
		{
			++cnt;
		}
	}
	long long ans=0LL;
	for (int i = 0; i <= min(k/2,cnt); ++i)
	{
		for (int j = 0; j <= min(n,k-i); ++j)
		{
			long long nans=0LL;
			multiset<long long> memo={};
			for (int l = 0; l < j; ++l)
			{
				nans+=v[l];
				memo.insert(v[l]);
			}
			for (int l = n-1; l > n-1-min(n,k-i)+j; --l)
			{
				nans+=v[l];
				memo.insert(v[l]);
			}
			int t=0;
			for (auto l = memo.begin(); l != memo.end(); ++l)
			{
				if (*l>0||t==i)
				{
					break;
				}
				nans-=*l;
				++t;
			}
			ans=max(ans,nans);
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
def all_sum(val):
    sum = 0
    for i in range(val):
        sum = sum + i + 1
    return sum / val


[n, k] = input().split()

p = input().split()

k = int(k)
n = int(n)
p = [int(i) for i in p]

total = 0
max_total = 0
for i in range(k):
    total = total + p[i]
max_total = total
max_ind = 0

for i in range(n - k):
    total = total - p[i] + p[i + k]
    if(max_total < total):
        max_total = total
        max_ind = i + 1
ans = 0
for i in range(k):
    ans = ans + all_sum(p[i + max_ind])

print("{:.8f}".format(ans))


Measured memory_bytes: 71792
/// In The Name Of God

#include <bits/stdc++.h>

#define f first
#define s second

#define pb push_back
#define pp pop_back
#define mp make_pair

#define sz(x) (int)x.size()
#define sqr(x) ((x) * 1ll * (x))
#define all(x) x.begin(), x.end()

#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, l, r) for (int i = (l); i >= (r); i--)

#define Kazakhstan ios_base :: sync_with_stdio(0), cin.tie(0), cout.tie(0);

#define nl '\n'
#define ioi exit(0);

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

const int N = (int)2e6 + 7;
const int inf = (int)1e9 + 7;
const int mod = (int)1e9 + 7;
const ll linf = (ll)1e18 + 7;

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

using namespace std;

int bp(int x, int y) {
	int res = 1;
	while (y) {
		if (y & 1) res = res * 1ll * x % mod;
		x = x * 1ll * x % mod, y >>= 1;
	}
	return res;
}

int n, k;
int dp[N], f[N], rv[N];
char s[N];

int cnk(int x, int y) {
	return (f[x] * 1ll * rv[x - y] % mod) * 1ll * rv[y] % mod;
}

int main() {
	#ifdef wws
		freopen ("in.txt", "r", stdin);
	#endif
	Kazakhstan
	cin >> k >> (s + 1);
	n = strlen(s + 1);
	f[0] = rv[0] = 1;
	rep(i, 1, n + k) {
		f[i] = f[i - 1] * 1ll * i % mod;
		rv[i] = bp(f[i], mod - 2);
	}
	dp[n + k] = 1;
	per(i, n + k - 1, 1) {
		dp[i] = cnk(n + k, i) * 1ll * bp(25, n + k - i) % mod;
		// dp[i] -= dp[i + 1];
		dp[i] += mod;
		dp[i] %= mod;
	}
	int ans = 0;
	// rep(i, 1, n + k) cout << i << ' ' << dp[i] << nl;
	rep(i, n, n + k) ans = (ans + dp[i]) % mod;
	cout << ans;
	ioi
}


Measured memory_bytes: 27952
package main

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

const (
	initialBufSize = 100000
	maxBufSize     = 10000000
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wt = bufio.NewWriter(os.Stdout)
)

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

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(next(), 64)
	return f
}

func nextFloat64s(n int) []float64 {
	slice := make([]float64, n)
	for i := 0; i < n; i++ {
		slice[i] = nextFloat64()
	}
	return slice
}

func putf(format string, a ...interface{}) {
	fmt.Fprintf(wt, format, a...)
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, initialBufSize), maxBufSize)
	defer wt.Flush()

	n, m := nextInt(), nextInt()
	h := nextInts(n)

	top := make([]bool, n)
	for i := range top {
		top[i] = true
	}
	for i := 0; i < m; i++ {
		a, b := nextInt()-1, nextInt()-1
		if h[a] <= h[b] {
			top[a] = false
		}
		if h[b] <= h[a] {
			top[b] = false
		}
	}
	// puts(top)

	ans := 0
	for i := range top {
		if top[i] {
			ans++
		}
	}
	puts(ans)
}


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

// #define multitest 1
// #define Debug 1
#ifdef Debug
#define db(...) ZZ(#__VA_ARGS__, __VA_ARGS__);
template <typename Arg1>
void ZZ(const char *name, Arg1 &&arg1)
{
	std::cerr << name << " = " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void ZZ(const char *names, Arg1 &&arg1, Args &&... args)
{
	const char *comma = strchr(names + 1, ',');
	std::cerr.write(names, comma - names) << " = " << arg1;
	ZZ(comma, args...);
}
#else
#define db(...)
#endif

typedef long long ll;
typedef long double ld;
#define f first
#define s second
#define pb push_back
const long long mod = 1000000007;

const int nax = 405;
ll INF = 1e18 + 5;
ll dp[nax][nax];

void solve()
{
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; ++i)
		cin >> a[i];
	auto sum = [&](int L, int R) {
		ll sum = 0;
		for (int i = L; i <= R; ++i)
			sum += a[i];
		return sum;
	};
	for (int l = n - 1; l >= 0; --l)
		for (int r = l; r < n; ++r)
		{
			if (l == r)
				dp[l][r] = 0;
			else
			{
				dp[l][r] = INF;
				ll s = sum(l, r);
				for (int i = l; i <= r - 1; ++i)
					dp[l][r] = min(dp[l][r], dp[l][i] + dp[i + 1][r] + s);
			}
		}
	cout << dp[0][n - 1];
}

int main()
{
#ifndef Debug
	ios_base::sync_with_stdio(0);
	cin.tie(0);
#endif
	int t = 1;
#ifdef multitest
	cin >> t;
#endif
	while (t--)
		solve();
	return 0;
}

Measured memory_bytes: 1536
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

def main():
    N,K = map(int, readline().split())
    A = [int(i) - 1 for i in readline().split()]

    p = 0
    while K:
        if K & 1:
            p = A[p]
        A = [A[a] for a in A]
        K >>= 1
    
    print(p + 1)


if __name__ == "__main__":
    main()


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

public class Main {

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

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

		String line = "";
		int[] weight = {91,81,75,69,64,60,57,54,51,48,0};
		String[] cls = {"heavy","light heavy","middle","light middle",
						"welter","light welter","light","feather","bantam","fly","light fly"};

		while ((line = br.readLine()) != null) {
			double w = Double.parseDouble(line);
			for (int i = 0; i < cls.length; i++) {
				if (w > weight[i]) {
					System.out.println(cls[i]);
					break;
				}
			}
		}


	}

}

Measured memory_bytes: 16884
package main

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

var par []int

func main() {
	var n int
	fmt.Scan(&n)
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	ps := make([][]int, n)
	for i := range ps {
		sc.Scan()
		x, _ := strconv.Atoi(sc.Text())
		sc.Scan()
		y, _ := strconv.Atoi(sc.Text())
		ps[i] = []int{x, y, i}
	}
	rs := make([][]int, 0)

	sort.Slice(ps, func(i, j int) bool { return ps[i][0] < ps[j][0] })
	for i := 0; i < n-1; i++ {
		cost := ps[i+1][0] - ps[i][0]
		rs = append(rs, []int{ps[i][2], ps[i+1][2], cost})
	}

	sort.Slice(ps, func(i, j int) bool { return ps[i][1] < ps[j][1] })
	for i := 0; i < n-1; i++ {
		cost := ps[i+1][1] - ps[i][1]
		rs = append(rs, []int{ps[i][2], ps[i+1][2], cost})
	}

	sort.Slice(rs, func(i, j int) bool { return rs[i][2] < rs[j][2] })
	par = make([]int, n)
	for i := range par {
		par[i] = i
	}
	var ans int
	for i := range rs {
		a, b := rs[i][0], rs[i][1]
		if same(a, b) {
			continue
		}
		ans += rs[i][2]
		unite(a, b)
	}
	fmt.Println(ans)
}

func root(x int) int {
	if par[x] == x {
		return x
	}
	par[x] = root(par[x])
	return par[x]
}

func unite(x, y int) {
	rx := root(x)
	ry := root(y)
	if rx == ry {
		return
	}
	par[rx] = ry
}

func same(x, y int) bool {
	return root(x) == root(y)
}

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

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

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


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


int main(){
  ll N,ans=0;
  cin >> N;
  
  vector<ll> a(N);
  rep(i,N)
    cin >> a.at(i);
  
  sort(a.begin(),a.end());
  reverse(a.begin(),a.end());
 
  ans+=a.at(0);
  
  for(int i=1;i<N-1;i++){
    if(i%2==1){
      ans+=a.at(i/2+1);
    }else{
      ans+=a.at(i/2);
    }
  }
    
  cout << ans << endl;
}

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

#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define ACC(c) (accumulate(ALL(c), 0LL))
#define PRINT(x) cout << (x) << "\n"

using namespace std;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;

inline int std_in(int& a) {return scanf("%d", &a);}
auto pint_compare = [](pint x, pint y) -> bool{return (x.first < y.first);};
const int MOD = 1000000007;


signed main(){
    int A, B;
    cin >> A >> B;
    if(0 < A && A < 10 && 0 < B && B < 10) PRINT(A * B);
    else PRINT("-1");
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include "bits/stdc++.h"
using namespace std;
#define print(x) cout<<x<<endl;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a) for(int i=0;i<a;i++)
#define debug int debug = 0;
#define RREP(i,a) for(int i=a-1;i>=0;i--)
#define rrep(i,a,b) for(int i=a-1;i>=b;i--)
#define printall(n,array) {for(int i=0;i<n;i++){cout<<array[i]<<" ";}cout<<endl;}
#define U() cout<<endl;
typedef long long ll;
typedef pair<int, int> Pi;
typedef pair<int, Pi> V;
typedef vector<int> VE;
const ll mod = 1e9 + 7; //10^9+7

int main(){
    int Odd[100002] = {};
    int Even[100002] = {};
    int n;
    int q;
    int v[100002];
    int max_odd = 0;
    int max_even = 0;
    int max_odd_i = 0;
    int max_even_i = 0;
    int semi_max_odd = 0;
    int semi_max_even = 0;

    cin >> n;
    REP(i, n){
        cin >> v[i];
        if(i % 2 == 1){
            Odd[v[i]]++;
            if(max_odd > Odd[v[i]])continue;
            max_odd = Odd[v[i]];
            max_odd_i = v[i];
        }else{
            Even[v[i]]++;
            if(max_even > Even[v[i]])continue;
            max_even = Even[v[i]];
            max_even_i = v[i];
        }
    }
    int cnt = 0;
    /*
8
5 3 5 2 5 5 5 5
    */
    sort(Odd, Odd + 100002, greater<>());
    sort(Even, Even + 100002, greater<>());
    if(max_odd_i == max_even_i){
        cnt = min(n - Odd[0] - Even[1], n - Even[0] - Odd[1]);
    }else{
        cnt = n - Odd[0] - Even[0];
    }
    print(cnt);
}

Measured memory_bytes: 1408
K,N = gets.strip.split(nil).map(&:to_i)
house = gets.strip.split(nil).map(&:to_i)
#一番長い区間を避ける、折り返しはかならず損する
ary = [ ]
(0..N-2).each do |x|
  ary.unshift(house[x+1]-house[x])
end
ary.unshift(K-house[N-1]+house[0])
puts ((ary.sum)-(ary.max))

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

using namespace std;

typedef long long ll;

ll get () {
  string s;
  cin >> s;

  ll ans = 0;
  bool dot = false;
  int aft = 0;
  for (char c : s) {
    if (c == '.') {
      dot = 1;
    } else {
      ans *= 10;
      ans += c - '0';
      if (dot) aft++;
    }
  }

  while (aft < 9) {
    ans *= 10;
    aft++;
  }
  return ans;
}

const int MAX_N = 20;

ll cnt [MAX_N][MAX_N];

int divc (ll x, int K) {
  int ans = 0;
  while (x % K == 0) {
    ans++;
    x /= K;
  }
  return ans;
}

void add (ll x) {
  cnt[min(MAX_N - 1, divc(x, 2))][divc(x, 5)]++;
}

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

  int n;
  cin >> n;

  for (int i = 0; i < n; i++) {
    ll cur = get();
    add(cur);
  }

  ll ans = 0;
  for (int i = 0; i < MAX_N; i++) {
    for (int j = 0; j < MAX_N; j++) {
      for (int k = 0; k < MAX_N; k++) {
        for (int l = 0; l < MAX_N; l++) {
          if (i + k >= 18 && j + l >= 18) {
            if (i == k && j == l) {
              ans += cnt[i][j] * (cnt[k][l] - 1);
            } else {
              ans += cnt[i][j] * cnt[k][l];
            }
          }
        }
      }
    }
  }
  cout << ans / 2 << endl;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;

int main(){
	int n; ll lbound;
	cin >> n >> lbound;
	vector<ll> a(n);
	for( auto &k : a ) cin >> k;
	int knot = -1;
	for( int i = 0; i < n-1; ++i ){
		if( a[i] + a[i+1] >= lbound ){
			knot = i+1;
		}
	}
	if( knot == -1 ){
		cout << "Impossible" << endl;
		return 0;
	}
	cout << "Possible" << endl;
	for( int i = 1; i < n; ++i ){
		if( i == knot ) break;
		cout << i << endl;
	}
	for( int i = n-1; i >= 0; --i ){
		if( i == knot ) break;
		cout << i << endl;
	}
	cout << knot << endl;
	return 0;
}

Measured memory_bytes: 1664
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    int N;
    cin >> N;
    vector<ll> A(N);
    map<ll, int> M, C;
    rep(i, N) {
        cin >> A[i];
    }
    
    for(int i = N - 1; i >= 0; i--){
        M[A[i]] = i;
        C[A[i]]++;
    }
    vector<pair<ll, int>> B;
    
    for(auto c: C){
        B.pb(mp(c.first, c.second));
    }
    
    int sz = (int)B.size();
    for(int i = sz - 2; i >= 0; i--){
        B[i].second += B[i + 1].second;
    }
    
    vector<ll> R(N);
    int m = inf;
    for(int i = sz - 2; i >= 0; i--){
        m = min(m, M[B[i + 1].first]);
        ll d = B[i + 1].first - B[i].first;
        R[m] += d * B[i + 1].second;
    }
    m = min(m, M[B[0].first]);
    R[m] += B[0].first * B[0].second;
    rep(i, N){
        output(R[i]);
    }
    
    
    
    return 0;
}

Measured memory_bytes: 16756
import numpy as np

H, W = map(int, input().split())
max_value = H + W #左上から右下までの最大手数
matrix = []

#黒の場合0, それ以外の場合、max_valueを代入したリストを作成-->arrayへ変換
for _ in range(H):
    matrix.append([0 if i == '#' else max_value for i in list(input())])
matrix = np.array(matrix)

for c in range(W-1):#y座標を増やしていく
    matrix[:,c+1] = np.minimum(matrix[:,c]+1, matrix[:,c+1]) #一個左+1　と　自分自身の値　の小さい方
#print (matrix)
for c in range(W-1,0,-1):
    matrix[:,c-1] = np.minimum(matrix[:,c]+1, matrix[:,c-1]) #一個右+1　と　自分自身の値　の小さい方
#print (matrix)
for c in range(H-1):
    matrix[c+1,:] = np.minimum(matrix[c,:]+1, matrix[c+1,:]) #一個下+1　と　自分自身の値　の小さい方　
#print (matrix)
for c in range(H-1,0,-1):
    matrix[c-1,:] = np.minimum(matrix[c,:]+1, matrix[c-1,:]) #一個上+1　と　自分自身の値　の小さい方
#print (matrix)
print (np.max(matrix))


Measured memory_bytes: 28964
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n; i >= 0; i--)
#define inf LLONG_MAX
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;


int main()
{
    ll n, m;
    cin >> n >> m;
    if (2 * n >= m) {
        cout << m / 2 << endl;
        return 0;
    }
    ll count = n;
    m -= 2 * n;
    count += m / 4;
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long; 
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
//constexpr long long MOD = 998244353LL;
template<class T, class U> inline bool chmax(T &a, U b) { if (a < b) { a = b; return true;} return false; }
template<class T, class U> inline bool chmin(T &a, U b) { if (a > b) { a = b; return true;} return false; }
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
int a[15][15];

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

    int n = 3;
    rep(i,n)rep(j,n) cin>>a[i][j];
    
    rep(i,n-1){
        if(a[0][i] - a[1][i] != a[0][i+1] - a[1][i+1] ||
           a[1][i] - a[2][i] != a[1][i+1] - a[2][i+1]){
               cout << "No" << ln;
               return 0;
        }
    }
    cout << "Yes" << ln;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb emplace_back
#define mp make_pair
#define ff first
#define ss second
#define rev(r) reverse(r.begin(),r.end())
#define SORT(ar) sort(ar.begin(), ar.end())
#define sz(x) (int)(x).size()
#define len(x) (int)x.length()
#define in(a) scanf("%d",&a)
#define pr(x) printf("%d ",x)
#define endl '\n'
#define read(v,n) for(int h=0;h<n;h++) cin>>v[h];
#define fo(i,a,b) for(i=a;i<b;i++)
#define fi(i,a,b) for(i=a;i>=b;i--)
#define mo 1000000007
#define N 300007

int main()
{
    int n,i,j,k;
    cin>>n>>k;
    int h[n];
    fo(i,0,n) cin>>h[i];
    int dp[n];
    fill(dp,dp+n,INT_MAX);
    dp[0]=0;
    fo(i,1,n)
    {
        fo(j,1,min(i,k)+1) dp[i]=min(dp[i],dp[i-j]+abs(h[i]-h[i-j]));
    }
    cout<<dp[n-1]<<endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

int main(){
  bool begin = true;
  while(true){
    string s, text, query;
    while(getline(cin, s) && s != ""){
      text += s;
    }
    if(text == "") break;
    getline(cin, query);
    assert(query != "");
    getline(cin, s); // empty
    assert(s == "");

    /*
    if(begin) begin = false;
    else cout << endl;
    */

    int N = text.size();
    int L = query.size();

    map<char, int> to_idx;
    REP(i, L) to_idx[query[i]] = i;

    vector<int> idx_vec[100];
    REP(i, N) if(to_idx.count(text[i])) idx_vec[to_idx[text[i]]].push_back(i);

    bool ok = true;
    REP(i, L) if(idx_vec[i].empty()) ok = false;
    if(!ok){
      cout << 0 << endl;
      cout << endl;
      continue;
    }

    map<int, set<int> > cnt;
    int shortest_length = INF;
    vector<int> cur(L);
    while(true){
      int b = idx_vec[0][cur[0]], e = idx_vec[0][cur[0]];
      REP(i, L) {
        b = min(b, idx_vec[i][cur[i]]);
        e = max(e, idx_vec[i][cur[i]]);
      }
      int l = e - b + 1;
      shortest_length = min(shortest_length, l);
      if(shortest_length == l) cnt[l].insert(b);

      int idx = -1;
      REP(i, L)if(cur[i] + 1 < idx_vec[i].size()){
        if(idx == -1 || idx_vec[i][cur[i] + 1] < idx_vec[idx][cur[idx] + 1]){
          idx = i;
        }
      }
      if(idx == -1) break;
      cur[idx] += 1;
    }
    cout << cnt[shortest_length].size() << endl;
    cout << endl;
    string ans = text.substr(*cnt[shortest_length].begin(), shortest_length);
    for(int i = 0; i < ans.size(); i += 72){
      if(i + 72 < ans.size()) cout << ans.substr(i, 72) << endl;
      else cout << ans.substr(i) << endl;
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 3712
#include<bits/stdc++.h>
using namespace std;
int main(){
//    freopen("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);
    string s;
    int x = 0;
    cin >> s;
    int n = s.size();
    for(int i = 0; i < n; i++){
        if(s[i] == '+') x++;
        if(s[i] == '-') x--;
    }
    cout << x << endl;
return 0;
}


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

int main () {
  int n;
  cin>>n;
  vector<long long>a(n);
  for (int i=0;i<n;i++){
    cin>>a[i];
  }
  sort(a.begin(),a.end());
  long long cho=a[0];
  int cnt =0;
  for (int i=1;i<n;i++){
    if(cho < a[i]){
      cho =a[i];
    }else if (cho ==a[i]){
      cnt =1;
    }
  }
  if(cnt ==1){
    cout <<"NO"<<endl;
  }else{
    cout <<"YES"<<endl;
  }
}


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

using Graph = vector<vector<pair<int, int>>>;
Graph G;
vector<int> color;

void dfs(int v, int cur = 0) {
    color[v] = cur;
    for (auto e : G[v]) {
        if (color[e.first] != -1) continue;
        // if (e.first == v) continue;
        if (e.second % 2 == 0) {
            dfs(e.first, cur);
        }
        else dfs(e.first, 1-cur);
    }
    return;
}

int main() {
    int N;
    cin >> N;
    G.assign(N, vector<pair<int, int>>());
    color.assign(N, -1);

    for (int i = 0; i < N-1; i++) {
        int a, b, c; cin >> a >> b >> c; a--; b--;
        G[a].push_back(pair<int, int>(b, c));
        G[b].push_back(pair<int, int>(a, c));
    }

    dfs(0);

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

Measured memory_bytes: 8192
#include<iostream>
#include<string.h>
using namespace std;
const int MAXN = 3000000;
const int MAXA = 20000;

int A[MAXN];
int B[MAXN];
int C[MAXA];

int main()
{
	int n;
	cin >> n;
	memset(C,0,sizeof(C));
	for(int i = 1; i <= n; i++)
	{
		cin >> A[i];
		C[A[i]]++;
	}
	for(int i = 1; i<=MAXA;i++)
		C[i] = C[i]+C[i-1];
		
	for(int i = 1; i<=n;i++)
	{
		B[C[A[i]]] = A[i];
		C[A[i]]--;	
	}
	
	for(int i = 1; i<=n; i++)
	{
		if(i>1) cout << " ";
		cout << B[i];	
	}
	cout << endl;
		
}

Measured memory_bytes: 18784
/*
 _____ ____ _____   ___   ___   ___   ___ 
|_   _/ __ \_   _| |__ \ / _ \ |__ \ / _ \
  | || |  | || |      ) | | | |   ) | | | |
  | || |  | || |     / /| | | |  / /| | | |
 _| || |__| || |_   / /_| |_| | / /_| |_| |
|_____\____/_____| |____|\___/ |____|\___/ 
*/
#include <bits/stdc++.h>
#include <fstream>
//#include "ele.h"
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define per(i, a, b) for (int i = (a); i > (b); i--)
#define a(x) (x.begin(), x.end())
#define ar(x) (x.rbegin(), x.rend())
#define pb push_back
#define Pb() pop_back()
#define ll long long int
#define ull unsigned long long int
#define pii pair<int, int>
#define pll pair<ll, ll>
#define sc scanf
#define scin(x) sc("%d", &(x))
#define scln(x) sc("%lld", &(x))
#define pf prllf
#define ms(a, b) memset(a, b, sizeof(a))
#define mp make_pair
#define db double
#define EPS 10E-10
#define ff first
#define ss second
#define sqr(x) (x) * (x)
#define vi vector<int>
#define vl vector<ll>
#define vii vector<vector<int>>
#define vll vector<vector<ll>>
#define DBG pf("HI\n")
#define MOD 1000000007
#define CIN                       \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0)
#define RUN_CASE(t, T) for (__typeof(t) t = 1; t <= T; t++)
#define CASE(t) prllf("Case %d: ", t)
#define CASEL(t) prllf("Case %d:\n", t)
#define intlimit 2147483647
#define longlimit 9223372036854775807
#define infinity (1 << 28)
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) ((a) * (b) / gcd(a, b))
#define PI 2 * acos(0.0)
// assert(x==y); gives run time when false
using namespace std;
int main()
{
    CIN;
    int n;
    cin >> n;
    vi v(n);
    rep(i,0,n)cin >> v[i];
    int sum = 0,mini = 1000000001;
    rep(i,0,n){
        if(mini > v[i]){
            sum++;
            mini = v[i];
        }
    }
    cout << sum;
}


Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int main(){
	int a, b = 0;
	cin >> a >> b;
	if (a > b){
		cout << "a > b" << endl;
	}
	if (a < b){
		cout << "a < b" << endl;
	}
	if(a==b){
		cout << "a == b" << endl;
	}
	return 0;
}

Measured memory_bytes: 3104
/// Kazuki Hoshino


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;
typedef vector<pi> vpi;
#define inf 1000000000
#define mod 1000000007
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define rep1(i, a, b) for(int i =a; i >=b; i--)
#define f first
#define ss second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple

int n, x[101010], y[101010], t[101000];

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

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


cin >> n;

rep(i, 1, n){

cin >> t[i] >> x[i] >> y[i];

int temp = (t[i]-t[i-1]) - (abs(x[i]-x[i-1])+abs(y[i]-y[i-1]));
    if(temp<0 || temp%2){
    cout << "No";
    return 0;
}

}

cout << "Yes" << endl;






return 0;}
///.... Maria Otonashi


Measured memory_bytes: 1408
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        char[] cs = S.toCharArray();
        int ans = 0;
        int l = S.length();
//        if (l % 2 == 0) {
            for(int i=0;i<l/2;i++){
                if(cs[i] != cs[l-1-i]){
                    ans++;
                }
            }
//        }
//        else {
//            for(int i=0;i<l/2;i++){
//                if(cs[i] != cs[l-1-i]){
//                    ans++;
//                }
//            }
//        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 23636
#include<iostream>
#include<vector>
#include<string>
#include<stdlib.h>

using namespace std;

int main() {

	int a, b, c, d, e, k;
	cin >> a >> b >> c >> d >> e >>k;

	if (e - a > k)
		cout << ":(";
	else
		cout << "Yay!";
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
const int N = 100001;
string k;
int d;
long long dp[N][100][2];
long long calc(int idx, int sum, bool sml) {
	if (idx >= (int)k.size()) {
		if (sum % d == 0)
			return 1;
		return 0;
	}
	long long &ret = dp[idx][sum][sml];
	if (ret != -1)
		return ret;
	ret = 0;
	for (int i = 0; i <= 9; ++i) {
		int num = k[idx] - '0';
		if (!sml && i > num)
			break;
		ret = (ret + calc(idx + 1, (sum + i) % d, sml || (i < num))) % MOD;
	}
	return ret;
}
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> k >> d;
	memset(dp, -1, sizeof(dp));
	long long ans = (calc(0, 0, false) + MOD - 1) % MOD;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 157440
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cmath>

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define EPS (1e-15)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
#define bet(x, a, b) (a) <= (x) && (x) < (b)
typedef long long ll;
typedef unsigned long long ull;

int main()
{
	int N, M;

	cin >> N >> M;

	cout << N * (N - 1) / 2 + M * (M - 1) / 2 << endl;

	return 0;
}


Measured memory_bytes: 256
S = list(input())
 
left = [0]*(len(S)+1)
 
right = [0]*(len(S)+1)
 
for i in range(len(S)):
    if S[i] == '<':
        left[i+1] += 1+left[i]
 
for i in range(len(S)-1,-1,-1):
    if S[i] == '>':
        right[i] = right[i+1]+1
 
ans = [0]*(len(S)+1)
for i in range(len(S)+1):
    ans[i] = max(left[i],right[i])
print(sum(ans))


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

string s[3];

int main() {
  for(int i = 0; i < 3; ++i) cin >> s[i];
  for(int i = 0; i < 3; ++i)
    cout << (char)(s[i][0] - 'a' + 'A');
  cout << endl;
  return 0;
}

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

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

#define mod 1000000007
typedef long long ll;

int main() {
    ll n,ans=0;
    cin>>n;
    rept(i,1,n+1){
        if(i%3&&i%5) ans+=i;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3636
#include <iostream>

using namespace std;

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

int m, n;
bool tront[90][90];

int dfs(int y, int x) {
	int dx[4] = {0,1,0,-1}, dy[4] = {1,0,-1,0};
	int rep = 0;

	REP(i, 4) {
		int nx = x + dx[i], ny = y + dy[i];
		if (! (nx >= 0 && nx < m && ny >= 0 && ny < n)) continue;
		if (! tront[ny][nx]) continue;
		tront[ny][nx] = false;
		rep = max(rep, dfs(ny, nx));
		tront[ny][nx] = true;
	}
	return rep + 1;
}


int main() {
	while (true) {
		int ans = 0;
		cin >> m >> n;
		if (n == 0 && m == 0) break;
		REP(i, n) REP(j, m) cin >> tront[i][j];

		REP(i, n) REP(j, m) if (tront[i][j]) {
			tront[i][j] = false;
			ans = max(ans, dfs(i, j));
			tront[i][j] = true;
		}

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

Measured memory_bytes: 1168
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
using namespace std;
using Edge=pair<int,int>;
using Graph=vector<vector<int>>;
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T>inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
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;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,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;}

int main(){
  ll A,B;
  cin>>A>>B;
  
  if(abs(A-B)<=1) co("Brown");
  else co("Alice");
  return 0;
}

Measured memory_bytes: 3548
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

    public static void main(String[] args) throws Exception {
        String line = readLine();
        StringTokenizer st = new StringTokenizer(line, " ");
        int a = Integer.parseInt(st.nextToken());
        int b = Integer.parseInt(st.nextToken());

        if (a > b ) {
        	System.out.println(String.valueOf(a-1));
        } else {
        	System.out.println(String.valueOf(a));
        }
    }

    private static String readLine() throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        return br.readLine();
    }
}

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

int main() {
    int A, B, count;
    cin >> A >> B;
    count = 0;
  
    for (int i = A; i <= B; i++){
      
      if (i % 10 == i / 10000 && (i / 10) % 10 == (i /1000) % 10){
        count++;
      }
    }
    cout << count << endl;
}
      

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	
	static int n;
	static int c[], s[], f[];
	
	public static int solve(int start) {
		int ans = 0;
		if(start == n - 1)return 0;
		ans = s[start] + c[start];
		int t = ans;
		for(int i = start + 1; i < n - 1; ++i) {
			int tmp = (t - s[i]) / f[i];
			if((t - s[i]) % f[i] != 0)tmp++;
			if(t < s[i])tmp = 0;
			tmp = s[i] + (f[i] * tmp);
			tmp = tmp - t;
			ans += tmp + c[i];
			t += tmp + c[i];
		}
		return ans;
	}
	
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		c = new int[n - 1];
		s = new int[n - 1];
		f = new int[n - 1];
		for(int i = 0; i < n - 1; ++i) {
			c[i] = sc.nextInt();
			s[i] = sc.nextInt();
			f[i] = sc.nextInt();
		}
		int x = 0;
		sc.close();
		for(int i = 0; i < n; ++i) {
			x = solve(i);
			System.out.println(x);
		}
		
	}
}


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

class Main{
	public static void main(String[] args)throws IOException {
		String str="";
		BufferedReader bfr = new BufferedReader(new InputStreamReader(System.in));
		String[] datas;
		int[] rika=new int[4];
		int[] syakai=new int[2];
		int rikamin=100;
		int syamin=100;

		int sum=0;

		for(int i=0; i<6; i++) {
			if(i<4) {
				rika[i]=Integer.parseInt(bfr.readLine());
				if(rika[i]<rikamin) {
					rikamin=rika[i];
				}
				sum+=rika[i];
			}
			else if(i>=4) {
				syakai[i-4]=Integer.parseInt(bfr.readLine());
				if(syakai[i-4]<syamin) {
					syamin=syakai[i-4];
				}
				sum+=syakai[i-4];
			}
		}
		sum=sum-syamin-rikamin;
		System.out.println(sum);
	}
}


Measured memory_bytes: 24220
#include<bits/stdc++.h>
#define ll long long int
#define M 1000000007
using namespace std;
ll n,t;

int main(){
      ios_base::sync_with_stdio(false); cin.tie(NULL);
      cin>>n;
      ll a[n],x=0;
      for(int i=0;i<n;i++)
      {
        cin>>a[i];
        x^=a[i];
      }
      for(int i=0;i<n;i++)
      {
        cout<<(x^a[i])<<" ";
      }
}

Measured memory_bytes: 5148
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1LL << 60;

int main() {
    int a, b; cin >> a >> b;
    string s; cin >> s;
    
    bool flag = true;
    if (s.length() != a + b + 1) flag = false;
    if (s[a] != '-') flag = false;
    for (int i = 0; i < s.length(); i++) {
        if (s[i] == '-') {
            if (i != a) flag = false;
        }
    }

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

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cstring>
#include <utility>

using namespace std;

int main(){

    int N;
    cin >> N;
    vector<int> W(N);
    for(int i = 0; i < N; i++){
        cin >> W[i];
    }    

    int ans = 1000000;
    for(int i = 0; i < N; i++){
        int leftW = 0;
        int rightW = 0;

        for(int j = 0; j <= i; j++){
            leftW += W[j];
        }

        for(int j = i + 1; j < N; j++){
            rightW += W[j];
        }

        ans = min(ans, abs(leftW - rightW));
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string.h>
using namespace std;

char s1[205],s2[205];
bool mark;
int w,ww,i,j;
int main()
{
	while(1)
	{
		w=0;
		mark=0;
		scanf("%s",s1);
		if(s1[0]=='.') break;
		scanf("%s",s2);
		int l=strlen(s1),len=strlen(s2);
		for(i=0,j=0;i<l&&j<len;j++,i++)
		{
			//printf("%d %c %d %c %d\n",i,s1[i],j,s2[j],mark);
			if(s1[i]==s2[j]&&s1[i]!='"') continue;
			if(s1[i]=='"'&&s2[j]=='"') 
			{
				mark=(mark+1)%2;
			}
			if(s1[i]!=s2[j]&&!(mark)) 
			{
				printf("DIFFERENT\n");
				w=2;
				break;
			} 
			if(s1[i]!=s2[j]&&mark)
			{
				w++;
				if(w>1)
				{
					printf("DIFFERENT\n");
					break;	
				}
				else 
				{
					while(s1[i]!='"') i++;
					while(s2[j]!='"') j++;
					mark=0;
				}
			}
		} 
		if(w!=2&&(len-j>0||l-i>0))
		{
			printf("DIFFERENT\n");
			w=2;
		} 
		else if(w==1) printf("CLOSE\n");
			if(w==0) printf("IDENTICAL\n");
	}
	return 0;
}


Measured memory_bytes: 3108
#include<iostream>
#include<vector>
int main()
{
    int n, q ;
    std::cin >> n ;
    std::vector<int> vec1(n) ;
    for( int i = 0 ; i < n ; ++i )
    {
        std::cin >> vec1.at(i) ;
    }
    std::cin >> q ;
    std::vector<int> vec2(q) ;
    for( int i = 0 ; i < q ; ++i )
    {
        std::cin >> vec2.at(i) ;
    }

    int count{} ;

    for( int i = 0 ; i < q ; ++i )
    {
        for( int j = 0 ; j < n ; ++j )
        {
            if( vec1.at(j) == vec2.at(i) )
            {
                ++count ;
                break ;
            }
        }
    }

    std::cout << count << std::endl ;
}



Measured memory_bytes: 3076
import java.util.*;
public class Main {
	public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String t = sc.next();
        char[] chS = s.toCharArray();
        char[] chT = t.toCharArray();
        int min = t.length(); 
        for (int i = 0; i <= s.length() - t.length(); i++) {
            int cur = 0; 
            for (int j = 0; j < t.length(); j++) {
                    if (chS[i + j] != chT[j]) {
                        cur++;
                    } 
            }
            min = Math.min(min, cur);
        }
        System.out.println(min);
	}
}

Measured memory_bytes: 35584
n , h = map(int,input().split())
p = []
q = []
for i in range(n):
    a , b = map(int,input().split())
    p.append(a)
    q.append(b)
A = max(p)
q.sort(reverse=True)
ans = 0
for i in range(n):
    ans += 1
    h -= max(q[i],A)
    if h <= 0:
        print(ans)
        exit()

ans += -(-h//A)
print(ans)

Measured memory_bytes: 11296
N = int(input())
T = []
for i in range(N):
    A = int(input())
    for j in range(A):
        x,y = map(int,input().split())
        T.append([i,x-1,y==1])

ans = 0
for i in range(1<<N):
    h=[]
    for j in range(N):
        if(i&(1<<j)):
            h.append(j)

    for j,x,y in T:
        if(j in h):
            if(not((x in h)==y)):
                break
    else:
        ans = max(ans,len(h))

print(ans)
            



Measured memory_bytes: 45292
#include<stdio.h>
#include<algorithm>
#include<math.h>
using namespace std;
typedef pair<double, double>P;

int main(){
	int n;
	float a, b, c, d[100];
	scanf("%d%f%f%f", &n, &a, &b, &c);
	P best(c, a);
	for (int i = 0; i < n; i++)
		scanf("%f", &d[i]);
	sort(d, d + n, [](int a, int b){return a > b; });
	for (int i = 0; i < n; i++){
		if (best.first / best.second < (best.first + d[i]) / (best.second + b))
			best = P(best.first + d[i], best.second + b);
		else break;
	}
	printf("%d\n", (int)floor(best.first / best.second));
	return 0;
}

Measured memory_bytes: 2756