akhauriyash/Code-Regression huggingface dataset:
import sys
from bisect import bisect
def input():
	return sys.stdin.buffer.readline()[:-1]

MOD = 998244353
n = int(input())
r = []
for _ in range(n):
	x, d = map(int, input().split())
	r.append((-x, -x-d))
r.sort()

INF = 10**30

class Rmin():
	def __init__(self, size):
		#the number of nodes is 2n-1
		self.n = 1
		while self.n < size:
			self.n *= 2
		self.node = [INF] * (2*self.n-1)

	def Access(self, x):
		return self.node[x+self.n-1]

	def Update(self, x, val):
		x += self.n-1
		self.node[x] = val
		while x > 0:
			x = (x-1)//2
			self.node[x] = min(self.node[2*x+1], self.node[2*x+2])
		return

	#[l, r)
	def Get(self, l, r):
		L, R = l+self.n, r+self.n
		s = INF
		while L<R:
			if R & 1:
				R -= 1
				s = min(s, self.node[R-1])
			if L & 1:
				s = min(s, self.node[L-1])
				L += 1
			L >>= 1
			R >>= 1
		return s

leftmost = Rmin(n)

wait = [r[0][0]]
dp = [[0 for _ in range(2)] for _ in range(n)]#0: いない 1: いる
dp[0] = [1, 1]
leftmost.Update(0, 0)

for i in range(1, n):
	dp[i][1] = (dp[i-1][0] + dp[i-1][1]) % MOD	
	if r[i][1] < wait[-1]:
		b = bisect(wait, r[i][1])
		mi = leftmost.Get(b, i)
		dp[i][0] = dp[mi][0]
		leftmost.Update(i, mi)
	else:
		dp[i][0] = dp[i][1]
		leftmost.Update(i, i)
	wait.append(r[i][0])

print((dp[n-1][0] + dp[n-1][1]) % MOD)

