akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<ctime>
#define MAXN 500000
struct node
{
	int key;
	node *ch[2];
};
node tree[MAXN+5];
node *Root,*NIL,*ncnt;
//bool first=true;
void Init()
{
	NIL=&tree[0];
	ncnt=&tree[1];
	Root=NIL;
}
inline node *NewNode(int val)
{
	node *p=++ncnt;
	p->key=val;
	p->ch[0]=p->ch[1]=NIL;
	return p;
}
void Insert(node *&rt,int val)
{
	if(rt==NIL)
	{
		rt=NewNode(val);
		return;
	}
	int d=(val>=rt->key);
	Insert(rt->ch[d],val);
}
void PreOrder(node *&rt)
{
	if(rt==NIL)
		return;
//	if(first==true)
//		printf("%d",rt->key),first=false;
//	else
		printf(" %d",rt->key);
	PreOrder(rt->ch[0]);
	PreOrder(rt->ch[1]);
}
void InOrder(node *&rt)
{
	if(rt==NIL)
		return;
	InOrder(rt->ch[0]);
//	if(first==true)
//		printf("%d",rt->key),first=false;
//	else
		printf(" %d",rt->key);
	InOrder(rt->ch[1]);
}
node *Find(node *rt,int val)
{
	if(rt==NIL)
		return NIL;
	if(rt->key==val)
		return rt;
	int d=(val>rt->key);
	return Find(rt->ch[d],val);
}
int main()
{
	Init();
	int n,x;
	char op[100];
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	{
		scanf("%s",op);
		if(op[0]=='i')
			scanf("%d",&x),Insert(Root,x);
		else if(op[0]=='p')
		{
			InOrder(Root);
			printf("\n");
			PreOrder(Root);
			printf("\n");
		}
		else if(op[0]=='f')
		{
			scanf("%d",&x);
			if(Find(Root,x)==NIL)
				printf("no\n");
			else
				printf("yes\n");
		}
	}
	return 0;
}

Measured memory_bytes: 12124
import std.algorithm;
import std.bigint;
import std.bitmanip;
import std.concurrency : generator = Generator, yield;
import std.container;
import std.conv;
import std.functional;
import std.format;
import std.math;
import std.meta;
import std.numeric;
import std.random;
import std.range;
import std.stdio;
import std.string;
import std.traits;
import std.typecons;


auto solve(string S) {
    string s = S[0 .. S.length / 2];
    string t = S[S.length / 2 .. $];
    return zip(s, t.retro).count!"a[0] != a[1]";
}


void main() {
    auto input = stdin.byLine.map!split.joiner;

    string S;
    S = input.front.to!string;
    input.popFront;

    static if (is(ReturnType!solve == void))
        solve(S);
    else {
        auto ans = solve(S);

        static if (isFloatingPoint!(ReturnType!solve))
            writeln(format("%.9f", ans));
        else static if (is(ReturnType!solve == bool))
            writeln(ans ? YES : NO);
        else
            writeln(ans);
    }
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

		int cnt = 0;
		int n = s.length();
		for (int i = 0; i < n; ++i) {
			if (s.charAt(i) == '1')
				++cnt;
		}

		System.out.println(cnt);
	}

}


Measured memory_bytes: 22868
#include<stdio.h>

#define N 100000
int partition(int*,int,int);

int main(void){
  int n,A[N],index;
  int i;

  scanf(" %d",&n);
  for(i = 0; i < n; i++){
    scanf(" %d",&A[i]);
  }

  index = partition(A,0,n-1);

  for(i = 0; i < n; i++){
    if(i > 0)printf(" ");
    if(i == index)printf("[");
    printf("%d",A[i]);
    if(i == index)printf("]");
  }
  printf("\n");
  
  return 0;
}

int partition(int *A, int p, int r){
  int x,tmp;
  int i,j;

  x = A[r];
  i = p-1;
  for(j = p; j < r; j++){
    if(A[j] <= x){
      i++;
      tmp = A[j];
      A[j] = A[i];
      A[i] = tmp;
    }
  }
  tmp = A[i+1];
  A[i+1] = A[r];
  A[r] = tmp;
  return i+1;
}



Measured memory_bytes: 2100
H, W = map(int, input().split())

l = []
for i in range(H):
    l.append(list(input()))

for i in range(H):
    for j in range(W):
        if l[i][j] == '.':
            pass
        elif 0<i and l[i-1][j] == '#':
            pass
        elif 0<j and l[i][j-1] == '#':
            pass
        elif j<W-1 and l[i][j+1] == '#':
            pass
        elif i<H-1 and l[i+1][j] == '#':
            pass
        else:
            print('No')
            exit()
print('Yes')

Measured memory_bytes: 9208
#include<cstdio>
#include<functional>
#include<algorithm>
#include<queue>
using namespace std;
typedef pair<int,int> P;
P pp[100001];
int main(void)
{
	int w,h,n,i,j,mn;
	priority_queue<int> qu;
	scanf("%d %d %d",&w,&h,&n);
	for(i=0;i<n;i++)	{
		scanf("%d %d",&pp[i].first,&pp[i].second);
	}
	pp[n].first=0;	pp[n].second=0;
	sort(pp,pp+n+1);
	mn=pp[n].first;
	for(i=n-1;i>=0;i--)	{
		qu.push(pp[i+1].second);
		mn=min(mn,pp[i].first+qu.top());
	}
	printf("%d\n",mn);
	return 0;
}


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

using namespace std;
typedef long long ll;

const ll INF = (1LL<<31)-1;
const ll MOD = 1000000007;


struct SegmentTree{
private:
    ll n;
    vector<ll> node;

public:
    SegmentTree(vector<ll> v){
        ll sz = v.size();
        n = 1;
        while(n<sz)n*=2;
        node.resize(2*n-1,INF);
        for(int i=0;i<sz;i++) node[i+n-1]=v[i];
        for(int i=n-2;i>=0;i--) node[i] = min(node[2*i+1],node[2*i+2]);
    }

    void update(ll x, ll val){
        x += (n-1);
        node[x] = val;
        while(x > 0){
            x = (x-1)/2;
            node[x] = min(node[2*x+1], node[2*x+2]);
        }
    }

