akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
int head[8192],last[16384],to[16384],cnt=0;
void add(int u,int v)
{
	cnt++;
	last[cnt]=head[u];
	head[u]=cnt;
	to[cnt]=v;
}
int num[8192];
int size[8192],dp[5005][5005];
int tmp[8192];
void dfs(int u,int f)
{
	size[u]=1;
	dp[u][1]=1;
	for(int i=head[u];i;i=last[i])
	{
		int v=to[i];
		if(v==f)
		{
			continue;
		}
		dfs(v,u);
		for(int j=0;j<=size[u]+size[v];j++)
		{
			tmp[j]=0;
		}
		for(int j=0;j<=size[u];j++)
		{
			for(int k=0;k<=size[v];k++)
			{
				tmp[j+k]+=(long long)dp[u][j]*dp[v][k]%1000000007;
				if(tmp[j+k]>=1000000007)
				{
					tmp[j+k]-=1000000007;
				}
			}
		}
		for(int j=0;j<=size[u]+size[v];j++)
		{
			dp[u][j]=tmp[j];
		}
		size[u]+=size[v];
	}
	for(int i=1;i<=size[u];i++)
	{
		dp[u][0]-=(long long)dp[u][i]*num[i]%1000000007;
		if(dp[u][0]<0)
		{
			dp[u][0]+=1000000007;
		}
	}
}
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=1;i<n;i++)
	{
		int u,v;
		scanf("%d%d",&u,&v);
		add(u,v);
		add(v,u);
	}
	num[0]=1;
	for(int i=2;i<=n;i+=2)
	{
		num[i]=(long long)num[i-2]*(i-1)%1000000007;
	}
	dfs(1,0);
	int ans=-dp[1][0];
	if(ans<0)
	{
		ans+=1000000007;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 97152
N=gets.to_i
tl=tr=bl=br=nil
N.times{
    x,y=gets.split.map(&:to_i)
    if !tr||x+y>tr
        tr=x+y
    end
    if !br||x-y>br
        br=x-y
    end
    if !tl||-x+y>tl
        tl=-x+y
    end
    if !bl||-x-y>bl
        bl=-x-y
    end
}
#warn [tl,tr,bl,br].inspect
puts [(tr+bl).abs,(tl+br).abs].max


Measured memory_bytes: 14268
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>

using namespace std;

#define INF 100100100

int cost[10][10];
int d[10];
bool used[10];
int V = 10;

void dijkstra(int s)
{
    fill(d, d + V, INF);
    fill(used, used + V, false);
    d[s] = 0;
    while (true)
    {
        int v = -1;
        for (int u = 0; u < V; u++)
        {
            if (!used[u] && (v == -1 || d[u] < d[v]))
            {
                v = u;
            }
        }
        if (v == -1)
        {
            break;
        }
        used[v] = true;
        for (int u = 0; u < V; u++)
        {
            d[u] = min(d[u], d[v] + cost[u][v]);
        }
    }
}

int main()
{
    int H, W;

    cin >> H >> W;

    for (int i = 0; i <= 9; i++)
    {
        for (int j = 0; j <= 9; j++)
        {
            cin >> cost[i][j];
        }
    }

    dijkstra(1);

    int sum = 0;
    for (int i = 0; i < H; i++)
    {
        for (int j = 0; j < W; j++)
        {
            int a;
            cin >> a;
            if (a == 1 || a == -1)
            {
                continue;
            }
            sum += d[a];
        }
    }

    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(),(x).end())
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < n; i++)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define repr(i, m, n) for(int i = m; i >= n; i--)
#define db(x) cout<<#x<<"="<<x<<endl
template<class T>bool maxi(T &a,const T &b){if(a<b){ a=b; return 1;} return 0;}
template<class T>bool mini(T &a,const T &b){if(b<a){ a=b; return 1;} return 0;}
#define y0 y3487465 //y1 j0 j1
#define INF2 4000000000000000037
#define INF 1000000007
#define PI (acos(-1))
#define MOD 1000000007
#define EPS 1e(-9);
using namespace std;
typedef long long ll;

bool cmp(vector<int> &a, vector<int> &b, int asize, int bsize)
{
    if(asize!=bsize) return asize<bsize;
    repr(i,9,0){
        if(a[i]!=b[i]) return a[i]<b[i];
    }
    return false;
}

void Main(){

    // 1 2hon 7 3hon 4 4hon 5 5hon 9 6hon 8 7hon

    // [nhon]=dp最大の整数

    vector<int> cost={0,2,5,5,4,5,6,3,7,6}; //使うマッチ

    int N,M; cin>>N>>M;

    int A[M];
    rep(i,M){
        cin>>A[i]; //使える数字
    }

    vector<int> dp[N+100];
    int num[N+100];
    rep(i,N+100){
        dp[i]={0,0,0,0,0,0,0,0,0,0};
        num[i]=0;
    }

    rep(i,N){
        rep(j,M){
            if(num[i]==0 and i!=0) continue;
            vector<int> buff=dp[i];
            ++buff[A[j]];
            if(cmp(dp[i+cost[A[j]]], buff, num[i+cost[A[j]]], num[i]+1)){
                dp[i+cost[A[j]]]=buff;
                num[i+cost[A[j]]]=num[i]+1;
            }
        }
    }
    repr(i,9,0){
        rep(j,dp[N][i]){
            cout<<i;
        }
    }
    cout<<"\n";

}

//-----------------------------------
int main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}
//-----------------------------------


Measured memory_bytes: 1024
import bisect
n=int(input())
L=list(map(int,input().split()))

L.sort()
cnt=0
for i in range(n-2):
    for j in range(i+1,n-1):
        if L[i]+L[j]<=L[j+1]:
            continue
        if L[i]+L[j]>L[n-1]:
            cnt+=n-j-1
            continue
        index=bisect.bisect_left(L,L[i]+L[j])
        cnt+=index-j-1
print(cnt)

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

ll mod = 1e9 + 7;

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

  ll n, m;
  cin >> n >> m;

  ll a[m];
  REP(i, m) cin >> a[i];

  if(m <= n){
    cout << 0 << endl;
    return 0;
  }

  SORT(a, m);
  ll b[m - 1];

  REP(i, m - 1){
    b[i] = a[i + 1] - a[i];
  }

  SORT(b, m - 1);

  ll ans = 0;

  REP(i, m - n) ans += b[i];
  cout << ans << endl;

  return 0;
}


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