Measured memory_bytes: 136968
#include <cstdio>
#include <iostream>
using namespace std;
#define Maxn 200000
char s[Maxn+5];
int main(){
	int len=0;
	scanf("%s",s+1);
	while(s[++len]!='\0');
	len--;
	long long ans=0;
	int now=0;
	for(int i=1;i<=len;i++){
		if(s[i]=='B'){
			now++;
		}
		else{
			ans+=now;
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 384
int_a, int_b, int_c, int_d = map(int, input().split())

result = False

if abs(int_a - int_c) <= int_d:
    result = True
elif abs(int_a - int_b) <= int_d and abs(int_b - int_c) <= int_d:
    result = True

if result:
    print('Yes')
else:
    print('No')



Measured memory_bytes: 2940
from fractions import gcd

V = 1001
G = []
visited = []
match = []

def add_edge(u,v):
    G[u].append(v)
    G[v].append(u)

def dfs(v):
    visited[v] = True
    for u in G[v]:
        w = match[u]
        if w < 0 or not visited[w] and dfs(w):
            match[v] = u
            match[u] = v
            return True

def bipartite_matching():
    global match,visited
    res = 0
    match = [-1]*V
    for v in xrange(V):
        if match[v] < 0:
            visited = [False]*V
            if dfs(v):
                res += 1
    return res

while True:
    m,n = map(int,raw_input().split())
    V = m+n
    if V == 0:
        break
    G = [[] for _ in xrange(V)]
    data = []
    while len(data) < V:
        data += map(int,raw_input().split())
    for i,b in enumerate(data[:m]):
        for j,r in enumerate(data[m:],m):
            if gcd(b,r) != 1:
                add_edge(i,j)
    print bipartite_matching()

Measured memory_bytes: 11500
#include<iostream>
#include<complex>
#include<cstdio>
using namespace std;

double cross_product(complex<double>, complex<double>);
int main(void) {
	complex<double> p[120];
	int n;
	double x, y, s = 0;

	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> x >> y;
		p[i] = complex<double>(x, y);
	}
	for (int i = n - 1; i >= 0; i--) {
		p[i] -= p[0];
	}
	for (int i = 2; i < n; i++) {
		s += cross_product(p[i - 1], p[i]);
	}
	if (s < 0) s = -s;
	s /= 2;
	printf("%.1f\n", s);
	return 0;
}

double cross_product(complex<double> a, complex<double> b) {
	return (conj(a)*b).imag();
}

Measured memory_bytes: 1252
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <cstring>
#include <algorithm>
#define fo(i,a,b) for(int i=a;i<=b;++i)
#define fod(i,a,b) for(int i=a;i>=b;--i)
#define mo 1000000007
#define LL long long
using namespace std;
LL ksm(LL k,LL n)
{
	LL s=1;
	for(;n;n>>=1,k=k*k%mo) if(n&1) s=s*k%mo;
	return s;
}
int pi[100005];
LL f[100005];
int main()
{
	LL n,m;
	cin>>n>>m;
	fo(i,1,sqrt(n)) 
	{
		if(n%i==0) 
		{
			pi[++pi[0]]=i;
			if(n%(n/i)==0&&n/i!=i) pi[++pi[0]]=n/i;
		}
	}
	LL ans=0;
	sort(pi+1,pi+pi[0]+1);
	fo(i,1,pi[0])
	{
		if(n/pi[i]%2==0)
		{
			f[i]=ksm(m,pi[i]);
		}
		else
		{
			f[i]=ksm(m,(pi[i]+1)/2);
		}
		fo(j,1,i-1) if(pi[i]%pi[j]==0) f[i]=(f[i]-f[j]+mo)%mo;
		ans=(ans+f[i]*pi[i])%mo;
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
 
////////////// Prewritten code follows. Look down for solution. ////////////////

#define fs first
#define sc second
#define pb push_back
#define len(x) ((int)(x).size())
#define fastio ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef long long ll;

const ll LINF = 1e18;
const int INF = 1e9;
const ll mod = 1e9+7;

/// command for char arrays with spaces -> scanf(" %[^\n]", text);
 
////////////////////////// Solution starts below. //////////////////////////////

const int N = 1e6+5;
ll x, y;

ll fat(ll n){
	ll ans = 1;
	for(ll i = 2; i <= n; i++){
		ans = (ans*i%mod)%mod;
	}
	return ans%mod;
}

ll modpow(ll base, ll power){
	if(power == 0) return 1;
	ll ans = modpow(base, power/2);
	ans = (ans*ans)%mod;
	if(power&1LL) return (ans*(base%mod))%mod;
	return ans;
}

int main(){
	fastio;
	cin >> x >> y;
	// x = 2*a + b
	// y = a + 2*b
	//--------------
	// 2x = 4a + 2b
	// 2x - y = 3a
	// a = (2x - y)/3
	// b = (2y - x)/3
	if((x+y)%3 != 0 or 2*x < y or 2*y < x){
		cout << 0 << endl;
		return 0;
	}
	ll a = (2*x - y)/3;
	ll b = (2*y - x)/3;
	ll ab = (x+y)/3;
	// C(a+b, a) mod P = (a+b)!/a! * b! mod P
	// C(a+b, a) mod P = (a+b)! * a!^(P-2) * b!^(P-2) mod P
	cout << (((fat(ab)*modpow(fat(a), mod-2))%mod)*modpow(fat(b), mod-2))%mod << endl;
	return 0;
}

Measured memory_bytes: 256
//#pragma warning(disable:4996)
#include <stdio.h>
#include <math.h>

int main() {
	int n;
	scanf("%d", &n);
	int length = log10(n) + 1;

	int n1 = n;
	int s = 0;
	for (int i = length; i > 0; i--) {
		int tmp = n1 / pow(10, i - 1);
		s += tmp;
		n1 -= tmp*pow(10, i - 1);
	}
	//printf("%d %d", n, s);
	if (n%s) {
		printf("No\n");
	}else{
		printf("Yes\n");
	}
	//while (1);
}

Measured memory_bytes: 640
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int h[] = new int[n];
		for(int i = 0; i < n; ++i)
		h[i] = sc.nextInt();
		sc.close();
		int cnt = 0;
		int max = 0;
		for(int i = 0; i < n - 1; ++i){
			if(h[i] >= h[i + 1])++cnt;
			else{
				max = Math.max(max, cnt);
				cnt = 0;
			}
		}
		max = Math.max(max, cnt);
		System.out.println(max);
	}
}


Measured memory_bytes: 60348
#include <iostream>
#include <queue>

using namespace std;

#define WH 300

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

int main(int argc, char const *argv[])
{
	int t,n;
	int x,y;
	int sx,sy;

	int f[WH][WH];
	int cnt;

	while(1){
		cin>>t>>n;
		if(t+n==0) break;

		for(int i1=0;i1<WH;i1++){
			for(int i2=0;i2<WH;i2++){
				f[i1][i2]=0;
			}
		}

		for(int i1=0;i1<n;i1++){
			cin>>x>>y;
			f[y+150][x+150]=-1;
		}

		cin>>sx>>sy;

		queue<pair<int,int> > q;
		q.push(make_pair(sx+150,sy+150));

		while(!q.empty()){
			x=q.front().first;
			y=q.front().second;
			q.pop();

			for(int i1=0;i1<6;i1++){
				if(f[y+dy[i1]][x+dx[i1]]==0 && f[y][x]<t){
					if(x+dx[i1]==sx+150 && y+dy[i1]==sy+150){}
					else {
						f[y+dy[i1]][x+dx[i1]]=f[y][x]+1;
						q.push(make_pair(x+dx[i1],y+dy[i1]));
					}
				}
			}
		}

		cnt=1;
		for(int i1=0;i1<WH;i1++){
			for(int i2=0;i2<WH;i2++){
				if(f[i1][i2]>0)cnt++;
			}
		}

		cout<<cnt<<endl;
	}

	return 0;
}

Measured memory_bytes: 1572
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    [n, k] <- getIntList
    s <- length . group <$> getLine
    print $ solve n s k

solve n s 0 = n - s
solve n s k
    | s <= 3 = n - 1
    | otherwise = solve n (s - 2) (k - 1)

Measured memory_bytes: 5500
using System;
class Program
{
	static void Main(string[] args)
	{
		string[] input = Console.ReadLine().Split(' ');
		int a = int.Parse(input[0]);
		int b = int.Parse(input[1]);
      	int sm = a < b ? a : b;
      	int la = sm == a ? b : a;
      	string s = string.Empty;
      	for(int i = 0; i < la; i++){ s += sm; }
      	Console.WriteLine(s);

	}
}

Measured memory_bytes: 11092
#include <iostream>
#include <sstream>
#include <stack>
#include <iomanip>
#include <string>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

// ---- BEGIN LIBRARY CODE ----
// ---- END LIBRARY CODE ----
void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    int N, K;
    cin >> N >> K;

    double ret = 0.0;
    FOR(i, 1, N + 1) {
        int p = i, t = 0;
        while (p < K) {
            p *= 2;
            t++;
        }
        ret += 1.0 / N * pow(0.5, t);
    }
    cout << fixed << setprecision(10) << ret << endl;
    return 0;
};


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <utility>
#include <vector>

using namespace std;

vector<int> f[100001], b[100001];
int g[100010], s[100010];

void dfs(int x, int y) {
  g[x] = y;
  s[y]++;
  for (int i = 0; i < f[x].size(); i++) {
    if (g[f[x][i]] == 0) {
      dfs(f[x][i], y);
    }
  }
}

int main() {
  int n, m, k, c, d;
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 0; i < m; i++) {
    scanf("%d%d", &c, &d);
    f[c].push_back(d);
    f[d].push_back(c);
  }
  for (int i = 0; i < k; i++) {
    scanf("%d%d", &c, &d);
    b[c].push_back(d);
    b[d].push_back(c);
  }
  for (int i = 1; i <= n; i++) {
    if (g[i] == 0) {
      dfs(i, i);
    }
  }
  for (int i = 1; i <= n; i++) {
    int ans = s[g[i]];
    ans -= f[i].size();
    for (int j = 0; j < b[i].size(); j++) {
      if (g[i] == g[b[i][j]]) {
        ans--;
      }
    }
    ans--;
    printf("%d ", ans);
  }
  printf("\n");
}

