akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#define MAXN 101
using namespace std;
int A[2][MAXN];
int main()
{
    int N, x;
    cin >> N;
    for (int i = 1; i <= N; ++i) {
        cin >> A[0][i];
        A[0][i] += A[0][i - 1];
    }
    for (int i = 1; i <= N; ++i) {
        cin >> x;
        A[1][i] = max(A[0][i], A[1][i - 1]) + x;
    }
    cout << A[1][N];
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,a[110001];
main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin>>n;
	int p=0;
	for(int i=1;i<=n;i++)cin>>a[i],p+=(a[i]>=0);
	if(n==2){cout<<abs(a[1]-a[2])<<'\n'<<max(a[1],a[2])<<' '<<min(a[1],a[2])<<'\n';exit(0);}
	vector<pair<int,int>> ans;
	multiset<int> x,y;
	for(int i=1;i<=n;i++)(a[i]>=0?x:y).insert(a[i]);
	if(!p)
	{
		int u=*y.begin(),v=*y.rbegin();
		y.erase(y.begin());
		y.erase(--y.end());
		ans.push_back({v,u});
		x.insert(v-u);
	}
	else if(p==n)
	{
		int u=*x.begin(),v=*x.rbegin();
		x.erase(x.begin());
		x.erase(--x.end());
		ans.push_back({u,v});
		y.insert(u-v);
	}
	while(x.size()>1&&y.size()>1)
	{
		int u=*x.begin(),v=*y.begin();
		x.erase(x.begin());
		y.erase(y.begin());
		ans.push_back({u,v});
		x.insert(u-v);
	}
	if(x.size()==1)
		while(y.size()>1)
		{
			int u=*x.begin(),v=*y.begin();
			x.erase(x.begin());
			y.erase(y.begin());
			ans.push_back({u,v});
			x.insert(u-v);
		}
	if(y.size()==1)
	{
		while(x.size()>1)
		{
			int u=*x.begin(),v=*y.begin();
			x.erase(x.begin());
			y.erase(y.begin());
			ans.push_back({v,u});
			y.insert(v-u);
		}
		int u=*x.begin(),v=*y.begin();
		x.erase(x.begin());
		y.erase(y.begin());
		ans.push_back({u,v});
		x.insert(u-v);
	}
	cout<<*x.begin()<<'\n';
	for(auto o:ans)cout<<o.first<<' '<<o.second<<'\n';
}


Measured memory_bytes: 7800
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int  main() {
	char s[20];
	char *tp1,*tp2,*tp3;
	scanf("%s",s);
	tp1 = strtok(s,"/");
	tp2 = strtok(NULL,"/");
	tp3 = strtok(NULL,"/");
	char year[5],month[3],date[3];
	strcpy(year,tp1);
	strcpy(month,tp2);
	strcpy(date,tp3);
	int _year = atoi(year),_month = atoi(month),_date = atoi(date);	
	if (_year < 2019) {
		printf("Heisei\n");
		return 0;
	}
	if (_year > 2019) {
		printf("TBD\n");
		return 0;
	}
	if (_year == 2019 && _month > 4) {
		printf("TBD\n");
		return 0;
	}
	if (_year == 2019 && _month < 5 && _date < 32) {
		printf("Heisei\n");
		return 0;
	}
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
	static final int a = 100;
	static final double r = 1.01;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long x = Long.parseLong(sc.next());
		System.out.println(solve(x));
	}

	static public int solve(long x) {
		int year = 0;
		for (long i = a;; i = (long) (i * r), year++) {
			if (i >= x)
				return year;
		}
	}

}


Measured memory_bytes: 27008
use proconio::input;
use std::collections::BTreeMap;

fn main() {
    input! {
        n: usize,
        s: [String; n],
    }

    let mut map = BTreeMap::new();

    for s in s.iter() {
        map.entry(s).and_modify(|e| *e += 1).or_insert(1);
    }

    let max = map.values().max().unwrap();
    let mut ss: Vec<&String> = map
        .iter()
        .filter(|(_, v)| *v == max)
        .map(|(k, _)| k)
        .cloned()
        .collect();

    ss.sort();

    for s in ss {
        println!("{}", s);
    }
}


Measured memory_bytes: 22112
import java.util.*;
import java.io.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        int n = sc.nextInt();
        int odd = n/2+n%2;
        int even = n/2;
        pw.println(odd*even);
        pw.flush();
    }

    static class GeekInteger {
        public static void save_sort(int[] array) {
            shuffle(array);
            Arrays.sort(array);
        }
 
        public static int[] shuffle(int[] array) {
            int n = array.length;
            Random random = new Random();
            for (int i = 0, j; i < n; i++) {
                j = i + random.nextInt(n - i);
                int randomElement = array[j];
                array[j] = array[i];
                array[i] = randomElement;
            }
            return array;
        }
 
    }
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public double nextDouble() {
         return Double.parseDouble(next());
    }
    
    public String[] nextArray(int n) {
        String[] a = new String[n];
        for (int i = 0; i < n; i++)
            a[i] = next();
        return a;
    }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    } 
}


Measured memory_bytes: 25448
Card = {}
Cost = {}
n = int(raw_input())
for i in range(n):
  Card[(i, i)] = map(int, raw_input().split())
  Cost[(i, i)] = 0
for i in range(1, n):
  for j in range(0, n-i):
    Cost[(j, j+i)] = min([reduce(lambda a,b: a*b, Card[(j, j+k)]+Card[(j+k+1, j+i)]) + Cost[(j, j+k)]+Cost[(j+k+1, j+i)] for k in range(i)])
    Card[(j, j+i)] = [Card[(j, j)][0], Card[(j+i, j+i)][1]]
print Cost[0, n-1]

Measured memory_bytes: 5316
MOD = 10**9+7
n, k = map(int, input().split())
ans, s = 0, [0] * (k+1)

