akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

// iterator
#define REP(i,init, n) for(lli i=init;i<n;i++)
#define REPE(i,init, n) for(lli i=init;i<=n;i++)
#define REPIT(it,container) for(auto it = container.begin(); it != container.end(); it++)
#define REPIT_R(it,container) for(auto it = container.rbegin(); it != container.rend(); it++)

// input
#define cin1(x)             cin >> x
#define cin2(x, y)          cin >> x >> y
#define cin3(x, y, z)       cin >> x >> y >> z
#define ncin1(n, x)         REP(i, 0, n) {cin1(x[i]);}
#define ncin2(n, x, y)      REP(i, 0, n) {cin2(x[i], y[i]);}
#define ncin3(n, x, y, z)   REP(i, 0, n) {cin3(x[i], y[i], z[i]);}

// output
#define cout1(x)         cout << #x << ": " << x << endl;
#define cout2(x, y)      cout << #x << ": " << x << ", " << #y << ": " << y << endl;
#define cout3(x, y, z)   cout << #x << ": " << x << ", " << #y << ": " << y << ", " << #z << ": " << z << endl;;
#define ncout1(n, x)     REP(i, 0, n) {cout << #x << "[" << i << "]: "<< x[i] << endl;}

#define coutp(p)         cout << #p << ":" <<  " (" << p.first << ", " << p.second << ")" << endl;

// sort
#define sort_r(x, y)        sort(x, y, greater<lli>()); // 降順(5,4,3,,,)

#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

typedef long long int lli;
typedef pair<lli, lli> P;
typedef tuple<lli, lli, lli> tup;

int main() {
    lli n,m;
    cin2(n,m);
    lli a[n];
    ncin1(n,a);
    priority_queue<lli> que;

    REP(i,0,n) {
        que.push(a[i]);
    }
    REP(i,0,m) {
        lli x = que.top();
        que.pop();
        que.push(x/2);
    }
    lli ans = 0;
    while(!que.empty()) {
        ans += que.top();
        que.pop();
    }
    cout << ans << endl;
}


Measured memory_bytes: 2168
#include<bits/stdc++.h>
#define ll long long
using namespace std;
string s;
ll a[5],ans;
int n;
int main()
{
	cin>>n;
	while(n--)
	{
		cin>>s;
		switch(s[0])
		{
			case 'M':a[0]++;break;
			case 'A':a[1]++;break;
			case 'R':a[2]++;break;
			case 'C':a[3]++;break;
			case 'H':a[4]++;break;
		}
	}
	for(int i=0;i<5;i++)
	for(int j=i+1;j<5;j++)
	for(int k=j+1;k<5;k++)
	ans+=a[i]*a[j]*a[k];
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
use proconio::{fastout, input};

use rand::prelude::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::time::SystemTime;

#[fastout]

fn calc_score(d: usize, c: &Vec<i64>, s: &Vec<[i64; 27]>, t: &Vec<usize>) -> i64 {
    let mut res = 0;
    let mut last: [usize; 26 + 1] = [0; 26 + 1];
    for day in 1..=d {
        let now_contest = t[day];
        res += s[day][now_contest];
        last[now_contest] = day;
        for contest in 1..=26 {
            res -= c[contest] * (day - last[contest]) as i64;
        }
    }
    res
}

fn get_time(time: SystemTime) -> f64 {
    time.elapsed().unwrap().as_secs_f64()
}

fn main() {
    let time = SystemTime::now();
    let mut rand = rand_pcg::Pcg64Mcg::new(890482);

    // input
    input! {
        d: usize,
        _c: [i64; 26],
        _s: [[i64; 26]; d],
    }

    let mut c = vec![0];
    c.extend(_c.iter());

    let mut s = vec![[0; 26 + 1]; d + 1];
    for day in 1..=d {
        for contest in 1..=26 {
            s[day][contest] = _s[day - 1][contest - 1]
        }
    }

    let mut t = vec![1; d + 1];

    // process
    let mut score = calc_score(d, &c, &s, &t);
    while get_time(time) < 1.95 {
        for _ in 1..=1000 {
            let b: usize = rand.gen_range(0, 2);
            if b == 0 {
                let day = rand.gen_range(1, d + 1);
                let contest = rand.gen_range(1, 26 + 1);

                let tmp = t[day];
                t[day] = contest;
                let next_score = calc_score(d, &c, &s, &t);
                if next_score > score {
                    score = next_score;
                } else {
                    t[day] = tmp;
                }
            } else {
                let day = rand.gen_range(1, d);

                let tmp = t[day];
                t[day] = t[day + 1];
                t[day + 1] = tmp;

                let next_score = calc_score(d, &c, &s, &t);
                if next_score > score {
                    score = next_score;
                } else {
                    t[day + 1] = t[day];
                    t[day] = tmp;
                }
            }
        }
    }

    for i in 1..=d {
        println!("{}", t[i]);
    }
}


Measured memory_bytes: 2376
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    N = int(input())
    A = [int(input()) for _ in range(N)]

    ans = 0
    amari = 0
    for a in A:
        if amari == 0:
            amari = a % 2
            ans += a // 2
        else:
            ans += min(amari, a)
            a = max(0, a - amari)
            ans += a // 2
            amari = a % 2

    print(ans)

    
    
    

if __name__ == '__main__':
    main()



Measured memory_bytes: 12992
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
count=0
for i,b in enumerate(B):
    attack=min(b,A[i]+A[i+1])
    count+=attack
    A[i+1]-=max(0,attack-A[i])
print(count)

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

typedef long long llint;
typedef long double ld;

#define inf 1e18
#define mod 1000000007
priority_queue<llint,vector<llint>,greater<llint> > que;
priority_queue<llint> q;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

map<string,bool> mp;
int n;
string s;
set<string>x;
void solve(){
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> s;
        x.insert(s);
    }
    cout << x.size() << endl;
}

int main(){
  solve();
  return 0;
}


Measured memory_bytes: 19120
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n,m;
ll ds[11];
  