Measured memory_bytes: 13056
#[allow(unused_macros)]
macro_rules! scan {
    () => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().to_string()
        }
    };
    (;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().split_whitespace().map(|s| s.to_string()).collect::<Vec<String>>()
        }
    };
    (;;$n:expr) => {
        {
            (0..$n).map(|_| scan!()).collect::<Vec<_>>()
        }
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty;;$n:expr) => {
        (0..$n).map(|_| scan!($t;;)).collect::<Vec<_>>()
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    scan!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    scan!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let (h, w) = scan!(usize, usize);
    let (x, y) = scan!(usize, usize);
    println!("{}", (h * w + x * y) - (h * y + w * x));
}


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

int main(){
  int num[2001] = {0};

  for(int i =  0 ; i <= 1000 ; i++ ){
    for(int j =  0 ; j <= 1000 ; j++ ){
      num[i+j]++; 
    }
  }
  int n;
  while( cin >> n ){
    int res = 0;
    for(int i =  0 ; i <= n ; i++ ){
      if(i > 2000 || n - i > 2000)continue;
      res += num[i]*num[n-i];
    }
    cout << res << endl;
  }
  return 0;
}

Measured memory_bytes: 1168
#include<iostream>
#include<string>
#include<stack>
#include<queue>

using namespace std;

int main()
{
	string fields;
	
	getline( cin, fields );
	
	stack<int> st;
	deque< pair<int, int> > areas;
	int  pool, sum = 0;
	for( int i=0; i<fields.length( ); i++ ) {
		if( '\\' == fields[i] ) {
			st.push( i );
		} else {
			if( !st.empty( ) && '/' == fields[i] ) {
				int j = st.top( );
				st.pop( );
				pool = i - j;
				sum += pool;
				
				while( !areas.empty( ) ) {
					pair<int, int> preArea = areas.back( );
					if( j < preArea.first ) {
						pool += preArea.second;
						areas.pop_back( );
					} else {
						break;
					}
				}
				areas.push_back( make_pair( j, pool ) );
			}
		}
	}
	cout<<sum<<'\n';
	if( 0 < areas.size( ) ) {
		cout<<areas.size( )<<' ';
	} else {
		cout<<areas.size( );
	}
	deque< pair<int, int> >::iterator itr = areas.begin( );
	deque< pair<int, int> >::iterator itrE = areas.end( );
	for( ; itr!=itrE; itr++ ) {
		cout<<itr->second;
		if( itr != itrE-1 ) cout<<' ';
	}
	cout<<endl;
	
    return 0;
}

Measured memory_bytes: 1304
def read():
    h = int(input())
    w = int(input())
    n = int(input())
    return h, w, n


def calc(h, w, n):
    if h > w:
        w = h
    
    if n % w  == 0:
        return int(n / w)
    else:
        return int(n/w)+1


def main():
    print(calc(*read()))


if __name__ == "__main__":
    main()


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

#define endl '\n'
#define ff first
#define ss second
#define mp make_pair
#define pb push_back

typedef long long llong;
typedef pair<int, int> pii;

void solve() {
	int n, d;
	cin >> n >> d;
	int range = d * 2 + 1;
	int ans = (int)ceil((double)n / range);
	cout << ans;
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	#ifdef LOCAL
		ifstream in("in");
		cin.rdbuf(in.rdbuf());
	#endif
	solve();
}

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

int main(){
    int N;
    cin >> N;
    vector<int> A(N + 1, 0);
    vector<int> B(N + 1, 0);
    for(int i = 1; i <= N; i++)cin >> A[i];
    for(int i = N; i > 0; i--){
        int sum = 0;
        int see = i;
        while(see <= N){
            sum += B[see];
            see += i;
        }
        if(sum % 2 != A[i])B[i]++;
    }
    
    int cnt = 0;
    vector<int> ans;
    for(int i = 1; i <= N; i++){
        if(B[i] != 0){
            cnt++;
            ans.push_back(i);
        }
    }
    cout << cnt << endl;
    for(auto v : ans)cout << v << endl;
    return 0;
}

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define ii tuple<int, int>
#define iii tuple<int, int, int>
#define M 1000000007

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    lli n;
    set<string> s;
    string str;
    cin>>n;
    while(n--)
    {
        cin>>str;
        s.insert(str);
    }
    cout<<s.size();
    return 0;
}

Measured memory_bytes: 19280
#include <iostream>
#include <stdio.h>
#include <string>

using namespace std;

int main(){
	string str;
	int N;
	cin >> str;
	for (int i = 0; i < 4; i++){
		if (str[i] == '+'){
			N++;
		}
		else if (str[i] == '-'){
			N--;
		}
	}
	cout << N << endl;
}


Measured memory_bytes: 256
package main

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


var sc *bufio.Scanner

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

type edge struct {
	node   int
	weight int
}

func answer(reader io.Reader, writer io.Writer) {
	sc = bufio.NewScanner(reader)
	sc.Split(bufio.ScanWords)
	n := nextInt()
	c := make([]int, n)
	p := make([]int, n)
	//e := map[int]map[int]int{}
	e := make([][]edge, n)
	f := make([]bool, n)

	for i := 0; i < n - 1; i++ {
		u:= nextInt()
		v:= nextInt()
		w:= nextInt()
		e[u-1] = append(e[u-1], edge{v-1,w})
		e[v-1] = append(e[v-1], edge{u-1,w})
	}
	//fmt.Printf("%v\n", e)
	idx := 1
	for i:=0; i<idx; i++ {
		k1 := p[i]
		//fmt.Printf("k1:%d, len(e[k1]);%d\n", k1, len(e[k1]))
		for _, v := range e[k1] {
			k2 := v.node
			if f[k2] == true {
				continue
			}
			if v.weight % 2 == 0 {
				c[k2] = c[k1]
			} else {
				c[k2] = (c[k1]+1)%2
			}
			p[idx] = k2
			idx++
		}
		f[k1]= true
	}
	for i := 0; i < n; i++ {
		_, _ = fmt.Fprintf(writer, "%d", c[i])
		if i < n-1 {
			_, _ = fmt.Fprint(writer, "\n")
		}
	}
}

func main() {
	answer(os.Stdin, os.Stdout)
}