for i in range(k, 0, -1):
    s[i] = pow((k//i), n, MOD)
    for j in range(i*2, k+1, i):
        s[i] -= s[j]
    ans += s[i] * i
    ans %= MOD

print(ans)


Measured memory_bytes: 11168
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
using namespace std;

int m,n;
int b[510],r[510];
vector<int> G[1010];
bool v[1010];
int f[1010];

bool dfs(int t){
  v[t] = true;
  for(int i=0;i<(int)G[t].size();i++){
    int u = G[t][i], o = f[u];
    if(o<0 || !v[o] && dfs(o)){
      f[t] = u;
      f[u] = t;
      return true;
    }
  }
  return false;
}

int bi_matching(void){
  int res = 0;
  memset(f,-1,sizeof(f));
  for(int i=0;i<m+n;i++){
    if(f[i] < 0){
      memset(v,0,sizeof(v));
      if(dfs(i))res++;
    }
  }
  return res;
}

int main(){
  while(cin >> m >> n , m||n){
    for(int i=0;i<m;i++)cin >> b[i];
    for(int i=0;i<n;i++)cin >> r[i];

    for(int i=0;i<m+n;i++)G[i].clear();
    
    for(int i=0;i<m;i++){
      for(int j=0;j<n;j++){
	if(__gcd(b[i],r[j])>1){
	  G[i].push_back(m+j);
	  G[m+j].push_back(i);
	}
      }
    }

    cout << bi_matching() << endl;
  }
}

Measured memory_bytes: 3064
t = ["dream","dreamer","erase","eraser"]

# 反転

t_r = []
for i in range(len(t)):
    t_r.append(t[i][::-1])
    
s = input()
s_r = s[::-1]
#print(s_r)

flag = True
#for i in range(len(s_r)):
i=0
while(i<len(s_r)):
    flag2 = False
   
    for j in range(len(t_r)):
        t = t_r[j] 
        tmp_s = s_r[i:i+len(t)]
        #print(t)
        
        if(tmp_s == t):
            flag2 = True
            i += len(t)
    if flag2 == False:
        flag = False
        break

if flag==True:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 3188
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
typedef long long ll;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

struct Combination {
    const int MOD = 1000000007;
    vector<ll> fac, finv, inv;
    Combination(const int MAX) : fac(MAX), finv(MAX), inv(MAX) {
        fac[0] = fac[1] = 1;
        finv[0] = finv[1] = 1;
        inv[1] = 1;
        for(int i = 2; i < MAX; i++) {
            fac[i] = fac[i - 1] * i % MOD;
            inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
            finv[i] = finv[i - 1] * inv[i] % MOD;
        }
    }
    long long comb(int n, int k) {
        if(n < k)
            return 0;
        if(n < 0 || k < 0)
            return 0;
        return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
    }
};

int main() {
    int X, Y;
    cin >> X >> Y;
    Combination C(2000100);

    if((2 * Y - X) < 0 || (2 * Y - X) % 3 != 0) {
        cout << 0 << endl;
        return 0;
    } else {
        int a = (2 * Y - X) / 3;
        int b = (X - a) / 2;
        if(b < 0) {
            cout << 0 << endl;
            return 0;
        }
        cout << C.comb(a + b, a) << endl;
    }
    return 0;
}

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

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> b;
    rep(i,n)cin >> a[i];
    if(a.size() % 2 == 0){
        for(int i = n-1;i > 0;i -=2){
            b.push_back(a[i]);
        }
        for(int i = 0;i < n;i += 2){
            b.push_back(a[i]);
        }
    }
    else {
        for(int i = n-1;i >= 0;i -=2){
            b.push_back(a[i]);
        }
        for(int i = 1;i < n;i += 2){
            b.push_back(a[i]);
        }
    }
    rep(i,n-1)cout << b[i] << " ";
    printf("%d\n",b[n-1]);
}

Measured memory_bytes: 3828
#include<stdio.h>
int main(){
	int baris, kolom;
	for(int i=0; ; i++){
		scanf("%d %d", &baris, &kolom);
		if(baris==0 && kolom == 0){
			break;
		}
		else{
			for(int j=0; j<baris; j++){
				for(int k=0; k<kolom; k++){
					printf("#");
				}
				printf("\n");
			}
			printf("\n");
		}
	}
}


Measured memory_bytes: 2624
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        String ans = "No";
        if(A+B>=C) ans = "Yes";
        System.out.println(ans);
    }
}

Measured memory_bytes: 22604
#include<stdio.h>
int main(void)
{
	int b[4];
	
	scanf("%d %d %d",&b[0],&b[1],&b[2]);
	if(b[0] && b[1] || b[2] == 1){
		printf("Open\n");
	}
	else {
		printf("Close\n");
	}
	return 0;
}

Measured memory_bytes: 584
# 参考 https://atcoder.jp/contests/code-festival-2016-qualb/submissions/3090756
n, a, b=map(int,input().split())
for s in input():
    if s=='a':
        if a+b>0:
            print('Yes')
            a-=1
        else:
            print('No')
    elif s=='b'and a+b>0 and b>0:
        print('Yes')
        b-=1
    else:
        print('No')


Measured memory_bytes: 4016
#include<bits/stdc++.h>
using namespace std;
using vi=vector<int>;
int n,m,q,i;
vi a(50),b(50),c(50),d(50);
int main(){
  int ansmax=0;
  cin>>n>>m>>q;
  for(i=0;i<q;i++){
    cin>>a[i]>>b[i]>>c[i]>>d[i];
  }
  //数列bit全探索
  //m+n-1が調べるbit数
  for(int bits=0;bits<pow(2,m+n);bits++){
    int cnt=0;
    int ans=0;
    vi sq;
    for(i=0;i<m+n-1;i++){
      if(bits & (1<<i)){
        sq.push_back(i-cnt+1);
        cnt++;
      }
    }if(cnt!=n){
      continue;
    }else{
      for(i=0;i<q;i++){
        if(sq[b[i]-1]-sq[a[i]-1]==c[i]){
          ans+=d[i];
        }
        ansmax=max(ans,ansmax);
      }
    }
  }
  cout<<ansmax<<endl;
}

Measured memory_bytes: 4036
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <stack>
#include <cstring>
#include <cmath>
#include <deque>
#include <set>
#include <climits>

#define rep_(v, f, l) for (int v = (f); v < (l); ++v)
#define rep(v, n) rep_(v, 0, n)

using namespace std;

typedef long long int lint;