int main(){
while(true){
scanf("%d%d", &n, &m);
if(n+m==0)return 0;
for(int i=0;i<=10;i++)ds[i]=0;
while(n--){
ll d;
int x;
scanf("%lld%d",&d,&x);
ds[x] += d;
}
ll ans = 0;
for(int i=10;i>=0;i--){
ll use = min((ll)m, ds[i]);
ds[i] -= use;
m -= use;
ans += i * ds[i];
}
printf("%lld\n", ans);
  
}
}



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

int main(){
  int N,K,Q;
  cin>>N>>K>>Q;
  vector<int> B(Q);
  vector<int> A(N,K-Q);
  for(int i=0;i<Q;i++){
    cin>>B.at(i);
    A.at(B.at(i)-1)++;
  }
  
  for(int i=0;i<N;i++){
    if(A.at(i)>0){
      cout<<"Yes"<<endl;
    }else{
      cout<<"No"<<endl;
    }
  }
}

Measured memory_bytes: 4060
#include <iostream>
#include <queue>
#include <functional>
#include <algorithm>

using namespace std;

using ll = long long int;

ll arr[300010] = {};

ll resL[100010] = {};

int main(void){
    
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll k,sum = 0,result = 0,sum1 = 0;
    cin >> k;
    
    priority_queue<ll, vector<ll>, greater<ll> > que;
    priority_queue<ll> que1;
    
    for(int i = 0; i < 3*k; i++){
        cin >> arr[i];
        if(i >= k) continue;
        sum += arr[i];
        que.push(arr[i]);
    }
    
    resL[0] = sum;
    
    for(int i = 0; i < k; i++){
        
        sum1 += arr[3*k-(i+1)];
        que1.push(arr[3*k-(i+1)]);
        
        que.push(arr[i+k]);
        ll a = que.top();
        que.pop();
        
        sum += arr[i+k]-a;
        
        resL[i+1] = sum;
    }
    
    /// left
    
    result = resL[k] - sum1;
    
    for(int i = 1; i <= k; i++){
        
        que1.push(arr[2*k-i]);
        ll a = que1.top();
        que1.pop();
        
        sum1 += arr[2*k-i]-a;
        
        result = max(resL[k-i] - sum1,result);
    }
    
    /// right
    
    cout << result << endl;
}


Measured memory_bytes: 5492
using System;

public class hello
{
	public static void Main()
	{
		while (true)
		{
			var w = int.Parse(Console.ReadLine().Trim());
			if (w == 0) break;
			var m = int.Parse(Console.ReadLine().Trim()) - 1;
			var hit = int.Parse(Console.ReadLine().Trim()) - 1;
			var h = int.Parse(Console.ReadLine().Trim());
			var a = new int[h, w];
			var b = new string[h];
			for (int i = 0; i < h; i++)
				for (int j = 0; j < w; j++) a[i, j] = -1;
			for (int i = 0; i < h; i++)
			{
				var s = Console.ReadLine().Trim();
				b[i] = s;
				for (int j = 0; j < w - 1; j++)
					if (s[j] == '1') { a[i, j] = j + 1; a[i, j + 1] = j; }
			}
			if (w == 1) Console.WriteLine(0);
			else if (w == 2) getAns2(a, b, h, m, hit);
			else getAns(a, b, h, w, m, hit);
		}
	}
	static void getAns2(int[,] a, string[] b, int h, int m, int hit)
	{
		if (Amida(a, h, m) == hit) { Console.WriteLine(0); return; }
		for (int i = 0; i < h; i++)
			if (b[i] == "0") { Console.WriteLine("{0} 1", i + 1); return; }
		Console.WriteLine(1);
	}
	static void getAns(int[,] a, string[] b, int h, int w, int m, int hit)
	{

		if (Amida(a, h, m) == hit) { Console.WriteLine(0); return; }
		for (int i = 0; i < h; i++)
			for (int j = 0; j < w - 1; j++)
			{
				if ((j == 0 && b[i][0] == '0' && b[i][1] == '0') |
					(j == w - 2 && b[i][w - 2] == '0' && b[i][w - 3] == '0') |
					(j > 0 && j < w - 2 && b[i][j - 1] == '0' && b[i][j] == '0' && b[i][j + 1] == '0'))
				{
					a[i, j] = j + 1;
					a[i, j + 1] = j;
					if (Amida(a, h, m) == hit) { Console.WriteLine("{0} {1}", i + 1, j + 1); return; }
					a[i, j] = -1;
					a[i, j + 1] = -1;
				}
			}
		Console.WriteLine(1);
	}
	static int Amida(int[,] a, int h, int s)
	{
		var now = s;
		for (int i = 0; i < h; i++)
			now = a[i, now] != -1 ? a[i, now] : now;
		return now;
	}
}



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

int main(){
    int n;
    cin >> n;
    
    vector<int> t(n);
    rep(i,n) cin >> t[i];
    
    int total = 0;
    rep(i,n) total += t[i];
    
    int m;
    cin >> m;
    
    vector<pair<int, int>> drink(m);
    rep(i,m) cin >> drink[i].first >> drink[i].second;
    
    
    vector<int> ans(m);
    rep(i,m){
        int sum = total;
        int p,x;
        tie(p,x) = drink[i];
        sum -= t[p-1];
        sum += x;
        cout << sum << endl;
    }
}


Measured memory_bytes: 256
#pragma GCC optimize ("Ofast")
#pragma GCC optimize ("unroll-loops")
#include <bits/stdc++.h>
#define DAU  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define PLEC exit(0);
using namespace std;
string a, b;
int main() {
    DAU
    cin >> a >> b;
    cout << b << a;
    PLEC
}


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

