akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        int n = sc.nextInt();
        int k = sc.nextInt();
        int[] h = new int[n];
        for (int i = 0; i < n; i++) {
            h[i] = sc.nextInt();
        }
        int ans = 0;
        for (int i = 0; i < n; i++) {
            if (h[i] >= k) {
                ans++;
            }
        }
        System.out.println(ans);
    }
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte())
            return buffer[ptr++];
        else
            return -1;
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr]))
            ptr++;
        return hasNextByte();
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext())
            throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}


Measured memory_bytes: 21924
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<iostream>
#include <iomanip>
#include<queue>
#include<algorithm>
#include <functional>
#include<vector>
#include <math.h>
#include <numeric>
#include <stack>
using namespace std;

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

	int res = 0;
	while (true) {
		if (*max_element(h.begin(), h.end()) == 0) break;

		int i = 0;
		while (i < N) {
			if (h[i] == 0) ++i;
			else {
				++res;
				while (i < N && h[i]>0) {
					--h[i];
					++i;
				}
			}
		}
	}
	cout << res << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<stack>
#include<bitset>
#include<ext/pb_ds/priority_queue.hpp>
using namespace std;

struct Point{
	int x,y; Point(){}
	Point(int x,int y): x(x),y(y){}
}p[55],q[55];

int n,m;

int main()
{
	#ifdef DMC
		freopen("DMC.txt","r",stdin);
	#endif
	
	cin >> n >> m;
	for (int i = 1; i <= n; i++)
	{
		int x,y; scanf("%d%d",&x,&y);
		p[i] = Point(x,y);
	}
	for (int i = 1; i <= m; i++)
	{
		int x,y; scanf("%d%d",&x,&y);
		q[i] = Point(x,y);
	}
	for (int i = 1; i <= n; i++)
	{
		int Min = ~0U>>1,pos;
		for (int j = 1; j <= m; j++)
		{
			int now = abs(p[i].x - q[j].x) + abs(p[i].y - q[j].y);
			if (now < Min) Min = now,pos = j;
		}
		printf("%d\n",pos);
	}
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <iostream>
#include <iomanip>
#include <map>
#include <algorithm>
#include <vector>
#include <math.h>
#define MOD (long long)1000000007
using namespace std;

int main(void){
    int a,b;
    cin >> a >> b;
    cout << max(a,b)+max(max(a,b)-1,min(a,b)) << endl;
    return 0;
}

Measured memory_bytes: 256
/** By @ZhakudaMagzhan **/
# include  <bits/stdc++.h>

# define mp  make_pair
# define pb  push_back

# define   sz(x)  (int)x.size()
# define  all(x)  x.begin(), x.end()
# define  bit(x)  __builtin_popcountll(x)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

typedef pair <int,int> pii;

const int inf = (int) 1e9+50, mod = 999983ll;
const ll linf = (ll) 2e18;

int kob (int x, int y) { return ((ll)x * y) % mod; } 
int aza (int x, int y) { x -= y; if (x < 0) return x + mod; return x; } 
int kos (int x, int y) { x += y; if (x >= mod) return x - mod; return x; }

const int maxn = (int) 1e5 + 777, maxn2 = (int) 1e6 + 777;    

//temp.cpp

int cnt[50];

int main () {
	#define FN "" 
	#ifdef lcl	
		freopen (FN".in", "r", stdin);
		freopen (FN".out", "w", stdout);
	#endif
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); 
	string s;
	cin >> s;
	for (int i = 0; i < sz (s); ++ i) 
		cnt[s[i]-'a']++;
	ll res = 1;
	for (int i = 0; i < sz (s); ++ i) {
		for (int j = 0; j < 26; ++ j)
			if (j != s[i]-'a')
				res += cnt[j];
		cnt[s[i]-'a'] --;
	}

	cout << res;
	return 0;
}

Measured memory_bytes: 720
#include <bits/stdc++.h>
using namespace std;
#define ll long long
 
 
int main() {
    int N;
    cin >> N;
    ll ninf = (ll)1e16 * (-1);
    vector<ll> A(N+1);
    for (int i = 1; i <= N; i++) cin >> A[i];
    
    vector<ll> oddsum(N+1, 0), evensum(N+1, 0), allsum(N+1, 0);
    for (int i = 1; i <= N; i++) {
        oddsum[i] = oddsum[i-1];
        evensum[i] = evensum[i-1];
        allsum[i] = allsum[i-1];
        allsum[i] += A[i];
        if (i%2 == 1) oddsum[i] += A[i];
        else evensum[i] += A[i];
    }
    
    if (N%2 == 0) {
        ll ans = ninf;
        for (int i = 0; i <= N; i += 2) {
            ans = max(ans, oddsum[i] + evensum[N] - evensum[i]);
        }
        cout << ans << endl;
        return 0;
    }
    
    if (N%2 == 1) {
        ll ans = oddsum[N]-A[1];
        ll mi = 0;
        for (int i = 1; i <= N; i+=2) {
            ll rg = evensum[i] - oddsum[i];
            ans = max(ans, oddsum[N]+rg-mi);
            if (i < N) mi = min(mi, evensum[i+1]-oddsum[i+1]);
        }
        cout << ans << endl;
        return 0;
    }
    
    return 0;
}

Measured memory_bytes: 9524
#include <iostream>
#include <vector>
#include <limits.h>

#define ll long long int

using namespace std;
ll sum = 0;
void merge(ll v[], ll l,ll m,  ll r){
    ll l1 = m - l;
    ll r1 = r - m;
    ll lv[l1];
    for(ll i=0; i<l1; i++) lv[i] = v[l + i];
    ll rv[r1];
    for(ll i=0; i<r1; i++) rv[i] = v[m + i];
    ll i=0, j=0;
    for(ll k=l; k<r; k++){
        if( i<l1 and ( j == r1 or lv[i] < rv[j] )) v[k] = lv[i++];
        else {
            v[k] = rv[j++];
            sum += l1 - i;
        }
    }
}