template<typename T> inline bool in(T& x){ return cin >> x; }
template<typename T> inline T in(){T x; cin >> x; return x; }

int main()
{
    vector<vector<int> > tri;
    string line;
    while (cin >> line){
        vector<int> a;
        int s = 0;
        rep(i, line.size()){
            if (line[i] >= '0' && line[i] <= '9'){
                s *= 10;
                s += line[i] - '0';
            }
            else {
                a.push_back(s);
                s = 0;
            }
        }
        a.push_back(s);
        tri.push_back(a);
    }

    vector<vector<int> > max_tri = tri;
    rep(i, tri.size() - 1){
        rep(j, tri[i].size()){
            if (i < tri.size() / 2){
                max_tri[i + 1][j] = max(max_tri[i + 1][j], max_tri[i][j] + tri[i + 1][j]);
                max_tri[i + 1][j + 1] = max(max_tri[i + 1][j + 1], max_tri[i][j] + tri[i + 1][j + 1]);
            }
            else {
                if (j > 0) max_tri[i + 1][j - 1] = max(max_tri[i + 1][j - 1], max_tri[i][j] + tri[i + 1][j - 1]);
                if (j < tri[i].size() - 1) max_tri[i + 1][j] = max(max_tri[i + 1][j], max_tri[i][j] + tri[i + 1][j]);
            }
        }
    }
    printf("%d\n", max_tri[tri.size() - 1][0]);
	return (0);
}

Measured memory_bytes: 1228
#include<bits/stdc++.h>
using namespace std;
long long a[200009];
long long res = 2000000000;
int main()
{
	int N; scanf("%d", &N);
	for (int i = 0; i < N; i++) {
		scanf("%lld", &a[i]);
		if (i)a[i] += a[i - 1];
	}
	for (int i = 1; i < N; i++) {
		res = min(res, abs(a[N - 1] - 2 * a[i - 1]));
	}
	printf("%lld", res);
}

Measured memory_bytes: 1792
import Foundation

func readArrayDouble() -> [Double] {
    readLine()!.split(separator: " ").map({Double($0)!})
}

let line = readArrayDouble()
let (A, B, H, M) = (line[0], line[1], line[2], line[3])
print((A * A + B * B - 2 * A * B * cos(11 * Double.pi * (H + M / 60) / 6)).squareRoot())


Measured memory_bytes: 13848
#include<bits/stdc++.h>
#define f(i,n) for(long int i = 0; i<(long int)n; i++)
#define testcase ll tt; cin >> tt; while(tt--)
#define F first
#define S second
#define ll long long
#define pb push_back
#define vll vector<ll>
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;

int main(){
  string s; cin>>s;
  ll tot = 0;
  for(auto c: s){
  	tot+=c-'0';
  }
  if(tot%9) cout<<"No";
  else cout<<"Yes";
  return 0;
}

Measured memory_bytes: 3748
#include<stdio.h>

int main()
{
	char s1[1005], s2[1005], s3[1005];
	char a, b, c;
	scanf("%s %s %s", s1, s2, s3);
	a = s1[0] - 32;
	b = s2[0] - 32;
	c = s3[0] - 32;
	printf("%c%c%c\n", a, b, c);
}

Measured memory_bytes: 128
A,B,H,M=map(int,input().split())
import math

Hc=math.cos(math.radians(H*60+M)/2)
Hs=math.sin(math.radians(H*60+M)/2)
Mc=math.cos(math.radians(M*6))
Ms=math.sin(math.radians(M*6))

            
P=((Hc*A-Mc*B)**2+(Hs*A-Ms*B)**2)**0.5
print(P)

Measured memory_bytes: 9568
"use strict"
function main(arg) {
    var src = arg.trim().split("\n")[0]
    var data = 'abcdefghijklmnopqrstuvwxyz'.split('')
    var i = 0
    for (i = 0; i < data.length; i++) {
        if (data[i] === src) {
            break
        }
    }
    console.log(data[i+1])
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 21956
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define erep(i, n) for (ll i = 0; i <= (ll)(n); ++i)
#define FOR(i,a,b) for (ll i = (a); i < (ll)(b); ++i)
#define EFOR(i,a,b) for (ll i = (a); i <= (ll)(b); ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } }

#include <iostream>
#include <vector>
#include <queue>
using namespace std;
using Graph = vector<vector<int>>;
using P = pair<int, int>;

ll modnum = 1000000007;


long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}



int main() {
    ll x,y,a,b,c; cin >> x >> y >> a >> b >> c;
    priority_queue<ll> p;
    priority_queue<ll> q;
    priority_queue<ll> r;

    rep(i, a) {
        ll tmp; cin >> tmp;
        p.push(tmp);
    }
    rep(i, b) {
        ll tmp; cin >> tmp;
        q.push(tmp);
    }
    rep(i, c) {
        ll tmp; cin >> tmp;
        r.push(tmp);
    }

    priority_queue<ll> u;
    ll ans = 0;

    ll goal = x+y;

    rep(i, goal) {
        if(u.size() >= goal-(i+1));
        ll tr = 0;
        ll tg = 0;
        ll t = 0;

        if(!p.empty()) tr = p.top();
        if(!q.empty()) tg = q.top();
        if(!r.empty()) t = r.top();

        if(x == 0) tr = 0;
        if(y == 0) tg = 0;


        if(t > tr && t > tg) {
            u.push(t);
            r.pop();
        } else {
            if(tr > tg) {
                ans += tr;
                p.pop();
                x--;
            } else {
                ans += tg;
                q.pop();
                y--;
            }
        }

    }

    while(!u.empty()) {
        ans += u.top();
        u.pop();
    }


    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 4084
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(I, a, b) for (int i = (a); i < (b); ++i)
using namespace std;
using ll = long long;

int main() {
  string s,t = ""; 
  cin >> s;
  
  int n = s.size();
  
  REP(i,n) t.push_back('x');
  
  cout << t << endl;
  
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define int long long
#define FOR(i, m, n) for(int i = m;i < n;i++)
typedef vector<int> VI;
typedef vector<VI> VVI;
const int MOD=1000000007;
const long long INF = 1LL << 60;
//----------------------------------------------
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n; cin >> n;
 
    VI a(n);
    rep(i, n - 1) cin >> a[i];
 
    int ans = 0;
    ans += a[0];
    ans += a[n-2];
   	FOR(i,1,n-1) ans += min(a[i-1], a[i]);
    cout << ans << endl;

    return 0;
}

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

int main()
{
  int A, B, ans = -1;
  cin >> A >> B;
  for (int i = 1; i <= 1000; i++) {
    if (floor(i * 0.08) == A and floor(i * 0.10) == B) {
      ans = i;
      break;
    }
  }
  
  cout << ans << "\n";
}

Measured memory_bytes: 256
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}
import qualified Data.ByteString.Lazy.Char8 as B
import Data.Maybe
import Data.List
-- import qualified Data.Vector.Unboxed as VU
-- import qualified Data.Vector.Unboxed.Mutable as VUM
import Control.Monad
-- import Control.Monad.ST
-- import Debug.Trace