    //要求区間[a,b)での値を求める(ここではmin)
    //k : 自分がいるノードのインデックス
    //対象区間は[l,r)
    int find(ll a,ll b, ll k = 0, ll l = 0, ll r = -1){
        if(r < 0) r = n;

        //要求区間と対象区間が交わらない
        if(r <= a || b <= l) return INF;

        //要求区間が対象区間を完全に被覆
        if(a <= l && r <= b) return node[k];

        //一部を被覆
        //左の子がvl, 右がvr
        ll vl = find(a,b,2*k+1,l,(l+r)/2);
        ll vr = find(a,b,2*k+2,(l+r)/2,r);

        return min(vl,vr);
    }

};

//cout << fixed << setprecision(10);

int main() {
    ll N,Q;
    cin >> N >> Q;
    SegmentTree seg(vector<ll>(N,INF));
    for(int i=0;i<Q;i++){
        ll c;
        cin >> c;
        ll x,y;
        cin >> x >> y;
        if(c==0) seg.update(x,y);
        else cout << seg.find(x,y+1) << endl;
    }

    return 0;
}


Measured memory_bytes: 5760
use std::io;

fn read_input() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s);
    s
}

fn wa() {
    println!("WA");
    std::process::exit(0);
}

fn solve(s: String) {
    if !s.starts_with('A') {
        wa();
    }

    let v: Vec<_> = s.chars().collect();

    let mut count = 0;
    for c in &v[2..s.len()-2] {
        if *c == 'C' {
            count += 1;
        }
    }
    if count != 1 {
        wa();
    }

    count = 0;
    for c in &v {
        match *c {
            'A'...'Z' => count += 1,
            _ => ()
        }
    }

    if count != 2 {
        wa();
    }

    println!("AC");
}

fn main() {
    solve(read_input());
}


Measured memory_bytes: 4352
alph="abcdefghijklmnopqrstuvwxyz"
from collections import deque
import sys
input=sys.stdin.readline
moji=deque([])
s=input().rstrip()
for i in range(len(s)):
	for j in range(26):
		if s[i]==alph[j]:
			moji.append(j)
			break
q=int(input())
rev=0
for _ in range(q):
	qw=input().split()
	if qw[0]=="1":
		rev+=1
	else:
		f=qw[1]
		c=qw[2]
		for j in range(26):
			if c==alph[j]:
				x=j
				break
		if f=="1":
			if rev%2==0:
				moji.appendleft(x)
			else:
				moji.append(x)
		else:
			if rev%2==0:
				moji.append(x)
			else:
				moji.appendleft(x)
ans=""
r=[]
for i in range(len(moji)):
	r.append(moji.popleft())
for i in range(len(r)):
	ans+=alph[r[i]]
if rev%2==0:
	print(ans)
else:
	print(ans[::-1])


Measured memory_bytes: 8692
from itertools import product, count

n = int(input())
cnt = 0
flag = False
for i in count(1):
    for digits in product((3,5,7), repeat=i):
        if len(set(digits)) < 3:
            continue
        x = sum(10**j * d for j,d in enumerate(reversed(digits)))
        if x > n:
            flag = True
            break
        else:
            cnt += 1
    if flag:
        break

print(cnt)