void mergeSort(ll v[], ll l, ll r){
    if(l+1 < r){
        ll mid = (l+r)/2;
        mergeSort(v, l, mid);
        mergeSort(v, mid, r);
        merge(v, l,mid , r);
        
    }
} 


int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    ll n; cin >>n;
    ll v[n];
    for(ll i=0;i<n;i++) cin >> v[i];
    mergeSort(v, 0, n);
    cout << sum << endl;
    
    return 0;
}


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

map<int, int> prime_factor(int n)
{
    map<int, int> ret;
    int i = 2;
    while (i * i <= n)
    {
        int tmp = 0;
        while (n % i == 0)
        {
            tmp++;
            n /= i;
        }
        if (tmp > 0)
        {
            ret[i] = tmp;
        }
        i++;
    }
    if (n > 1)
    {
        ret[n]++;
    }

    return ret;
}

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

    map<int, int> mp = prime_factor(n);
    cout << n << ":";
    for (auto x : mp)
    {
        for (int i = 0; i < x.second; i++)
        {
            cout << " " << x.first;
        }
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 3108
use proconio::fastout;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
use std::cmp::min;

#[fastout]
fn main() {
    input! {
        n: usize,
        m: usize,
        x: usize,
    }
    let mut c = vec![];
    let mut a = vec![];
    for _ in 0..n {
        input! {
            ci: isize,
            ai: [usize; m],
        }
        c.push(ci);
        a.push(ai);
    }

    let mut ans = isize::max_value();
    for bits in 1..1 << n {
        let mut cost = 0;
        let mut skill = vec![0; m];
        for i in 0..n {
            if bits >> i & 1 == 1 {
                cost += c[i];
                for (si, ai) in skill.iter_mut().zip(a[i].iter()) {
                    *si += ai;
                }
            }
        }
        if skill.into_iter().all(|s| s >= x) {
            ans = min(ans, cost);
        }
    }
    println!("{}", if ans == isize::max_value() { -1 } else { ans });
}


Measured memory_bytes: 2200
#include<iostream>
#include<string>
#include<algorithm>	
#include<cmath>
using namespace std;
int main() {
	int n = 0, a, b, c, ans = 0;
	cin >> a >> b >> c;
	while (true) {
		ans++;
		n += a;
		if (ans % 7 == 0) {
			n += b;
		}
		if (n >= c) {
			cout << ans << endl;
			cin >> n; return 0;
		}
	}
}


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

typedef  long long ll;
//forループ
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
//
//
#define int long long

using namespace std;

int ctoi(char c) {
 switch (c) {
 case '0': return 0;
 case '1': return 1;
 case '2': return 2;
 case '3': return 3;
 case '4': return 4;
 case '5': return 5;
 case '6': return 6;
 case '7': return 7;
 case '8': return 8;
 case '9': return 9;
 default: return 0;
 }
}


 ll  a,b,c,s,t,i,j,k,x,y,z;
 ll A,B,C,S,T,X,Y,Z;
 ll count;
signed main(){
	
	cin>>a>>x>>y;
	if(y-x>=a || x%a>y%a || x%a==0 || y%a==0 ) cout<<"OK";
	else cout<<"NG";

 return 0;
}


Measured memory_bytes: 3620
import std.stdio;
import std.ascii;
import std.c.stdio;
import std.range;
import std.array;
import std.functional;
import std.algorithm;
import std.conv;
import std.container;
import std.math;
import std.numeric;
import std.string;
import std.c.string;
import std.regex;
import std.typecons;

void main() {
    int C, D, W, X;
    int[][] E;
    int[][] F;

    bool input() {
        scanf("%d %d %d %d\n", &C, &D, &W, &X);
        if (C == 0 && D == 0 && W == 0 && X == 0) return false;
        E = new int[][C];
        F = new int[][C];
        foreach (i; 0 .. C) {
            E[i] = readln.chomp.split(" ").map!(to!int).array;
        }
        foreach (i; 0 .. C) {
            F[i] = readln.chomp.split(" ").map!(to!int).array;
        }
        return true;
    }

    auto memo = new int[][][](31, 51, 6);
    auto memo2 = new int[][][][][](15, 31, 51, 6, 2);
    void solve() {
        foreach (i; 0 .. D + 1) foreach (j; 0 .. W + 1) memo[i][j][] = -1;
        foreach (i; 0 .. C) foreach (j; 0 .. D + 1) foreach (k; 0 .. W + 1) foreach (l; 0 .. X + 1) memo2[i][j][k][l][] = -1;
        int dfs(int d, int w, int x) {
            int dfs2(int c, int d, int w, int x, int dir) {
                if (memo2[c][d][w][x][dir] >= 0) return memo2[c][d][w][x][dir];
                //writeln("dfs2: ", [c, d, w, x, dir]);
                int Ret = dfs(d + 1, w, x);
                int i = (dir == 0 ? -1 : 1);
                if (! (c + i < 0 || c + i >= C || E[c + i][d] == 0 || w - F[c + i][d] < 0)) {
                    Ret = max(Ret, dfs2(c + i, d, w - F[c + i][d], x, dir) + E[c + i][d]);
                }
                return memo2[c][d][w][x][dir] = Ret;
            }
            if (d == D) return 0;
            if (memo[d][w][x] >= 0) return memo[d][w][x];
            int Ret = dfs(d + 1, w, x);
            foreach (c; 0 .. C) {
                if (E[c][d] == 0) continue;
                if (w - F[c][d] < 0) continue;
                Ret = max(Ret, dfs(d + 1, w - F[c][d], x) + E[c][d]);
                if (x >= 1) {
                    for (int i = -1; i <= 1; i += 2) {
                        if (c + i < 0 || c + i >= C) continue;
                        if (E[c + i][d] == 0) continue;
                        if (w - F[c][d] - F[c + i][d] < 0) continue;
                        Ret = max(Ret, dfs2(c + i, d, w - F[c][d] - F[c + i][d], x - 1, i > 0) + E[c][d] + E[c + i][d]);
                    }
                }
            }
            return memo[d][w][x] = Ret;
        }
        writeln(dfs(0, W, X));
    }
    
    while (input) solve;
}

Measured memory_bytes: 8332
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        int n = sc.nextInt();
        int d = sc.nextInt();
        
        int answer = n/(2*d+1);
        if((n%(2*d+1)) != 0){
            answer++;
        }
        System.out.println(answer);
    }
}