Measured memory_bytes: 12416
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = (1<<30)-1;
const ll INF = (1LL<<60)-1;
const ld EPS = 1e-10;
template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;};
template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;};

int main(){
    int N, D;
    cin >> N >> D;
    int d[N];
    rep(i, N) cin >> d[i];
    int pos[N+1]; //i回目の移動後の目的地との距離
    pos[0] = D;
    rep(i, N){
        pos[i+1] = min(pos[i], abs(pos[i]-d[i]));
    }
    int r[N+1];
    r[N] = 0;
    rep3(i, N-1, 0){
        if(r[i+1] < d[i]/2) r[i] = r[i+1];
        else r[i] = r[i+1]+d[i];
    }
    int Q;
    cin >> Q;
    rep(i, Q){
        int q;
        cin >> q;
        if(pos[q-1] <= r[q]) cout << "NO" << "\n";
        else cout << "YES" << "\n";
    }
}

Measured memory_bytes: 9484
#include <iostream>
#include <vector>
using namespace std;
int main(void){
    int nums[5];
    int k;
    for(int i = 0;i < 5;i++){
        cin >> nums[i];
    }
    cin >> k;
    
    if(nums[4] - nums[0] > k){
        cout << ":(" << endl;
    }else{
        cout << "Yay!" << endl;
    }
    
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	if(a==5&&b==5||a==5&&c==5||b==5&&c==5)printf("YES\n");
	else printf("NO\n");
	return 0;
}

Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n = I()
    p = LI()
    ans = 1
    min = p[0]
    for i in p[1:]:
        if i < min:
            ans += 1
            min = i
    print(ans)
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 71376
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
using namespace std;

int t, p, r, tID, pID, times;
int point[100], wrong[100][100], penalty[100], ans[100];
string message;

bool AC_comp(const int &a, const int &b){
    if(point[a] == point[b]){
	if(penalty[a] == penalty[b])
	    return  a < b;
	return penalty[a] < penalty[b];
    }
    return point[a] > point[b];
}

int main(){
    while(true){
	cin >> t >> p >> r;
	if(t == 0 && p == 0 && r == 0)return 0;
	memset(point, 0, sizeof(point));
	memset(penalty, 0, sizeof(penalty));
	memset(wrong, 0, sizeof(wrong));
	for(int i = 0;i < r;i++){
	    cin >> tID >> pID >> times >> message;
	    if(message == "CORRECT"){
		point[tID]++;
		penalty[tID] += times + wrong[tID][pID] * 1200;
	    }
	    else{
		wrong[tID][pID]++;
	    }
	}
	for(int i = 0;i < t;i++){
	    ans[i] = i + 1;
	}
	sort(ans, ans + t, AC_comp);
	for(int i = 0;i < t;i++){
	    int team = ans[i];
	    cout << team << ' ' << point[team] << ' ' << penalty[team] << endl;
	}
    }
}