Measured memory_bytes: 3064
if __name__ == '__main__':
    a, b = map(int, input().split())
    ans = 0

    if a > 1:
        a = a-1
        ans = (1+a)*a//2
    if b > 1:
        b = b-1
        ans =ans + (1+b)*b//2



    print(ans)

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
const int N=1e6+5;
const int mod1=1e9+7;
const int P1=19260817;
const int P2=998244353;
const int mod2=1004535809;
#define ll long long
typedef pair<ll,ll>Pi;
ll fsp(ll x,int y){
	ll ans=1;
	while(y){
		if(y&1)	ans=ans*x%mod1;
		x=x*x%mod1,y>>=1;
	}
	return ans;
}
ll ksm(ll x,int y){
	ll ans=1;
	while(y){
		if(y&1)	ans=ans*x%mod2;
		x=x*x%mod2,y>>=1;
	}
	return ans;
}
char s[N];
map<Pi,int>ma;
ll n,l1,l2=1,r1,r2=1,ans,res1,res2,add1,add2,inv1,inv2;
int main(){

	scanf("%lld%s",&n,s+1);
	add1=fsp(P1,n);add2=ksm(P2,n);
	inv1=fsp(P1,mod1-2),inv2=ksm(P2,mod2-2);
	for(int i=n;i;i--){
		if(s[i]=='-'){
			res1=(res1-add1+mod1)%mod1;
			res2=(res2-add2+mod2)%mod2;
		}
		if(s[i]=='+'){
			res1=(res1+add1)%mod1;
			res2=(res2+add2)%mod2;
		}
		if(s[i]=='<'){
			res1=res1*inv1%mod1;
			res2=res2*inv2%mod2;
		}
		if(s[i]=='>'){
			res1=res1*P1%mod1;
			res2=res2*P2%mod2;
		}
	}
	for(int i=n;i;i--){
		ll k1=0,k2=0;
		if(s[i]=='-'){
			l1=(l1-add1+mod1)%mod1,k1=mod1-add1;
			r1=(r1-add2+mod2)%mod2,k2=mod2-add2;
		}
		if(s[i]=='<'){
			l1=l1*inv1%mod1,l2=l2*inv1%mod1;
			r1=r1*inv2%mod2,r2=r2*inv2%mod2;
		}
		if(s[i]=='>'){
			l1=l1*P1%mod1,l2=l2*P1%mod1;
			r1=r1*P2%mod2,r2=r2*P2%mod2;
		}
		if(s[i]=='+'){
			l1=(l1+add1)%mod1,k1=add1;
			r1=(r1+add2)%mod2,k2=add2;
		}
		++ma[Pi((k1-l1+mod1)*fsp(l2,mod1-2)%mod1,(k2-r1+mod2)*ksm(r2,mod2-2)%mod2)];
		ans+=ma[Pi((res1-l1+mod1)*fsp(l2,mod1-2)%mod1,(res2-r1+mod2)*ksm(r2,mod2-2)%mod2)];
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 31744
#include<bits/stdc++.h>
    using namespace std;
    
    #define ll long long
    #define pb push_back
    #define printV(v) for(int i=0;i<v.size();i++){cout << v[i]<< " ";} cout << endl
    #define printRev(v) for(int i=v.size()-1;i >= 0;i--){cout << v[i] << " ";} cout << endl
    #define sortV(v) sort(v.begin(),v.end())
    #define revV(v) reverse(v.begin(),v.end())
    #define FOR(i,from,n) for(int i=from;i<n;i++)
    #define FOL(i,from,n) for(int i=from;i >= n;i--)
        
        ll a,b,c,d,e,f,g,n,m,k,t,x,h,w,q;
        ll mod = 1e9 + 7;

        
        void solve(){
            cin >> n >> k;
            ll begin = 0;
            ll end = 0;
            for(int i=0;i<k;i++) {
                begin += i;
                end += (n-i);
            }
            ll answer = end - begin + 1;
            //cout << end - begin << endl;
            //cout << answer << endl;
            for(int i=k;i<=n;i++){
                end += (n-i);
                begin += i;
              //  cout << end - begin + 1 << endl;
                answer = (answer + 1 + (end - begin)) % mod;
            }
            cout << answer << endl;
        }
            
        int main(){
        ios_base::sync_with_stdio(false);
        //freopen("input.txt","r",stdin);
        //freopen("output.txt","w",stdout);
        int cases = 1;
        //cin >> cases;
    
        while(cases--){ 
            solve();
        }

        return 0;

        }

Measured memory_bytes: 3656
import sys
input=sys.stdin.readline
n,d=map(int,input().split())
x=[list(map(int,input().split())) for i in range(n)]


cnt=0
def abc(n,m,i,res):
    global cnt,x,d
    if i==d:
        return res
    else:
        res=abc(n,m,i+1,res+(x[m][i]-x[n][i])**2)
    return res

for i in range(n-1):
    for j in range(i+1,n):
        a=abc(i,j,0,0)**0.5
        if int(a)==a:
            cnt+=1
print(cnt)

Measured memory_bytes: 38384
Module Module1

sub Main(ByVal args() as String)
    dim N as integer = Console.ReadLine()
    dim arr() as string = Split(Console.ReadLine())
    dim a(N) as integer
    for i as integer = 0 to N-1 step 1
        a(i) = arr(i)
    next i
    Array.Sort(a)
    Array.Reverse(a)

    dim sumAlice as integer = 0
    dim sumBob as integer = 0
    dim f as boolean = true
    for each i as integer in a
        if f then
            sumAlice += i
            f = false
        else    
            sumBob += i
            f = true
        end if
    next
    Console.WriteLine(sumAlice-sumBob)
end sub

end Module

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

char a[1000010];
int len;
int bada;
long long g;

int main(void)
{
	scanf("%s", a);
	
	len = strlen(a);
	
	for(int i = len - 1 ; i >= 0 ; i--)
	{
		a[i] += bada;
		
		if(a[i] > '9')
		{
			a[i] = a[i] - 10;
			bada = 1;
			
			if('0' <= a[i] && a[i] <= '5')
			{
				g += a[i] - '0';
			}
			
			else
			{
				g += 10 - a[i] + '0';
			}
			continue;
		}
		
		if('0' <= a[i] && a[i] <= '4')
		{
			g += a[i] - '0';
			bada = 0;
		}
		
		else if(a[i] == '5')
		{
			if(i != 0)
			{
				if(a[i - 1] >= '5')
				{
					g += 5;
					bada = 1;
				}
				
				else
				{
					g += 5;
					bada = 0;
				}
			}
			
			else
			{
				g += 5;
				bada = 0;
			}
		}
		
		else
		{
			g += 10 - a[i] + '0';
			bada = 1;
		}
	}
	
	printf("%lld", g + bada);
	return 0;
}

Measured memory_bytes: 1280
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int power(int x, int y)
{
	if (y ==0)
		return(1);
	if (x ==0)
		return(0);
	int index =0;
	int num = 1;
	while (index <y)
	{
		num = num * x;
		index++;
	}
	return (num);
}
int	main(void)
{

	int N, M;
	scanf("%d %d", &N, &M);
	int s[M],c[M];
	int index =0;
	while (index <M)
	{
		scanf("%d %d", &s[index], &c[index]);
		index++;
	}
	int i =power(10,N-1)-1;
	if (i !=0)
		i++;
	int j =0;
	while (i <1000)
	{
		j =0;
		while (j < M)
		{
			if(c[j] != (i/power(10,N-s[j]))%10)
			{
				j--;
				break;
			}
			j++;
		}
		if(j == M)
		{
			printf("%d\n", i);
			return (0);
		}
		i++;
	}

	printf("-1");
	return (0);
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int INF = 0x3f3f3f3f;
const LL mod = 1e9 + 7;
const int N = 100005;

vector<int> G[N]; 
int vis[N];
void dfs(int u){
	vis[u]=1;
	for(int i=0;i<G[u].size();i++){
		int v=G[u][i];
		if(vis[v]==0)dfs(v);
	}
}
int main() {
	int n,m;
	cin>>n>>m;
	while(m--){
		int u,v;
		cin>>u>>v;
		G[u].push_back(v);
		G[v].push_back(u); 
	}
	int cnt=0; 
	for(int i=1;i<=n;i++){
		if(vis[i]==0){
			dfs(i);
			cnt++;
		}
	}
	cout<<cnt-1<<endl;
    return 0;
}
 

Measured memory_bytes: 9968
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<stack>
#include<queue> 
using namespace std;
typedef long long LL;
const int INF=0x3f3f3f3f;
int n;
LL calc(LL a)
{
    int t=0;
    while(a) {t+=a%10; a/=10;}
    return t;
}

int main()
{
    scanf("%d",&n);
    LL x=0, m=1,x1,x2;
    for (int i=1; i<=n; i++)
    {
        x1=x+m; x2=x+m*10;
        if (x1*calc(x2)<=x2*calc(x1)) 
            x=x1;
        else
            {x=x2; m*=10;}
        printf("%lld\n",x);
    }
    return 0;
} 

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	while(1){
		int i=0;
		int sum=0;
		char num[1001]={};
		scanf("%s",num);
		if(num[0]-'0'==0){break;}
		while(num[i])
		{
			sum+=num[i]-'0';
			i++;
		}
		printf("%d\n", sum);
	}
	return 0;
}

Measured memory_bytes: 536
use std::cmp::*;
use std::collections::*;
#[cfg(debug_assertions)]
include! {"./debug.rs"}

#[cfg(not(debug_assertions))]
macro_rules! debug {
    ($($arg:expr),*) => {};
}

macro_rules! read {
    ([$t:ident] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ([$t:ident]) =>
        (rl().split_whitespace().map(|w| read_type!(w, $t)).collect::<Vec<_>>());
    (_, [$t:ident] ; $n:expr) =>
        ((0..$n).map(|_| read!(_, [$t])).collect::<Vec<_>>());
    (_, [$t:ident]) =>
        (rl().split_whitespace().skip(1).map(|w| read_type!(w, $t)).collect::<Vec<_>>());
    ($($t:ident),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ($t:ident) => (read_type!(rl(), $t));
    ($($t:ident),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(read_type!(w.next().unwrap(), $t)),*)
    }};
}

macro_rules! read_type {
    ($s:expr, chars) => {
        $s.chars().collect::<Vec<char>>()
    };
    ($s:expr, usize1) => {
        read_type!($s, usize) - 1
    };
    ($s:expr, $t:ty) => {
        $s.parse::<$t>().unwrap()
    };
}

fn rl() -> String {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    buf.trim_right().to_owned()
}

trait IteratorExt: Iterator + Sized {
    fn vec(self) -> Vec<Self::Item> {
        self.collect()
    }
}

impl<T: Iterator> IteratorExt for T {}

////////////////////////////////////////////////////////////////////////////////

fn main() {
    let mut s = read!(chars);
    let mut ans: i64 = 0;

    if s.len() >= 3 {
        loop {
            let mut found = false;
            for i in 0..s.len() - 2 {
                if s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C' {
                    found = true;
                    let mut l = i;
                    let mut a = 1;
                    while l > 0 && s[l - 1] == 'A' {
                        l -= 1;
                        a += 1;
                    }
                    let mut r = i + 1;
                    let mut bc = 1;
                    while r + 3 < s.len() && s[r + 2] == 'B' && s[r + 3] == 'C' {
                        r += 2;
                        bc += 1;
                    }
                    debug!(s.iter().cloned().collect::<String>(), i, l, r, a, bc);

                    ans += a * bc;
                    while bc > 0 {
                        s[l] = 'B';
                        s[l + 1] = 'C';
                        bc -= 1;
                        l += 2;
                    }
                    while a > 0 {
                        s[l] = 'A';
                        a -= 1;
                        l += 1;
                    }
                }
            }

            if !found {
                break;
            }
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<iostream>
#include<stdlib.h>
#include<algorithm>
int main(void){
    int n=0;
    std::cin >> n;
    int *p = (int*)malloc(n*sizeof(int));
    for(int i=0; i<n; i++){
        std::cin>>*(p+i);
    }
    std::sort(p,p+n);
     /*
    for(int i=0; i<n; i++){
        std::cout << *(p + i);
    }
    */
    std::cout<<'\n';
    std::cout << *(p + n/2) - *(p + n/2-1);
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int n, a, b;
    cin >> n;
    a = n / 100; b = n % 100;
    if (a >= 1 && a <= 12) {
        if (b >= 1 && b <= 12) cout << "AMBIGUOUS";
        else cout << "MMYY";
    } else {
        if (b >= 1 && b <= 12) cout << "YYMM";
        else cout << "NA";
    }
}


Measured memory_bytes: 256
import java.util.Scanner;

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

        String[] in = new String[3];

        for (int i = 0; i < 3; i++) {
            in[i] = sc.next();
        }

        sc.close();

        System.out.println(in[0].substring(0, 1) + in[1].substring(1, 2) + in[2].substring(2));
    }
}

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

int main() {
  int N;
  cin >> N;
  vector<string> vecs(N);
  string s;
  for (int i = 0; i < N; i++) {
    cin >> s;
    vecs.at(i) = s;
  }
  
  int M;
  cin >> M;
  vector<string> vect(M);
  string t;
  for (int j = 0; j < M; j++) {
    cin >> t;
    vect.at(j) = t;
  }
  
  vector<int> vec = {0};
  int c = 0;
  int counts = 0;
  int countt = 0;
  
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      if (vecs.at(i) == vecs.at(j)) 
        counts++;
      }
    for (int k = 0; k < M; k++) {
      if (vecs.at(i) == vect.at(k))
        countt++;
      }
    if (counts > countt) {
      c = counts - countt;
      vec.push_back(c);
    }
    else if (counts <= countt) {
      vec.push_back(0);
    }
    counts = 0;
    countt = 0;
  }
  int Ans = 0;
  for (int i = 0; i < N + 1; i++) {
    if (vec.at(i) > Ans)
      Ans = vec.at(i);
  }
  if (Ans > 0)
    cout << Ans << endl;
  else if (Ans <= 0)
    cout << 0 << endl;
}