Measured memory_bytes: 21712
#define _CRT_SECURE_NO_WARNINGS

#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;

#define N_MAX 30010

void solv()
{
	int N; scanf("%d", &N);
	char S[N_MAX]; scanf("%s", S);

	long long int ret = 0;
	for (int i = 0; i <= 9; i++){
		int cur1 = 0;
		for (; cur1 < N; cur1++){
			if ('0' + i == S[cur1]){
				break;
			}
		}
		if (cur1 >= N - 2){
			continue;
		}
		for (int j = 0; j <= 9; j++){
			int cur2 = cur1 + 1;
			for (; cur2 < N; cur2++){
				if ('0' + j == S[cur2]){
					break;
				}
			}
			if (cur2 >= N - 1){
				continue;
			}

			int table[10]; 
			fill(table, table + 10, 0);
			for (int k = cur2 + 1; k < N; k++){
				table[S[k] - '0'] = 1;
			}
			for (int k = 0; k < 10; k++){
				ret += (long long int)table[k];
			}
		}
	}

	printf("%lld", ret);

	return;
}

int main()
{
	FILE *fin = NULL, *fout = NULL;
	//fin = freopen("input.txt", "r", stdin);
	//fout = freopen("output.txt", "w", stdout);

	solv();

	//finalize
	if (NULL != fin) fclose(fin);
	if (NULL != fout) fclose(fout);

	return 0;
}

Measured memory_bytes: 256
from collections import Counter
N = int(input())
wlist = [input() for i in range(N)]
wlist_counter = Counter(wlist)
ans = 1

if wlist_counter.most_common()[0][1] >= 2:
    ans = 0

for i in range(0,N-1):
    W_ed = wlist[i]
    W_st = wlist[i+1]
    if W_ed[-1] != W_st[0]:
        ans = 0
        break

if ans == 0:
    print("No")
elif ans == 1:
    print("Yes")


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

int main(){
    int n;
    double sum = 0;
    cin>>n;
    int arr[n];
    for (int i=0;i<n;i++) {
        cin >> arr[i];
        sum+=arr[i];
    }
    int mean = round(sum/n);
    long long ans=0;
    for (int i=0;i<n;i++){
        ans+=(mean-arr[i])*(mean-arr[i]);
    }
    cout<<ans;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int n, a, b, s[300010];
void swa(int l, int r)
{
    while (l < r){
        swap(s[l], s[r]);
        ++l, --r;
    }
}
bool solve()
{
    int ta = n, tb = 1, ma = -1, r = n;
    if (tb < b){
        if (r - (b - tb) < 1) return false;
        swa(r - (b - tb), r);
        r -= (b - tb + 1);
        ta -= (b - tb);
        ma = (b - tb + 1);
        tb = b;
    }
    if (ta < a) return false;
    while (ta > a){
        if (ta - a + 1 > ma){
            if (r - ma + 1 < 1) return false;
            swa(r - ma + 1, r);
            r -= ma;
            ta -= (ma - 1);
        }else{
            if (r - (ta - a) < 1) return false;
            swa(r - (ta - a), r);
            r -= (ta - a + 1);
            ta -= ma;
        }
    }
    return true;
}
int main()
{
    scanf("%d %d %d", &n, &a, &b);
    for (int i = 1; i <= n; ++i) s[i] = i;
    if (a + b > n + 1) puts("-1");
    else{
        if (solve()){
            for (int i = 1; i <= n; ++i) printf(i == n ? "%d\n" : "%d ", s[i]);
        }else puts("-1");
    }
    return 0;
}

Measured memory_bytes: 3328
import sys
sys.setrecursionlimit(10**7) #再帰関数の上限,10**5以上の場合python
import math
from copy import copy, deepcopy
from copy import deepcopy as dcp
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque
#deque(l), pop(), append(x), popleft(), appendleft(x)
#q.rotate(n)で → にn回ローテート
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate,combinations,permutations#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone
#import fractions#古いatcoderコンテストの場合GCDなどはここからimportする
from functools import lru_cache#pypyでもうごく
#@lru_cache(maxsize = None)#maxsizeは保存するデータ数の最大値、2**nが最も高効率
from decimal import Decimal

def input(): 
    x=sys.stdin.readline()
    return x[:-1] if x[-1]=="\n" else x
def printl(li): _=print(*li, sep="\n") if li else None
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)
def matmat(A,B):
    K,N,M=len(B),len(A),len(B[0])
    return [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)]
def matvec(M,v):
    N,size=len(v),len(M)
    return [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)]
def T(M):
    n,m=len(M),len(M[0])
    return [[M[j][i] for j in range(n)] for i in range(m)]