Measured memory_bytes: 1272
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int (i)=(m);(i)<(n);++(i))
#define rREP(i,m,n) for(int (i)=(n)-1;(i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;
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;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int main() {
	init();

	string s; cin >> s;
	int n = s.size();
	char ch = 'a';
	int ans = INF;
	rep(i, 0, 26) {
		string str = s;
		if (str == string(str.size(), ch))ans = 0;
		while (1) {
			string tmp = string(str.size() - 1, '-1');
			int cnt = 0;
			rep(j, 0, tmp.size()) {
				if (str[j] == ch || str[j + 1] == ch) {
					tmp[j] = ch;
					++cnt;
				}
			}
			if (cnt == tmp.size()) {
				chmin(ans, (int)(s.size() - tmp.size()));
				break;
			}
			str = tmp;
		}
		++ch;
	}
	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 3540
#include <stdio.h>
 
using namespace std;
 
int main(){
    int W,H,x,y,r;
    scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
    if((x >= r && x <= W-r) && (y >= r && y <= H-r))
        printf("Yes\n");
    else{
        printf("No\n");
    }
}


Measured memory_bytes: 2676
#include <iostream>
#include <vector> 
#include <algorithm>
#include <queue>
#include <cmath>
#include <map>
#include <iomanip>
#include <list>
#include <deque>
using namespace std;

#define int long long

int n, a[3][3], b[10];
bool appear[3][3];

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

    if(a + 2 >= b) {
        cout << 1 + k << endl;
        return 0;
    }

    int rep = max(0.0, floor((k - (a - 1)) / 2));
    int res = 1 + k - 2 * rep; 
    int ans = (b - a) * rep + res;
 
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3596
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(perm),end(perm)
#define showall(obj) for(auto x:obj)cout<<x<<endl;
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
typedef vector<int> vint;
typedef vector<ll> vll;
const int inf = 100100100;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int main(){
    int MAX_V = 10;
    int V,E;
    cin>>V>>E;
    vector<vector<int>> es(MAX_V,vector<int>(MAX_V,0));
    rep(i,E){
        int a,b; cin>>a>>b;
        --a; --b;
        es[a][b] = 1;
        es[b][a] = 1;
    }
    int ans = 0;
    vector<int> per(V-1); int cnt=0;
    REP(i,V-1)per[cnt++] = i;
    do{
        int now = 0;
        rep(i,V-1){
            int next = per[i];
            if(es[now][next]){if(i==V-2)ans++;}
            else break;
            now = next;
        }
    }while(next_permutation(per.begin(),per.end()));
    cout<<ans<<endl; return 0;
}


Measured memory_bytes: 256
//解法AC
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using INT=mp::cpp_int;
using namespace std;
using ll=long long;
using vec=vector<ll>;
using vect=vector<double>;
using Graph = vector<vector<ll>>;
#define loop(i,n) for(ll i=0;i<n;i++)
#define Loop(i, m, n) for(ll i = m;i < n;i++)
#define pool(i,n) for(ll i=n;i>=0;i--)
#define Pool(i, m, n) for(ll i=n;i>=m;i--)
#define MAX 99999999999ll
#define MIN -99999999999ll
#define setbit bitset<8>
#define flagcount __builtin_popcount
#define flag(x) (1<<x)
#define flagadd(bit,x) bit|=flag(x)
#define flagpop(bit,x) bit&=~flag(x) 
#define flagon(bit,i) bit&flag(i)
#define flagoff(bit,i) !(bit & (1<<i))
#define all(v) v.begin(),v.end()
#define low2way(v,x) lower_bound(all(v),x)
#define high2way(v,x) upper_bound(all(v),x)
#define count2way(v,x) high2way(v,x)-low2way(v,x)
#define lower(v,x) low2way(v,x)-v.begin() //1番左が0、もし見つから無いならｎを出力
#define higher(v,x) high2way(v,x)-v.begin()-1 //1番左が0、もし見つからないならn-1を出力（注意）
#define putout(a) cout<<a<<endl
#define putout2(a,b) putout(a);putout(b)
#define putout3(a,b,c) putout(a);putout(b);putout(c)
#define putout4(a,b,c,d) putout(a);putout(b);putout(c);putout(d)
#define putout5(a,b,c,d,e) putout(a);putout(b);putout(c);putout(d);putout(e)
#define Gput(a,b) G[a].push_back(b)
#define cin1(a) cin>>a
#define cin2(a,b) cin>>a>>b
#define cin3(a,b,c) cin>>a>>b>>c
#define cin4(a,b,c,d) cin>>a>>b>>c>>d
#define cin5(a,b,c,d,e) cin>>a>>b>>c>>d>>e
#define sum(v) accumulate(all(v), 0ll)
#define gcd(x,y) __gcd(x,y)
ll ctoi(char c){
	if(c>='0'&&c<='9'){
		return c-'0';
	}
	return 0;
}
ll lcm(ll x,ll y){
  ll z=gcd(x,y);
  return x*y/z;
}
INT LCM(INT x,INT y){
  INT z=gcd(x,y);
  return x*y/z;
}
ll primejudge(ll n){
  if(n<2)return 0;
  else if(n==2)return 1;
  else if(n%2==0)return 0;
  double sqrtn=sqrt(n);
  Loop(i,3,sqrtn+1){
     if(n%i==0){
        return 0;
     }
     i++;
  }
  return 1;
}
INT modinv(INT a, INT m) {
    INT b = m, u = 1, v = 0;
    while (b) {
        INT t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
int main() {
  cout << fixed << setprecision(30);
  ll n,m;
  cin>>n>>m;
  vec p(m);
  vec y(m);
  loop(i,m)cin>>p[i]>>y[i];
  Graph G(n+1);
  loop(i,m)Gput(p[i],y[i]);
  Loop(i,1,n+1)sort(all(G[i]));
  loop(i,m){
    cout<<setfill('0')<<right<<setw(6)<<p[i];
    ll t=lower(G[p[i]],y[i])+1;
    cout<<setfill('0')<<right<<setw(6)<<t<<endl;
  }
}

Measured memory_bytes: 8576
#include<iostream>
#include<cstdio>
#include<string>
#include<cmath>
using namespace std;
#define MAX 87
#define ll long long
ll dp[MAX] = {};

void make() {
	dp[0] = 2;
	dp[1] = 1;
	for (int i=2;i<MAX;i++) {
	dp[i] = dp[i-1] + dp[i-2];
	}
}

int main() {
	make();
	int n;
	cin >> n;
	cout << dp[n] << endl;
	return 0;
}


Measured memory_bytes: 256
#include <map>
#include <set>
#include <ctime>
#include <queue>
#include <stack>
#include <cmath>
#include <vector>
#include <bitset>
#include <cstdio>
#include <cctype>
#include <string>
#include <numeric>
#include <cstring>
#include <cassert>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std ;
#define rep(i, a, b) for (ll i = (a); i <= (b); ++i)
#define per(i, a, b) for (ll i = (a); i >= (b); --i)
#define loop(it, v) for (auto it = v.begin(); it != v.end(); it++)
#define cont(i, x) for (int i = head[x]; i; i = edge[i].nex)
#define clr(a) memset(a, 0, sizeof(a))
#define ass(a, cnt) memset(a, cnt, sizeof(a))
#define cop(a, b) memcpy(a, b, sizeof(a))
#define lowbit(x) (x & -x)
#define all(x) x.begin(), x.end()
#define SC(t, x) static_cast <t> (x)
#define ub upper_bound
#define lb lower_bound
#define pqueue priority_queue
#define mp make_pair
#define pb push_back
#define pof pop_front
#define pob pop_back
#define fi first
#define se second
#define y1 y1_
#define Pi acos(-1.0)
#define iv inline void
#define enter cout << endl
#define siz(x) ((int)x.size())
#define file(x) freopen(x".in", "r", stdin),freopen(x".out", "w", stdout)
typedef double db ;
typedef long long ll ;
typedef unsigned long long ull ;
typedef pair <int, int> pii ;
typedef vector <int> vi ;
typedef vector <pii> vii ;
typedef queue <int> qi ;
typedef queue <pii> qii ;
typedef set <int> si ;
typedef map <int, int> mii ;
typedef map <string, int> msi ;
const int maxn = 2e5 + 10 ;
const int inf = 0x3f3f3f3f ;
const int iinf = 1 << 30 ;
const ll linf = 2e18 ;
const ll mod = 1e9 + 7 ;
const double eps = 1e-7 ;
template <class T> void read(T &a)
{
	int f = 1 ; a = 0;
	char ch = getchar() ;
	while (!isdigit(ch)) { if (ch == '-') f = -1 ; ch = getchar() ; }
	while (isdigit(ch)) { a =  (a << 3) + (a << 1) + ch - '0' ; ch = getchar() ; }
	a *= f;
}

ll n, ans = linf;

struct P
{
	ll x, y;
}
a[maxn];

signed main()
{
	scanf("%lld", &n);
	rep(i, 1, n) scanf("%lld %lld", &a[i].x, &a[i].y);
	if(n == 1) return puts("1"), 0;
	rep(i, 1, n)
	{
		rep(j, 1, n)
		{
			if(i == j) continue;
			ll p = a[i].x - a[j].x, q = a[i].y - a[j].y;
			ll tmp = 0;
			rep(k, 1, n) rep(l, 1, n) if(a[k].x - a[l].x == p && a[k].y - a[l].y == q) tmp ++;
			ans = min(ans, n - tmp);
		}
	}
	printf("%lld\n", ans);
	return 0;
}

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

int main(){
  int num,n;
  while(cin>>num>>n,n){
    int cnt=0,k[30],nn[1000000]={};
    while(1){
      vector<int> a;
      k[cnt]=num;
      cnt++;
      nn[num]++;
      if(nn[num]==2){
	for(int i=0;i<=cnt;i++){
	  if(k[i]==num){
	    cout<<i<<" "<<num<<" "<<cnt-i-1<<endl;
	    break;
	  }
	}
	break;
      }
      int neko=num;
      for(int i=0;i<n;i++){
	a.push_back(neko%10);
	neko/=10;
      }
      sort(a.begin(),a.end());
      int min=0,max=0;
      for(int i=0;i<n;i++){
	max+=a[i]*pow(10,i);
	min+=a[n-i-1]*pow(10,i);
      }
      num=max-min;
    }
  }
  return 0;
}

Measured memory_bytes: 7108
#include<bits/stdc++.h>
using namespace std;
 
#define ff              first
#define fo(i,n)         for(i=0;i<n;i++)
#define Fo(i,k,n)       for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define deb(x)          cout << #x << "=" << x << endl
#define deb2(x, y)      cout << #x << "=" << x << "," << #y << "=" << y << endl
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define w(x)            int x; cin>>x; while(x--)
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());
 
 
const int N = 1e6 , M = N;
//=======================
vi factorize (vi v){
	for(int i=1;i<=N;i++)
		for(int j=i;j<=N;j+=i){
			v[j]+=1;
		}
	return v;
}
 
void solve() {
	vi v(N+1,0);
	v=factorize(v);
	int n;
	cin>>n;
	int ans = 0;
	for(int c=n-1;c>=1;c--){
		ans += v[n-c];
		// deb2(n-c,v[n-c]);
	}
	cout<<ans;
}
 
int32_t main()
{
  FIO;
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
  solve();
  return 0;
}

Measured memory_bytes: 18692
#include <iostream>
#include <cstring>
#include <vector>
#include <set>
#include <list>
#include <map>
#include <deque>
#include <algorithm>
#include <utility>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
#define for1(i,n) for (ll i=0;i<(n);i++)
#define for2(i,m,n) for (ll i=(m);i<(n);i++)
#define for3(i,m,n,d) for (ll i=(m);i<(n);i+=(d))
#define DEBUG 0
template <class T>
void dumplist(T list)
{
    for (auto item : list) {
        cout << item << " ";
    }
    cout << endl;
}

ll gcd(ll a, ll b)
{
    if (b == 0) {
        return a;
    }
    return gcd(b, a % b);
}
ll lcm(ll a, ll b)
{
    return a / gcd(a,b) * b;
}

ll A,B,C,D;
ll calc(ll N)
{
    ll ans = 0;
    ans += N / C;
    ans += N / D;
    ans -= N / lcm(C,D);
    return N - ans;
}

void solve()
{
    cin >> A >> B >> C >> D;
    ll ans = 0;
    ans = calc(B) - calc(A - 1);
    cout << ans << endl;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    do {
        solve();
    } while (DEBUG);
}


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

int[int] NS;

void main()
{
    auto N = readln.chomp.to!int;
    foreach (_; 0..N) {
        auto A = readln.chomp.to!int;
        if (A in NS)
            ++NS[A];
        else
            NS[A] = 1;
    }
    int ret;
    foreach (a; NS.byValue) if (a & 1) ++ret;
    writeln(ret);
}

Measured memory_bytes: 8060
#include <bits/stdc++.h>
using namespace std;
static const int32_t dx[8] = {0,1,0,-1,1,1,-1,-1};
static const int32_t dy[8] = {1,0,-1,0,1,-1,-1,1};
typedef int64_t ll;
typedef vector<int8_t> vcc;
typedef vector<vcc> vvcc;
struct Solution {
    void solve(std::istream& in, std::ostream& out) {
        ll h, w;
        in >> h >> w;
        vvcc s(h, vcc(w, 0));
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                in >> s[i][j];
                if (s[i][j] == '.') {
                    s[i][j] = '0';
                }
            }
        }
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                if (s[i][j] == '#') {
                    continue;
                }
                for (int k = 0; k < 8; k++) {
                    if (0 <= j + dx[k] && j + dx[k] < w && 0 <= i + dy[k] && i + dy[k] < h) {
                        if (s[i + dy[k]][j + dx[k]] == '#') {
                            s[i][j] += 1;
                        }
                    }
                }
            }
        }
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                out << s[i][j];
            }
            out << '\n';
        }
    }
};
void solve(std::istream& in, std::ostream& out) {
    out << std::setprecision(12);
    Solution solution;
    solution.solve(in, out);
}
#include <fstream>
#include <iostream>
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    istream& in = cin;
    ostream& out = cout;
    solve(in, out);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000000