Measured memory_bytes: 3584
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);

	while(true){
		int X=in(),Y=in();
		if(!X && !Y) break;
		vector<vector<int>> V(Y,vector<int>(X)),dp(Y,vector<int>(X,0));
		REP(i,Y){
			REP(j,X){
				V[i][j]=in();
			}
		}
		REP(i,X){
			if(V[0][i]==0) dp[0][i]=1;
		}
		REP(i,Y-1){
			REP(j,X){
				if(V[i][j]==0){
					if(j>0 && V[i+1][j-1]==0) dp[i+1][j-1]+=dp[i][j];
					if(V[i+1][j]!=1) dp[i+1][j]+=dp[i][j];
					if(j<X-1 && V[i+1][j+1]==0) dp[i+1][j+1]+=dp[i][j];
				}
				else if(V[i][j]==2){
					if(i+2<Y){
						if(V[i+2][j]!=1) dp[i+2][j]+=dp[i][j];
					}
					else dp[Y-1][j]+=dp[i][j];
				}
			}
		}
		out(accumulate(ALL(dp[Y-1]),0));
	}

	return 0;
}



Measured memory_bytes: 3196
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);(i)++)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
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; }
inline void init() { cout.tie(nullptr); cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }

int main() {
    init();

    int n; ll W;
    cin >> n >> W;
    VI w(n);
    vector<deque<int>> v(4);
    int V;
    FOR(i, 0, n) {
        cin >> w[i] >> V;
        v[w[i] - w[0]].push_back(V);
    }
    FOR(i, 0, 4) {
        rSORT(v[i], [](int x, int y) {return x > y; });
        FOR(j, 1, v[i].size())v[i][j] += v[i][j - 1];
        v[i].push_front(0);
    }

    int ans = 0;
    FOR(a, 0, v[0].size())FOR(b, 0, v[1].size())FOR(c, 0, v[2].size())FOR(d, 0, v[3].size()) {
        ll cost = 0;
        ll s[4] = { a,b,c,d };
        FOR(i, 0, 4)cost += s[i] * (w[0] + i);
        if (cost > W)continue;
        chmax(ans, v[0][a] + v[1][b] + v[2][c] + v[3][d]);
    }
    cout << ans << "\n";
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n,a,b;
  cin >> n >> a >> b;
  int cnt1=0,cnt2=0,cnt3=0;
  for(int i=0;i<n;i++){
    int m;
    cin >> m;
    if(m<=a)cnt1++;
    else if(a<m && m<=b)cnt2++;
    else if(b<m)cnt3++;
  }
  cout << min(cnt1,min(cnt2,cnt3)) << endl;
}


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