def main():
    mod = 1000000007
    #w.sort(key=itemgetter(1),reversed=True)  #二個目の要素で降順並び替え

    #N = int(input())
    N, M = map(int, input().split())
    #A = tuple(map(int, input().split())) #1行ベクトル
    #L = tuple(int(input()) for i in range(N)) #改行ベクトル
    S = tuple(tuple(input()) for i in range(N)) #改行行列

    mi=-1
    for s in S:
        f=0
        for i,si in enumerate(s):
            if f==0 and si=="#":
                if i >=mi:
                    mi=i
                    f=1
                else:
                    print('Impossible')
                    return
            elif f==1 and si==".":
                f=2
            elif f==1 and si=="#":
                mi=i
            elif f==2 and si=="#":
                print('Impossible')
                return

    print('Possible')






if __name__ == "__main__":
    main()

Measured memory_bytes: 77124
/*
____    ____ .___________.
\   \  /   / |           |
 \   \/   /  `---|  |----`
  \      /       |  |     
   \    /        |  |     
    \__/         |__|     
                          
 */


#include<iostream>
#include<bits/stdc++.h>
#include<algorithm>
#include<iomanip>
#include<cmath>
#define ll long long
#define mod 1000000007
using namespace std;
const int INF = 2e9 + 1;


/*---------------Graph Class---------*/
class graph
{
private:
	ll novert;
	ll noedges;
	vector< vector<ll> > adjlist;
public:
	graph(ll n,ll m)
	{
		novert=n;
		noedges=m;
		adjlist.resize(n+1);	
	}
	
	void addedge(ll u,ll v)
	{
		//bidirectional
		adjlist[u].push_back(v);
		adjlist[v].push_back(u);	
	}
	
	void dfsutil(ll initvert,vector<bool>& visited,ll lastvert=-1)
	{
		if(lastvert==initvert)
		{
			//do something
		}
		visited[initvert]=true;
		for(auto itr:adjlist[initvert])
		{
			if(!visited[itr])
			{	
			}	
		}	
	}	
};
/*-----------------End of graph----------------*/





int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);


ll n,avg,avgs;
cin>>n;
vector<ll> arr(n);
for(ll i=0;i<n;i++)
{
	cin>>arr[i];
}

ll s=0;
for(auto itr:arr)
{
	s+=itr;
}
avg=ceil((float)s/n);
avgs=floor((float)s/n);


ll ans=0;
ll ans2=0;
for(auto itr:arr)
{
	ans+=(itr-avg)*(itr-avg);
	ans2+=(itr-avgs)*(itr-avgs);
}

ans=min(ans,ans2);

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


Measured memory_bytes: 3644
n,m = map(int,input().split())
x=list(map(int,input().split()))
y=list(map(int,input().split()))
mod = 10**9+7

lx = [x[i+1]-x[i] for i in range(n-1)]
ly = [y[i+1]-y[i] for i in range(m-1)]
lsum = [0]
for i in range(10**5+5):
    lsum.append((lsum[i]+i+1)%mod)

xres = 0
for i in range(1,n):
    xsum = 0
    kaisuu = min(i,n-i)
    xsum += lsum[kaisuu-1]*2
    xsum += kaisuu * (n-1-2*(kaisuu-1))
    xsum %= mod
    xsum = (xsum * lx[i-1])%mod
    xres += xsum
xres %= mod

yres = 0
for i in range(1,m):
    ysum = 0
    kaisuu = min(i,m-i)
    ysum += lsum[kaisuu-1]*2
    ysum += kaisuu * (m-1-2*(kaisuu-1))
    ysum %= mod
    ysum = (ysum * ly[i-1])%mod
    yres += ysum
yres %= mod

print((xres*yres)%mod)



Measured memory_bytes: 23064
#include <bits/stdc++.h>
using namespace std;typedef long long ll;typedef string str;
typedef vector<str> vst;
typedef vector<ll> vll;
ll mod = 1000000007;
ll INF = 10000000000000000;
// ll gcd(ll a, ll b){if (b==0){return a;}return gcd(b, a%b);}
// for (ll i = 0; i < n; i++) {
// sort(.begin(),.end());
int main(){
  ll n;
  cin >> n;
  
  vll pr(12);
  for (ll i = 0; i <= 6; i++) {
    pr[i] = pow(6, i);
  }
  for (ll i = 1; i <= 5; i++) {
    pr[i+6] = pow(9, i);
  }
  
  vll dp(100001);
  dp[1] = 1;
  
  for (ll i = 2; i <= 100000; i++) {
    INF = 100000;
    for (ll j = 0; j < 12; j++) {
      if (i-pr[j] < 0) continue;
      if (INF > dp[i-pr[j]]) {
        INF = dp[i-pr[j]];
      }
    }
    dp[i] = INF + 1;
  }
  cout << dp[n] << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
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;
}

using ll = long long;
using ull = unsigned long long;
const int INF = 2100100100;
// const int MOD = 1e9 + 7;