def solve(N: int, A: int, B: int):
    if A > B:
        tmp = A
        A = B
        B = tmp
    
    count = 0
    while True:
        if (B - A) % 2 == 0:
            count += (B - A) // 2
            break
        elif A != 1 and B != N:
            if A-1 < N-B:
                count += A-1
                B = B - (A-1)
                A = 1


            else:
                count += N-B
                A = A + (N-B)
                B = N
        else:
            if A == 1:
                count += 1
                B -= 1
                
            elif B == N:
                count += 1
                A += 1
    print(count)
    return


# Generated by 1.1.7.1 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
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(N, A, B)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
void main() {
    string s = readln.chomp;
    int price = 700;
    foreach (x; s) {
        if (x == 'o') price += 100;
    }
    price.writeln;
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.ascii;
import std.uni;

Measured memory_bytes: 256
#![allow(unused_imports, unused_macros, dead_code)]

macro_rules! min {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| min!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = min!($($ys),*);
        if $x < t { $x } else { t }
    }}
}
macro_rules! max {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| max!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = max!($($ys),*);
        if $x > t { $x } else { t }
    }}
}
macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! flush {
    () => {
        std::io::stdout().flush().unwrap();
    };
}
macro_rules! put {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(x) = it.next() { print!("{}", x); }
        for x in it { print!(" {}", x); }
        println!("");
    }};
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

const M: i64 = 1_000_000_007;

fn main() {
    let mut sc = Scanner::new();
    let n: usize = sc.cin();
    let xs: Vec<i64> = sc.vec(n);

    let mut zs: Vec<i64> = vec![0; n + 2];
    for i in 0..n {
        zs[i + 1] = xs[i];
    }

    let mut d = 0;
    for i in 0..n + 1 {
        d += (zs[i + 1] - zs[i]).abs();
    }

    for i in 0..n {
        put!(
            d - (zs[i] - zs[i + 1]).abs() - (zs[i + 2] - zs[i + 1]).abs()
                + (zs[i + 2] - zs[i]).abs()
        );
    }
}

use std::collections::VecDeque;
use std::io::{self, Write};
use std::str::FromStr;

struct Scanner {
    stdin: io::Stdin,
    buffer: VecDeque<String>,
}
impl Scanner {
    fn new() -> Self {
        Scanner {
            stdin: io::stdin(),
            buffer: VecDeque::new(),
        }
    }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.is_empty() {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> {
        self.cin::<String>().chars().collect()
    }
    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.cin()).collect()
    }
}


Measured memory_bytes: 11508
// #pragma GCC target("avx2")
#pragma GCC optimize("O3", "unroll-loops")

// #include <bits/extc++.h>
// using namespace __gnu_pbds;

#include <bits/stdc++.h>
using namespace std;

#define int long long
#define double long double
// template <typename T>
// using pbds_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
using pii = pair<int, int>;
template<typename T>
using prior = priority_queue<T, vector<T>, greater<T>>;
template<typename T>
using Prior = priority_queue<T>;

#define X first
#define Y second
#define ALL(x) (x).begin(), (x).end()
#define eb emplace_back
#define pb push_back

#define fastIO() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define RANDOM() random_device __rd; \
                 mt19937 __gen = mt19937(__rd()); \
                 uniform_int_distribution<int> __dis(1, 1E8); \
                 auto rnd = bind(__dis, __gen)

const int INF = 1E18;
const int mod = 1E9 + 7;

int32_t main() {
    fastIO();
    
    int n;
    cin >> n;
    
    vector<int> v(n);
    for (auto &x : v) cin >> x;
    
    vector<int> dp(n);
    dp[1] = abs(v[1] - v[0]);
    for (int i = 2; i < n; ++i) {
        dp[i] = min(dp[i-1] + abs(v[i] - v[i-1]), dp[i-2] + abs(v[i] - v[i-2]));
    }
    
    cout << dp[n - 1] << "\n";
    
    return 0;
}

Measured memory_bytes: 4744
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n)for(int i=0;i<(int)(n);i++)
#define PI 3.141592653589793
//vector < vector<int>>a(0, vector<int>(0));二次元配列宣言


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

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

void fast(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);  cout.tie(0);
}

int main() {
    fast();
    ll n,k;  cin >>n >>k;
    ll arr[n];
    for(ll i=0;i<n;i++){
        cin >>arr[i];
    }
    ll dp[n];
    dp[0]=0;
    dp[1] = abs(arr[1]-arr[0]);
    
    for(ll i=2;i<n;i++){
        ll j=max(i-k,1LL*0);
        ll possibleAns = 1e15;
        while(j<i){
            possibleAns = min(possibleAns, dp[j]+abs(arr[j]-arr[i]));
            j++;
        }
        dp[i] = possibleAns;
    }
    
    cout<<dp[n-1];
    
    return 0;
}


Measured memory_bytes: 5216
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
#define fr(i,a,b) for(ll i=a; i<b; i++)
#define rf(i,a,b) for(ll i=a; i>=b; i--)
#define pb push_back
#define mp make_pair
#define show(a) for(auto el:a)cout<<el<<" "
#define ff first
#define ss second
#define ppair vector<pair<ll,ll>>
#define vec vector <ll> 
#define all(a) a.begin(),a.end()
#define mo 1000000007

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll test;
    ll x,a;
    cin>>x>>a;
    if(x<a)
    cout<<"0";
    else
    cout<<"10";
    
     return 0;
}

Measured memory_bytes: 3616
N=int(input())
cnt_AC,cnt_WA,cnt_TLE,cnt_RE=0,0,0,0
ans=[cnt_AC,cnt_WA,cnt_TLE,cnt_RE]
result_list=["AC","WA","TLE","RE"]
for i in range(N):
    result=input()
    if result=="AC":
        ans[0]+=1
    elif result=="WA":
        ans[1]+=1
    elif result=="TLE":
        ans[2]+=1
    elif result=="RE":
        ans[3]+=1
for i in range(4):
    print(result_list[i]+" x "+str(ans[i]))

Measured memory_bytes: 9244
def dfs(i):
    global t
    t += 1
    D[i] = t
    for e in es[i]:
        if D[e] == 0:
            dfs(e)
    t += 1
    F[i] = t