solve :: Int -> [Int] -> Int
solve n as = binsch (try as) n 0

binsch f succ fail | abs (succ - fail) == 1 = succ
                   | f mid                  = binsch f mid fail
                   | otherwise              = binsch f succ mid
  where mid = (succ + fail) `div` 2

step :: Int -> (Int,[(Int,Int)]) -> Int -> Maybe (Int,[(Int,Int)])
step k (s,x) a | a > s     = Just (a,x)
               | k == 1    = Nothing
               | otherwise = (a, ) <$> inc a (cut a x)
  where
    cut a x = dropWhile ((> a) . fst) x
    inc a [] = Just [(a,1)]
    inc a x1@((b,p):x2) | a > b = Just ((a,1) : x1)
                        | p+1 < k = Just ((a,p+1) : x2)
                        | a-1 > 0 = inc (a-1) x2
                        | otherwise = Nothing

try as k = isJust $ try0 as k

try0 as k = foldM (step k) (0, []) as

readBInt :: B.ByteString -> Int
readBInt = fst . fromJust . B.readInt

tmain :: B.ByteString -> Int
tmain cont =
  let remLines0 = map B.words (B.lines cont)
      [bs_n]:remLines1 = remLines0
      n = readBInt bs_n
      line2:remLines2 = remLines1
      as = map readBInt line2
  in solve n as

outAnswer :: Int -> IO ()
outAnswer = putStrLn . show

main :: IO ()
main = outAnswer . tmain =<< B.getContents


Measured memory_bytes: 15612
#include<bits/stdc++.h>
using namespace std;
#define watch(x) cout<<(#x)<<" is "<<(x)<<endl;
#define mod 1000000007
#define pb push_back
#define endl '\n'
#define mp make_pair




int main()
{
	ios_base::sync_with_stdio(false); 
	cin.tie(NULL);
	cout.tie(0);

	int n;
	cin>>n;

	string s= to_string(n);

	if(s[s.size()-1]=='2' || s[s.size()-1]=='4' || s[s.size()-1]=='5' || s[s.size()-1]=='7'||s[s.size()-1]=='9')
	{
		cout<<"hon";
	}
	else if(s[s.size()-1]=='3') cout<<"bon";
	else cout<<"pon";

	cout<<endl;
}




Measured memory_bytes: 3700
#include <bits/stdc++.h>
#define FASTIO ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define LL long long int
using namespace std;

const int N = 1e5 + 5;
const int oo = 1e9 + 5;
const int MOD = 1e9 + 7;

void solve() {
    int n;
    cin >> n;
    LL ans = 0;
    for (int i=1;i<=n;++i) {
        for (int j=i;j<=n;j+=i) {
            ans += j;
        }
    }
    cout << ans << '\n';
} 