int SumOfDigits(int x) {
  int sum = 0;
  while (x > 0) {
    sum += x % 10;
    x /= 10;
  }
  return sum;
}

void PrintMap(std::map<int, int>& m) {
  for (auto iter: m) {
    std::cout << iter.first << " => " << iter.second << "\n";
  }
}

int Digits(int x) {
  int d = 0;
  while (x > 0) {
    x /= 10;
    d++;
  }
  return d;
}

signed main() {
  int a, b, c, d, e, f;
  std::cin >> a >> b >> c >> d >> e >> f;
  
  /*
  std::cout << f / (100 * a) + 1 << '\n';
  std::cout << f / (100 * b) + 1 << '\n';
  std::cout << f / c + 1 << '\n';
  std::cout << f / d + 1 << '\n';
  */
  
  int maxw, maxs, max, con;
  for (int i = 0; i < f / (100 * a) + 1; i++) {
    for (int j = 0; j < f / (100 * b) + 1; j++) {
      for (int k = 0; k < f / c + 1; k++) {
        for (int l = 0; l < f / d + 1; l++) {
          if (i == 0 && j == 0 && k == 0 && l == 0) {
            max = 0; maxw = 0; maxs = 0;
            continue;
          }
          int s = k * c + l * d;
          int w = i * (100*a) + j * (100*b) + s;
          if (s <= (i * a + j * b) * e && w <= f) {
            if (s * maxw >= maxs * w) {
              maxw = w;
              maxs = s;
            }
          }
        }
      }
    }
  }
   
  std::cout << maxw << ' ' << maxs << '\n';
  
  return 0;
}

Measured memory_bytes: 256
n = int(input())
cnt = 0
flag = 0
a = int(n ** 0.5)
if a == n ** 0.5:
    flag = 1
for i in range(1,a + 1):
    for j in range(i, n):
        if i * j < n:
            cnt += 1
        else:
            break
if flag == 1:
    num = (cnt - a + 1) * 2 + a - 1
else:
    num = (cnt - a) * 2 + a
print(num)


Measured memory_bytes: 9448
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<vector>
#include<string>
#include<stack>
#include<array>
#include<queue>
#include<algorithm>
#include<cassert>
#include<functional>
#include<random>
#include<boost/multiprecision/cpp_int.hpp>
#define int int64_t
#define REP(i, a, b) for (int64_t i = (int64_t)(a); i < (int64_t)(b); i++)
#define rep(i, a) REP(i, 0, a)
#define EACH(i, a) for (auto i: a)
#define ITR(x, a) for (auto x = a.begin(); x != a.end(); x++)
#define ALL(a) (a.begin()), (a.end())
#define HAS(a, x) (a.find(x) != a.end())
using namespace std;
using namespace boost;



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

	int N, K;
	cin >> N >> K;
	vector<vector<int>>tree(N);
	rep(i, N - 1) {
		int A, B;
		cin >> A >> B;
		A--; B--;
		tree[A].push_back(B);
		tree[B].push_back(A);
	}

	int answer = N;

	if (K % 2 == 0) {
		//各頂点を根として深さ優先探索して、
		//その頂点を切らない場合に切る必要のある頂点数の最小値を求める。
		rep(i, N) {
			vector<int>searched(N);
			priority_queue<pair<int, int>>bfs;
			searched[i] = 1;
			bfs.push(make_pair(0, i));
			int inner = 0;
			while (bfs.size()) {
				auto a = bfs.top();
				bfs.pop();
				if (K / 2 < -a.first)break;
				inner++;
				searched[a.second] = 1;
				EACH(j, tree[a.second])if (searched[j] == 0) {
					bfs.push(make_pair(-(-a.first + 1), j));
				}
			}
			answer = min(answer, N - inner);
		}
	}
	else {
		rep(i, N)EACH(j,tree[i])if(i < j) {
			vector<int>searched1(N);
			vector<int>searched2(N);

			priority_queue<pair<int, int>>bfs1;
			searched1[i] = 1;
			bfs1.push(make_pair(0, i));
			while (bfs1.size()) {
				auto a = bfs1.top();
				bfs1.pop();
				if (K / 2 < -a.first)break;
				searched1[a.second] = 1;
				EACH(k, tree[a.second])if (searched1[k] == 0) {
					bfs1.push(make_pair(-(-a.first + 1), k));
				}
			}

			priority_queue<pair<int, int>>bfs2;
			searched2[j] = 1;
			bfs2.push(make_pair(0, j));
			while (bfs2.size()) {
				auto a = bfs2.top();
				bfs2.pop();
				if (K / 2 < -a.first)break;
				searched2[a.second] = 1;
				EACH(k, tree[a.second])if (searched2[k] == 0) {
					bfs2.push(make_pair(-(-a.first + 1), k));
				}
			}

			int inner = 0;
			rep(k, N)if (searched1[k] == 1 || searched2[k] == 1)inner++;
			answer = min(answer, N - inner);
		}
	}
	cout << answer << endl;
}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);

    String s = sc.next();
    long tmp = 0;

    for (int i = 0; i < s.length(); i++) {
      tmp += Character.getNumericValue(s.charAt(i));
    }

    if ((tmp % 9) == 0) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 40576