int main(){
	int a,b;
	cin>>a>>b;
	int c;
	if(b==100){
		c=1000*a+b;
	}
	else if(b>9){
		c=100*a+b;
	}
	else{
		c=10*a+b;
	}
	for(int i=0;i<400;i++){
		if(c==i*i){
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	cout<<"No"<<endl;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<iostream>
#include<fstream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<climits>
#include<set>
#include<map>
#include<cmath>
#include<iomanip>
#include<iterator>
#include<queue>
#include<stack>
#include<cctype>
#include<deque>
#include<time.h>
#include<bitset>
#include<random>
#include<unordered_set>
#include<unordered_map>
#include<sstream>
#include<random>
#include<numeric>

//by Skeef79

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

#pragma warning(disable : 4996)
#pragma comment(linker, "/STACK:16777216")
#define pb push_back
#define en '\n'
#define for0(i,n) for(int i = 0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define vec vector
#define pii pair<int,int>
#define pll pair<ll,ll>
#define what_is(x) cout<<#x<<" is "<<x<<en;

using namespace std;

const int INF = 2000000000;
const ll LINF = 2000000000000000000;

template<typename T> void print(vector<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cout << a[i] << ' ';
	cout << en;
}

template<typename T> void print(deque<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cout << a[i] << ' ';
	cout << en;
}

template<typename T> void print(vector<vector<T>>& a)
{
	for (int i = 0; i < a.size(); i++)
	{
		for (int j = 0; j < a[i].size(); j++)
			cout << a[i][j] << ' ';
		cout << en;
	}
}

template <typename T> void input(vector<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cin >> a[i];
}

template<typename T> void input(deque<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cin >> a[i];
}

template<typename T> void input(vector<vector<T>>& a)
{
	for (int i = 0; i < a.size(); i++)
		for (int j = 0; j < a[i].size(); j++)
			cin >> a[i][j];
}

void solve()
{
	int n;
	cin >> n;
	vector<ll>a(n);
	vector<ll>cnt(n+1);
	for (int i = 0; i < n; i++)
	{
		int x;
		cin >> x;
		cnt[x]++;
		a[i] = x;
	}
	ll ans = 0;
	for (auto to : cnt)
		ans += to * (to - 1) / 2;

	for (auto to : a)
	{
		cout << ans - cnt[to] + 1;
		cout << en;
	}
}

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

#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
#endif

	int tst = 1;
	//cin >> tst;
	while (tst--)
		solve();
}

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

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

ll lcm(ll a, ll b) {
    return a * b / gcd(a, b);
}

int main(){
    ll a, b;
    cin >> a >> b;

    ll ans = lcm(a, b);

    cout << ans << endl;
}

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

bool ispal(string V) {
	for (int i = 0; i < V.size(); i++) {
		if (V[i] != V[V.size() - 1 - i]) return false;
	}
	return true;
}

int main() {
	string S; cin >> S;
	string T = S.substr(0, S.size() / 2);
	string U = S.substr(S.size() / 2 + 1, S.size() / 2);
	if (ispal(S) == true && ispal(T) == true && ispal(U) == true) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<cmath>
#include<bitset>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
const int INF=1e9;
const double eps=1e-9;
const int maxn=2e3+10;
const int maxsum=4e6+10;
int a[maxn],Sum[maxn];
bitset <maxsum> dp;
inline int read(){
	int x=0,flag=1;
	char ch=getchar();
	while(!isdigit(ch) && ch!='-')ch=getchar();
	if(ch=='-')flag=-1,ch=getchar();
	while(isdigit(ch))x=(x<<3)+(x<<1)+ch-'0',ch=getchar();
	return x*flag;
}
int main(){
	int i,j,k,m,n,sum=0;
	n=read();
	for(i=1;i<=n;i++)a[i]=read(),sum+=a[i];
	sort(a+1,a+n+1);
	for(i=1;i<=n;i++)Sum[i]=Sum[i-1]+a[i];
	dp[0]=1;
	for(i=1;i<=n;i++)dp|=dp<<a[i];
	for(i=(sum+1)/2;i<=sum;i++)
		if(dp[i]){
			printf("%d\n",i);
			return 0;
		}
	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<ll,ll> P;
#define M 1000000007
#define F first
#define S second
#define PB push_back
#define INF 100000000000000000
ll n,k,dp[100105],h[100105];
int main(void){
    scanf("%lld%lld",&n,&k);
    for(int i=0;i<n;i++)scanf("%lld",h+i);
    for(int i=0;i<=n;i++)dp[i]=INF;
    dp[0]=0;
    for(int i=0;i<n-1;i++){
        for(int j=1;j<=k;j++){
            dp[i+j]=min(dp[i+j],dp[i]+abs(h[i+j]-h[i]));
        }
    }
    printf("%lld\n",dp[n-1]);
}


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

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(lol i=0;i<lol(n);i++)
#define REPD(i,n) for(lol i=n-1;i>=0;i--)
#define FOR(i,a,b) for(lol i=a;i<=lol(b);i++)
#define FORD(i,a,b) for(lol i=a;i>=lol(b);i--)
#define VL vector<lol>
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() //sortなどの引数を省略したい
#define SIZE(x) lol(x.size()) //sizeをsize_tからllに直しておく
//定数
#define PI 3.1415926535897932385 //pi
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//最大値最小値
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}

lol dp[1005][10005], n;
lol a[1005], b[10005];

lol f(lol idx, lol hp)
{
    if(hp <= 0) return 0;
    if(idx > n) return INF;
    lol *sol = &dp[idx][hp];
    if(*sol != -1) return *sol;
    return *sol = min(f(idx+1, hp), f(idx, hp - a[idx])+b[idx]);
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    lol result{0};
    lol h; cin >> h >> n;
    FOR(i, 1, n)
    {
        cin >> a[i] >> b[i];
    }
    memset(dp, -1, sizeof(dp));
    result = f(1, h);

    cout << result << '\n';
    return 0;
}

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

using std::min;
using std::max;

const int N=810,Inf=1e9+10;

int n,m,k,sx,sy;
int d[N][N];
bool map[N][N],inq[N][N];

void Init() {
	scanf("%d%d%d",&n,&m,&k);
	for (int i=1;i<=n;++i) {
		for (int j=1;j<=m;++j) {
			char ch=getchar();
			while (ch!='.' && ch!='#' && ch!='S') ch=getchar();
			if (ch=='#') map[i][j]=1;
			if (ch=='S') sx=i,sy=j;
		} 
	} 
} 

std::pair<int,int>que[N*N]; 
void Bfs(int x,int y) {
	int h=0,t=0; que[++t]=std::make_pair(x,y);
	for (int i=1;i<=n;++i) 
		for (int j=1;j<=m;++j) d[i][j]=Inf;
	d[x][y]=0;
	while (h!=t) {
		std::pair<int,int> u=que[++h]; int dnow=d[u.first][u.second];
		if (dnow>k || map[u.first][u.second]) { d[u.first][u.second]=Inf; continue;}
		if (u.first>1 && d[u.first-1][u.second]>dnow+1) { 
			d[u.first-1][u.second]=dnow+1;
			if (!inq[u.first-1][u.second]) que[++t]=std::make_pair(u.first-1,u.second),inq[u.first-1][u.second]=1;
		}
		if (u.first<n && d[u.first+1][u.second]>dnow+1) { 
			d[u.first+1][u.second]=dnow+1;
			if (!inq[u.first+1][u.second]) que[++t]=std::make_pair(u.first+1,u.second),inq[u.first+1][u.second]=1;
		}
		if (u.second>1 && d[u.first][u.second-1]>dnow+1) { 
			d[u.first][u.second-1]=dnow+1;
			if (!inq[u.first][u.second-1]) que[++t]=std::make_pair(u.first,u.second-1),inq[u.first][u.second-1]=1;
		}
		if (u.second<m && d[u.first][u.second+1]>dnow+1) { 
			d[u.first][u.second+1]=dnow+1;
			if (!inq[u.first][u.second+1]) que[++t]=std::make_pair(u.first,u.second+1),inq[u.first][u.second+1]=1;
		}
	} 
}

void Solve() {
	Bfs(sx,sy);
	int dis=max(n,m); 
	for (int i=1;i<=n;++i)
		for (int j=1;j<=m;++j) if (d[i][j]!=Inf) {
			dis=min(dis,min(min(i-1,n-i),min(j-1,m-j)));
		}
	printf("%d\n",(dis+k-1)/k+1);
}

int main() {
	Init();
	Solve(); 
	return 0;
}

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

int main(){
	int n,ans=0;
	stack< pair<int,int> > q;
	cin >> n;
	q.push({0,0});
	while(!q.empty()){
		auto k = q.top();
		q.pop();
		if(k.first<=n&&k.second==7)ans++;
		if(k.first<=n/10){
			q.push({k.first*10+3,k.second|1});
			q.push({k.first*10+5,k.second|2});
			q.push({k.first*10+7,k.second|4});
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<unordered_map>
#include<array>
#include<map>
#include<bitset>
#include<iomanip>
#include<list>
#include <numeric>
using namespace std;
typedef unsigned long long int ulint;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
#define RE return 0
//ios::sync_with_stdio(false);
//std::cin.tie(0);
//<< setprecision(20)
const int mod=(int)1e9+7;
const llint big=(llint)(2.19e15+1);
const long double pai=3.141592653589793238462643383279502884197;
const long double ena=2.71828182845904523536;
const long double eps=1e-7;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
template <class T> void soun(T& ar)
{sort(ar.begin(),ar.end());ar.erase(unique(ar.begin(),ar.end()),ar.end());}
llint gcd(llint a,llint b){if(a%b==0){return b;}else{return gcd(b,a%b);}}
llint lcm(llint a,llint b){return a/gcd(a,b) *b;}
template<class T,class U> auto LB(T& ve,U in){return lower_bound(ve.begin(),ve.end(),in);}
template<class T,class U> auto UB(T& ve,U in){return upper_bound(ve.begin(),ve.end(),in);}
template<class T,class U> auto LBI(T& ve,U in){return LB(ve,in)-ve.begin();}
template<class T,class U> auto UBI(T& ve,U in){return UB(ve,in)-ve.begin();}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
int main(void){
	int n;cin>>n;
	llint a=big,b=-big,c=0;
	while(n--){
		llint d;cin>>d;
		mineq(a,d);
		maxeq(b,d);
		c+=d;
	}
	cout<<a<<" "<<b<<" "<<c<<endl;
	RE;
}


Measured memory_bytes: 3120
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <bitset>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define index(xs, x) (int)(lower_bound(all(xs), x) - xs.begin())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007

int N;
string S;
int X[1<<26];

signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> S;
  N = S.length();
  rep(i, 1<<26) X[i] = INF;
  X[0] = 0;
  int b = 0;
  rep(i, N) {
    b ^= 1<<(S[i]-'a');
    rep(k, 26) X[b] = min(X[b], X[b^(1<<k)]+1);
  }
  cout << max(X[b], 1) << "\n";
  return 0;
}


Measured memory_bytes: 262736
#include <iostream>
using namespace std;
int main(void){
  int x,a,b;
  cin >> x >> a >>b;
  
  int c = b - a;
  
  if(c <= 0)
    cout << "delicious" << endl;
  else if(c <= x)
    cout << "safe" << endl;
  else
    cout << "dangerous" << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
using ll = long long;
using ld = long double;
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
using pll = pair<long long,long long>;
#define cY cout<<"Yes"<<endl
#define cN cout<<"No"<<endl
const long long INF = 1LL << 60;
const long long MOD = 1000000007;
const long double pi = (acos(-1));
#define pb push_back
#define vs vector<string>

//最大最小の入れ替え
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;
}

//約数列挙
vector<long long> divisor(long long n) {
    vector<long long> ret;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    sort(ret.begin(), ret.end()); // 昇順に並べる
    return ret;
}
//コンビネーション
ll nCr(ll n, ll r) {
    ll ans = 1;
    for (ll i = n; i > n - r; --i) {
        ans = ans*i;
    }
    for (ll i = 1 ; i < r + 1; ++i) {
        ans = ans / i;
    }
    return ans;
}
//素因数分解
map< ll, ll > prime_factor(ll n) {
  map< ll, ll > ret;
  for(ll i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}

//切り上げの割り算は(a + b - 1) / bでできる

//ここから
int main(){
    ll N;
    cin>>N;
    cout<<(N+1)/2<<endl;
}


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


typedef unsigned long long ULONG;
typedef long long LONG;
using namespace std;

#define PI 3.1415926535897932384626433
#define _DBG_





int main(void) {
	vector<int> price;
	int N, K;
	cin >> N >> K;
	for (int i = 0; i < N; i++) {
		int tmpi;
		cin >> tmpi;
		price.push_back(tmpi);
	}
	sort(price.begin(), price.end());
	
	int sum = 0;
	for (int i = 0; i < K; i++) {
		sum += price[i];
	}

	cout << sum << endl;



	return 0;
}


Measured memory_bytes: 3632
n,m=map(int, input().split())
s=input()
t=input()
def euc(x,y):
  if max(x,y) % min(x,y)==0:
    return min(x,y)
  else:
    return euc(max(x,y) % min (x,y),min(x,y))
d=euc(n,m)
ans=n*int(m/d)
if d==1:
  if s[0]==t[0]:
    print(n*m)
  else:
    print(-1)
else:
  for i in range(d):
    if s[i*int(n/d)]!=t[i*int(m/d)]:
      ans=-1
  print(ans)


Measured memory_bytes: 3316
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	static boolean p[]=new boolean[1000000];

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int i,j,count,a,d,n;
		Arrays.fill(p, true);
		p[0]=p[1]=false;
		for(i=2;i<=1000;i++){
			if(p[i]){
				for(j=2;i*j<1000000;j++){
					p[i*j]=false;
				}
			}
		}
		while(true){
			a=sc.nextInt();
			d=sc.nextInt();
			n=sc.nextInt();
			if(a+d+n==0) break;
			count=0;
			for(;;){
				if(p[a]) count++;
				if(count==n){
					System.out.println(a);
					break;
				}
				a+=d;
			}
		}
	}

}

Measured memory_bytes: 13000
import sys
sys.setrecursionlimit(10**7)
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return sys.stdin.readline().strip()
INF = 10 ** 18
MOD = 10 ** 9 + 7

def main(): 
    N = II()
    A = LI()
    B = LI()

    A_sum = sum(A)  # モンスターの合計数

    # 貪欲

    for i in range(N):
        # まずは自分と同じ番号の町を見る。
        if A[i] >= B[i]: # 街にいるモンスターのほうが多いとき
            A[i] -= B[i]  # 倒せるだけ倒す。
            B[i] = 0
        else: # 勇者の能力のほうが高いとき
            B[i] -= A[i]
            A[i] = 0

        # 次に次の街の面倒を見る。
        if A[i+1] >= B[i]:
            A[i+1] -= B[i]  # 倒せるだけ倒す。
            B[i] = 0
        else: # 勇者の能力のほうが高いとき
            B[i] -= A[i+1]
            A[i+1] = 0

    print(A_sum - sum(A))


main()

Measured memory_bytes: 19228
#include <bits/stdc++.h>
      
#define FOR(i,a,b) for( ll i = (a); i < (ll)(b); i++ )
#define REP(i,n) FOR(i,0,n)
#define YYS(x,arr) for(auto& x:arr)
#define ALL(x) (x).begin(),(x).end()
#define SORT(x) sort( (x).begin(),(x).end() )
#define REVERSE(x) reverse( (x).begin(),(x).end() )
#define UNIQUE(x) (x).erase( unique( ALL( (x) ) ) , (x).end() )
#define PW(x) (1LL<<(x))
#define SZ(x) ((ll)(x).size())
#define SHOW(x) cout << #x << " = " << x << endl
#define SHOWA(x,n) for( int i = 0; i < n; i++ ){ cout << x[i] << " "; } cout << endl

#define pb emplace_back
#define fi first
#define se second
     
using namespace std;

typedef long double ld;
typedef long long int ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<ld> vd;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<vpl> gr;
typedef vector<vl> ml;
typedef vector<vd> md;
typedef vector<vi> mi;
     
const ll INF = (ll)1e9 + 10;
const ll INFLL = (ll)1e18 + 10;
const ld EPS = 1e-12;
const ll MOD = 1e9+7;
     
template<class T> T &chmin( T &a , const T &b ){ return a = min(a,b); }
template<class T> T &chmax( T &a , const T &b ){ return a = max(a,b); }
template<class T> inline T sq( T a ){ return a * a; }

ll in(){ ll x; scanf( "%lld" , &x ); return x; }
char yuyushiki[1000010]; string stin(){ scanf( "%s" , yuyushiki ); return yuyushiki; }

// head


int n, q;
ll a[100010];
int t;

ll ts[100010];
ll ans[100010];

int main(){

  n = in();
  q = in();
  a[t++] = n;
  REP( i , q ){
    ll x = in();
    while( t > 0 and a[t-1] >= x ){
      t--;
    }
    a[t++] = x;
  }

  // SHOWA( a , t );

  ts[t-1] = 1;
  for( int i = t-1; i >= 0; i-- ){
    ll cur = a[i];
    while( 1 ){
      int ne = upper_bound( a , a+i , cur ) - a - 1;
      if( ne == -1 ){
	break;
      }
      assert( a[ne] <= cur );
      ts[ne] += ts[i] * ( cur / a[ne] );
      ll prv = cur;
      cur %= a[ne];
    }
    ans[1] += ts[i];
    ans[1+cur] -= ts[i];
  }

  FOR( i , 1 , n ){
    ans[i+1] += ans[i];
  }

  FOR( i , 1 , n+1 ){
    printf( "%lld\n" , ans[i] );
  }

  return 0;
}


Measured memory_bytes: 4096
/* ITP1_9_C */
import java.io.*;

class Main
{
  public static void main(String[] args)
  {
    try{
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      StringBuilder sb = new StringBuilder();

      int n = Integer.parseInt(br.readLine());
      int taro = 0;
      int hanaco = 0;

      for(int i = 0; i < n; i++){
        String[] str = br.readLine().split(" ");
        String taro_card = str[0];
        String hanaco_card = str[1];

        if(taro_card.compareTo(hanaco_card) > 0) taro += 3;
        else if(taro_card.compareTo(hanaco_card) < 0 ) hanaco += 3;
        else if(taro_card.equals(hanaco_card)){
          taro++;
          hanaco++;
        }
      }
      sb.append(taro).append(" ").append(hanaco);
      System.out.println(sb);
    }catch(Exception e){
      System.out.println(e);
    }
  }
}

Measured memory_bytes: 25052
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;   
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define sz(a) (ll)(a.size())
int main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int d,t,s;
	cin>>d>>t>>s;
	if(d > t*s)
		cout<<"No\n";
	else
		cout<<"Yes\n";
	return 0;
}

Measured memory_bytes: 3612
n = int(input())

a = [int(input()) for i in range(n)]

a_max = max(a)
a_max_count = a.count(a_max)

if a_max_count > 1:
  for i in range(n):
    print(a_max)
    
else:
  print(max(a[1:]))
  
  for i in range(1, n-1):
    if a[i] == a_max:
      print(max(max(a[:i]), max(a[i+1:])))
      
    else:
      print(a_max)

  print(max(a[:-1]))

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

using namespace std;

using ll = long long;

int const maxn = 101010;
int const mod = 1e9 + 7;

vector<int> v[maxn];
int dp[maxn][2];

// color = 1 can color black
// color = 0 can color white
int solve(int x, int p, int color) {
    int& d = dp[x][color];

    if (d != -1) return d;

    d = 1;

    for (int u : v[x]) {
        if (u == p) continue;

        if (color == 1) {
            d = (ll)d*solve(u, x, 0)%mod;
        }
        else {
            int temp = solve(u, x, 0) + solve(u, x, 1);
            if (temp >= mod) {
                temp -= mod;
            }

            d = (ll)d*temp%mod;
        }
    }
    return d;
}

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

    int n;
    cin >> n;

    for (int i = 0; i < n-1; i++) {
        int a, b;
        cin >> a >> b;

        v[a].push_back(b);
        v[b].push_back(a);
    }

    memset(dp, -1, sizeof(dp));

    cout << (solve(1, 1, 1) + solve(1, 1, 0))%mod << "\n";
}

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

int main(){
  int a, b, c;
  cin >> a >> b >> c;
  
  if( a < b && b < c ){
    cout << "Yes" << endl;
    return 0;
  }
  
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 3100
module.exports=function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=0)}([function(e,t,r){r(1)(r(2).readFileSync("/dev/stdin","UTF-8"))},function(e,t){e.exports=function(e){for(var t=e.split("\n"),r=Number(t[0]),n=t[1].split(" ").map(function(e){return Number(e)-1}),o=t[2].split(" ").map(function(e){return Number(e)}),u=t[3].split(" ").map(function(e){return Number(e)}),i=o[n[0]],f=n[0],l=1;l<r;l++)i+=o[n[l]],n[l]==f+1&&(i+=u[n[l]-1]),f=n[l];console.log(i)}},function(e,t){e.exports=require("fs")}]);

Measured memory_bytes: 7372
#include <iostream>

using namespace std;

int H, W, K;
int dp[101][8];

int isValidAmida(int cur) {

	bool prev = false;
	for (int i = 0; i < W - 1; i++) {
		if (cur & 1) {
			if (prev) {
				return false;
			}
			prev = true;

		} else {
			prev = false; 
		}
		cur = cur / 2;
	}
	return true;
}

int pos(int cur, int x) {
	if (x == 0) {
		if (cur & 1) {
			return 1;
		}
		return 0;
	}

	cur = cur >> (x - 1);

	if (cur & 1) {
		return x - 1;
	}
	if (cur & 2) {
		return x + 1;
	}
	return x;
}

int main() {

	cin >> H >> W >> K;
	K--;

	for (int y = 0; y < H + 1; y++) {
		for (int x = 0; x < W; x++) {
			dp[y][x] = 0;
		}
	}
	int max_bit = 1;
	for (int i = 0; i < W - 1; i++) {
		max_bit *= 2;
	}
	//cout << "max_bit:" << max_bit << endl;




	dp[H][K] = 1;
	for (int y = H - 1; y >= 0; y--) {
		//cout << "y:" << y << endl;
		for (int x = 0; x < W; x++) {
		//cout << "x:" << x << endl;

			for (int i = 0; i < max_bit; i++) {
				//cout << "i:" << i << endl;
				int cur = i;
				if (isValidAmida(cur) == false) continue;
				//cout << "cur:" << cur << endl;
				dp[y][x] = (dp[y][x] + dp[y+1][pos(cur, x)] % 1000000007) % 1000000007 ; 
			}
		}
	}
	int result = 0;
	for (int x = 0; x < W; x ++) {
		result = (result + dp[0][x]) % 1000000007 ; 
	}
	cout << dp[0][0] << endl;
	/*
	cout << result << endl;
	for (int y = 0; y <= H; y++) {
		for (int x = 0; x < W; x++ ) {
			cout << dp[y][x] << "*";
		}
		cout << endl;
	}
	*/
	
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
public class Main
{
	private void solve()throws Exception
	{
		long n=nextLong();
		int ans=0;
		for(long i=2;i*i<=n;i++)
		{
			int p=0;
			while(n%i==0)
			{
				p++;
				n=n/i;
			}
			int j;
			for(j=1;j*(j+1)/2<=p;j++);
			j--;
			ans+=j;
		}
		if(n>1)
			ans++;
		out.println(ans);
	}

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

	public void run()throws Exception
	{
		br=new BufferedReader(new InputStreamReader(System.in));
		st=null;
		out=new PrintWriter(System.out);

		solve();
		
		br.close();
		out.close();
	}
	public static void main(String args[])throws Exception{
		new Main().run();
	}
	BufferedReader br;
	StringTokenizer st;
	PrintWriter out;
	String nextToken()throws Exception{
		while(st==null || !st.hasMoreTokens())
		st=new StringTokenizer(br.readLine());
		return st.nextToken();
	}
	String nextLine()throws Exception{
		return br.readLine();
	}
	int nextInt()throws Exception{
		return Integer.parseInt(nextToken());
	}
	long nextLong()throws Exception{
		return Long.parseLong(nextToken());
	}
	double nextDouble()throws Exception{
		return Double.parseDouble(nextToken());
	}
}

Measured memory_bytes: 32932
import sys
n = int(input())
A = [int(e)for e in sys.stdin]
cnt = 0
G = [int((2.25**i-1)/1.25)for i in range(17,0,-1)]
G = [v for v in G if v <= n]
def insertionSort(A, n, g):
    global cnt
    for i in range(g, n):
        v = A[i]
        j = i - g
        while j >= 0 and A[j] > v:
            A[j+g] = A[j]
            j = j - g
            cnt += 1
        A[j+g] = v
for g in G:
    insertionSort(A, n, g)
print(len(G))
print(*G)
print(cnt)
print(*A,sep='\n')


Measured memory_bytes: 53352
import sys
input = sys.stdin.readline


def read():
    K, A, B = list(map(int, input().strip().split()))
    return K, A, B


def solve(K, A, B):
    ans = 1
    if B-A <= 1:
        ans += K
        return ans
    if K < A-1:
        ans += K
        return ans
    ans += (A-1)
    k = K-A+1
    ans += (B-A) * (k//2) + k % 2
    return ans


if __name__ == '__main__':
    inputs = read()
    outputs = solve(*inputs)
    if outputs is not None:
        print("%s" % str(outputs))


Measured memory_bytes: 9200
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val N, K = sc.nextInt()
  val head :: tail = loop(K, List(K, Int.MaxValue))

  @scala.annotation.tailrec
  def loop(div: Int, acc: List[Int]): List[Int] = {
    if (div == 1) acc else {
      val d = math.ceil(div / 2.0).toInt
      loop(d, d :: acc)
    }
  }

  @scala.annotation.tailrec
  def counts(head: Int, list: List[Int], acc: List[Int]): List[Int] = {
    list match {
      case List() => acc
      case x :: xs if head < N && x <= N => counts(x, xs, (x - head) :: acc)
      case x :: xs if head <= N && N < x => counts(x, xs, (N - head + 1) :: acc)
      case x :: xs => counts(x, xs, 0 :: acc)
    }
  }

  val powCounts = counts(head, tail, List.empty)
  val denominator = powCounts.zipWithIndex.reverse.collectFirst {
    case (count, i) if 0 < count => math.pow(2.0, i) * N
  }.getOrElse(1.0)
  val molecule = powCounts.reverse.zipWithIndex.collect {
    case (count, i) if 0 < count => math.pow(2.0, i) * count
  }.sum
  println(molecule / denominator)
}


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

int main(){
    ll l,r,d; cin >> l >> r >> d;
    ll res=0;
    for(int i=l;i<=r;i++){
        if(i%d==0) res++;
    }
    cout << res << endl;
}

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

int main() {
	vector<char> v;
	int n; cin >> n;
	string s;
	cin >> s;
	for (int i = 0; i < n; i++) {
		v.push_back(s[i]);
	}
	int r = 0, b = 0;
	for (int j = 0; j < n; j++) {
		if (v[j] =='R') {
			r = r + 1;
		}
		else {
			b = b + 1;
		}
	}
	if (b < r) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}
	system("pause");
	return 0;
}

Measured memory_bytes: 504
#include<stdio.h>
#define N 100
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n, M[N][N];
int color[N], d[N], f[N], tt;

void dfs_visit(int u) {
  int v;
  color[u] = GRAY;
  d[u] = ++tt;
  for ( v = 0; v < n; v++ ) {
    if ( M[u][v] == 0) continue;
    if ( color[v] == WHITE )
      dfs_visit(v);
  }
  color[u] = BLACK;
  f[u] = ++tt;
}

void dfs() {
  int u;
  for ( u = 0; u < n; u++ ) color[u] = WHITE;
  tt = 0;

  for ( u = 0; u < n; u++ )
    if ( color[u] == WHITE ) dfs_visit(u);
  for ( u = 0; u < n; u++ )
    printf("%d %d %d\n", u + 1, d[u], f[u]);
}

int main() {
  int u, v, k, i, j;

  scanf("%d", &n);
  for ( i = 0; i < n; i++ )
    for ( j = 0; j < n; j++ ) M[i][j] = 0;

  for ( i = 0; i < n; i++ ) {
    scanf("%d %d", &u, &k);
    u--;
    for ( j = 0; j < k; j++ ) {
      scanf("%d", &v);
      v--;
      M[u][v] = 1;
    }
  }

  dfs();

  return 0;
}


Measured memory_bytes: 2044
#include <stdio.h>
#include <stdlib.h>

int cmp(int *a, int *b);
void reverse(int count[4]);
void sort(int card[5]);
void sort2(int count[4]);

int main(void){
	int card[5], count[4];
	int i;
	while(scanf("%d,%d,%d,%d,%d", &card[0], &card[1], &card[2], &card[3], &card[4]) != EOF){
		for(i = 0;i < 4;i++){
			count[i] = 1;
		}
		
		qsort(card, 5, sizeof(int), cmp);

		for(i = 1;i < 5;i++){
			if(card[0] == card[i]){
				count[0]++;
			} else {
				break;
			}
		}

		for(i = count[0] + 1;i < 5;i++){
			if(card[count[0]] == card[i]){
				count[1]++;
			} else {
				break;
			}
		}

		if(count[0] + count[1] <= 4){
			for(i = count[0] + count[1] + 1;i < 5;i++){
				if(card[count[0] + count[1]] == card[i]){
					count[2]++;
				} else {
					break;
				}
			}

			if(count[0] + count[1] + count[2] <= 4){
				for(i = count[0] + count[1] + count[2] + 1;i < 5;i++){
					if(card[count[0] + count[1] + count[2]] == card[i]){
						count[3]++;
					} else {
						break;
					}
				}
			}
		}

		qsort(count, 4, sizeof(int), cmp);
		reverse(count);


		if(count[0] == 4){
			printf("four card\n");
		} else if(count[0] == 3 && count[1] == 2){
			printf("full house\n");
		} else if((card[0] == card[1] - 1 && card[0] == card[2] - 2 && card[0] == card[3] - 3 && card[0] == card[4] - 4)|| (card[0] == 1 && card[1] == 10 && card[2] == 11 && card[3] == 12 && card[4] == 13)){
			printf("straight\n");
		} else if(count[0] == 3){
			printf("three card\n");
		} else if(count[0] == 2 && count[1] == 2){
			printf("two pair\n");
		} else if(count[0] == 2){
			printf("one pair\n");
		} else {
			printf("null\n");
		}
	}

	return 0;
}

int cmp(int *a, int *b){
	return *a < *b ? -1 : *a > *b;
}

void sort(int card[5]){
	int i, j, temp;

	for(i = 0;i < 5;i++){
		for(j = 4;j > i;j--){
			if(card[j] < card[j - 1]){
				temp = card[j - 1];
				card[j - 1] = card[j];
				card[j] = temp;
			}
		}
	}
}


void sort2(int count[4]){
	int i, j, temp;

	for(i = 0;i < 4;i++){
		for(j = 3;j > i;j--){
			if(count[j] > count[j - 1]){
				temp = count[j - 1];
				count[j - 1] = count[j];
				count[j] = temp;
			}
		}
	}
}

void reverse(int count[4]){
	int i, temp[4];
	for(i = 0;i < 4;i++){
		temp[i] = count[3 - i];
	}

	for(i = 0;i < 4;i++){
		count[i] = temp[i];
	}
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<vector<int>> g(n);
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    --x; --y;
    g[x].push_back(y);
    g[y].push_back(x);
  }
  vector<bool> mark(n);
  function<int(int)> Dfs = [&](int v) {
    mark[v] = 1;
    int res = 1;
    for (int to : g[v]) {
      if (!mark[to]) {
        res += Dfs(to);
      }
    }
    return res;
  };
  int res = 0;
  for (int i = 0; i < n; i++) {
    if (!mark[i]) {
      int cur = Dfs(i);
      res = max(res, cur);
    }
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 26556
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 2147483647 / 2;
const long long int llINF = 9223372036854775807 / 2;

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define SP(a) setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))
#define UNIQUE(vec)                                                            \
  do {                                                                         \
    sort(ALL((vec)));                                                          \
    (vec).erase(std::unique(ALL((vec))), (vec).end());                         \
  } while (0)

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp);
  } else {
    return (n * POW(n, m - 1));
  }
}

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