int main() {
    int x, a, b;
    cin >> x >> a >> b;
    if (abs(x - a) < abs(x - b)) {
        cout << "A\n";
    } else {
        cout << "B\n";
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <sstream>
#include <stdexcept>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define FOR(i, a, done) for (int i = (a); i < (done); ++i)
#define all(a) (a).begin(), (a).end()
#define F first
#define S second
#define x first
#define y second
#define pb push_back
#define pf push_front
#define debug(a) cout << (a) << endl
namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

ll M = 1000000007;

void solve()
{
	ll n;
	cin >> n;
	if (n % 2 == 0)
	{
		ll pow5=10;
		ll cnt=0;
		while (1)
		{	
			if(n<pow5){
				break;
			}else{
				ll t=n/pow5;
				cnt+=t;
				pow5*=5;
			}
		}
		
		ll ans=cnt;
		cout<<ans<<endl;
	}
	else
	{
		cout << 0 << endl;
	}
}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long long int l;
    cin >> l;
	long long int sum = 0;
	while(l >= 500)
	{
		sum += 1000;
		l -= 500;
	}
	while(l >= 5)
	{
		sum += 5;
		l -= 5;
	}
	cout << sum << endl;
	
}


Measured memory_bytes: 256
/*
　　こんにちは。あたしはｶｳｶﾞｰﾙ。
　　redcoderになるためAtCoderを巡る旅をしてます。

　　　 　 ＿_
　　　 ヽ|＿_|ノ　　　　ﾓｫ
　　　　||‘‐‘||ﾚ　　_)_, ―‐ 、
　　　　/(Ｙ (ヽ＿ /・ ヽ　　 ￣ヽ
　　　　∠ ＿ ゝ　 ｀^ヽ ﾉ.::::_(ノヽ
　　　　 _/ヽ　 　　  /ヽ￣￣/ヽ
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define dump(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl

#define rep(i, n) REP(i, 0, n)                              // 0, 1, ..., n-1
#define REP(i, x, n) for(int i = x; i < n; i++)             // x, x + 1, ..., n-1
#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(v) (v).begin() , (v).end()
#define RALL(v) (v).rbegin(), (v).rend()

#define COUT(x) cout << (x) << endl

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; }

int a[10];

bool dfs(int B, int C, int cnt) {
    if(cnt == 10) return true;

    if(B < a[cnt]){
        return dfs(a[cnt], C, cnt + 1);
    }
    if(C < a[cnt]) {
        return dfs(B, a[cnt], cnt + 1);
    }
    if(B > a[cnt] && C > a[cnt]) {
        return false;
    }
}

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

    int n;
    cin >> n;
    rep(i, n) {
        rep(j, 10) cin >> a[j];
        if(dfs(0, 0, 0)) cout << "YES" << endl;
        else cout << "NO" << endl;
    }
}



Measured memory_bytes: 3132
# coding: utf-8
# Your code here!
#C
import itertools
N=int(input())
P=list(map(int,input().split()))
Q=list(map(int,input().split()))
A=[]
for i in range(1,N+1):
    A.append(i)
#print(A)

A=list(itertools.permutations(A))
#print(A)
#print(tuple(P))
#print(tuple(Q))
M=1
for i in range(1,N+1):
    M*=i
for i in range(M):
    if A[i]==tuple(P):
        a=i+1
    if A[i]==tuple(Q):
        b=i+1
print(abs(b-a))

Measured memory_bytes: 46064
package main

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

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

	for i := 2; i < n; i += 2 {
		x -= 2 * a[i-1]
	}
	fmt.Print(x)
	for i := 0; i < n-1; i++ {
		x = a[i]*2 - x
		fmt.Printf(" %v", x)
	}
	fmt.Println()
}


Measured memory_bytes: 4992
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <queue>

template<typename T>
class TBinaryHeap
{
    std::vector<T> FArray;
    void BubbleUp(int Index)
    {
        assert(FArray.size() > Index);
        if(Index == 1) return;
        int Parent = Index / 2;
        if(FArray[Index] <= FArray[Parent]){
            return;
        }
        std::swap(FArray[Index], FArray[Parent]);
        BubbleUp(Parent);
    }
    void BubbleDown(int Index)
    {
        assert(FArray.size() > Index);
        int Left  = Index * 2;
        int Right = Index * 2 + 1;
        if(Left  >= FArray.size()) return;
        
        int Target = Right >= FArray.size() ? Left : FArray[Left] > FArray[Right] ? Left : Right;
        if(FArray[Target] > FArray[Index]){
            std::swap(FArray[Index], FArray[Target]);
            BubbleDown(Target);
        }
    }
public:
    TBinaryHeap()
    {
        FArray.reserve(2000000);
        FArray.resize(1); // dummy
    }
    void push(const T& Value)
    {
        FArray.push_back(Value);
        BubbleUp(FArray.size()-1);
    }
    void pop()
    {
        assert(FArray.size() >= 1);
        FArray[1] = FArray.back();
        FArray.pop_back();
        if(FArray.size() == 1) return; // dummy???????????????
        BubbleDown(1);
    }
    const T& top()
    {
        return FArray[1];
    }
};
int main()
{
    char Line[19];
    int Value;

    // std::priority_queue<int> S;
    TBinaryHeap<int> S;
    while(1){
        std::fgets(Line, 19, stdin);
        if(Line[0] == 'i'){
            S.push(std::atoi(&Line[7]));
        }else
        if(Line[1] == 'x'){
            std::printf("%d\n", S.top());
            S.pop();
        }else{
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 6236
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
typedef long long ll;

using namespace std;

int main()
{
	int n,m;
	int min=1e6;
	int minindex,maxindex;
	int max=-1e6;
	int a[50];
	int ans[100][2];
	
	cin>>n;
	m=0;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		if(max<a[i])
		{
			max=a[i];
			maxindex=i;
		}
		if(min>a[i])
		{
			min=a[i];
			minindex=i;
		}
	}
	for(int i=0;i<100;i++)
	{
		for(int j=0;j<2;j++)
		{
			ans[i][j]=0;
		}
	}
	
	if(abs(min)>abs(max))
	{
		for(int i=0;i<n;i++)
		{
			if(a[i]!=min)
			{
				a[i]+=min;
				ans[m][0]=minindex+1;
				ans[m][1]=i+1;
				m++;
			}
		}
		for(int i=1;i<n;i++)
		{
			a[n-i-1]+=a[n-i];
			ans[m][0]=n-i+1;
			ans[m][1]=n-i;
			m++;
		}
	}else{
		for(int i=0;i<n;i++)
		{
			if(a[i]!=max)
			{
				a[i]+=max;
				ans[m][0]=(maxindex+1);
				ans[m][1]=(i+1);
				m++;
			}
		}
		for(int i=0;i<n-1;i++)
		{
			a[i+1]+=a[i];
			ans[m][0]=(i+1);
			ans[m][1]=(i+2);
			m++;
		}
	}
	/*
	cerr<<"err"<<endl;
	for(int i=0;i<n;i++)
	{
		cerr<<a[i]<<endl;
	}
	cerr<<"err"<<endl;
	*/
	cout<<m<<endl;
	for(int i=0;i<m;i++)
	{
		cout<<ans[i][0]<<" "<<ans[i][1]<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>
#include <numeric>

using namespace std;

#define mod 1000000007

int main()
{
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if(a + b > c + d) cout << "Left" << endl;
	else if(a + b < c + d) cout << "Right" << endl;
	else cout << "Balanced" << endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define REP(i, n) for(int i = 0; i < int(n); i++)
#define FOR(i,n,m) for(int i = int(n); i < int(m); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9 + 6;
const ll LLINF = 1e18 + 1;


bool nibu_judge(const vector<vector<int>> &G) {
    int n = G.size();
    vector<int> mark(n,-1); // 0 or 1
    struct vertex { int v; int p; int m; };
    REP(i, n) {
        if (mark[i] != -1) continue;
        stack<vertex> sta;
        sta.push({i,-1,0}); // start is 0
        while (!sta.empty()) {
            vertex q = sta.top(); sta.pop();
            int v = q.v, p = q.p, m = q.m;
            if (mark[v] != -1) {
                if (mark[v] != m) return false;
                continue;
            }
            mark[v] = m;
            for (int u : G[v]) {
                if (u == p) continue;
                sta.push({u,v,1 - m});
            }
        }
    }
    return true;
}

int bfs(const vector<vector< int>> &G, int s) {
    int n = G.size();
    vector<bool> visited(n, false);
    queue<pair<int, int>> que; // 頂点,深さ
    que.push({s,1});
    visited[s] = true;
    int res = 0;
    while (!que.empty()) {
        pair<int, int> p = que.front(); que.pop();
        res = max(res, p.second);
        for (int v : G[p.first]) {
            if (visited[v]) continue;
            visited[v] = true;
            que.push({v,p.second + 1});
        }
    }
    return res;
}

int main() {
    int n; cin >> n;
    vector<vector<int>> G(n);
    vector<string> g(n);
    REP(i, n) cin >> g[i];
    REP(i, n) {
        FOR(j, i + 1, n) {
            if (g[i][j] == '1') {
                G[i].push_back(j);
                G[j].push_back(i);
            }
        }
    }
    if (!nibu_judge(G)) {
        puts("-1");
        return 0;
    }
    int ans = 0;
    REP(i, n) {
        ans = max(ans, bfs(G, i));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define int long long
#define double long double
#define all(a) a.begin(), a.end()
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; }
using namespace std;

signed main(void){
    
    int R, C, N;
    cin >> R >> C >> N;

    auto make = [&](int x, int y){
        int res = -1;
        if(x == 0){
            res = (R + C) * 2 - y;
        } else if(x == R){
            res = R + y;
        } else if(y == 0){
            res = x;
        } else if(y == C){
            res = R * 2 + C  - x;
        }
        return res;
    };

    typedef pair<int, int> pa;
    vector<pa> vec;

    rep(i, N){
        int x1, y1, x2, y2;
        cin >> x1 >> y1 >> x2 >> y2;
        int st = make(x1, y1), en = make(x2, y2);
        if(st == -1 or en == -1)continue;
        if(st > en)swap(st, en);
        vec.push_back(pa(st, i));
        vec.push_back(pa(en, i + N));
    }

    sort(all(vec));
    stack<int> use;
    rep(i, (int)vec.size()){
        if(vec[i].second < N)use.push(vec[i].second);
        else {
            if(use.top() == vec[i].second - N)use.pop();
            else {
                cout << "NO" << endl;
                return 0;
            }
        }
    }

    cout << "YES" << endl;
    return 0;

}

Measured memory_bytes: 6384
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef pair<int,int> P;
constexpr int INF = 2e9;
int main(){ 
  int h1, h2, m1, m2, k;
  cin >> h1 >> m1 >> h2 >> m2 >> k;
  int d = h2 - h1;
  d *= 60;
  d += m2 - m1;
  cout << max(0, d - k) << endl;
  return 0;
} 

Measured memory_bytes: 3636
#include <stdio.h>
int main(void)
{
  int n,k,i,j,sum=0;
  int a[1001],tmp;
  scanf("%d %d",&n,&k);
  for(i=0;i<n;i++)
  {
    scanf("%d",&a[i]);
  }
  for (i=0; i<n; ++i) 
  {
    for (j=i+1; j<n; ++j) 
    {
      if (a[i] > a[j]) 
      {
        tmp =  a[i];
        a[i] = a[j];
        a[j] = tmp;
      }
    }
  }
  for(i=0;i<k;i++){
    sum+=a[i];
  }
  printf("%d",sum);
  return 0;
}

Measured memory_bytes: 1732
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<algorithm> // sort
#include<map> // pair
#include<cmath>
using namespace std;
using ll = long long;
const ll mod = 1e9+7;
int main(){
  ll n,k,count0=0,count1=0,sum=0,size=0;
  string s;
  cin >> n >> k;
  cin >> s;
  vector<ll> vec(n+1,0);
  vec[size] = 0;
  size++;
  for(int i=0;i<n;i++){
    if(s[i] == '0'){
      if(count1 != 0){
        vec[size] = i;
        count1=0;
        count0++;
        size++;
      }else{
        count0++;
      }
    }else{
      if(count0 != 0){
        vec[size] = i;
        count0 = 0;
        count1++;
        size++;
      }else{
        count1++;
      }
    }
  }
  vec[size] = n;
  // size++;
  // for(int i=0;i<size;i++){
  //   cout << vec[i] << endl;
  // }
  // cout << endl;
  //cout << "size" << size << endl;
  if(s[0]=='0'){
    if((size+1)/2 <= k){
      sum = n;
    }else{
      sum = vec[2*k];
      //cout << sum << endl;
      for(int i=0;i+2*k+2<size;i+=2){
        sum = max(sum,vec[2*k+i+2]-vec[i+1]);
        //cout << vec[2*k+i+2]-vec[i+1] << endl;
      }
      if(size%2==0){
        sum = max(sum,n-vec[size-2*k-1]);
        //cout << n-vec[size-2*k-1] << endl;
      }else{
        sum = max(sum,n-vec[size-2*k]);
        //cout << n-vec[size-2*k] << endl;
      }
    }
  }else{
    if(size/2 <= k){
      sum = n;
    }else{
      sum = vec[2*k+1];
      //cout << sum << endl;
      for(int i=1;i+2*k+2<size;i+=2){
        sum = max(sum,vec[2*k+i+2]-vec[i+1]);
        //cout << vec[2*k+i+2]-vec[i+1] << endl;
      }
      if(size%2==0){
        sum = max(sum,n-vec[size-2*k]);
        // cout << n-vec[size-2*k-1] << endl;
      }else{
        sum = max(sum,n-vec[size-2*k-1]);
        //cout << n-vec[size-2*k-1] << endl;
      }
    }
  }
  cout << sum;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a, b, c, d, e, f;
    cin >> a >> b >> c >> d >> e >> f;
    vll water(31, 0), sugar(1501, 0);
    REP(i, 31){
        REP(j, 31){
            if(a * i + b * j > 30) continue;
            water[a * i + b * j] = 1;
        }
    }
    REP(i, f / 2 + 2){
        REP(j, f / 2 + 2){
            if(c * i + d * j > 1500) continue;
            sugar[c * i + d * j] = 1;
        }
    }
    ll resw = 1, ress = 0;
    FOR(i, 1, 30){
        FOR(j, 1, 3000){
            if(!water[i] || !sugar[j]) continue;
            ll w = 100 * i, s = j;
            if(w + s > f || s > e * i) continue;
            if(s * (resw + ress) > ress * (w + s)){
                resw = w;
                ress = s;
            }
        }
    }
    if(resw == 1){
        cout << a * 100 << " " << 0 << endl;
        return 0;
    }
    cout << resw + ress << " " << ress << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
void solve()
{
    ll n,k,i,s=0;
    cin>>n>>k;
    ll a[n];
    for(i=0;i<n;i++)
    {
        cin>>a[i];
    }
    sort(a,a+n);
    for(i=0;i<k;i++)
    {
        s=s+a[i];
    }
    cout<<s<<endl;
   
  
}
    
int main()
{
    ll t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, x, y;
  cin >> n >> m >> x >> y;
  int xx[110];
  int yy[110];
  for(int i=0; i<n; i++){
    cin >> xx[i];
  }
  for(int i=0; i<m; i++){
    cin >> yy[i];
  }
  int z = -110;
  for(int i=0; i<n; i++){
    z = max(z, xx[i]);
  }
  z = z+1;
  int minn = 110;
  for(int i=0; i<m; i++){
    minn = min(minn, yy[i]);
  }
  if(minn >= z && x < z && z <= y){
    cout << "No War" << endl;
  }
  else{
    cout << "War" << endl;
  }
}

Measured memory_bytes: 256
import bisect as bs
def prime(m):
  N = range(1,m+1, 2)
  N[0] = 2
  for i in range(1, len(N)):
    x = N[i]
    if x: N[i+x::x] = [0]*len(N[i+x::x])
  return filter(None, N)

P = prime(1000000)
while 1:
  n = input()
  if n==0: break
  s = 0
  for _ in [0]*n:
    p, m = map(int, raw_input().split())
    s += bs.bisect_right(P, p+m) - bs.bisect_left(P, p-m)-1
  print s

Measured memory_bytes: 39232
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<deque>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#include<regex>
#include<bitset>
#include<complex>
#include<chrono>
#include<random>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

ll gcd(ll n, ll m) {
	ll tmp;
	while (m!=0) {
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m) {
	return abs(n) / gcd(n, m)*abs(m);//gl=xy
}
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
 
using namespace std;


void solve(){
  int n,r;
  cin>>n>>r;
  if(n>=10)cout<<r;
  else cout<<r+100*(10-n);
}

int main(){
	ios::sync_with_stdio(false);
  cin.tie(0);
	cout<<fixed<<setprecision(15);
  solve();
	return 0;
}


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

int main()
{
    int n;
    cin >> n;
    double p[n];
    for(int i=0;i<n;i++){
        cin >> p[i];
    }
    
    double dp[n+1][n+1];
    dp[0][0] = 1.0;
    for(int i=0;i<=n;i++){
        for(int j=0;j<=n;j++){
            if(i==0 && j==0){
                dp[0][0] =1.0;
            }
            else if(i<j){
                dp[i][j] = 0.0;
            }
            else{
                if(j<1){
                    dp[i][j] = dp[i-1][j]*(1-p[i-1]);
                }else{
                    dp[i][j] = dp[i-1][j-1]*p[i-1] + dp[i-1][j]*(1-p[i-1]);   
                }
            }
        }
    }
    double sum=0.0;
    for(int i = n;i>=(n/2)+1;i--){
        sum+=dp[n][i];
    }
    cout << fixed << setprecision(9) << sum << endl;
    return 0;
}


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

const int maxn = 1e5+5;
int inv[maxn];
int n, p[maxn];

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> p[i];
        inv[p[i]] = i;
    }
    set<int> pos;
    pos.insert(inv[n]);
    ll sum = 0;
    for (int i = n-1; i >= 1; i--) {
        int curpos = inv[i];
        auto lb = pos.lower_bound(curpos);
        auto ub = pos.lower_bound(curpos);
        int l1 = 0, l2 = 0;
        if (lb != pos.begin()) {
            --lb;
            l1 = *lb;    
            if (lb != pos.begin()) {
                --lb;
                l2 = *lb;
            }
        }
        
        int r1 = n+1, r2 = n+1;
        if (ub != pos.end()) {
            r1 = *ub;
            ++ub;
            if (ub != pos.end()) {
                r2 =*ub;
            }
        }
        
        sum += 1LL*i*(r2-r1)*(curpos-l1);
        sum += 1LL*i*(l1-l2)*(r1-curpos);
        
        pos.insert(curpos);
    }
    cout << sum << '\n';
}



Measured memory_bytes: 5760
import java.util.*;
import java.lang.*;
import java.math.*;

public class Main {
	Scanner sc = new Scanner(System.in);

	void run() {

		for (;;) {
			int n = sc.nextInt();
			if (n == 0) {
				break;
			}

			boolean[][] map = new boolean[n][n];

			int[][] rl = new int[n][n];
			int[][] td = new int[n][n];
			int[][] url = new int[n][n];
			int[][] ulr = new int[n][n];

			for (int i = 0; i < n; i++) {
				String buffer = sc.next();

				for (int j = 0; j < n; j++) {
					map[i][j] = (buffer.charAt(j) == '1');
				}
			}

			int max = 0;
			for (int i = 0; i < n; i++) {
				for (int j = 0; j < n; j++) {
					if (map[i][j]) {
						int ni;
						int nj;

						ni = i - 1;
						nj = j;
						rl[i][j] = 1;
						if (ni >= 0 && ni < n)
							if (nj >= 0 && nj < n)
								rl[i][j] = rl[ni][nj] + 1;

						max = Math.max(max, rl[i][j]);

						ni = i;
						nj = j - 1;
						td[i][j] = 1;
						if (ni >= 0 && ni < n)
							if (nj >= 0 && nj < n)
								td[i][j] = td[ni][nj] + 1;

						max = Math.max(max, td[i][j]);

						ni = i - 1;
						nj = j - 1;
						url[i][j] = 1;
						if (ni >= 0 && ni < n)
							if (nj >= 0 && nj < n)
								url[i][j] = url[ni][nj] + 1;

						max = Math.max(max, url[i][j]);

						ni = i - 1;
						nj = j + 1;
						ulr[i][j] = 1;
						if (ni >= 0 && ni < n)
							if (nj >= 0 && nj < n)
								ulr[i][j] = ulr[ni][nj] + 1;

						max = Math.max(max, ulr[i][j]);

					}
				}
			}
			System.out.println(max);
		}

	}

	public static void main(String[] args) {
		Main m = new Main();
		m.run();
	}
}

Measured memory_bytes: 0
#include <stdio.h>
//#include <stdlib.h>
//#include <string.h>
//#include <stdbool.h>
//#include <limits.h>
//#include <math.h>

int main() {
  int n;
  scanf("%d", &n);
  long ans = 0;
  for (int i=1; i<=n; i++) {
    if (i%3 != 0 && i%5 != 0)
      ans += i;
  }
  printf("%ld\n", ans);
  return 0;
}


Measured memory_bytes: 1732
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func main() {
	sc.Split(bufio.ScanLines)
	for sc.Scan() {
		n := strings.Split(sc.Text(), ",")
		id, _ := strconv.Atoi(n[0])
		weight, _ := strconv.ParseFloat(n[1], 64)
		height, _ := strconv.ParseFloat(n[2], 64)
		bmi := weight / (height * height)
		if bmi >= 25.0 {
			fmt.Println(id)
		}
	}
}


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

int main() {
  int n; cin >> n;
  long long ans = 0;
  
  for(int i=1; i<=n; i++){
    if(i%3 != 0 && i%5 != 0){
      ans += i;
    }
    
  }
    
  cout << ans << endl;
}
    

Measured memory_bytes: 3624
#include <iostream>
#include <stdio.h>
using namespace std;
int main(void){
    int a,b,c;
    
    while(1){
        scanf("%d %d %d",&a,&b,&c);
        if(a==-1&&b==-1&&c==-1){
            break;
        }
        
        if(a==-1||b==-1)cout<<'F'<<endl;
        else if(a+b>=80)cout<<'A'<<endl;
        else if(a+b>=65)cout<<'B'<<endl;
        else if(a+b>=50)cout<<'C'<<endl;
        else if(a+b>=30&&c>=50)cout<<'C'<<endl;
        else if(a+b>=30)cout<<'D'<<endl;
        else cout<<'F'<<endl;
    }
    
    
    
    return 0;
}



Measured memory_bytes: 3236
N,M=map(int,input().split())
Tree=[i for i in range(N)]
size=[1]*N
 
def find(x):
  if x==Tree[x]:
      return x
  else:
      Tree[x]=find(Tree[x])
      return Tree[x]
def unite(x,y):
  s1=find(x)
  s2=find(y)
  if s1!=s2:
    Tree[s2]=s1
    size[s1]+=size[s2]
ans=N
for i in range(M):
  X,Y,Z=map(int,input().split())
  X,Y=X-1,Y-1
  if find(X)!=find(Y):
    unite(X,Y)
    ans-=1
print(ans)

Measured memory_bytes: 7856
package main

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

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 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
}

type Store struct {
	price, num int
}

type ByPrice []Store

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

func main() {
	sc := NewScanner()
	N, M := sc.nextInt(), sc.nextInt()
	stores := make([]Store, N)
	for i := 0; i < N; i++ {
		stores[i] = Store{sc.nextInt(), sc.nextInt()}
	}
	sort.Sort(ByPrice(stores))
	count := 0
	total := 0
	for _, s := range stores {
		if M <= count+s.num {
			for M > count {
				total += s.price
				count++
			}
		} else {
			total += s.price * s.num
			count += s.num
		}
	}
	fmt.Println(total)
}


Measured memory_bytes: 3840