# -*- coding: utf-8 -*-

a,b,c,d = map(int, input().split())

if abs(c-a) < d or abs(c-a) == d:
    print("Yes")
elif abs(b-a) < d or abs(b-a) == d:
    if abs(c-b) < d or abs(c-b) == d:
        print("Yes")
    else:
        print("No")
else:
    print("No")

Measured memory_bytes: 3060
S = input()
T = input()
cnt = 0
for i in range(len(S)):
  if cnt > 30:
    break
  if S[i] != T[i]:
    X = S[i]
    S = S.replace(S[i],"X")
    if T[i] in S:
      S = S.replace(T[i],X)
    S = S.replace("X",T[i])
    cnt += 1
print("Yes" if S == T else "No")

Measured memory_bytes: 3632
#include<iostream>
#include<algorithm>

using namespace std;
#define INF (1 << 30)
int dp[21600];
int p[21600];
int m, n, c, e;

int main(){
	cin >> m >> n;
	for(int i = 0;i < m;i++){
		cin >> p[i];
	}
	sort(p, p + m, greater<int>() );
	for(int i = 1;i < m;i++)p[i] += p[i-1];
	fill(dp, dp + 21600, INF);
	dp[0] = 0;
	for(int i = 0;i < n;i++){
		cin >> c >> e;
		for(int j = 21000;j - c >= 0;j--){
			dp[j] = min(dp[j], dp[j - c] + e);
		}
	}
	for(int i = 21000;i >= 0;i--){
		dp[i] = min(dp[i+1], dp[i]);
	}
	int res = 0;
	for(int i = 0;i < m;i++){
		res = max(res, p[i] - dp[i+1]);
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 1304
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
 
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using vpii = vector<pii>;
using vs = vector<string>;
using vd = vector<double>;
using ul = unsigned long;
 
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }
 
const int mod=1e9+7;
 
struct mint {
  ll x;
  mint(ll x=0):x(x%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
};
 
mint c[4005][4005];
void init() {
  c[0][0] = 1;
  for (int i = 0; i <= 4000; i++) {
    for (int j = 0; j <= i; j++) {
      c[i+1][j] += c[i][j];
      c[i+1][j+1] += c[i][j];
    }
  }
}
mint comb(int n, int k) {
  return c[n][k];
}
 
bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;
 
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
 
    return true;
}
 
map<ll, ll> primeFact(ll n) {
  map<ll, ll> res;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      res[i]++;
      n /= i;
    }
  }
  if (n != 1) res[n]++;
  return res;
}
 
void printv(vi& v){
  rep(i,v.size()) cout << v[i] << " ";
  cout << endl;
}
void printv(vll& v){
  rep(i,v.size()) cout << v[i] << " ";
  cout << endl;
}
int vtotal(vi& v){
  int total=0;
  rep(i,v.size()) total+=v[i];
  return total;
}
 
int main()
{
  //init(); // mint初期化
  cin.tie( 0 );
  ios::sync_with_stdio( false );
 
  int n,k;
  cin>>n>>k;
  int ans=1;
  if(n%k==0)ans=0;
  cout(ans);
  return 0;
}

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

int main(){
	string s;
	int cnt = 0;

	while(cin >> s){
		if(s.length() == 1){
			cnt++;
			continue;
		}

		int center = s.length()/2;

		if(s.length() % 2 == 1){
			cnt++;

			for(int i = 0, j = s.length()-1; i < center, j > center; i++, j--){
				if(s[i] != s[j]){
					cnt--;
					break;
				}
			}
		}
		else if(s.length() % 2 == 0){
			cnt++;
			for(int i = 0, j = s.length()-1; i < center, j >= center; i++, j--){
				if(s[i] != s[j]){
					cnt--;
					break;
				}
			}
		}
	}
	cout << cnt << endl;
}

Measured memory_bytes: 1184
#define _USE_MATH_DEFINES
#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
#pragma endregion //#include
/////////

#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9+7;
const LL LINF = (LL)4e18+20;
const LD PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;

void solve(){
	int N;
	cin>>N;
	vector<pair<int,int> > A(N);
	for(int i=0;i<N;++i){
		cin>>A[i].first;
		A[i].second = i;
	}
	int ter = N/2;
	sort(A.begin(),A.end());
	vector<int> ans(N);
	for(int i=0;i<N;++i){
		if( i<ter ){
			ans[ A[i].second ] = A[ter].first;
		}else{
			ans[ A[i].second ] = A[ter-1].first;
		}
	}
	for(int i=0;i<N;++i){
		cout << ans[i] << endl;
	}
}

#pragma region main
signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}
#pragma endregion //main()


Measured memory_bytes: 4608
#include<bits/stdc++.h>
#include<algorithm>
#include<string>
#include <stdlib.h>
using namespace std;
#define         rep(i,n)       for (int i = 0;i<(int)(n);i++)
#define         rep1(i,n)      for (int i = 1;i<=(int)(n);i++)
#define         sajo(str)      sort(str.begin(),str.end())
#define         rsajo(str)     reverse(str.begin(),str.end())
#define         pi             3.14159265359
#define         neli            printf("\n")
#define         gcd(a,b)       __gcd(a,b)
#define         lcm(a,b)       (a/gcd(a,b))*b
#define         yes            cout<<"Yes"<<"\n"
#define         no             cout<<"No"<<"\n"
#define         pf             printf
#define         sf             scanf
#define         pb             push_back
#define         pbk            pop_back
#define         Faysal         ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int N = 2e5+5;
typedef long long int         lli;
typedef long long             ll;
typedef unsigned long long    ull;
typedef double                db;
typedef long double           ldb;

int pos(int arr[], int n, int x)
{
    for (int i = 0; i < n; i++)
        if (arr[i] == x)
            return i+1;
}

int fact(int n)
{
   if(n==0)
      return(1);

   return(n*fact(n-1));
}

int main()
{
    Faysal;
    lli x,y,ans=0,q,n,cnt=0;
    string s,t;

    cin>>s;
    t[0]=s[0]+1;
    cout<<t[0]<<endl;

    return 0;

}


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