if __name__ == "__main__":
    N = int(input())
    es = [[] for _ in range(N+1)]
    for _ in range(N):
        ipts = [int(ipt) for ipt in input().split()]
        if ipts[1] > 0:
            es[ipts[0]] = ipts[2:]
    D = [0 for _ in range(N+1)]
    F = [0 for _ in range(N+1)]
    t = 0
    for i in range(1, N+1):
        if D[i] == 0:
            dfs(i)
    for i in range(1, N+1):
        print(i, D[i], F[i])


Measured memory_bytes: 5664
N = int(input())
a = list(map(int,input().split()))

b = [[a[i],i] for i in range(N)]
b.sort(key=lambda x:x[0],reverse=True)

lr = [[0,0] for i in range(N)]
ans = 0
for i in range(N):
    ans+=b[i][0]*(lr[b[i][1]][1]+1)*(lr[b[i][1]][0]+1)
    if b[i][1]+lr[b[i][1]][1]+1<N:
        lr[b[i][1]+lr[b[i][1]][1]+1][0] = lr[b[i][1]][0]+lr[b[i][1]][1]+1
    if b[i][1]-lr[b[i][1]][0]-1>-1:
        lr[b[i][1]-lr[b[i][1]][0]-1][1] = lr[b[i][1]][0]+lr[b[i][1]][1]+1


print(ans)

Measured memory_bytes: 123472
#include <iostream>

using namespace std;