void func(vvl &G, vl &P, vl &A, ll s, ll p) {
  if (p != -1)
    A[s] = A[p] + P[s];
  else
    A[s] = P[s];
  REP(j, G[s].size()) {
    if (G[s][j] != p) {
      func(G, P, A, G[s][j], s);
    }
  }
  return;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll N, Q;
  cin >> N >> Q;
  vvl G(N);
  vl P(N, 0);
  vl A(N, 0);
  REP(i, N - 1) {
    ll a, b;
    cin >> a >> b;
    a--;
    b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  REP(i, Q) {
    ll p, x;
    cin >> p >> x;
    p--;
    P[p] += x;
  }
  func(G, P, A, 0, -1);
  REP(i, N) cout << A[i] << endl;
  return 0;
}


Measured memory_bytes: 28928
$n = gets.chomp

n_size = $n.size

$n = $n.to_i

count = 0

def factorial(number)
  (1..number).inject(1,:*)
end

def x(i, remain, has3, has5, has7)
#	p [i, remain, has3, has5, has7]
	if remain == 1 then
		result = 0
		result += 1 if (i * 10 + 3) <= $n && has5 && has7
		result += 1 if (i * 10 + 5) <= $n && has3 && has7
		result += 1 if (i * 10 + 7) <= $n && has3 && has5
#		p ["result", result]
		result
	else
		x(i * 10 + 3, remain -1, true, has5, has7) +
		x(i * 10 + 5, remain -1, has3, true, has7) +
		x(i * 10 + 7, remain -1, has3, has5, true)
	end
end

(3..n_size).each{ |max|
	count += x(0, max, false, false, false)
}

puts count


Measured memory_bytes: 1788
#include <bits/stdc++.h>  
using namespace std;  
// Important header files   
#include <ext/pb_ds/assoc_container.hpp> // Common file  
#include <ext/pb_ds/tree_policy.hpp>  
#include <functional> // for less  
#include <iostream>  
using namespace __gnu_pbds;  
using namespace std;  
  
// Declaring ordered_set 
typedef tree<int, null_type, less<int>, rb_tree_tag,  
            tree_order_statistics_node_update>  
    ordered_set; 
#define rep(i,n) for(li i=0;i<n;i++)
#define li long long int
#define ll long long int
#define pb push_back
#define all(v) sort(v.begin(),v.end())
const int N = 40043;
const ll mod = 1e9 + 7;
#define FAST_IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define f first
#define s2 second
const ll INF=(1LL<<60)-1;


li gcd(li a,li b)
{
    if(b==0) return a;
    return gcd(b,a%b);
}
li lcm(li a,li b)
{
    return (a*b)/gcd(a,b);
}
li power(li a,li b)
{
    li res=1;
    while(b)
    {
        if(b&1)
        res=(res*a);
        a=((a)*(a));
        b>>=1;
    }
    return res;
}
 
li xx,yy,dd;
void equation(li a,li b)
{
    if(b==0)
    {
        xx=1;
        yy=0;
        dd=a;
    }
    else
    {
        equation(b,a%b);
        li temp=xx;
        xx=yy;
        yy=temp-(a/b)*yy;
    }
}
li inverse(li a,li m)
{
    equation(a,m);
    return(xx%m+m)%m;
}
bool compare(const pair<li,li> &i, pair<li,li> &j)
{
    if(i.f==j.f)
    return i.s2 > j.s2;
    else
    return i.f<j.f;
    
}


void solve()
{
    int x;
  cin>>x;
  if(x>=30)
  cout<<"Yes";
  else
  cout<<"No";
}
signed main()
{
   //seive();
   //cout<<prime.size();
   FAST_IO;
   int t;
   t=1;
   while(t--)
   {
       solve();
       cout<<endl;
      
   }
}

Measured memory_bytes: 3632
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	B
# CreatedDate:  2020-07-05 21:06:56 +0900
# LastModified: 2020-07-05 21:14:39 +0900
#


import os
import sys
# import numpy as np
# import pandas as pd
from collections import Counter

def main():
    n = int(input())
    s = []
    for _ in range(n):
        s.append(input())
    cnt = Counter(s)
    if 'AC' in cnt.keys():
        print("AC x {}".format(cnt['AC']))
    else:
        print("AC x 0")
    if 'WA' in cnt.keys():
        print("WA x {}".format(cnt['WA']))
    else:
        print("WA x 0")
    if 'TLE' in cnt.keys():
        print("TLE x {}".format(cnt['TLE']))
    else:
        print("TLE x 0")
    if 'RE' in cnt.keys():
        print("RE x {}".format(cnt['RE']))
    else:
        print("RE x 0")
 
    



if __name__ == "__main__":
    main()


Measured memory_bytes: 16612