int main() {
    FASTIO;
    int t = 1;
    // cin >> t;
    while(t--) solve();
    return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
int int_abc(long long n) {
    string str="abcdefghijklmnopqrstuvwxyz";
    
        return str[n%26];
    
}

int main() {
   long long N;
   cin >> N;
   vector<char> data;
   bool limit =false;
   while(limit==false) {
       data.push_back(int_abc(N-1));
       N--;
       N/=26;
       
       if (N==0) {
           limit = true;
       }
   }
   int len=data.size();
   for (int i=0;i<len;i++) {
       cout << data[len-1-i];
   }
   
   cout << endl;
   
}

Measured memory_bytes: 3628
n, m = map(int, input().split())
G = [[] for _ in range(n)]
for _ in range(m):
    a, b = map(lambda x: int(x) - 1, input().split())
    G[a].append(b)
    G[b].append(a)


from collections import deque
q = deque([[0, 0]])
visited = [0] * n
visited[0] = 1
while q:
    node, c = q.popleft()
    if c > 2:
        continue
    if node == n-1:
        print('POSSIBLE')
        break

    for to in G[node]:
        if visited[to] == 1:
            continue
        visited[to] = 1
        q.append([to, c+1])
else:
    print('IMPOSSIBLE')

Measured memory_bytes: 51084
N = int(input())
#x, y = map(int, input().split())
#a = [list(map(int, input().split())) for _ in range(N)]
v = list(map(int, input().split()))
#s = input()
v.sort()
ans = (v[0] + v[1])/2
for i in range(2, N):
    ans = (ans + v[i])/2
print(ans)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define range(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i, a) range(i, 0, a)
using namespace std;

int main() {
    int N, M, X, Y;
    cin >> N >> M >> X >> Y;
    vector <int> x(N), y(M);
    rep(i, N) cin >> x[i];
    rep(i, M) cin >> y[i];
    x.push_back(X);
    y.push_back(Y);
    sort(x.begin(), x.end());
    sort(y.begin(), y.end());
    string va = (x.back() < y.front() ? "No " : "");
    cout << va + "War" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
typedef long long ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const long long INF = 1LL << 60;
const long long MOD = 998244353;

ll dp[3010];
ll dpdp[3010];

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

  rep(i, n){
    int a; cin >> a;
    REP(j, 0, s){
      dpdp[j] = dp[j] * 2;
      if(j-a >= 0){
        dpdp[j] += dp[j-a];
      }
    }
    dpdp[0]++;
    dpdp[a]++;
    REP(j, 0, s){
      dpdp[j] %= MOD;
      dp[j] = dpdp[j];
    }
  }

  cout << dp[s] << endl;

  return 0;
}


Measured memory_bytes: 3680
//https://atcoder.jp/contests/abc125/tasks/abc125_a
#include<bits/stdc++.h>
using namespace std;
#define TEMPLATE
#ifdef BTK
#define DEBUG if(1)
#else
#define CIN_ONLY if(1)
struct cww {cww() {CIN_ONLY{ios::sync_with_stdio(false); cin.tie(0);}}}star;
#define DEBUG if(0)
#endif
#define ALL(v) (v).begin(),(v).end()
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline bool chmin(T &l, T r){bool a = l>r; if (a)l = r; return a;}
template <typename T>inline bool chmax(T &l, T r){bool a = l<r; if (a)l = r; return a;}
template <typename T>istream& operator>>(istream &is, vector<T> &v){for (auto &it : v)is >> it;return is;}
template<typename T>inline T& unused_var(T& v){return v;}
class reverse_range {private:struct I {int x;int operator*() {return x-1;}bool operator!=(I& lhs) {return x>lhs.x;}void operator++() {--x;}};I i, n;public:reverse_range(int n) :i({ 0 }), n({ n }){}reverse_range(int i, int n) :i({ i }), n({ n }){}I& begin() {return n;}I& end() {return i;}};
class range {private: struct I { int x; int operator*() { return x; }bool operator!=(I& lhs) { return x<lhs.x; }void operator++() { ++x; } }; I i, n;public:range(int n) :i({ 0 }), n({ n }) {}range(int i, int n) :i({ i }), n({ n }) {}I& begin() { return i; }I& end() { return n; }reverse_range operator!(){return reverse_range(*i,*n);}};
using LL = long long;

int main(){
    int a,b,t;
    cin>>a>>b>>t;
    cout<<b*(t/a)<<endl;
    return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
def input(): return sys.stdin.readline().rstrip()

def main():
    H=int(input())
    W=int(input())
    N=int(input())
    print(-(-N//max(H,W)))

if __name__ == '__main__':
    main()


Measured memory_bytes: 38256
#include <iostream>
#include <string>
#define REP(i,n) for(int i=0;i<(n);++i)
using namespace std;
typedef long long LL;

int main(){
  LL W, H, X, Y;
  cin >> W >> H >> X >> Y;
  int r2 = (W == X * 2) & (H == Y * 2);
  cout << (0.5D * W * H) << " " << r2 << endl;
}

Measured memory_bytes: 384
N = int(input())
judge = []
for i in range(N):
    judge.append(input())

counter = [0, 0, 0, 0]
for i in range(N):
    if judge[i] == "AC":
        counter[0] += 1
    if judge[i] == "WA":
        counter[1] += 1
    if judge[i] == "TLE":
        counter[2] += 1
    if judge[i] == "RE":
        counter[3] += 1

print("AC x " + str(counter[0]))
print("WA x " + str(counter[1]))
print("TLE x " + str(counter[2]))
print("RE x " + str(counter[3]))

Measured memory_bytes: 16080
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    int num = (N - M) * 100 + M * 1900;
    while(M--) {
        num *= 2;
    }
    cout << num << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define deb(x)   cout<<"> "<<#x<<" : "<<x<<endl;
#define deb2(x,y)cout<<"> "<<#x<<"->"<<x<<"  "<<#y<<"->"<<y<<endl;
#define LINE   cout << "--- LINE NO : " << __LINE__ <<"  ---"<< endl;
#define pnr(a)   for(auto x:a){cout<<x<<" ";}cout<<endl;
#define pnr2(a)  for(auto x:a){cout<<x.first<<" "<<x.second<<endl;}
#define   pi       2*acos(0.0)
#define   inf      (int)1e18
const int mod =    1e9 + 7, mxn =    2e5 + 5;

#define   vt       vector
#define   ff       first
#define   ss       second
#define   int      long long
#define   db       long double
#define   pii      pair<int,int>
#define   Maxpq(x) priority_queue<x>
#define   Minpq(x) priority_queue<x,vt<x>,greater<x>>

#define   pb       push_back
#define   si(x)    (int)x.size()
#define   all(x)   x.begin(),x.end()
#define   mem(a,x) memset(a,x,sizeof(a))
#define   rep(n)    for(int i =0 ; i<n ; i++)
#define   forr(i,n) for(int i=0;i<n;i++)
#define   FOR(a)   for(auto& x :  a )

int mainx() {
    int n;
    cin >> n;
    if (n == 0)
        cout << 1 << endl;
    else
        cout << 0 << endl;
    return 0;
}


bool cmp(pii &a , pii &b) {
    if (a.ff < b.ff)return true;
    if (a.ff == b.ff )return a.ss < b.ss;
    return false;
}
inline void INCLUDE() {
#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
//freopen("out.txt","w",stdout);
#endif
}
int32_t main() {

    //INCLUDE();

    ios::sync_with_stdio(0);
    cin.tie(NULL); cout.tie(NULL);
    //cout << fixed << setprecision(20);

    int tt = 1;
    //cin>>tt;
    for (int t = 1 ; t <= tt ; t++ )
    {
        // cout<<"Case #"<<t<<": ";
        mainx();
    }
    return 0 ;
}



Measured memory_bytes: 3600
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline int my_getchar_unlocked(){
  static char buf[1048576];
  static int s = 1048576;
  static int e = 1048576;
  if(s == e && e == 1048576){
    e = fread_unlocked(buf, 1, 1048576, stdin);
    s = 0;
  }
  if(s == e){
    return EOF;
  }
  return buf[s++];
}
inline void rd(int &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = my_getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = my_getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
struct MY_WRITER{
  char buf[1048576];
  int s;
  int e;
  MY_WRITER(){
    s = 0;
    e = 1048576;
  }
  ~MY_WRITER(){
    if(s){
      fwrite_unlocked(buf, 1, s, stdout);
    }
  }
}
;
MY_WRITER MY_WRITER_VAR;
void my_putchar_unlocked(int a){
  if(MY_WRITER_VAR.s == MY_WRITER_VAR.e){
    fwrite_unlocked(MY_WRITER_VAR.buf, 1, MY_WRITER_VAR.s, stdout);
    MY_WRITER_VAR.s = 0;
  }
  MY_WRITER_VAR.buf[MY_WRITER_VAR.s++] = a;
}
inline void wt_L(char a){
  my_putchar_unlocked(a);
}
inline void wt_L(const char c[]){
  int i=0;
  for(i=0;c[i]!='\0';i++){
    my_putchar_unlocked(c[i]);
  }
}
int main(){
  int D;
  rd(D);
  int T;
  rd(T);
  int S;
  rd(S);
  if(T*S >= D){
    wt_L("Yes");
    wt_L('\n');
  }
  else{
    wt_L("No");
    wt_L('\n');
  }
  return 0;
}
// cLay varsion 20200906-1

// --- original code ---
// {
//   int @D, @T, @S;
//   wt(if[T*S >= D, "Yes", "No"]);
// }


Measured memory_bytes: 3560
#include <algorithm>
#include <string.h>
#include <cmath>
#include <stdio.h>

int main()
{
	const double EPS = 1.0e-10;
	double a,b,c,d,e,f;
	double x1,x2,x3,y1,y2,y3;
	double x,y;
	int n;
	int i;
	scanf("%d",&n);
	for(i = 0; i < n; i++){
		scanf("%lf %lf %lf %lf %lf %lf", &x1, &y1, &x2, &y2, &x3, &y3);
		a = x1 - x2;
		b = y1 - y2;
		c = (x1 * x1 + y1 * y1 - x2 * x2 - y2 * y2) / 2;
		d = x1 - x3;
		e = y1 - y3;
		f = (x1 * x1 + y1 * y1 - x3 * x3 - y3 * y3) / 2;
		x = (e * c - b * f) / (a * e - b * d);
		y = (a * f - d * c) / (a * e - b * d);
		if(-0.0005 < x && x < 0.0+EPS) x = 0.0;
        if(-0.0005 < y && y < 0.0+EPS) y = 0.0;

		printf("%.3f %.3f %.3f\n",x,y,sqrt((x1 - x) * (x1 - x) + (y1 - y) * (y1 - y)));
	}
	return 0;
}

Measured memory_bytes: 1092
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <numeric>
#include <ctime>
#include <complex>
#include <bitset>
#include <random>
#include <climits>
#include <stack>

using namespace std;

typedef long long ll;
typedef long double ld;

#define int ll
#define double ld
#define loop(i, n) for(int i = 0; i < (int)n; ++i)
#define loop1(i, n) for(int i = 1; i <= (int)n; ++i)
#define F first
#define S second
#define pb push_back
#define pi pair <int, int>
#define all(x) begin(x), end(x)
#define ti tuple <int, int, int>
#define Point Vect
#define no {cout << -1; return;}
#define yes {cout << "Yes"; return;}
#define mkp make_pair
#define mkt make_tuple
#define cerr if(0) cerr

void solve() {
    string ss;
    deque <char> s;
    bool rev = 0;
    cin >> ss;
    for (char c : ss)
        s.pb(c);
    int q; cin >> q;
    loop(i, q) {
        int t; cin >> t;
        if (t == 1)
            rev = !rev;
        else {
            int f; char c;
            cin >> f >> c;
            if ((f == 1 && !rev) || (f == 2 && rev))
                s.push_front(c);
            else
                s.push_back(c);
        }
    }
    while (!s.empty()) {
        if (!rev) {
            cout << s.front(); s.pop_front();
        }
        else {
            cout << s.back(); s.pop_back();
        }
    }
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    solve();
    return 0;
}


Measured memory_bytes: 4080
n = int(input())
arr = list(map(int, input().split()))

for i, v in enumerate(arr):
  if i == 0:
    arr[i] = v - 1
  else:
    if v - arr[i-1] > 0:
      arr[i] = v - 1
    elif v - arr[i-1] < 0:
      print("No")
      break
else:
  print("Yes")


Measured memory_bytes: 15020
url = "https://atcoder.jp/contests/abc082/tasks/arc087_a"
import copy
def main():
    n = int(input())
    li = list(map(int, input().split()))
    inds = {}
    ans = 0
    for i in range(len(li)):
        inds.setdefault(li[i], 0)
        inds[li[i]] += 1
    for k, v in inds.items():
        if k == v:
            pass
        elif k > v:
            ans += v
        elif k < v:
            ans += v - k
    print(ans)


if __name__ == '__main__':
    main()




Measured memory_bytes: 18540
#include <algorithm>
#include <iostream>
#include <list>
#include <map> //連想配列
#include <queue>
#include <set> //
#include <stack>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <vector> //動的配列

using namespace std;

int main() {
  int X, A, B;
  cin >> X >> A >> B;
  if (A >= B) {
    cout << "delicious" << endl;
  } else {
    if (B - A > X) {
      cout << "dangerous" << endl;
    } else {
      cout << "safe" << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#define P pair<ll,ll>
#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 TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
int gcd(int a,int b){if(a<b)swap(a,b);if(a%b==0)return b;return gcd(b,a%b);}
int lcm(int a,int b){int c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=1e18+7;
const ll MOD=1e9+7;
#define pri(a) cout << (a) << endl

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll N,P;
	cin >> N >> P;
	ll ans = 1;
	map<ll,ll> ma;
	ll PP = P;
	FOR(i,2,sqrt(P)+1){
		while(PP%i==0){
			PP/=i;
			ma[i]++;
		}
	}
	if(PP!=1)ma[PP]++;
	for(auto x:ma){
		ll n = x.second;
		ll a = x.first;
		while(n>=N){
			ans *= a;
			n-=N;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(void){
    int n;
    cin>>n;
    int h[n];
    for(int i=0;i<n;i++){
        cin>>h[i];
    }
    int num=0;
    int max=0;
    for(int i=0;i<n;i++){
        if(max<=h[i]){
            max=h[i];
            num++;
        }
    }
    cout<<num;
    return 0;
}

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

int main(void) {
    int N;
    int a[101];

    cin >> N;
    rep(i, N) {
        cin >> a[i];
    }

    int cost = numeric_limits<int>::max();
    for(int i=-100; i<=100; ++i) {
        int tmp = 0;
        rep(j, N) {
            tmp += pow(a[j]-i, 2);
        }
        cost = min(tmp, cost);
    }
    cout << cost << endl;
}

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

int main() {
    int i;
    int sum;
    string read,r;
    while(1){
        sum = 0;
        getline(cin, read);
        if(read.compare("0")==0) break;
        for(i=0;i<read.length();i++){
            r = read[i];
            sum += stoi(r);
        }
        cout << sum << endl;
    }
    return 0;
}


Measured memory_bytes: 3228
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UncheckedIOException;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) {
		SC sc = new SC(System.in);
		String s=sc.next();
		String[] a=s.split("/");
		int[] aa=new int[3];
		for(int i=0; i<3; i++) {
			aa[i]=Integer.parseInt(a[i]);
		}
		if(aa[0]>=2020) {
			pl("TBD");
		}
		else if(aa[0]==2019){
			if(aa[1]<=4) {
				pl("Heisei");
			}
			else {
				pl("TBD");
			}
		}
		else {
			pl("Heisei");
		}
	}
	static class SC {
		private BufferedReader reader = null;
		private StringTokenizer tokenizer = null;
		public SC(InputStream in) {
			reader = new BufferedReader(new InputStreamReader(in));
		}
		public String next() {
			if (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public double nextDouble() {
			return Double.parseDouble(next());
		}
		public String nextLine() {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new UncheckedIOException(e);
			}
		}
	}
	public static void pl(Object o) {
		System.out.println(o);
	}
	public static void pl() {
		System.out.println();
	}
	public static void p(Object o) {
		System.out.print(o);
	}
}

Measured memory_bytes: 21204
n = int(input())
res = [['a'],[],[],[],[],[],[],[],[],[]]
cha = ['a','b','c','d','e','f','g','h','i','j']

for x in range(1,n):
  for y in res[x-1]:
    for c in range(10):
      if cha[c] not in y:
        for d in range(c+1):
          res[x].append(y+cha[d])
        break
  if x > n + 1:
    break

for ans in range(len(res[n-1])):
  print(res[n-1][ans])


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

int main() {
    int A, B, C;
    cin >> A >> B >> C;
    bool pity = false;
    if (A == B && A != C) pity = true;
    if (A == C && A != B) pity = true;
    if (B == C && B != A) pity = true;

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(it,st,en) for(int it=(st);it<(int)(en);++it)
#define allof(c) (c).begin(), (c).end()
#define mt make_tuple
#define mp make_pair
#define pb push_back
#define X first
#define Y second
typedef long long int ll; 
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<ll,ll> pii;
const int INF=(int)1e9; 
const double EPS=(ld)1e-7;


vector<vector<pii> > g;
vector<int> sz;
int n;
int cen = -1;
int dfs(int x, int p){
    sz[x] = 1;
    bool b = true;
    for(auto y:g[x]) if(y.X != p){
        sz[x] += dfs(y.X,x);
        if(2*sz[y.X] > n) b = false;
    }
    if(2*(n-sz[x]) > n) b = false;
    if(b) cen = x;
    return sz[x];
}

ll solve(int x, int p){
    ll ans = 0;
    for(auto y:g[x]) 
        if(y.X != p)
            ans += solve(y.X,x);
        else
            ans += 2*sz[x]*y.Y;
    return ans;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n;
    g.resize(n);
    sz.resize(n);
    rep(i,0,n-1){
        int a,b,c;
        cin>>a>>b>>c;
        --a,--b;
        g[a].emplace_back(b,c);
        g[b].emplace_back(a,c);
    }
    dfs(0,-1);
    dfs(cen,-1);
    ll ans = 0;
    ll mn = 1e9;
    ll mnn = -1;
    for(auto y:g[cen]){
        ans += solve(y.X,cen);
        mn = min(mn,y.Y);
        if(2*sz[y.X] == n) mnn = y.Y;
    }
    if(mnn != -1) mn = mnn;
    cout<<ans-mn<<endl;
    return 0;
}


Measured memory_bytes: 14976
n, k = list(map(int, input().split()))
sunuke_list = [0] * n
for i in range(k):
    treat_count = input()
    give_treat = list(map(int, input().split()))
    for j in give_treat:
        sunuke_list[j - 1] += 1
print(len([i for i in sunuke_list if i == 0]))


Measured memory_bytes: 9016
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#include <map>
typedef long long ll;
#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using Graph = vector<vector<int>>;


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;
}
ll modinv(ll a, ll m){
    ll b = m, u = 1, v = 0;
    while(b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if(u < 0) u += m;
    cout << u << endl;
    return u;
}

ll paty_counter(ll level, ll x){
    ll size = pow(2, level+2) - 3;
    ll pmi = pow(2, level) - 1;
    if(x == 0){
        return 0;
    }else if(level == 0){    
        return 1;
    }else{
        if(x <= (size - 1)/2){
            return paty_counter(level-1, x-1);
        }else{
            return pmi + 1 + paty_counter(level-1, x - pow(2, level+1) + 3 - 2);
        }
    }

}
 
int main() {
    string s;
    cin >> s;
    if(s == "RRR"){
        cout << 3 << endl;
    } else if (s=="SRR"){
        cout << 2 << endl;
    }else if(s=="RRS"){
        cout << 2 << endl;
    }else if(s=="SSS"){
        cout << 0 << endl;
    } else {
        cout << 1 << endl;
    }
}



Measured memory_bytes: 3620
// tsukasa_diary's programing contest code template
#include <bits/stdc++.h>
using namespace std;
#define TSUKASA_DIARY_S_TEMPLATE
// define
#define for_(i,a,b) for(int i=(a);i<(b);++i)
#define for_rev(i,a,b) for(int i=(a);i>=(b);--i)
#define allof(a) (a).begin(),(a).end()
#define minit(a,b) memset(a,b,sizeof(a))
#define size_of(a) int((a).size())
#define cauto const auto
// typedef
typedef long long lint;
typedef double Double;
typedef pair< int, int > pii;
template< typename T > using Vec = vector< T >;
template< typename T > using Matrix = Vec< Vec< T > >;
template< typename T > using USet = unordered_set< T >;
template< typename T, class C > using MyUSet = unordered_set< T, C >;
template< typename T, typename F > using UMap = unordered_map< T, F >;
template< typename T, typename F, class C > using MyUMap = unordered_map< T, F, C >;
// hash
class PiiHash { public: size_t operator () (const pii& p) const { return (p.first << 16) | p.second; } };
// popcount
inline int POPCNT(int x) { return __builtin_popcount(x); }
inline int POPCNT(lint x) { return __builtin_popcount(x); }
// inf
const int iINF = 1L << 30;
const lint lINF = 1LL << 60;
// eps
const Double EPS = 1e-9;
const Double PI = acos(-1);
// inrange
template< typename T >
inline bool in_range(T v, T mi, T mx) { return mi <= v && v < mx; }
template< typename T >
inline bool in_range(T x, T y, T W, T H) { return in_range(x,0,W) && in_range(y,0,H); }
// neighbor clockwise
const int DX[4] = {0,1,0,-1}, DY[4] = {-1,0,1,0};
const int DX_[8] = {0,1,1,1,0,-1,-1,-1}, DY_[8] = {-1,-1,0,1,1,1,0,-1};
// variable update
template< typename T > inline void modAdd(T& a, T b, T mod) { a = (a + b) % mod; }
template< typename T > inline void minUpdate(T& a, T b) { a = min(a, b); }
template< typename T > inline void maxUpdate(T& a, T b) { a = max(a, b); }
// converter
template< typename F, typename T >
inline void convert(F& from, T& to) {
	stringstream ss;
	ss << from; ss >> to;
}

template< typename T >
T extgcd(T a, T b, T& x, T& y) {
	T g = 1; x = 1; y = 0;
	if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x;
	return g;
}

template< typename T >
T invMod(T a, T mod) {
	T x, y;
	if (extgcd(a, mod, x, y) == 1) return (x + mod) % mod;
	return 0;
}

lint H, W, A, B;
lint src[300030], inv[100010];
const lint MOD = (lint)1e9 + 7;

void solve() {
	src[0] = 1; inv[0] = 1;
	
	for_(i,1,300030) src[i] = (src[i - 1] * i) % MOD;
	for_(i,1,100010) inv[i] = invMod(src[i], MOD);
	
	lint ans = 0;
	
	for_(w,B,W) {
		lint a1 = src[w + (H - A - 1)];
		a1 = (a1 * inv[w]) % MOD;
		a1 = (a1 * inv[H - A - 1]) % MOD;
		
		//if (H - A - 1 == 1) a1 = 1;
		
		lint a2 = src[A - 1 + (W - w - 1)] % MOD;
		a2 = (a2 * inv[A - 1]) % MOD;
		a2 = (a2 * inv[W - w - 1]) % MOD;
		
		//if (A - 1 == 0) a2 = 1;
		
		//cerr << a1 << " " << a2 << endl;
		
		lint add = (a1 * a2) % MOD;
		modAdd(ans, add, MOD);
	}
	
	cout << ans << endl;
}

int main() {
	cin >> H >> W >> A >> B;
	solve();
}

Measured memory_bytes: 3328
#include <cmath>
#include <iostream>

bool is_prime(int n) {
  for (int i = 2; i <= std::sqrt(n); ++i) {
    if (n % i == 0)
      return false;
  }
  return true;
}

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

  int x, count = 0;
  for (int i = 0; i < n; i++) {
    std::cin >> x;
    count += is_prime(x);
  }

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



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

int main() {
  // Nの入力
  int N,K;
  cin >> N >> K;

  int ans;
  int i = 0;
  bool flag = true;

  while(flag){
    if( pow(K,i) <= N ){
      i++;
    } else {
      ans = i;
      flag = false;
    }
  }

  if(flag == true){
    ans = 1;
  }

  cout << ans << endl;

}


Measured memory_bytes: 256
while True:
  n, x = map(int, input().split())
  if n == x == 0:
    break

  ans = 0
  for i in range(1,n+1):
    for j in range(1, n+1):
      if i == j:
        break
      for k in range(1, n+1):
        if j == k:
          break
        if i + j + k == x:
          ans += 1

  print(ans)


Measured memory_bytes: 5592
#include <iostream>
#include <set>
#include <vector>
#include <string>
#include <algorithm>
#include <iterator>
#include <map>
#include <utility>
#include <list>
#include <climits>
#include <bitset>
#include <numeric>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, n) for(auto i = (n).begin(); i != (n).end(); i++)
#define in_arr(type, a, n) copy_n(istream_iterator<type>(cin), n, (a).begin());
#define ll long long int

int main(){
    int n;
    cin >> n;
    set<int> m;
    rep(i, n){
        int a;
        cin >> a;
        m.insert(a);
    }
    cout << m.size() << endl;
    return 0;
}


Measured memory_bytes: 256
// Aizu Vol0 0025: Hit and Blow
// 2017.7.29

#include <stdio.h>
#include <stdlib.h>

int main()
{
	int a[4], b[4];
	int i, j;
	int hit, blow;

	while (scanf("%d%d%d%d", &a[0], &a[1], &a[2], &a[3]) == 4) {
		scanf("%d%d%d%d", &b[0], &b[1], &b[2], &b[3]);
		hit = blow = 0;
		for (i = 0; i < 4; i++) {
			if (a[i] == b[i]) hit++, a[i] = -1, b[i] = -2;
		}
		if (hit < 4) {
			for (i = 0; i < 4; i++) {
				if (a[i] < 0) continue;
				for (j = 0; j < 4; j++) {
					if (a[i] == b[j]) blow++;
				}
			}
		}
		printf("%d %d\n", hit, blow);
	}
	return 0;
}

Measured memory_bytes: 596
n = int(input())
a = list(map(int,input().split()))
a.append(0)
a.insert(0,0)
b = 0
for i in range(n+1):
    b += abs(a[i]-a[i+1])
for i in range(1,n+1):
    c = b + abs(a[i-1]-a[i+1]) - abs(a[i]-a[i+1])-abs(a[i]-a[i-1])
    print(c)

Measured memory_bytes: 14048