int main() {
    int N;
    cin >> N;
    int l[N], r[N];
    for(int i = 0; i < N; ++i) cin >> l[i] >> r[i];
    
    int counter;
    for(int i = 0; i < N; ++i){
        counter += r[i] - l[i] + 1;
    }
    cout << counter << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)
#define REP1(i,n) for(int i=1;i<=n;++i)
#define ALL(c) (c).begin(),(c).end()
typedef long long ll;
vector<int> d[10],a;
void init(){
	d[0].push_back(0);
	d[1].push_back(1);
	d[2].push_back(2);
	d[2].push_back(4);
	d[2].push_back(8);
	d[2].push_back(6);
	d[3].push_back(3);
	d[3].push_back(9);
	d[3].push_back(7);
	d[3].push_back(1);
	d[4].push_back(4);
	d[4].push_back(6);
	d[5].push_back(5);
	d[6].push_back(6);
	d[7].push_back(7);
	d[7].push_back(9);
	d[7].push_back(3);
	d[7].push_back(1);
	d[8].push_back(8);
	d[8].push_back(4);
	d[8].push_back(2);
	d[8].push_back(6);
	d[9].push_back(9);
	d[9].push_back(1);
}
int main(){
	init();
	ll n,m,k,ans=0;
	cin >> n >> m >> k;
	n%=10;
	int dis=d[n].size(),cnt=0;
	do{
		a.push_back(d[n][m*cnt%dis]);
		ans+=d[n][m*cnt%dis];
		cnt++;
	}while(m*cnt%dis!=0);
	ans*=(k/a.size());
	rep(i,k%a.size()) ans+=a[i];
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1216
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <math.h>
#include <list>
#include <stack>
#include <queue>
#include <utility>

using namespace std;

#define ll long long
#define MOD 1000000007
#define rep(i, n) for(int i = 0;i < n;i++)

int main()
{

    int a,b;
    cin >> a >> b;
    if (2*b<a)
    {
        cout << a-2*b << endl;
    }else{
        cout << 0 << endl;
    }
    
}

Measured memory_bytes: 256
import itertools

n = int(input())
ps = list(map(int, input().strip().split()))
qs = list(map(int, input().strip().split()))

perms = itertools.permutations(range(1, n + 1))

for idx, perm in enumerate(perms):
    perm_l = list(perm)
    if ps == perm_l:
        a = idx + 1
    if qs == perm_l:
        b = idx + 1

print(abs(a - b))


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

using namespace std;

#define int long long

const int DIM = 2e5 + 7;

int v[DIM];

main()
{
	int n;
	cin >> n;
	
	int total = 0;
	
	for(int i = 1; i <= n; i++)
	{
		cin >> v[i];
		total ^= v[i];
	}
	
	for(int i = 1; i <= n; i++)
		v[i] = ((v[i] | total) ^ total);
	
	vector <int> bases;
	
	sort(v + 1, v + 1 + n);
	
	for(int i = n; i >= 1; i--)
	{
		for(auto j : bases)
			v[i] = min(v[i], v[i] ^ j);
		
		if(v[i])
			bases.push_back(v[i]);
	}
	
	int s = 0;
	
	for(auto i : bases)
		s = max(s, s ^ i);
	
	cout << 2 * s + total;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define boost_io ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define num(a) a-'0'
#define maxself(a,b) if(b>a)a=b
#define minself(a,b) if(b<a)a=b;
#define debug(x) cout<<#x<<":"<<x<<" "
#define all(a) (a).begin(), (a).end()
#define vi vector<int>
#define vl vector<long long int>
#define pb push_back
#define mk make_pair
#define f first
#define s second
#define ln "\n"
typedef long long int ll;
typedef long double ld;
typedef double d;
using namespace std;
ll modF=1e9+7;
ll INF=1e11;

typedef vector<pair<int,int>> vpi;
vpi points(8);
int n;

ld brute(ld len,int np,vi vis,pair<int,int> pp){
	if(np==n){
		return len;
	}
	else{
		int h=0;
		ld sum=0;
		for(int i=0;i<n;i++){
			if(vis[i]){
				h++;
				ld cl;
				if(pp.f==1001 && pp.s==1001){
					cl=0;
				}
				else{
					cl=sqrt((points[i].f-pp.f)*(points[i].f-pp.f)+(points[i].s-pp.s)*(points[i].s-pp.s));
				}
				vis[i]=0;
				sum+=brute(cl+len,np+1,vis,points[i]);
				vis[i]=1;
			}
		}
		return sum/h;
	}
}

void solve(){
	cin>>n;
	rep(i,0,n){
		int x,y;
		cin>>x>>y;
		points[i]=mk(x,y);
	}
	vi vis(n,1);
	cout<<brute(0,0,vis,mk(1001,1001))<<ln;
}

int main(){
	boost_io;
	cout<<fixed;
	cout<<setprecision(9);
	solve();
	return 0;
}

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

int main(){
    int w,h,n;
    int x,y,a;
    cin >> w >> h >> n;
    vector<vector<int>> plane(h,vector<int>(w,0));
    for(int i=0; i<n; i++){
        cin >> x >> y >> a;
        int xs,ys,xe,ye;
        if(a == 1){
            xe = x; xs = 0;
            ye = h; ys = 0;
        }else if(a == 2){
            xs = x; xe = w;
            ys = 0; ye = h;
        }else if(a == 3){
            xs = 0; xe = w;
            ys = 0; ye = y;
        }else if(a == 4){
            xs = 0; xe = w;
            ys = y; ye = h;
        }
        for(int j=ys; j<ye; j++){
            for(int k=xs; k<xe; k++){
                plane[j][k]++;
            }
        }
    }
    int sum = 0;
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            if(plane[i][j] == 0){
                sum++;
            }
        }
    }
    cout << sum << endl;
}

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

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

  for(int i=0; i<a; i++) {
    s.pop_back();
    if(s.size() % 2 == 0) {
      int A = s.size() / 2;
      string Q = s.substr(0, A);
      string E = s.substr(A, A);
      if(Q == E) {
        cout << s.size() << endl;
        return 0;
      }
    }
  }
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
// Welcome to my source code!