int main(){
	
	int N,M;
	cin>>N>>M;
	
	string S;
	cin>>S;
	
	vector<vector<int>> cnt(N,vector<int>(2,0));
	vector<vector<int>> E(N,vector<int>());
	
	for(int i=0;i<M;i++){
		int a,b;
		cin>>a>>b;
		a--;b--;
		
		E[a].push_back(b);
		E[b].push_back(a);
		if(S[b]=='A')cnt[a][0]++;
		else cnt[a][1]++;
		
		if(S[a]=='A')cnt[b][0]++;
		else cnt[b][1]++;
	}
	
	vector<bool> f(N,true);
	queue<int> Q;
	
	for(int i=0;i<N;i++){
		if(cnt[i][0]==0||cnt[i][1]==0){
			f[i]=false;
			Q.push(i);
		}
	}
	
	while(Q.size()!=0){
		int from = Q.front();
		Q.pop();
		for(int i=0;i<E[from].size();i++){
			int to = E[from][i];
			if(!f[to])continue;
			if(S[from]=='A'){
				cnt[to][0]--;
			}
			else{
				cnt[to][1]--;
			}
			if(cnt[to][0]==0||cnt[to][1]==0){
				f[to] = false;
				Q.push(to);
			}
		}
	}
	
	for(int i=0;i<N;i++){
		if(f[i]){
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	
	cout<<"No"<<endl;

	return 0;
}

Measured memory_bytes: 21124
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<tuple>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<deque>
#include<cmath>
#include<stack>
#include<string.h>
#include <iomanip>
#define rep(i,n) for(int i = 0;i<n;i++)
#define _GLIBCXX_DEBUG
using ll = long long; 
using namespace std;
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 main() {
    ll a,b,n;
    cin >> a >> b >> n;
    ll x = min(b-1LL,n);
    ll ans = (a*x)/b-a*(x/b);
    cout << ans << endl;
}

Measured memory_bytes: 3604
console.log((args=>{
  const [[D,G],...tmp] = args.trim().split('\n').map( r=>r.split(' ').map(v=>v|0));
  const p = [], c = [];
  for ( let i = 0; i < D; i++ ) {
    p.push( tmp[i][0] );
    c.push( tmp[i][1] );
  }
  let min = Infinity;
  for ( let bit = 0; bit < 1<<D; bit++ ) {
    let q = 0, s = 0, x = 0;
    for ( let i = 0; i < D; i++ ) {
      if ( bit & 1<<i ) {
        q += p[i];
        s += (i+1) * 100 * p[i] + c[i];
      } else x = i;
    }
    if ( s >= G && min > q ) {
      min = q;
      continue;
    }
    for ( let i = 1; i < p[x]; i++ ) {
      if ( G <= s + i*(x+1)*100 && min > q + i ) {
        min = q + i;
        break;
      }
    }
  }
  return `${min}`;
})(require('fs').readFileSync('/dev/stdin', 'utf8')));


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

int main(){
  string masu1,masu2;
  cin >> masu1 >> masu2;
  if(masu1[0]==masu2[2]&&masu1[1]==masu2[1]&&masu1[2]==masu2[0]){
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstddef>
#include<queue>
#include<math.h>
#include<iomanip>
using namespace std;

int main()
{
    int k;
    cin >> k;
    string s;
    cin >> s;
    string ans = "";
    if(s.size() > k){
        for(int i = 0; i < k; ++i) ans += s.at(i);
        ans += "...";
    }
    else ans = s;
    cout << ans << endl;
    return 0;
}

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

int c;

int seisu_1(int n){
    if(0<=n && n<10) return c;
    else{    
    int nmax=(n/10)*(n%10), m;
    for(int j=10; j<=n; j*=10){
        m = (n/j)*(n%j);
        if(nmax<m)  nmax = m;
    }
    c++;
    return seisu_1(nmax);
    }
}


int main(void){
    int Q, n;
    cin >> Q;
    for(int i=1; i<=Q; i++){
        c = 0;
        cin >> n;
        cout << seisu_1(n) << endl;
    }
    
    return 0;
}


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

using namespace std;
double ans,a[3005];
double dp[3005][3005];
int n;

double Rec(int coin,int tails){
if(coin==n)
  if(tails <= n/2)
    return 1;
  else
    return 0;
    if(dp[coin][tails]!=-1)
        return dp[coin][tails];
    double Res=0.0;
Res=Rec(coin+1,tails+1)*(1-a[coin])+Rec(coin+1,tails)*a[coin];

return dp[coin][tails]=Res;


}

int main()
{
    cin>>n;
    for(int i=0; i<n; i++)
        cin>>a[i];
    for(int i=0; i<3005; i++)
        for(int j=0; j<3005; j++)
        dp[i][j]=-1;

 cout<<fixed<<setprecision(10)<<Rec(0,0);
    return 0;
}


Measured memory_bytes: 71040
//Rounding

#include <iostream>
#include <vector>
#include <math.h>
#include <string>

using namespace std;

int main()
{
    int X,A;
    cin >> X >> A;
    if(X<A) {
        cout << 0 << endl;
    }
    else {
        cout << 10 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int x, y;
	int a;
	
	while (1){
		
		scanf("%d %d", &x, &y);
		
		if (x == 0 && y == 0) break;
		
		
		if (x > y) {
			a = x;
			x = y;
			y = a;
		}
		
		printf("%d %d\n", x, y);
		
	}
	
	return (0);
}

Measured memory_bytes: 600
#include <iostream>
#include <vector>
using namespace std;
int main(){
  string s;cin>>s;
  vector<int> a;
  for(int i = 0; s.size() > i; i++){
    if(s[i] == '0')a.push_back(0);
    if(s[i] == '1')a.push_back(1);
    if(s[i] == 'B' && a.size()!=0)a.pop_back();
  }
  for(int i = 0; a.size() > i; i++){
    cout << a[i];
  }
  cout << endl;
}

Measured memory_bytes: 256
h,w = map(int,input().split())
a = [input() for i in range(h)]

from collections import deque
q = deque()
reach = [[False]*w for i in range(h)]
for i in range(h):
    for j in range(w):
        if a[i][j]=='#':
            q.append([i,j,0])
            reach[i][j] = True

ans = 0
while q:
    i,j,cnt = q.popleft()
    ans = max(ans,cnt)
    for k,l in [[1,0],[-1,0],[0,1],[0,-1]]:
        if 0<=i+k<h and 0<=j+l<w:
            if not reach[i+k][j+l]:
                q.append([i+k,j+l,cnt+1])
                reach[i+k][j+l] = True

print(ans)

Measured memory_bytes: 179104
#!/usr/bin/env python3
import sys


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors


def solve(N: int):
    ndiv = make_divisors(N)
    count = 0
    for div in ndiv:
        if div == 1:
            continue
        n = N
        while n % div == 0:
            n //= div
        if n % div == 1:
            count += 1
    print(len(make_divisors(N-1))+count-1)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
#include <stdio.h>
#include <iostream>
#include <string>
#include <cstdlib>

using namespace std;

int main(){
	int A, B, C, X;
	cin >> A >> B >> C >> X;
	int cnt = 0;
	for(int i = 0; i <= A; i++){
		for(int j = 0; j <= B; j++){
			for(int k = 0; k <= C; k++){
				int money = 500*i + 100*j + 50*k;
				if(money == X){
					cnt++;
				}
			}
		}
	}
	cout << cnt << "\n";
}


Measured memory_bytes: 256
import java.math.BigInteger;
import java.util.Scanner;

public class Main {

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

        int N = sc.nextInt();
        String s = sc.next();

        sc.close();

        char[] charArray = s.toCharArray();


        int R = 0;
        int B = 0;
        for(int i=0; i<N; i++){
            char tmp = charArray[i];
            if(tmp == 'R'){
                R++;
            }else{
                B++;
            }
        }

        String result = R>B ? "Yes" : "No";

        System.out.println(result);

    }
}


Measured memory_bytes: 21716
#import pysnooper
#import os,re,sys,operator,math,heapq,string
from collections import Counter,deque
#from operator import itemgetter
#from itertools import accumulate,combinations,groupby,combinations_with_replacement,permutations
from sys import stdin,setrecursionlimit
#from copy import deepcopy

setrecursionlimit(10**6)
input=stdin.readline

while 1:
    s=input().rstrip()
    if s=="-":
        break
    q=deque(list(s))
    m=int(input().rstrip())
    for _ in range(m):
        h=int(input().rstrip())
        q.rotate(-h)
    print("".join(q))


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

#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ALL(a) (a).begin(),(a).end()
#define Yes(hoge) cout<<((hoge)?"Yes":"No")<<endl;
#define YES(hoge) cout<<((hoge)?"YES":"NO")<<endl;
using namespace std;
struct Grid{int x,y,t;};
struct Edge{int to,cost;};
struct Graph{vector<vector<Edge>>E;int V;
  Graph(int n):E(n){E.resize(n);V=n;}
  void add_edge(int from,int to,int cost){E[from-1].pb({to-1,cost});}
};
int main(){
  int n,m;cin>>n>>m;
  vector<int>hoge(100100);
  for(int i=0;i<m;i++){
    int a,b;cin>>a>>b;
    hoge[a]++;hoge[b]++;
  }
  bool flag=true;
  for(int i=0;i<=n;i++){
    if(hoge[i]%2)flag=false;
  }
  YES(flag);
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
void solve()
{
    long long n, m, l;
    cin >> n >> m;
    long long sum = 0;
    vector<long long> v(n);
    for (int i = 0; i < n; i++)
    {
        cin >> v[i];
        sum += v[i];
    }
    long long c = 0;
    long long res = ceil(sum / (4.0 * m));
    for (int i = 0; i < v.size(); i++)
    {
        if (v[i] >= res)
            c++;
    }
    if (c >= m)
        cout << "Yes";
    else
    {
        cout << "No";
    }
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    solve();
    return 0;
}

Measured memory_bytes: 256
object Main {

	def main(arg:Array[String]) = {
		var list = scala.io.StdIn.readLine().split(" ").map(_.toInt).toList;
		var l = scala.io.StdIn.readLine().split(" ").map(_.toInt).toList;
		println(l.sorted.takeRight(list(1)).sum);
	}

}



Measured memory_bytes: 27448
#include<bits/stdc++.h>
#define int long long
#define mod 1000000007
using namespace std;
int sum(int *a,int i,int j){
    int sum=0;
    for(int k=i;k<=j;k++){
        sum+=a[k];
    }
    return sum;
}
int slime(int *a,int i,int j,int dp[][401]){
    if(i>=j){
        return 0;
    }
    if(dp[i][j]!=-1){
        return dp[i][j];
    }
    int ans=LONG_LONG_MAX;
    for(int k=i;k<=j-1;k++){
        ans=min(ans,sum(a,i,j)+slime(a,i,k,dp)+slime(a,k+1,j,dp));
    }
    return dp[i][j]=ans;
}
int32_t main(){
    int n;
    cin>>n;
    int a[401];
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    int dp[401][401];
    memset(dp,-1,sizeof dp);
    cout<<slime(a,1,n,dp)<<endl;
    return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define rep(a,n) for (ll a = 0; a < (n); ++a)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<vector<ll> > Graph;
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 = 1e18;

vector<ll>s,t,x;
ll di(ll x){
    int itr1 = lower_bound(s.begin(),s.end(),x)-s.begin();
    int itr2 = lower_bound(t.begin(),t.end(),x)-t.begin();
    ll Rs = s[itr1];
    ll Rt = t[itr2];
    ll Ls = s[itr1-1];
    ll Lt = t[itr2-1];
    ll res = INF;
    chmin(res,x-min(Ls,Lt));
    chmin(res,max(Rs,Rt)-x);
    chmin(res,Rs-Lt+min(Rs-x,x-Lt));
    chmin(res,Rt-Ls+min(Rt-x,x-Ls));
    return res;
}
int main(){
    int a,b,q;
    cin >> a >> b >> q;
    s.resize(a+2);t.resize(b+2);x.resize(q);
    rep(i,a)cin >> s[i+1];
    rep(i,b)cin>>t[i+1];
    rep(i,q)cin>>x[i];
    s[0]=-INF;s[a+1]=INF;
    t[0]=-INF;t[b+1]=INF;
    rep(i,q){
        cout << di(x[i]) << endl;
    }
    return 0;
}


Measured memory_bytes: 3712
#include <stdio.h>

int a,b,c,k,max,i,twice,ans ;

int main(void){

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

    max = a ;
    if (max<b){
        max = b ;
    }
    if (max<c){
        max = c ;
    }
    
    twice = max ;
    
    for (i=0; i<k; i++){
        twice = twice * 2 ;
    }
    
    ans = a+b+c+twice-max ;
    
    printf ("%d",ans) ;

    return 0 ;
}

Measured memory_bytes: 128
import Data.Array

main = do
    n <- readLn :: IO Int
    hs <- listArray (1,n) . map read.words <$> getLine
    print $ answer n hs

answer n hs = dp ! 1 where
    dp = array (1,n) $ (n,0): (n-1, n#(n-1)):[ (now, move now) | now <- [1..n-2]]
    move now = min (dp!(now+1) + now#(now+1)) (dp!(now+2) + now#(now+2))
    a # b = abs $ (hs!a) - (hs!b)

Measured memory_bytes: 48508