int main()
{
	int k, x;
	cin >> k >> x;
	
	cout << x - k + 1 ;
	for(int i = x - k + 2; i <= x + k - 1; ++i)
	{
		cout << " " << i;
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 256
l = input()
col = l.split(' ')
a = int(col[0])
op = col[1]
b = int(col[2])

if 1 <= a <= 10 ** 9 and 1 <= b <= 10 ** 9:
  if op == '+':
    print(a + b)
  elif op == '-':
    print(a - b)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
int main(void){
    string s;
    cin>>s;
    std::deque<char> deq;
    for (int i=0;i<s.size();i++) {
        deq.emplace_back(s.at(i));
    }
    auto itr=find(deq.begin(),deq.end(),'*');
    int dis=distance(deq.begin(),itr);
    int left=dis;
    int right=dis;
    int count=0;
    while (left>0) {
        left--;
        if (deq[left]=='(') {
            int flag=0;
            while (right<s.size()) {
                right++;
                if (deq[right]==')'&&flag==0) {
                    count++;
                    break;
                } else if (deq[right]=='(') {
                    flag++;
                } else if (deq[right]==')'&&flag!=0) {
                    flag--;
                }
            }
        }
    }
    cout<<count<<endl;
}



Measured memory_bytes: 3208
# Bi >= max(Ai, A(i+1))
# sum(A)を最大にしたときの値

# Aの要素は可能な限り大きくしたい
# A1の最大値はB1, Aiの最大値はBiとB(i-1)の小さい方

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

a = []  # B[0] = B1, B[N-2] = B(N-1)
for i in range(N-2):
    a.append(min(B[i], B[i+1]))

print(sum(a)+B[0]+B[N-2])


Measured memory_bytes: 2940
#include<iostream>
#include<vector>
#include<string>
#include<set>
using namespace std;

int main() {
	int a;
	cin >> a;
	set<string>b;
	for (int c = 0; c < a; c++) {
		string d, e;
		cin >> d >> e;
		if (d == "insert")b.insert(e);
		else {
			if (b.find(e) == b.end())cout << "no" << endl;
			else cout << "yes" << endl;
		}
	}
}

Measured memory_bytes: 32084
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<string>
#include<stack>
#include<cstdio>
#include<cmath>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<ll,P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
#define mp1(a,b,c) P1(a,P(b,c))

const int INF=1000000000;
const int dir_4[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
const int dir_8[8][2]={{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};

const ll M = 1000000007;

int main(){
	int n;
	char c[202];
	scanf("%d",&n);
	rep(i,n){
		scanf("\n%c",&c[i]);
	}
	
	vector<int> U,D;
	rep(i,n){
		if(c[i] == 'U')U.pb(i);
		if(c[i] == 'D')D.pb(i);
	}
	sor(U);
	sor(D);
	
	ll dp[2][202];
	int t = 0 , t_ = 1;
	rep(i,202)dp[0][i] = 0;
	dp[0][0] = 1;
	int cnt = 0;
	rep(i,n){
		if(c[i] == '-'){ cnt ++; continue; }
		rep(j,U.size()+1){
			dp[t_][j] = 0;
			if(j > 0)dp[t_][j] += dp[t][j-1]*max(0LL,(ll)(lb(U,i)-U.begin())-j+1);
			dp[t_][j] += dp[t][j]*max(0LL,(ll)(D.begin()-ub(D,i))+i-cnt-j+1);
			dp[t_][j] %= M;
		}
		swap(t,t_);
	}
	
	cout << dp[t][U.size()] << endl;
}
	

Measured memory_bytes: 1228
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
typedef long long int ll;
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<signed(n);i++)
#define EREP(i,n) for (int i=1;i<=(n);i++)
#define ALL(a) (a).begin(),(a).end()
//#define EVEL 1

#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const int MOD = 1000000007;
const ll INF = 200000000000;
struct edge {int to,cost;};
typedef std::pair<int,int> P;

    ll N;
    int A[100010];
    int C[100010];
    ll ans=0;

int main(){
    ios_base::sync_with_stdio(false);
    cin>>N;
    REP(i,N){
        cin>>A[i];
        C[A[i]]++;
    }
    ll temp=0;
    REP(i,100001){
        if(i<=2){
            temp+=C[i];
            if(i==2)ans=temp;
        }else{
            temp+=C[i];
            temp-=C[i-3];
            ans=max(ans,temp);
        }

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

Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <map>
#include <queue>
#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

int main() {
	int x, y, z;
	cin >> x >> y >> z;

	cout << z << " " << x << " " << y << endl;


	return 0;
}

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

const int MAXN = 305;

int a[MAXN][MAXN];

int n, m;

int main()
{
	ios::sync_with_stdio(false);
	cin >> n >> m;
	for (int i = 1; i <= n; i++) 
		for (int j = 1; j <= m; j++)
			cin >> a[i][j];
	auto judge = [](int mid) {
		static int vis[MAXN], cnt[MAXN], id[MAXN];
		memset(vis, 0, sizeof vis);
		memset(cnt, 0, sizeof cnt);
		for (int i = 1; i <= n; i++) id[i] = 1, cnt[a[i][1]]++;
		for (int i = 1; i <= m; i++) {
			for (int j = 1; j <= m; j++)
				if (cnt[j] > mid)
					vis[j] = 1;
			for (int j = 1; j <= n; j++)
				while (id[j] <= m && vis[a[j][id[j]]]) {
					id[j]++;
					cnt[a[j][id[j]]]++;
				}
		}
		for (int i = 1; i <= m; i++)
			if (!vis[i])
				return true;
		return false;
	};
	int L = 0, R = n, mid;
	while (L <= R) {
		mid = (L+R)>>1;
		if (judge(mid)) R = mid-1;
		else L = mid+1;
	}
	cout << R+1 << endl;
	return 0;
}


Measured memory_bytes: 640
s=input()
r=set()
last=0
power=1
d={0:0}
total=0
rem=0
for i in range(len(s)-1,-1,-1):#handling of 0's as n and rem
    n=int(s[i])*power+rem
    power*=10
    power=power%2019
    rem=n%2019
    if rem in d.keys():
        d[rem]+=1
    else:
        d[rem]=1
    total+=d[rem]-1
print(total+d[0])





Measured memory_bytes: 68508
n,k = (int(x) for x in input().split())
sunuke = [True] * n
for i in range(k):
    c = int(input())
    ar = [int(x) for x in input().split()]
    for v in ar:
        sunuke[v - 1] = False

ans = 0
for v in sunuke:
    if v == True:
        ans +=1

print(ans)



Measured memory_bytes: 9172
#include <bits/stdc++.h>
using namespace std;
deque<int> numbers;
bool poss;
vector<int> order;
int n;
void make(int a, int b, bool must = 1)
{
	if (!numbers.size()) return;
	if (!a || !b)
	{
		poss = false;
		return;
	}
	if (must && a + b > n+1) { poss = false; return; }
	vector<int> addingreverse;
	for (int i = 0; i < b && numbers.size(); i++)
	{
		addingreverse.push_back(numbers.front());
		numbers.pop_front();
	}
	reverse(addingreverse.begin(), addingreverse.end());
	for (auto a : addingreverse) order.push_back(a);
	addingreverse.clear();
	for (int i = 1; i < a && numbers.size(); i++)
	{
		addingreverse.push_back(numbers.back());
		numbers.pop_back();
	}
	reverse(addingreverse.begin(), addingreverse.end());
	for (auto a : addingreverse) order.push_back(a);
	make(a-1, b-1, 0);
}
int main()
{
	int a, b;
	scanf("%d%d%d", &n, &a, &b);
	for (int i = 1; i <= n; i++) numbers.push_back(i);
	poss = 1;
	make(a, b);
	if (!poss)
	{
		printf("-1\n");
	}
	else
	{
		assert(order.size() == n);
		for (auto a : order) printf("%d ", a);
		printf("\n");
	}
/*	if ((a + b != n && a + b != n+1) || (a + b == n && min(a, b) == 1)) 
	{
		printf("-1\n");
		return 0;
	}
	for (int i = a; i > 0; i--)
	{
		printf("%d ", i);
	}
	if (a + b == n+1)
	{
		for (int i = a + 1; i <= n; i++) printf("%d ", i);
	}
	else
	{
		for (int i = a + 2; i <= n; i++) printf("%d ", i);
		printf("%d", a+1);
	}
	printf("\n");*/

}

Measured memory_bytes: 5400
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i = 0; i<(ll)(n); i++)
#define REPS(i,n) for (ll i = 1; i<=(ll)(n); i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define pb push_back
#define MOD 1000000007
#define MOD2 998244353
#define PI 3.141592653

int main(){
	vector<vector<ll>> c(10,vector<ll>(10));
	ll h, w, a; cin >> h >> w;
	REP(i,10) REP(j,10){
		cin >> c[i][j];
	}
	REP(k,10) REP(i,10) REP(j,10){
		c[i][j] = min(c[i][j],c[i][k]+c[k][j]);
	}
	ll ans = 0;
	REP(i,h) REP(j,w){
		cin >> a;
		if (a>=0){
			ans += c[a][1];
		}
	}
	cout << ans << endl;
}

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

 using namespace std;
 typedef long long ll;
 #define rep(i, n) for(int i = 0; i < (int)(n); i++)

 int main() {
   ll W, H, x, y;
   cin >> W >> H >> x >> y;

   cout << fixed << setprecision(10) << W * H / 2.0 << " ";

   if (2 * x == W && 2 * y == H) cout << 1 << endl;
   else cout << 0 << endl;
 }


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

int main() {
  int n;
  cin >>n;
  vector<int> s(n);
  for(int i=0;i<n;i++){
    cin >>s.at(i);
  }
  int sum=0;
  for(int i=0;i<n-1;i++){
    for(int j=i+1;j<n;j++){
      sum = sum+s.at(i)*s.at(j);
    }
  }
  cout <<sum <<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <iomanip>
#include <cassert>
#include <random>
#include <tuple>
#include <cstdint>
#include <complex>

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

using namespace std;
typedef long long ll;
typedef pair<int, int> P;

const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

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


bool dp[5010][5010];

int main() {
    int n, k; cin >> n >> k;
    vector<int> a(n); rep(i, n) cin >> a[i];
    sort(a.begin(), a.end());

    // 単調性が成り立つことを示す。
    // k - a[i] <= S < k となるSが存在するとすると、
    // a[j] > a[i] を満たす任意のa[j]について、k - a[j] <= S' < k が成り立つようなS'が存在することが示せる。
    // (Sに a[j]が含まれる場合と、a[j]が含まれない場合に分けると示せた。)

    int left = -1;
    int right = n;
    int mid;
    while (right - left > 1) {
        mid = (left + right) / 2;
        memset(dp, false, sizeof(dp));
        dp[0][0] = true;

        rep(i, n) {
            rep(j, k+1) {
                if (i == mid) {
                    dp[i+1][j] |= dp[i][j];
                } else {
                    dp[i+1][j] |= dp[i][j];
                    if (j + a[i] <= k) {
                        dp[i+1][j+a[i]] |= dp[i][j];
                    } else {
                        dp[i+1][k] |= dp[i][j];
                    }
                }
            }
        }

        bool flag = 0;
        for (int j = max(0, k - a[mid]); j < k; j++) {
            flag |= dp[n][j];
        }
        if (flag) right = mid;
        else left = mid;
    }

    cout << left + 1 << endl;

    return 0;
}


    

Measured memory_bytes: 24832
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9+7;

int main(void){
	ll a,b,c,d;
	cin>>a>>b>>c>>d;
	ll ans = 0;
	ans = abs(b-a)+1;
	ll tmp = 0;
	tmp += (b/c)-((a-1)/c);
	tmp += (b/d)-((a-1)/d);

	 ll x = c * d;

	  if(c<d){
	    ll tmp2 = c;
	    c = d;
	    d = tmp2;
	  }

	  ll r = c % d;
	  while(r!=0){
	    c = d;
	    d = r;
	    r = c % d;
	  }
	  ll lcm = x/d;
	 // cout<<lcm<<endl;
	  tmp -= (b/lcm)-((a-1)/lcm);
	  //cout<<tmp<<endl;
	  cout<<ans-tmp<<endl;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"math"
)

func main() {
	var N, D int
	fmt.Scan(&N, &D)

	points := make([][]float64, N)
	for i := range points {
		points[i] = make([]float64, D)
	}

	for i := range points {
		for j := range points[i] {
			var X float64
			fmt.Scan(&X)
			points[i][j] = X
		}
	}

	count := 0
	for i := 0; i < N; i++ {
		for j := i + 1; j < N; j++ {
			dist := 0.0
			for k := 0; k < D; k++ {
				dist += (points[i][k] - points[j][k]) * (points[i][k] - points[j][k])
			}
			dist = math.Sqrt(dist)
			if math.Ceil(dist) == dist {
				count++
			}
		}
	}

	fmt.Println(count)
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

#define CHMIN(a, b) a=min((a), (b))
#define CHMAX(a, b) a=max((a), (b))

const ll MOD=1000000007ll;
// const ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	ll a[114514], b[114514], suma=0, sumb=0;
	cin>>n;
	REP(i, n){
		cin>>a[i];
		suma+=a[i];
	}
	REP(i, n){
		cin>>b[i];
		sumb+=b[i];
	}
	if(suma<sumb){
		cout<<-1<<'\n';
		return 0;
	}
	ll minus=0;
	int ans=0;
	REP(i, n){
		a[i]-=b[i];
		if(a[i]<0){
			minus+=a[i];
			++ans;
		}
	}
	sort(a, a+n);
	FORR(i, 0, n){
		if(minus>=0){
			break;
		}
		minus+=a[i];
		++ans;
	}
	cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 1792
from bisect import *
from collections import *
from fractions import gcd

N,K=map(int,input().split())
P=list(map(int,input().split()))
value=0
for i in range(K):
    value+=(P[i]*(P[i]+1)//2)/P[i]
maxvalue=value
for i in range(N-K):
    value-=(P[i]*(P[i]+1)//2)/P[i]
    value+=(P[i+K]*(P[i+K]+1)//2)/P[i+K]
    maxvalue=max(value,maxvalue)
print(maxvalue)


Measured memory_bytes: 97388
#include <stdio.h>

int main(void)
{
	int n;
	int i;
	int num[3];

	scanf("%d", &n);

	for (i = 0; i < 3; i++)
	{
		num[i] = n % 10;
		n /= 10;
	}

	for (i = 0; i < 3; i++)
	{
		if (num[i] == 7)
		{
			printf("Yes\n");
			return 0;
		}	
	}
	printf("No\n");

	return 0;
}

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

MOD = 1000000007  # type: int

class ModOperator:
    def __init__(self, MOD: int = 10 ** 9 + 7):
        self.MOD = MOD

    def mod_pow(self, x: int, n: int):
        bi = str(format(n, "b"))
        res = 1
        a = x
        for i in range(len(bi)):
            if n >> i & 1:
                res = (res * a) % self.MOD
            a = (a * a) % self.MOD
        return res
    
    def mod_fact(self, x: int):
        res = 1
        for i in range(1, x + 1):
            res = res * i % self.MOD
        return res % self.MOD
    
    def mod_partial_fact(self, x: int, y: int):
        res = 1
        for i in range(x - y + 1, x + 1):
            res = res * i % self.MOD
        return res % self.MOD

    def mod_inv(self, x: int):
        return self.mod_pow(x, self.MOD - 2)
    
    def mod_comb(self, n: int, k: int):
        numerator = self.mod_partial_fact(n, k)
        denomintator = self.mod_fact(k)
        return numerator * self.mod_inv(denomintator) % self.MOD

def solve(n: int, a: int, b: int):
    op = ModOperator()
    print((op.mod_pow(2, n) - op.mod_comb(n, a) - op.mod_comb(n, b) - 1) % MOD)

    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
    a = int(next(tokens))  # type: int
    b = int(next(tokens))  # type: int
    solve(n, a, b)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3192
from collections import deque


k = int(input())

queue = deque([1, 2, 3, 4, 5, 6, 7, 8, 9])

for _ in range(k):
    num = queue.popleft()
    x = num % 10

    if x != 0:
        queue.append(num*10 + x-1)

    queue.append(num*10 + x)

    if x != 9:
        queue.append(num*10 + x+1)

print(num)


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod (ll)(1e9+7)

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

signed main() {
  string s;
  cin >> s;
  ll ans = 0, num = 0;
  rep(i, 0, s.length()) {
    num += (int)s[i] - 48;
  }
  ans = max(num, (ll)(s.length() - 1) * 9);
  int i = s.length() - 1;
  while(i >= 0) {
    if(i && s[i] != '9') {
      s[i] = '9';
      dep(j, i - 1, 0) {
        if(s[j] == '0') {
          if(j != 0) s[j] = '9';
        }else {
          s[j] = s[j] - 1;
          break;
        }
      }
    }
    i--;
    num = 0;
    rep(j, 0, s.length()) {
      num += (int)s[j] - 48;
    }
    ans = max(num, ans);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<math.h>
#include<map>
#include<iterator>
#include<set>
#include<queue>

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

using namespace std;


int main(){
	int k,t; cin >> k >>t;
	vector<int> a;
	int sum = 0;
	int maximum = -1;
	rep(i,t){
		int temp; cin >> temp;
		a.push_back(temp);
		sum += temp;
		maximum = max(maximum, temp);
	}
	if(maximum <= sum - maximum + 1)
		cout << 0 << endl;
	else{
		cout << maximum - (sum - maximum) - 1 << endl;
	}
}

Measured memory_bytes: 256
// 参考
// https://techracho.bpsinc.jp/jhonda/2019_08_05/78537

// Input macro
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! stdin {
    () => {{
        use std::io::Read;
        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }};
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

// Test Code
macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}

test! {
r"5 2 7
" => r"B",

r"1 999 1000
" => r"A"
}

use std::cmp;
use std::cmp::{max, min};
use std::collections::HashSet;
use std::f32::MAX;

fn main() {
    println!("{}", solve(&stdin!()));
}

fn solve(src: &str) -> String {
    input! {
        source = src,
        x: i32,
        a: i32,
        b: i32,
    }

    if (x - a).abs() < (x - b).abs() {
        "A".to_string()
    } else {
        "B".to_string()
    }
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
string to_string(const string& s) {
	return '"' + s + '"';
}
string to_string(const bool b) {
	return (b ? "true" : "false");
}
string to_string(const char* s) {
	return to_string((string)s);
}
string to_string(const char c) {
	string s = "'";
	s += c;
	s += "'";
	return s;
}
template<class T, class U>
string to_string(const pair<T, U>& p) {
	string s = "(";
	s += to_string(p.first);
	s += ", ";
	s += to_string(p.second);
	s += ")";
	return s;
}
template<class T>
string to_string(const T& a) {
	bool first = true;
	string s = "{";
	for (const auto& x : a) {
		if(!first){
			s += ", ";
		}
		first = false;
		s += to_string(x);
	}
	s += "}";
	return s;
}
void debug_out() {cerr << '\n';}
template<class Head, class... Tail>
void debug_out(Head head, Tail... tail) {
	cerr << ' ' << to_string(head);
	debug_out(tail...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "] = ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif
using ll = long long;
using ld = long double;
const int mod = 1e9 + 7;
const int inf = 2e9;
const ll inf64 = 7e18l;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(20);
	int a, b, c, k;
	cin >> a >> b >> c >> k;
	int answer = min(a, k);
	k -= min(a, k);
	k -= min(b, k);
	answer -= min(c, k);
	cout << answer << '\n';
	
	
 	return 0;
}


Measured memory_bytes: 3620
#include<cstdio>
#include<iostream>
#include <string>
#include<algorithm>
using namespace std;

int main()
{
    int a;
    cin >> a ;
    int c = (a%100)%10;
    int d = a/100;
    int e = (a/10)%10;
    
    cout << c + d + e;
}




Measured memory_bytes: 3164
#include "bits/stdc++.h"
using namespace std;
int main() {
	long long K; cin >> K;
	queue<long long>Q;
	Q.push(1); Q.push(2); Q.push(3); Q.push(4); Q.push(5); Q.push(6); Q.push(7); Q.push(8); Q.push(9);
	long long ans = 0;
	for (long long i = 0; i < K; i++) {
		long long x = Q.front();
		Q.pop();
		ans = x;
		if (x % 10 != 0) Q.push(10 * x + (x % 10) - 1);
		Q.push(10 * x + (x % 10));
		if (x % 10 != 9) Q.push(10 * x + (x % 10) + 1);
	}
	cout << ans << endl;
}

Measured memory_bytes: 5152
#include <stdio.h>
#include <math.h>
double fun(double a,double b,double c);
double fun2(double a,double b,double c,double d);

int main(void)
{
	double x1,x2,x3,xp,y1,y2,y3,yp;
	double ABC,APB,BPC,CPA,AB,BC,CA,AP,BP,CP;
	while(scanf("%lf %lf %lf %lf %lf %lf %lf %lf",&x1,&y1,&x2,&y2,&x3,&y3,&xp,&yp)!=EOF){
		AB=fun2(x1,x2,y1,y2);
		BC=fun2(x2,x3,y2,y3);
		CA=fun2(x3,x1,y3,y1);
		AP=fun2(x1,xp,y1,yp);
		BP=fun2(x2,xp,y2,yp);
		CP=fun2(x3,xp,y3,yp);
		ABC=fun(AB,BC,CA);
		APB=fun(AP,BP,AB);
		BPC=fun(BP,CP,BC);
		CPA=fun(CP,AP,CA);
		if(fabs(ABC-APB-BPC-CPA)<0.1) puts("YES");
		else puts("NO");
	}
	return 0;
}

double fun(double a,double b,double c)
{
	double s=(a+b+c)/2,S;
	S=sqrt(s*(s-a)*(s-b)*(s-c));
	return S;
}

double fun2(double a,double b,double c,double d){
	double L;
	L=sqrt((a-b)*(a-b)+(c-d)*(c-d));
	return L;
}

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

struct circle{
  int x, y, r;
  circle(int a, int b, int c){ x=a, y=b, r=c; }
  bool operator<(const circle right)const{
    return r<right.r;
  }
};

double get_dis_PP(int x1, int y1, int x2, int y2){
  return sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));
}

int n, dp[1005], xs, ys, xt, yt;
vector<circle> c;

signed main(){

  while(1){
  
    cin>>n;
    if(!n) break;
    cin>>xs>>ys>>xt>>yt;

    c.clear();
  
    for(int i=0;i<n;i++){
      int x, y, r;
      cin>>x>>y>>r;
      int flag=0;
      if(get_dis_PP(xs,ys,x,y)<r) flag^=1;
      if(get_dis_PP(xt,yt,x,y)<r) flag^=1;
      if(flag) c.push_back(circle(x,y,r));
    }
  
    sort(c.begin(),c.end());
  
    for(int i=0;i<c.size();i++) dp[i]=1;
        
    for(int i=0;i<c.size();i++)
      for(int j=i+1;j<c.size();j++){
	circle A=c[j], B=c[i];
	double d=get_dis_PP(A.x,A.y,B.x,B.y);
	if(d+B.r<A.r) dp[j]=max(dp[j],dp[i]+1);
      }
    
    int ans=0;
    
    for(int i=0;i<c.size();i++){
      ans=max(ans,dp[i]);
      for(int j=i+1;j<c.size();j++){
	circle A=c[j], B=c[i];
	double d=get_dis_PP(A.x,A.y,B.x,B.y);
	if(d>A.r+B.r) ans=max(ans,dp[i]+dp[j]);
      }
    }
    
    cout<<ans<<endl;
  
  }
  
  return 0;
}

Measured memory_bytes: 3104
#include<bits/stdc++.h>
using namespace std;
int main()
{
   int n,maxi=0,sum=0,x;
   scanf("%d",&n);
   for(int i=0;i<n;i++)
   {
       scanf("%d",&x);
       maxi=max(maxi,x);
       sum+=x;
   }
   printf("%d\n",sum-maxi/2);
    return 0;
}


Measured memory_bytes: 256
/*自由木を作成し、それらの情報を書き出すプログラム*/
#include<stdio.h>

/*マクロ*/
#define MAX 100005
#define NIL -1

/*グローバル変数*/
int n, D[MAX];//n=接点の個数
int dep = 0;

/*プロトタイプ宣言*/
void TreePrint(int );

/*構造体(入れ子)*/
struct Node{ 
  int p, l, r;
};

struct Node T[MAX];



int main(){
  int i, j;//カウンター変数
  int d, v, c, l;//d=degree, v=verteck, c=child, l=leaf`
  int u = 0;
  int dep = 0;

  scanf("%d", &n);

  for(i = 0; i < n; i++) {
    T[i].p = NIL;
    T[i].l = NIL;
    T[i].r = NIL;
  }
  
  for(i = 0; i < n; i++) {
    scanf("%d %d", &v, &d);

    for(j = 0; j < d; j++) {
      scanf("%d", &c);

      T[c].p = v;

      if(j == 0) {
	T[v].l = c;
      }

      if(j > 0) {
	T[l].r = c;
      }
	l = c;
    }

  }


  for(i = 0 ;i < n ;i++) {
    u = i;

  while(1)
    {
    if(T[u].p == NIL)  {
      break;
    }
    // printf("%d\n",dep);
    dep++;
    u = T[u].p;
    }

    D[i] = dep;
    dep = 0;
  }
  
  for(i = 0 ;i < n ;i++) {

    TreePrint(i);
  }
 
  return 0;
}

/*結果を出力する関数*/
void TreePrint(int u) {
  int i;

  printf("node %d: parent = %d, depth = %d, ",u ,T[u].p ,D[u]);

  if(T[u].p == NIL) {
    printf("root, ");
  }

  else if(T[u].l == NIL) {
    printf("leaf, ");
  }

  else if(T[u].l != NIL) {
    printf("internal node, ");
  }

  printf("[");

  if(T[u].l != NIL) {
    printf("%d",T[u].l);
    u=T[u].l;
  

    if(T[u].r != NIL)printf(", ");

    while(1){
	if(T[u].r == NIL)break;

      printf("%d",T[u].r);
      u=T[u].r;

      if(T[u].r != NIL) {
	printf(", ");
      }

    }
  }
  
  printf("]\n");
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define ft first
#define sd second
#define pb push_back
using namespace std;
const ll mod = 1e9+7;
const ll inf = 1e9+7;
 
ll power(ll a, ll b, ll m = mod) {
    ll x = 1;
    while(b) {
        if(b & 1) {
            x = 1ll * x * a % m;
        }
        a = 1ll * a * a % m;
        b /= 2;
    }
    return x;
}
 
const int N = 50+3;
// ll a[N];
const int B = 20;
int n, m; 
ll f[N], cnt, marks[N];
vector<int> g[N];
vector<pair<int, int>> rests;
int ht[N], p[N];
void dfs0(int u, int par) {
    ht[u] = ht[par] + 1;
    p[u] = par;
    for(int v: g[u]) {
        if(v == par) continue;
        dfs0(v, u);
    }
}
void dfs(int u, int par) {
    f[u] += marks[u];
    for(int v: g[u]) {
        if(v == par) continue;
        dfs(v, u);
        f[u] += f[v];
    }
}
int lca[N][N];
signed main() {  
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);    
    cin >> n;
    for(int i = 1; i < n; i++) {
        int u, v; cin >> u >> v;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    dfs0(1, 0);
    cin >> m;
    for(int i = 1; i <= m; i++) {
        int u, v; cin >> u >> v;
        if(u > v) swap(u, v);
        rests.push_back({u, v});
    }
    for(int i = 1; i <= n; i++) {
        for(int j = i; j <= n; j++) {
            int u = i, v = j;
            while(ht[u] < ht[v]) v = p[v];
            while(ht[v] < ht[u]) u = p[u];
            while(u != v) {
                u = p[u];
                v = p[v];
            }
            lca[i][j] = u;
            // cout << i << " " << j << " " << u << endl;
            assert(u == v && u > 0);
        }
    }

    ll ans = 0;
    for(int msk = 0; msk < (1 << m); msk++) {
        for(int i = 1; i <= n; i++) {
            marks[i] = 0;
        }
        int coeff = 1;
        for(int bit = 0; bit < m; bit++) {
            if((msk >> bit) & 1) {
                int u = rests[bit].first, v = rests[bit].second;
                marks[u]++; marks[v]++; marks[lca[u][v]] -= 2;
                coeff *= -1;
            }
        }
        cnt = -1;
        for(int i = 1; i <= n; i++) f[i] = 0;
        dfs(1, 0);
        for(int i = 1; i <= n; i++) cnt += f[i] == 0;
        // cout << "cnt=" << cnt << " " << msk << endl;;
        ans += coeff * (1ll << (cnt));
    }
    cout << ans << "\n";

 
    return 0;
    
}

Measured memory_bytes: 256
#include <stdio.h>

#define MAX 100005
#define NIL -1

typedef struct {int p, l, r;} Node;

Node T[MAX];
int n, D[MAX];

void print(int u) {
  int i,c;
  printf("node %d: ",u);
  printf("parent = %d, ",T[u].p);
  printf("depth = %d, ",D[u]);

  if( T[u].p == NIL ) printf("root, ");
  else if( T[u].l == NIL ) printf("leaf, ");
  else printf("internal node, ");

  printf("[");

  for(i=0, c=T[u].l; c != NIL; i++, c=T[c].r) {
    if(i) printf(", ");
    printf("%d",c);
  }
  printf("]\n");
}

void rec(int u, int p) {
  D[u] = p;
  if(T[u].r != NIL) rec(T[u].r,p);
  if(T[u].l != NIL) rec(T[u].l,p+1);
}

int main(void) {
  int i,j,d,v,c,l,r;
  scanf("%d",&n);
  for(i=0;i<n;i++) T[i].p = T[i].l = T[i].r = NIL;
  for(i=0;i<n;i++) {
    scanf("%d %d",&v,&d);
    for(j=0;j<d;j++) {
      scanf("%d",&c);
      if(j==0) T[v].l=c;
      else T[l].r =c;
      l = c;
      T[c].p = v;
    }
  }
  for(i=0;i<n;i++) {
    if(T[i].p == NIL) r = i;
  }
  
  rec(r,0);
  
  for(i=0;i<n;i++) print(i);
  
  return 0;
}


Measured memory_bytes: 6424
#include <bits/stdc++.h>
#define PI 3.1415926535897
using namespace std;
typedef long long ll;
const int INF = 1000000000;
const ll LINF = 1000000000000000000; //1e18
const double EPS = 1e-10;

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

    if (a + b == c || a + c == b || b + c == a)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }

    return (0);
}

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

using namespace std;

void solve(string x, string y) {
    int c{0};
    for (int i = 0; i < x.size(); ++i) {
        if(x[i] != y[i]) {
            c++;
        }
    }
    cout << c << endl;
}

int main() {
    string s1;
    string s2;
    cin >> s1 >> s2;
    solve(s1, s2);
}


Measured memory_bytes: 3672
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
typedef long long LL;
const int N=15;
LL n,m,z,x,y,len,ans,sum,f[N][127],cj,a[10],jc[N],cf[11][N];
char s[15];
void work1(){
	for (int i=0;i<len;++i) sum+=s[i]-'0';
	f[0][0]=1;
	for (int i=1;i<=len;++i)
	for (int j=0;j<sum;++j)
	for (int k=0;k<=9;++k)
	if (j>=k) f[i][j]+=f[i-1][j-k];
	for (int i=0;i<sum;++i) ans+=f[len][i];
}
LL calc(){
	LL ans=1,tot=0;
	for (int i=0;i<=9;++i) tot+=a[i];
	ans*=jc[tot];
	for (int i=0;i<=9;++i) ans/=jc[a[i]];
	return ans;
}
void work3(){
	LL b[10];
	memcpy(b,a,sizeof(a));
	for (int i=1;i<=len;++i){
		for (int j=0;j<s[i-1]-'0';++j)
		if (a[j]!=0){
			--a[j];ans+=calc();++a[j];
		}
		if (a[s[i-1]-'0']!=0) --a[s[i-1]-'0'];
		else break;
	}
	memcpy(a,b,sizeof(a));
}
void dfs(int w,int now,int Sum,LL nowj){
	if (w==9){
		a[9]=len-now;
		if (Sum+a[9]*9!=sum) return;
		if (nowj*cf[10][a[9]]>cj) return;
		if (nowj*cf[10][a[9]]==cj){
			work3();return;
		}
		ans+=calc();
		return;
	}
	if (Sum+w*(len-now)>sum) return;
	for (int i=0;i<=len-now;++i)
	if (nowj*cf[w+1][i]<=cj && Sum+w*i<=sum) {
		a[w]=i;
		dfs(w+1,now+i,Sum+w*i,nowj*cf[w+1][i]);
	}
}
void work2(){
	cj=1;
	for (int i=0;i<len;++i) cj*=s[i]-'0'+1;
	dfs(0,0,0,1);
}
int main(){
	scanf("%s",s);
	len=strlen(s);
	jc[0]=1;
	for (int i=1;i<=14;++i) jc[i]=jc[i-1]*i;
	for (int i=1;i<=10;++i) cf[i][0]=1;
	for (int i=1;i<=10;++i)
	for (int j=1;j<=14;++j) cf[i][j]=cf[i][j-1]*i;
	work1();
	work2();
	cout<<ans<<endl;
}

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

int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  string s, t;
  cin >> s >> t;
  t.erase(t.end()-1);
  cout << (s == t ? "Yes" : "No") << "\n"; 
return 0;
}


Measured memory_bytes: 3640
main :: IO ()
main = do
    line <- getLine
    let [w, h, x, y, r] = map (\n -> read n :: Int) $ words line
    putStrLn $ circleInRectangle (x, y, r) (w, h)

onLine :: Int -> Int -> Int -> Bool
onLine right n r = 0 <= n-r && n-r <= n+r && n+r <= right

circleInRectangle :: (Int, Int, Int) -> (Int, Int) -> String
circleInRectangle (x, y, r) (w, h)
  | onLine w x r && onLine h y r = "Yes"
  | otherwise                    = "No"


Measured memory_bytes: 3568
/* 
	Author: ankrypt
*/


#include <bits/stdc++.h>

using namespace std;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int

ll N;

int main() {
	scanf("%lld", &N);
	if(N & 1) {
		printf("0\n");
	}
	else {
		ll ans = 0;
		N /= 2;
		for(ll i = 5; i <= N; i *= 5) {
			ans += (N / i);
			// cout << i << "\n";
		}
		printf("%lld\n", ans);
	}

	return 0;
}
/*
	Powered by Buggy Plugin
*/


Measured memory_bytes: 256
readInt :: IO Int
readInt = read <$> getLine

func :: Int -> [Int]
func x | r == 0    = [x * 10, x * 10 + 1]
       | r == 9    = [x * 10 + 8, x * 10 + 9]
       | otherwise = [(x * 10 + r - 1) .. (x * 10 + r + 1)]
    where r = mod x 10

lunlun :: [Int]
lunlun = [1 .. 9] ++ concatMap func lunlun

main = do
    k <- readInt
    print $ lunlun !! (k - 1)


Measured memory_bytes: 7036
#include <iostream>
#include <string>
using namespace std;
typedef long long ll;
int main(void){
  	string s;
  	ll ans = -1;
  	ll a, b, A, B;
  	cin >> a >> b;
  	
  	for(ll i=1000;i>=1;i--){
  	    A=i*0.08;
  	    B=i*0.1;
  	    if(b==B&&a==A)ans=i;
  	}
  	
    cout << ans << endl;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
A.sort()
U = N
L = -1
while U - L > 1:
    m = (U+L)//2
    x = A[m]
    x1 = A[m]
    f = True
    f1 = True
    for a in A:
        if a == x1 and f1:
            f1 = False
            continue
        if a <= 2 * x:
            x += a
        else:
            f = False
            break
    if f:
        U = m
    else:
        L = m
print(N-U)
        

Measured memory_bytes: 63856