int main() {
    int n;
    cin >> n;
    int digits[10][10] = {};
    for (int i = 1; i <= n; i++) {
        int t = i, cnt = 1;
        while (t / 10) t /= 10, cnt++;
        if (cnt == 1) digits[t][t]++;
        else digits[t][i%10]++;
    }
    ll ans = 0;
    for (int i = 1; i < 10; i++)for (int j = 1; j < 10; j++) {
        ans += digits[i][j] * digits[j][i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
// 標準入力からデータを読み込む準備
try (Scanner sc = new Scanner(System.in)) {
int w = sc.nextInt();
int n = sc.nextInt();
int[] values = new int[w];
for (int i = 0; i < values.length; i++) {
values[i] = i + 1;
}
for (int i = 0; i < n; i++) {
String str = sc.next();
String[] ab = str.split(",");
int a = Integer.parseInt(ab[0]) - 1;
int b = Integer.parseInt(ab[1]) - 1;
int c=values[a];
values[a]=values[b];
values[b]=c;
}
for(int i=0;i<values.length;i++)System.out.println(values[i]);
}
}
}


Measured memory_bytes: 25996
import java.util.*;
import java.lang.*;
import java.io.*;
class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		// your code goes here
		for(int i=1;i<=9;i++)
		{
			for(int j=1;j<=9;j++)
			{
				System.out.printf("%dx%d=%d\n",i,j,i*j);
			}
		}
	}
}

Measured memory_bytes: 17948
#include <iostream>

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

    int b2 = b;
    int c2 = c;
    int clear = 0;
    for(int i = 0; i <= k; i++){
        for(int j = 0; j < i; j++){
            b2 = b2 * 2;
        }
        for(int l = 0; l < (k - i); l++){
            c2 = c2 * 2;
        }
        if(b2 > a && c2 > b2){
            clear = 1;
        }
        //std::cout << a << " " << b2 << " " << c2 << std::endl;
        //std::cout << clear << std::endl;
        b2 = b;
        c2 = c;
    }
    if(clear == 0){
        std::cout << "No" << std::endl;
    }
    else if(clear == 1){
        std::cout << "Yes" << std::endl;
    }
    
}

Measured memory_bytes: 3628
#include <stdio.h>

int main (void){
	
	/*?????°?????£?¨???¨?????????*/

	int n = 0 ;
	int m = 0 ;	
	
	int i = 0 ;
	int j = 0 ;
	int sum = 0 ;
	
	scanf("%d" ,&n);
	scanf("%d" ,&m);
	
	int A[n][m] ;			//A???n???m????????????
	int b[m] ;				//b???m??????????????????
	
	/*??????A??????????????????*/
	for( i = 0 ; i < n ; i++){
		for( j = 0 ; j < m ; j++){
			scanf("%d", &A[i][j]);
		}
	}
	
	/*????????????b???????????????*/
	
	for( j = 0 ; j < m ; j++){
		scanf("%d", &b[j]);
	}
	
	/*c???????´?????¨??????¨??????*/
	
	for( i = 0 ; i < n ; i++){
		for( j = 0 ; j < m ; j++){
			sum += A[i][j] * b[j];
		}

		printf("%d\n" ,sum);
		sum = 0 ;			//sum????????????
	}
	
	return 0;
}

Measured memory_bytes: 640
#if !defined(__clang__) && defined(__GNUC__)
#include <bits/stdc++.h>
#else
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#endif //  !defined(__clang__) && defined(__GNUG__)
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/math/common_factor_rt.hpp>

using namespace std;

int main()
{
    int64_t N;
    std::cin >> N;

    int64_t odd = 0;
    int64_t even = 0;
    std::vector<int64_t> A;
    for (decltype(N) i = 0; i < N; ++i) {
        int64_t t;
        std::cin >> t;

        if (t & 1) {
            odd++;
        }
        else {
            even++;
        }
    }

    if (odd & 1) {
        // 奇数が残る
        std::cout << "NO" << std::endl;
    }
    else {
        std::cout << "YES" << std::endl;
    }

    return 0;
}


Measured memory_bytes: 256
#! /usr/bin/env python3

import math

d, g = map(int, input().split())

p = []
c = []
done = [False for _ in range(d)]
avg = {}

for i in range(d):
    tp, tc = map(int, input().split())
    p.append(tp)
    c.append(tc)


res = 100000000

for i in range(1<<(d)):
    cnt = 0
    val = 0
    enabled = []
    for j in range(d):
        if i & (1 << (j)) > 0:
            enabled.append(j)
    enabled.reverse()

    for j in enabled:
        if val >= g:
            break
        cnt += p[j]
        val += (j + 1) * 100 * p[j] + c[j]
    
    for j in range(d):
        if val >= g:
            break
        idx = d - 1 - j
        if idx in enabled: continue
        if val + (idx + 1) * 100 * p[idx] < g:
            continue
        tmp = math.ceil((g - val) // ((idx + 1) * 100))
        cnt += tmp
        val += tmp * (idx + 1) * 100

    if val < g:
        cnt = 100000000
    if cnt < res:
        res = cnt

print(res)


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

#define rep(i,n) for(int i = 0; i < n; i++)
#define Rep(i,n) for(int i = 1; i <= n; i++)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
template<class T> using V = vector<T>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
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; }



int main(){
    
    int d, t, s;
    cin >> d >> t >> s;
    YesorNo(d <= t*s);
}

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

#define FAST {ios::sync_with_stdio(false); cin.tie(NULL);}
#define pb push_back
#define fi first
#define se second
#define ll long long int
#define f(i,a,b) for(int i=a;i<b;i++)
#define mod 1000000007


int main(){
	FAST

	int n;
	cin>>n;

	vector<vector<double>> dp(n+1,vector<double>(n+1,0.0));

	dp[0][0] = 1.000;

	for(int i=1;i<=n;i++){
		double ph;
		cin>>ph;
		for(int j=0;j<=i;j++){
			if(j == 0){
				dp[i][j] = dp[i-1][j] * (1.0 - ph);
			}
			else
				dp[i][j] = dp[i-1][j] * (1.0 - ph) + dp[i-1][j-1] * ph;
		}
	}

	double ans = 0.0;
	for(int i=0;i<=n;i++){
		if(i > (n-i)){
			ans += dp[n][i];
		}
	}
	cout<<fixed<<setprecision(10)<<ans<<endl;
	return 0;
}


Measured memory_bytes: 73676