akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#line 2 "/home/miurawakuya/git/verify_cplib/graph/tree/diameter.cpp"
#include <vector>
#include <utility>

#line 3 "/home/miurawakuya/git/verify_cplib/graph/graph_template.cpp"
template<typename T=long long>
struct edge {
public:
    int from;
    int to;
    T cost;
    edge(int from,int to,T cost):from(from),to(to),cost(cost){}
};

template<typename T>
using graph = std::vector<std::vector<edge<T>>>;//重み付きグラフ

using Graph = std::vector<std::vector<int>>;//重み無しグラフ
#line 6 "/home/miurawakuya/git/verify_cplib/graph/tree/diameter.cpp"

//G:グラフを管理してる型（vector<vector>やvector<set>を指定する）
//T:辺のコスト
template <typename T>
struct TreeDiam {
private:
    using G = graph<T>;
    int u,v;//直径の両端
    T maxdist;//直径
    void dfs(G &g,int x,int p,int dist) {
    //std::cerr<<"x:"<<x<<std::endl;
        if(dist>maxdist){
            v=x;
            maxdist=dist;
        }
        for(auto y:g[x]) {
            if(y.to==p)continue;
            dfs(g,y.to,x,dist+y.cost);
        }
    }

public:
    TreeDiam(G g) {
        u=0;//仮に置いた端点
        maxdist=0;
        dfs(g,u,-1,0);
    //std::cerr<<"md:"<<maxdist<<std::endl;
        u=v;
        maxdist=0;
        dfs(g,u,-1,0);
    }

    std::pair<int,int> end_nodes(){
        return std::make_pair(u,v);
    }

    T diameter(){
        return maxdist;
    }
};
#line 5 "diameter.test.cpp"

void solve() {
    int n;
    std::cin>>n;
    graph<int> G(n);
    for(int i = 0;i < n-1;++i) {
        int s,t,w;
        std::cin>>s>>t>>w;
        G[s].emplace_back(s,t,w);
        G[t].emplace_back(t,s,w);
    }
    TreeDiam<int> td(G);
    std::cout<<td.diameter()<<std::endl;
}

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



Measured memory_bytes: 16708
import qualified Data.ByteString.Char8 as C
import Data.List
import qualified Data.Vector.Unboxed as V

main = C.interact $ put . sol . get

get = V.tail . V.unfoldr (C.readInt . C.dropWhile (<'0'))

put = C.pack . unwords . fmap show

sol v = [max 1 n0, n0+n1]
  where
  (c0,c1) = V.partition (<8) $ V.map (`div` 400) v
  z0 = V.replicate 8 0 :: V.Vector Int
  p0 = V.zip c0 (V.replicate (V.length c0) 1 :: V.Vector Int)
  a0 = V.unsafeAccumulate (+) z0 p0
  n0 = V.length (V.filter (>0) a0)
  n1 = V.length c1

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

signed main(void)
{
	int n, k, j, cnt; cin >> n >> k;
	map<int, int> m;
	priority_queue<int, vector<int>, greater<int>> pq;

	cnt = 0;
	rep(i, n)
	{
		int a;
		cin >> a;
		m[a]++;
	}
	for(auto p : m) pq.push(p.second);
	j =  m.size() - k;
	rep(i, j)
	{
		cnt += pq.top();
		pq.pop();
	}
	cout << cnt << endl;
	return 0;
}


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

int main() {
  string S;
  cin >> S;
  if(S.at(2) == S.at(3)){
    if(S.at(4) == S.at(5)){
      cout << "Yes" << endl;
    }
    else{
      cout << "No" << endl;
    }
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <algorithm>
#include <unordered_map>

#define rep(i, a, b) for (ll i = a; i < b; i++)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef unordered_map<string, ll> u_map;

// input
void input() {}
template <class Head, class... Tail>
void input(Head &&a, Tail &&... b)
{
    cin >> a;
    input(forward<Tail>(b)...);
}

template <class V>
void input(vector<V> &v)
{
    for_each(v.begin(), v.end(), [](auto &i) { input(i); });
}

// output
template <class V>
void output(vector<V> &v)
{
    for_each(v.begin(), v.end(), [](auto &x) { cout << x << " "; });
    cout << endl;
}

// math functions
ll mpow(ll a, ll n, ll p)
{
    ll x = 1;
    while (n > 0)
    {
        if (n & 1)
        {
            x = a * x % p;
        }
        a = a * a % p;
        n >>= 1;
    }

    return x;
}

ll mfact(ll n, ll p)
{
    ll res = 1;
    for (ll i = 2; i <= n; i++)
    {
        res = res * i % p;
    }
    return res;
}

ll mcomb(ll n, ll r, ll p)
{
    if (n == 0 && r == 0)
    {
        return 1;
    }
    if (n < r || n < 0 || r < 0)
    {
        return 0;
    }

    ll a = mfact(n, p);
    ll b = mfact(n - r, p);
    ll c = mfact(r, p);
    return (((a * mpow(b, p - 2, p)) % p) * mpow(c, p - 2, p)) % p;
}

ll gcd(ll a, ll b)
{
    if (a < b)
    {
        a ^= b;
        b ^= a;
        a ^= b;
    }
    return b ? gcd(b, a % b) : a;
}

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

int main()
{
    ll X, Y;
    input(X, Y);

    ll res;
    if (X <= 3)
    {
        res += (4 - X) * 100000;
    }
    if (Y <= 3)
    {
        res += (4 - Y) * 100000;
    }

    res += (X == 1 && Y == 1) ? 400000 : 0;
    cout << res << endl;
    return 0;
}

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

int main(){
  ll n,m,k; cin >>n >>m >>k;
  vector<int> a(n);
  rep(i,n) cin >>a[i];
  ll total = 0;
  vector<int> b(m);
  rep(i,m) {
    cin >>b[i];
    total += b[i];
  }
  int ans = 0;
  int j = m;
  rep(i,n+1){
    while(j>0 && total>k){
      j--;
      total -= b[j];
    }
    if(total>k) break;
    ans = max(ans, i+j);
    if(i==n) break;
    total += a[i];
  }
  cout << ans << endl;
  return 0; 
}

Measured memory_bytes: 4824
#
# abc054 b
#
import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """3 2
#.#
.#.
#.#
#.
.#"""
        output = """Yes"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """4 1
....
....
....
....
#"""
        output = """No"""
        self.assertIO(input, output)


def resolve():
    N, M = map(int, input().split())
    A = [list(input()) for _ in range(N)]
    B = [list(input()) for _ in range(M)]

    ans = "No"
    for i in range(N-M+1):
        for j in range(N-M+1):
            ans = "Yes"
            for k in range(M):
                if ans == "No":
                    break
                for l in range(M):
                    if A[i+k][j+l] != B[k][l]:
                        ans = "No"
                        break
            if ans == "Yes":
                break
        if ans == "Yes":
            break

    print(ans)


if __name__ == "__main__":
    # unittest.main()
    resolve()


Measured memory_bytes: 16200
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <string>
#define SS(i) scanf("%s",i)
#define SC(i) scanf("%d",&i)
#define SCC(i,j) scanf("%d%d",&i,&j)
#define SCCC(i,j,z) scanf("%d%d%d",&i,&j,&z)
#define PR(i) printf("%d\n",i)
#define LL long long
#define FF(i,a,b) for(int i=a;i<=b;++i)
#define RR(i,a,b) for(int i=a;i>=b;--i)
#define CL(i,x) memset(i,x,sizeof(i))
#define IN freopen("in.txt","r",stdin)
#define OUT  freopen("out.txt","w",stdout)
#define PB(i) push_back(i)
#define lson x,m,rt<<1
#define rson m+1,y,rt<<1|1
#define mid int m=(x+((y-x)>>1))
#define ll rt<<1
#define rr rt<<1|1
#define pii pair<int, int>
#define mp(x, y) make_pair(x, y)
#define eq(x, y) (fabs(x-y) < eps)
#define forv(x, y) FF(y, 0, (int)x.size()-1)
using namespace std;

const int N = 1000 + 10;

char s[N];
int main()
{


    SS(s+1);
    int len = strlen(s+1);
    FF(i, 1, len-8) putchar(s[i]);
    return 0;
}


Measured memory_bytes: 256
#pragma optimization_level 3
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#include<bits/stdc++.h>

using namespace std;
 
#define  fastio         ios:: sync_with_stdio(0);cin.tie(0);cout.tie(0);cout<<fixed;cout<<setprecision(10);
#define  f              first                 
#define  s              second
#define  endl           "\n"
#define  pb             push_back  
#define  mset(a,x)      memset(a,x,sizeof(a))
#define  debv(a)        for(auto it: a)cout<<it<<" ";cout<<endl;
#define  deb1(a)        cout<<a<<endl;
#define  deb2(a,b)      cout<<a<<" "<<b<<endl;
#define  deb3(a,b,c)    cout<<a<<" "<<b<<" "<<c<<endl;
#define  deb4(a,b,c,d)  cout<<a<<" "<<b<<" "<<c<<" "<<d<<endl;            
 
typedef  long long             ll;
typedef  long double           ld;
typedef  pair<ll,ll>           pll;
typedef  vector<ll>            vll;
typedef  unordered_map<ll,ll>  um;
typedef  vector<pll>           vpll;
 
const ll   N     =  5e5+5;
const ll   mod   =  1e9+7;
const ll   INF   =  1e18;
const int  INFi  =  0x7f7f7f7f;

ll test = 1, n;
vll adj[N];

ll tree[N] = {};

void update(int idx, int val){ 
    idx++;
    while(idx <= N+1){ 
        tree[idx] += val;
        idx += idx & (-idx); 
    } 
} 

ll query(int idx){
    idx++;
    ll sum = 0;
    while(idx > 0){ 
        sum += tree[idx];
        idx -= idx & (-idx); 
    } 
    return sum; 
}

void solve(){
    cin>>n;
    for(int i = 0; i < n-1; i++){
        int u,v;
        cin>>u>>v;
        if(v > u) swap(u,v);
        adj[u].pb(v);
    }
    for(int i = 1; i <= n; i++) update(i,-1);
    ll sz = 0, ans = 0, ct = 0;
    for(int i = 1; i <= n; i++){
        for(auto it : adj[i]){
            update(it,1);
            ct += (i-1-it);
        }
        ct += query(i-1);
        sz += 1-adj[i].size();
        ans += i*sz;
        ans += ct;
    }
    deb1(ans)
}

int main(){
    fastio;
    //cin>>test;
    for(int i = 1; i <= test; i++){
        solve();
    }
}

Measured memory_bytes: 23084
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;
ll INF = 1LL << 60;
int main() {
  ll n;
  cin >> n;
  vector<string> ch = {"A", "C", "G", "T"};
  vector<map<string, ll>> m(2);
  for (const auto& a : ch) {
    for (const auto& b : ch) {
      for (const auto& c : ch) {
        string s = a + b + c;
        // cout << s << endl;
        if (s != "AGC" && s != "GAC" && s != "ACG") {
          m[1][s] = 1;
        } else {
          m[1][s] = 0;
        }
      }
    }
  }
  REP(i, 4, n + 1) {
    for (const auto& a : ch) {
      for (const auto& b : ch) {
        for (const auto& c : ch) {
          string s = a + b + c;
          m[i & 1][s] = 0;
        }
      }
    }
    for (auto& me : m[(i + 1) & 1]) {
      for (auto& d : ch) {
        string s = me.first + d;
        if (s[0] == 'A' && s[1] == 'G' && s[2] == 'C') continue;
        if (s[0] == 'G' && s[1] == 'A' && s[2] == 'C') continue;
        if (s[0] == 'A' && s[1] == 'C' && s[2] == 'G') continue;
        if (s[1] == 'A' && s[2] == 'G' && s[3] == 'C') continue;
        if (s[1] == 'G' && s[2] == 'A' && s[3] == 'C') continue;
        if (s[1] == 'A' && s[2] == 'C' && s[3] == 'G') continue;
        if (s[0] == 'A' && s[2] == 'G' && s[3] == 'C') continue;
        if (s[0] == 'A' && s[1] == 'G' && s[3] == 'C') continue;
        string ns = s.substr(1);
        m[i & 1][ns] = (m[i & 1][ns] + me.second) % MOD;
      }
    }
  }
  ll ans = 0;
  for (auto& me : m[n & 1]) {
    ans = (ans + me.second) % MOD;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rep_ll(i,n) for(ll i = 0; i < (ll)(n); i++)
using namespace std;
typedef long long ll;
typedef unsigned long long u_ll;
typedef pair<int, int> pair_;
const long double PI = (acos(-1));
const int INF = 1001001001;
const int dx[] = {-1, 0, 1, 0}; const int dy[] = {0, -1, 0, 1};
ll mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}//ｺﾝｽﾄﾗｸﾀxを()式で初期化
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {//演算子のｵｰﾊﾞｰﾛｰﾄﾞ
    if ((x += a.x) >= mod) x -= mod;
    return *this;//thisはﾒﾝﾊﾞ関数を呼び出したｵﾌﾞｼﾞｪｸﾄのｱﾄﾞﾚｽを取得できる
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {//powは本来べき乗
    if (!t) return 1;//t==0だと入る条件
    mint a = pow(t>>1);//tを二進数で表して累乗計算
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
  // 以下modが素数の場合
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
mint chose(ll n, ll a){
    mint x=1;   mint y=1;
    rep(i, a){
        x *= n-i;
        y *= i+1;
    }
    return x/y;//mintなので容易に書ける
}
int main(){
    ll n;
    cin >> n;
    ll a, b;
    cin >> a >> b;
    mint a_(2);
    mint ans = a_.pow(n);
    ans -= chose(n,a);
    ans -= chose(n,b);
    ans -= 1;
    cout << ans.x;
    return 0;
}

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


using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  int n, m;
  pair<int, int> student[50], point[50];
  cin >> n >> m;
  for(int i = 0; i < n; i++){
    cin >> student[i].first >> student[i].second;
  }
  for(int i = 0; i < m; i++){
    cin >> point[i].first >> point[i].second;
  }
  for(int i = 0; i < n; i++){
    long long ans = 0, dis = 400000000;
    for(int j = 0; j < m; j++){
      if(dis > llabs(student[i].first - point[j].first) + llabs(student[i].second - point[j].second)){
        ans = j + 1;
        dis = llabs(student[i].first - point[j].first) + llabs(student[i].second - point[j].second);
      }
    }
    cout << ans << "\n";
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cassert>
#include<math.h>
#include<complex>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<unordered_map>
#include<functional>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=2e18;
const ll MOD=1e9+7;

ll N;
map<string,ll> mp;
int main(){
    cin>>N;
    for(ll i=0;i<N;i++){
        string s;cin>>s;
        mp[s]++;
    }
    cout<<"AC x "<<mp["AC"]<<endl;
    cout<<"WA x "<<mp["WA"]<<endl;
    cout<<"TLE x "<<mp["TLE"]<<endl;
    cout<<"RE x "<<mp["RE"]<<endl;
    return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<functional>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<set>
#include<unordered_set>
#include<map>
#include<unordered_map>
typedef long long int ll;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<signed(n);i++)
#define EREP(i,n) for(int i=1;i<=signed(n);i++)
#define ALL(a) (a).begin(),(a).end()
using namespace std;
//#define EVEL 1
#ifdef EVEL
#define DEB(X) cout << #X <<":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const ll MOD = 1000000007;
const ll INF = 9e14;
typedef std::pair<ll,ll> P;
struct edge{ int to,cost; };
#define VMAX 100000

ll N,M,X,K,Q;
ll A,B,C,D;

ll ans;
bool F=false;
string S,T,U;
int main(){
    cin>>A;
    printf("%.07lf\n",(double)A*A*A/27.0);
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = RInt();
            int[] weights = RArInt();

            int res = int.MaxValue;
            for (int i = 0; i < weights.Length; i++)
            {
                int s1 = weights.Take(i).Sum();
                int s2 = weights.Skip(i).Take(weights.Length - i).Sum();
                res = Math.Min(res, Math.Abs(s1 - s2));
            }
            Console.WriteLine(res);
        }
        static string RSt() { return Console.ReadLine(); }
        static int RInt() { return int.Parse(Console.ReadLine().Trim()); }
        static long RLong() { return long.Parse(Console.ReadLine().Trim()); }
        static double RDouble() { return double.Parse(Console.ReadLine()); }
        static string[] RArSt(char sep = ' ') { return Console.ReadLine().Trim().Split(sep); }
        static int[] RArInt(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => int.Parse(e)); }
        static long[] RArLong(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => long.Parse(e)); }
        static double[] RArDouble(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => double.Parse(e)); }
        static string WAr<T>(IEnumerable<T> array, string sep = " ") { return string.Join(sep, array.Select(x => x.ToString()).ToArray()); }
    }
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,c=0;cin>>n;
  vector<int> p(n);
  for(int i=0; i<n; i++)cin>>p[i];
  for(int i=1; i<n-1; i++){
    if(p[i]==p[i-1]+p[i]+p[i+1]-(max({p[i-1],p[i],p[i+1]})+min({p[i-1],p[i],p[i+1]})))c++;
  }
  cout<<c<<endl;
}

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

int main(void)
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    while (true)
    {
        c -= b;
        if (c <= 0)
        {
            cout << "Yes" << endl;
            break;
        }
        a -= d;
        if (a <= 0)
        {
            cout << "No" << endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 3676
import itertools
while 1:
    n,m,s=map(int,input().split())
    if n==0:break
    dp=[[0 for _ in range(s+1)] for _ in range(n*n+1)]
    dp[0][0]=1
    for i,j in itertools.product(range(1,n*n+1),range(s+1)):
        if j>=i:dp[i][j]+=dp[i-1][j-i]+dp[i][j-i]
        if j-m>=1:dp[i][j]+=100000-dp[i-1][j-m-1]
        dp[i][j]%=100000
    print(dp[n*n][s])

Measured memory_bytes: 13108
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <functional>
#include <math.h>
#include <stdlib.h>
#include <map>
#include <deque>
#include <sys/timeb.h>
#include <fstream>

using namespace std;

#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define repi(itr,ds) for(auto itr=ds.begin();itr!=ds.end();itr++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define INF 1050000000
#define INFL 1100000000000000000LL
#define EPS (1e-10)
#define MOD 1000000007
#define PI 3.1415926536
#define RMAX 4294967295

typedef long long ll;
typedef pair<int, int> Pi;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<vector<int> > vvi;
typedef vector<vector<bool> > vvb;
typedef vector<vector<ll> > vvll;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<double> > vvd;
typedef vector<vector<Pi> > vvPi;
typedef priority_queue<int, vector<int>, greater<int> > pqli;
typedef priority_queue<ll, vector<ll>, greater<ll> > pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi> > pqlP;
struct Edge {
	int from, to, cost;
	bool operator<(Edge e) {
		return cost < e.cost;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
template <class T>
using vec = vector<T>;
template<class T>
using pql = priority_queue<T, vector<T>, greater<T>>;
string debug_show(Pi a) {
	return "(" + to_string(a.first) + "," + to_string(a.second) + ")";
}

template<class T>
struct augEdge {
	T from, to;
	int cost;
	bool operator<(augEdge e) { return cost < e.cost; }
	bool operator>(augEdge e) { return cost > e.cost; }
};
template<class T>
using augGraph = vector<augEdge<T>>;


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

	int x, a, b;
	cin >> x >> a >> b;
	if (a >= b) {
		cout << "delicious" << endl;
	}
	else {
		if (x >= b - a) {
			cout << "safe" << endl;
		}
		else {
			cout << "dangerous" << endl;
		}
	}

	return 0;
}


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

using namespace std;
#define ll long long
const ll mx=1e18+7;

int main() {
	int a, b, c;
	cin>>a>>b>>c;
	int sum= a+b+c;
	
	if((a==sum/2 || b==sum/2 || c==sum/2 ) && sum%2==0 ){
		cout<<"Yes"<<endl;
		}	
	else cout<<"No"<<endl;	
	return 0;
}


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

class UnionFind():
  def __init__(self, n):
    self.n = n                           # 要素数
    self.parents = [i for i in range(n)] # 要素の親
    self.rank = [0] * n                  # 木の深さ
    self.size = [1] * n                  # iを根とする集合の要素数

  def find(self, x):
    if self.parents[x] == x:
      return x
    else:
      # 経路圧縮
      self.parents[x] = self.find(self.parents[x])
      return self.parents[x]
    
  def union(self, x, y):
    root_x = self.find(x)
    root_y = self.find(y)
    
    if root_x != root_y:
      # 深さが小さい方を大きい方に併合する
      if self.rank[root_x] > self.rank[root_y]:
        self.parents[root_y] = root_x
        self.size[root_x] += self.size[root_y]
      else:
        self.parents[root_x] = root_y
        self.size[root_y] += self.size[root_x]
        if self.rank[root_x] == self.rank[root_y]:
          self.rank[root_y] += 1

N, M, K = map(int, input().split())
A = list()
B = list()
C = list()
D = list()
union_find = UnionFind(n=N)
direct_and_block_count = [0] * N
ans = ''
for i in range(M):
  a, b = map(int, input().split())
  A.append(a-1)
  B.append(b-1)
  union_find.union(a-1, b-1)
  direct_and_block_count[a-1] += 1
  direct_and_block_count[b-1] += 1
for i in range(K):
  c, d = map(int, input().split())
  C.append(c-1)
  D.append(d-1)
  if union_find.find(c-1) == union_find.find(d-1):
    # 同じ集合の場合
    direct_and_block_count[c-1] += 1
    direct_and_block_count[d-1] += 1

ans = [0] * N
for i in range(N):
  # 直接の友達、ブロック、自分自身を除く
  ans[i] = union_find.size[union_find.find(i)] - direct_and_block_count[i] - 1
print(*ans)

Measured memory_bytes: 110040
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define inf 1e+9
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }

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

    int n,m,ans1=0;
	cin >> n >> m;
	int k[m],s[m][n],p[m];

	rep(i,m){
		cin >> k[i];
		rep(j,k[i]){
			cin >> s[i][j];
		}
	}

	rep(i,m){
		cin >> p[i];
	}

	int sum[m],sw[n],count=0;

	rep(a,2){
	rep(o,2){
	rep(i,2){
	rep(u,2){
	rep(y,2){
	rep(t,2){
	rep(r,2){
	rep(e,2){
	rep(w,2){
	rep(q,2){
		sw[0] = q;
		sw[1] = w;
		sw[2] = e;
		sw[3] = r;
		sw[4] = t;
		sw[5] = y;
		sw[6] = u;
		sw[7] = i;
		sw[8] = o;
		sw[9] = a;
		// rep(b,10){
		// 	if(b>=n){
		// 		sw[b] = -100;
		// 	}
		// }
		rep(num,m){
			sum[num] = 0;
			rep(j,k[num]){
				sum[num] += sw[s[num][j]-1];
			}
		}
		int ans=0;
		rep(num,m){
			if(sum[num]%2==p[num]){
				ans++;
			}
		}
		if(ans==m){
			ans1++;
			//cout << sw[0] << sw[1] << endl;
		}
		count++;
		if(count==pow(2,n)){
			break;
		}
	}
	if(count==pow(2,n)){
			break;
		}
	}
	if(count==pow(2,n)){
			break;
		}
	}
	if(count==pow(2,n)){
			break;
		}
	}
	if(count==pow(2,n)){
			break;
		}
	}
	if(count==pow(2,n)){
			break;
		}
	}
	if(count==pow(2,n)){
			break;
		}
	}
	if(count==pow(2,n)){
			break;
		}
	}
	if(count==pow(2,n)){
			break;
		}
	}
	if(count==pow(2,n)){
			break;
		}
	}
	
	cout << ans1 << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n); i >= 0; i--)
#define loop(i, r, n) for (int i = (r); i < (n); i++)
#define pb push_back
#define all(in) in.begin(),in.end()

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; }

using ll = long long;
using ull = unsigned long long;
using namespace std;

int main(){
  int d, t, s; cin >> d >> t >> s;
  cout << (d <= t * s ? "Yes" : "No") << endl;
  return 0;
}

Measured memory_bytes: 3548
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.NoSuchElementException;

public class Main {
	static PrintWriter out;
	static InputReader ir;

	static void solve() {
		long a = ir.nextLong();
		long b = ir.nextLong();
		out.println((a * b % 2 == 0) ? "Even" : "Odd");
	}

	public static void main(String[] args) {
		ir = new InputReader(System.in);
		out = new PrintWriter(System.out);
		solve();
		out.flush();
	}

	static class InputReader {

		private InputStream in;
		private byte[] buffer = new byte[1024];
		private int curbuf;
		private int lenbuf;

		public InputReader(InputStream in) {
			this.in = in;
			this.curbuf = this.lenbuf = 0;
		}

		public boolean hasNextByte() {
			if (curbuf >= lenbuf) {
				curbuf = 0;
				try {
					lenbuf = in.read(buffer);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (lenbuf <= 0)
					return false;
			}
			return true;
		}

		private int readByte() {
			if (hasNextByte())
				return buffer[curbuf++];
			else
				return -1;
		}

		private boolean isSpaceChar(int c) {
			return !(c >= 33 && c <= 126);
		}

		private void skip() {
			while (hasNextByte() && isSpaceChar(buffer[curbuf]))
				curbuf++;
		}

		public boolean hasNext() {
			skip();
			return hasNextByte();
		}

		public String next() {
			if (!hasNext())
				throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while (!isSpaceChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}

		public int nextInt() {
			if (!hasNext())
				throw new NoSuchElementException();
			int c = readByte();
			while (isSpaceChar(c))
				c = readByte();
			boolean minus = false;
			if (c == '-') {
				minus = true;
				c = readByte();
			}
			int res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res = res * 10 + c - '0';
				c = readByte();
			} while (!isSpaceChar(c));
			return (minus) ? -res : res;
		}

		public long nextLong() {
			if (!hasNext())
				throw new NoSuchElementException();
			int c = readByte();
			while (isSpaceChar(c))
				c = readByte();
			boolean minus = false;
			if (c == '-') {
				minus = true;
				c = readByte();
			}
			long res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res = res * 10 + c - '0';
				c = readByte();
			} while (!isSpaceChar(c));
			return (minus) ? -res : res;
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}

		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;
		}

		public char[][] nextCharMap(int n, int m) {
			char[][] map = new char[n][m];
			for (int i = 0; i < n; i++)
				map[i] = next().toCharArray();
			return map;
		}
	}

	static void tr(Object... o) {
		out.println(Arrays.deepToString(o));
		out.flush();
	}
}


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

void main()
{
    auto nk = readln.split.to!(long[]);
    auto N = nk[0];
    auto K = nk[1];
    writeln(min(N - N/K*K, (N/K+1)*K - N));
}

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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define ff first
#define ss second
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int S = int(1e5)+10;
const ll MOD = ll(1e9)+7;

int dp[S], n, h[S];


int main() {
	cin.sync_with_stdio(0); cin.tie(0);
	cin >> n;
	rep(i, 0, n) 
		cin >> h[i];
	rep(i, 1, n) {
		dp[i] = dp[i-1] + abs(h[i] - h[i-1]);
		if(i > 1)
			dp[i] = min(dp[i], dp[i-2] + abs(h[i] - h[i-2]));
	}
	cout << dp[n-1] << endl;
	return 0;
}

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

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> x(n);
  rep(i, n) cin >> x[i];

  int d = 0;
  rep(i, n) d += 2 * min(x[i], k - x[i]);
  cout << d << endl;
  return 0;
}

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

int main(){
  int X;
  std::cin >> X;
  if (X <= 599){
  	std::cout << 8 << "\n";
  }else if (X <= 799){
    std::cout << 7 << "\n";
  }else if (X <= 999){
   	std::cout << 6 << "\n";
  }else if (X <= 1199){
  	std::cout << 5 << "\n";
  }else if (X <= 1399){
  	std::cout << 4 << "\n";
  }else if (X <= 1599){
  	std::cout << 3 << "\n";
  }else if (X <= 1799){
  	std::cout << 2 << "\n";
  }else {
  	std::cout << 1 << "\n";
  }
  return 0;
}


Measured memory_bytes: 3636
N,M,K = map(int,input().split())
AB = [tuple(map(int,input().split())) for i in range(M)]
CD = [tuple(map(int,input().split())) for i in range(K)]

class UnionFind:
    def __init__(self,N):
        self.parent = [i for i in range(N)]
        self.rank = [0] * N
        self.count = 0
    def root(self,a):
        if self.parent[a] == a:
            return a
        else:
            self.parent[a] = self.root(self.parent[a])
            return self.parent[a]
    def is_same(self,a,b):
        return self.root(a) == self.root(b)
    def unite(self,a,b):
        ra = self.root(a)
        rb = self.root(b)
        if ra == rb: return
        if self.rank[ra] < self.rank[rb]:
            self.parent[ra] = rb
        else:
            self.parent[rb] = ra
            if self.rank[ra] == self.rank[rb]: self.rank[ra] += 1
        self.count += 1

blocks = [[] for _ in range(N)]
for c,d in CD:
    c,d = c-1,d-1
    blocks[c].append(d)
    blocks[d].append(c)

friends = [0] * N
uf = UnionFind(N)
for a,b in AB:
    a,b = a-1,b-1
    friends[a] += 1
    friends[b] += 1
    if uf.is_same(a,b): continue
    uf.unite(a,b)
for i in range(N):
    uf.root(i)

from collections import Counter
ctr = Counter()
for i in range(N):
    r = uf.root(i)
    ctr[r] += 1

ans = []
for i in range(N):
    tmp = ctr[uf.root(i)] - 1 - friends[i]
    for b in blocks[i]:
        if uf.is_same(i,b):
            tmp -= 1
    ans.append(tmp)
print(*ans)

Measured memory_bytes: 63900
/*
adrui's submission
Language : C++
Result : Accepted
Love : ll
Favorite : Dragon Balls

Standing in the Hall of Fame
*/

#include<stdio.h>
#include<string.h>
typedef long long LL;

LL gcd(LL a, LL b) {
	while (b) {
		LL tmp = b;
		b = a % b;
		a = tmp;
	}

	return a;
}
int main() {
	//freopen("in.txt", "r", stdin);
	LL a, b;
	while (scanf("%lld%lld", &a, &b) != EOF) {
		LL res = gcd(a, b);
		printf("%lld %lld\n", res, a / res * b);
	}
	return 0;
}

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

using namespace std;

typedef long long  ll;
typedef vector<ll> VL;
typedef pair<ll,ll> PLL;
#define pb push_back
#define F first
#define S second
#define fr(i,x,y) for(ll i=x;i<y;i++)
#define frr(i,x,y) for(ll i=x-1;i>=y;i--)
#define inf 1e18+5
const ll mod=998244353;


void solve()
{
	ll n,k;
	cin>>n>>k;
	ll ans=inf;
	n=n%k;
	fr(i,0,1e6)
	{
		ans=min(ans,n);
		ll x=abs(n-k);
		n=x;
	}
	cout<<ans<<endl;
	return;
}
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
	solve();
	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 ll long long
int main(){
  ll n,k;
  cin >> n >> k;
  ll p=n/k;
  ll q=0;
  if(k%2==0){
    ll p=k/2;
    while(p<=n){
      p+=k;
      q++;
    }
  }
  ll ans=q*q*q+p*p*p;
  cout << ans;
}


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

#define int long long
#define sp ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define cps CLOCKS_PER_SEC
#define mod (int)(1000000007)
#define f first
#define s second
#define debug1(x) cerr<<x<<"\n"
#define debug2(x,y) cerr<<x<<" "<<y<<"\n"
#define debug3(x,y,z) cerr<<x<<" "<<y<<" "<<z<<"\n"
#define nl cerr<<"\n";
#define pq priority_queue
#define inf 9999999999999999
#define test cerr<<"abcd\n";
#define pi pair<int,int>
#define pii pair<int,pi>
#define pb push_back
#define mxn 100005
#define mxnn 2000005
int arr[mxn],dp[105][mxn],sum[105][mxn];
int32_t main(){
sp;
for(int i =0;i<105;i++) for(int j = 0;j<mxn;j++) dp[i][j] = inf;
int n,k;
cin >>n>>k;
memset(sum,0,sizeof sum);
for(int i = 1;i<mxn;i++) dp[0][i] = 0;
for(int i = 0;i<=n;i++) dp[i][0] = 1;
sum[0][0] = 1;
for(int i = 1;i<=k;i++) sum[0][i] = sum[0][i-1] + dp[0][i];
for(int i = 1;i<=n;i++) cin >>arr[i];
for(int i = 1;i<=n;i++){
    for(int j = 1;j<=k;j++){
        dp[i][j] = (sum[i-1][j]-(j-arr[i]-1<0 ? 0 :sum[i-1][j-arr[i]-1])+mod)%mod;
    }
    sum[i][0] = dp[i][0];
    for(int j = 1;j<=k;j++) sum[i][j] = (sum[i][j-1] + dp[i][j])%mod;
}
cout<<dp[n][k];
return 0;
}


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


using namespace std;

int main()
{

    int N,X,in,position,flag=0;
    cin >> N >> X;

    position = 0;
    if(position <= X){
        flag++;
        }
        while(N--){
          cin >> in;
          position += in;
          if(position <= X){
            flag++;
          }else {
            break;
          }
        }
        cout << flag << endl;


    }


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define EPS (1e-7)
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const double PI = acos(-1);
const ll MOD = 1000000007;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
 
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

vector<bool> A(1299710,true);
vector<int> B(0);

int main() {
  int N; cin >> N;
  int k = N;
  int count = 0;
  while (k != 0) {
    k /= 10;
    count++;
  }
  int ans = 0;
  for (int i = 1; i <= count; i++) {
    if (i % 2 == 1) {
      if (i == count) {
        ans += (N - pow(10,i-1) + 1);
      } else ans += (pow(10,i) - pow(10,i-1));
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
  vector<int> v(3);
  rep(i,3) cin>>v[i];
  int K;
  cin>>K;
  rep(i,K){
    sort(v.begin(),v.end());
    v[2] *= 2;
  }
  cout<<v[0]+v[1]+v[2]<<endl;
  return 0;
}

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

int main() {
	bool flag[26];
	char S[100001];
	cin>>S;
	for(int i =0;i<26;i++)
	{
		flag[i]=true;
	}
	for(int i=0;i<strlen(S);i++)
	{
		flag[int(S[i]-'a')]=false;
	}
	
	for(int i=0;i<26;i++)
	{
		if(flag[i]==true){
		cout<<char('a'+i);
			break;
		}
		if(i==25)cout<<"None";
	}
}

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


int main() {
  int x , y , z ;
  cin >> x >> y >> z ;
  int c=0;
  for(int i=x;i<=y;i++){
    if(z%i==0){
      c++;
    }
  }
  cout << c<< endl;
}
    




Measured memory_bytes: 3100
#include<stdio.h>

int main(){
   int a,b;
   scanf("%d %d", &a,&b);
   if(a>=13){
     printf("%d", b);
   } else if(a>=6 && a<13){
     printf("%d", b/2);
   } else {
		printf("0");
   }
	return 0;

}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store")  
#pragma GCC optimize ("-fno-defer-pop")
#define all(a) a.begin(),a.end()
#define ll long long int
#define ld long double
ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m)%m; t=(t*t)%m; if(b&1) t=((t%m)*(a%m))%m; return t;}
ll modInverse(ll a, ll m) { return power(a, m-2, m); }
#define ipr pair<ll,ll>
#define ps push_back
#define fs first
#define sc second
#define endl "\n"
#define mod 1000000007
int main(){
	
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	ll i,j,k,l,n;
	cin>>n;
	char ar[n+1];
	cin>>ar;
	cin>>k;
	k--;
	char c=ar[k];
	for(i=0;i<n;i++){
		if(ar[i]!=c){
			ar[i]='*';
		}
	}
	ar[n]='\0';
	cout<<ar;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define meow(args...) fprintf(stderr, args)
typedef unsigned u32;
typedef long long s64;
typedef unsigned long long u64;
template<class T1, class T2> inline bool cmin(T1 &a, const T2 &b) {return b<a?(a=b, true):false;}
template<class T1, class T2> inline bool cmax(T1 &a, const T2 &b) {return a<b?(a=b, true):false;}
template<class Type> Type read() {
	Type a;
	bool b;
	unsigned char c;
	while(c=getchar()-48, (c>9)&(c!=253));
	for(a=(b=c==253)?0:c; (c=getchar()-48)<=9; a=a*10+c);
	return b?-a:a;
}
int (*rd)()=read<int>;

const int N=1e5+1;
int n, m, u[N], v[N], u0[N], v0[N], follow[N], swap[N], ans, dep[N], euler_n, el[N], st[12][2*N], *euler=st[0], cnt[N], deg[N], queue[N];
bool vis[N];
std::vector<int> edge[N], path[N];
void dfs(int u, int p, int d) {
	euler[el[u]=euler_n++]=u;
	dep[u]=d;
	for(int v: edge[u])
		if(v!=p) {
			dfs(v, u, d+1);
			euler[euler_n++]=u;
		}
}
int lca(int x, int y) {
	x=el[x], y=el[y];
	if(x>y) std::swap(x, y);
	int lv=31-__builtin_clz(y-x+1);
	x=st[lv][x], y=st[lv][y-(1<<lv)+1];
	return dep[x]<dep[y]?x:y;
}
void dfs2(int u, int p) {
	for(int v: edge[u])
		if(v!=p) {
			dfs2(v, u);
			cnt[u]+=cnt[v];
		}
	ans+=std::min(cnt[u], 2);
}
int find(int x) {
	if(follow[x]==0) return x;
	int y=find(follow[x]);
	swap[x]^=swap[follow[x]];
	return follow[x]=y;
}
int main() {
	n=rd(), m=rd();
	for(int i=1; i<n; ++i) {
		int a=rd(), b=rd();
		edge[a].push_back(b);
		edge[b].push_back(a);
		++deg[a], ++deg[b];
	}
	dfs(1, 0, 0);
	for(int i=1; (1<<i)<=euler_n; ++i)
		for(int j=0; (1<<i)+j<=euler_n; ++j) {
			int x=st[i-1][j], y=st[i-1][(1<<(i-1))+j];
			st[i][j]=dep[x]<dep[y]?x:y;
		}
	for(int i=1; i<=m; ++i) {
		u[i]=u0[i]=rd();
		v[i]=v0[i]=rd();
		path[u[i]].push_back(i);
		path[v[i]].push_back(i);
		cnt[lca(u[i], v[i])]-=2;
		++cnt[u[i]], ++cnt[v[i]];
	}
	dfs2(1, 0);
	int *qhead=queue, *qtail=queue;
	for(int i=1; i<=n; ++i) if(deg[i]==1) *qtail++=i;
	for(int i=1; i<n; ++i) {
		int x=*qhead++, y;
		std::vector<int> t;
		vis[x]=true;
		for(int j: edge[x]) if(!vis[j]) y=j;
		for(int j: path[x])
			if(u[j]!=v[j]&&follow[j]==0)
				t.push_back(j);
		for(int j=0; j+1<t.size(); j+=2) {
			int p=t[j], q=t[j+1];
			follow[q]=p;
			swap[q]=(u[p]==x)^(u[q]==x)^1;
			if(u[p]==x) {
				u[p]^=u[q]^v[q];
				path[u[p]].push_back(p);
			} else {
				v[p]^=u[q]^v[q];
				path[v[p]].push_back(p);
			}
		}
		if(t.size()%2==1) {
			int p=t.back();
			if(u[p]==x) u[p]=y; else v[p]=y;
			path[y].push_back(p);
		}
		if(--deg[y]==1) *qtail++=y;
	}
	printf("%d\n", ans);
	for(int i=1; i<=m; ++i) {
		find(i);
		if(swap[i]) std::swap(u0[i], v0[i]);
		printf("%d %d\n", u0[i], v0[i]);
	}
	return 0;
}


Measured memory_bytes: 18944
def solve():
    N = int(raw_input())
    ret = [('a', 'a')]
    for i in range (2, N+1):
        tmp = []
        for stri in ret:
            for j in range(ord('a'), ord(stri[1]) + 1):
                tmp.append((stri[0] + chr(j), stri[1]))
            tmp.append((stri[0] + chr(ord(stri[1]) + 1), chr(ord(stri[1]) + 1)))
        ret = tmp
    for stri in ret:
        print stri[0]

if __name__ == '__main__':
    solve()


Measured memory_bytes: 51100
#include <iostream>
#include <vector>

using namespace std;
typedef long long ll;
typedef vector<ll> vl ;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;

#define rep(i,N) for(int i=0; i < (int)N; i++)
#define all(v) (v).begin(),(v).end()

const int INF = 100000002;

int main(){
	int n; cin >> n;
	ll ans = 0;
	for(int i=1; i<=n; i++){
		if(i%3==0 || i%5==0){
			continue;
		}else{
			ans += i;
		}
	}
	cout << ans << endl;
}

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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

int main()
{
    ll i,j;
    ll n,k;
    cin >> n >> k;
    vector<ll> a(n);
    for(i = 0;i < n;++i){
        cin >> a.at(i);
    }
    sort(all(a));
    vector<bool> dp(k+1);
    for(i = 0;i < a.front();++i){
        dp.at(i) = false;
    }
    for(i = i;i <= k;++i){
        bool flag = false;
        rep(j,n){
            if(i < a.at(j)) continue;
            ll tmp = i - a.at(j);
            if(!dp.at(tmp))
            flag = true;
        }
        if(flag) dp.at(i) = true;
        else dp.at(i) = false;
    }
    if(dp.at(k)) cout << "First" << endl;
    else cout << "Second" << endl;

    return 0;
}

Measured memory_bytes: 384
#include <iostream>

using namespace std;

int main(){

	int time_begin[3] , time_end[3];

	for(int j = 0; j < 3; j++){
		for(int i = 0; i < 3; i++){
			cin >> time_begin[i];
		}for(int i = 0; i < 3; i++){
			cin >> time_end[i];
		}

		int h = time_end[0] - time_begin[0];
		int m = time_end[1] - time_begin[1];
		int s = time_end[2] - time_begin[2];

		if(s < 0){
			m = m - 1;
			s = 60 + s;
		}if(m < 0 ){
			h = h - 1;
			m = 60 + m;
		}

		cout << h << " " << m << " " << s << endl;
	}
	return 0;
}

Measured memory_bytes: 3008
import sys
sys.setrecursionlimit(10**6)

N=int(input())
s=input()


G1 = []
G2 = [[] for i in range(10)]
G3 = [[[] for i in range(10)] for j in range(10)]

def dfs3(x,y,new):
	if new not in G3[x][y]:
		G3[x][y].append(new)


def dfs2(x,new):
	for i in G2[x]:
		dfs3(x,i,new)
	if new not in G2[x]:
		G2[x].append(new)



def dfs1(new):
	for i in G1:
		dfs2(i,new)
	if new not in G1:
		G1.append(new)




for i in s:
	dfs1(int(i))

ans = 0
for i in range(10):
	for j in range(10):
		ans += len(G3[i][j])
print(ans)


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

int main() {
    int N;
    ll D;
    cin >> N >> D;

    int ans = 0;
    rep(i, N) {
        ll X, Y;
        cin >> X >> Y;
        if (X * X + Y * Y <= D * D) ans++;
    }
    cout << ans << endl;
        
    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0; (i)<(n); (i)++)
const double PI = acos(-1);
#define INF 1000000000000 
#define MOD 1000000007 

int main(void) {
    int A, B, H, M;
    cin >> A >> B >> H >> M;

    double c_H = H * 30.0 + M * 0.5;
    double H_rad = c_H * PI / 180;
    //cout << c_H << " " << H_rad << endl;

    double c_M = M * 6.0;
    double M_rad = c_M * PI / 180;
    //cout << c_M << " " << M_rad << endl;

    double A_X = A * cos(H_rad);
    double A_Y = A * sin(H_rad);
    double B_X = B * cos(M_rad);
    double B_Y = B * sin(M_rad);
    //cout << A_X << " " << A_Y << " " << B_X << " " << B_Y << endl;

    // float res = sqrt(((A_X - B_X) * (A_X - B_X)) + ((A_Y - B_Y) * (A_Y - B_Y)));

    // cout << res << endl;

    // 余弦定理版
    double degree = abs(c_H - c_M);
    double rad = degree * (PI / 180);
    // cout << degree <<  " " << rad << endl;

    double pow_A = pow(A, 2);
    double pow_B = pow(B, 2);
    double cosrad = cos(rad);
    // cout << pow_A << " " << pow_B << " " << cosrad << endl;

    double res2 = sqrt(pow(A, 2.0) + pow(B, 2.0) - (2.0 * A * B * cos(rad)));
    // cout << res2 << endl;
    printf("%.15lf\n", res2);
    
    return 0; 
}

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

int main() {
	int n, a, b;
	cin >> n >> a >> b;
	int ansa, ansb;
	ansa = min(a, b);
	if (a + b - n > 0) {
		ansb = a + b - n;
	}
	else {
		ansb = 0;
	}
	cout << ansa << " " << ansb;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define endl "\n"
#define int long long

using namespace std;

const int N = 300707;
int x, y;
int mod = 1e9 + 7;
int xx, yy;


int gcd (int a, int b, int & xx, int & yy) {
	if (a == 0) {
		xx = 0; yy = 1;
		return b;
	}
	int x1, y1;
	int d = gcd (b%a, a, x1, y1);
	xx = y1 - (b / a) * x1;
	yy = x1;
	return d;
}

signed main()
{
	ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //freopen("input.txt","r",stdin);
    //freopen("diameter.in", "r", stdin);
    //freopen("diameter.out", "w", stdout);
    cin >> x >> y;
    if ((x + y) % 3 != 0){
        cout << 0 << endl;
        return 0;
    }
    int mv = (x + y) / 3;
    int b = x - mv;
    if (b != 2 * mv - y || b < 0){
        cout << 0 << endl;
        return 0;
    }

    int one = 1;
    for (int i = 2; i <= b; i++){
        one = one * i;
        one = one % mod;
    }

    int g = gcd(one, mod, xx, yy);
	xx = (xx % mod + mod) % mod;

	//cout << xx << endl;

    int res = 1;
    //cout << b << " " << mv << endl;
    for (int i = mv - b + 1; i <= mv; i++){
        res = res * i;
        res = res % mod;
    }

    //cout << res << endl;

    res *= xx;
    res %= mod;
    while (res < 0){
        res += mod;
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include <numeric>
 
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<n;i++)
#define ALL(a) (a).begin(),(a).end()

int main(){
    int n;
    cin >> n;
    vector<ll> prim = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47,
     53, 59, 61, 67, 71, 73, 79, 83, 89, 97};
    vector<ll> count(25, 0);

    for(int i = 2; i <= n; i++){
        int c = i;
        int no = 0;
        while(c != 1){
            while(c%prim[no] == 0){
                c/=prim[no];
                count[no]++;
                //cout << prim[no] << ":";
            }no++;
        }
    }
    //cout << endl;
    vector<int> s(5, 0);
    rep(i, 15){
        if(count[i] >= 74)s[0] = i+1;
        else if(count[i] >=  24)s[1] = i+1;
        else if(count[i] >=  14)s[2] = i+1;
        else if(count[i] >=  4)s[3] = i+1;
        else if(count[i] >=  2)s[4] = i+1;
    }
    rep(i, 4)s[i+1] = max(s[i+1], s[i]);
    //rep(i, 15)cout << count[i] << " ";

    int ans = 0;
    rep(i, 15){
        if(count[i] >= 74)ans += s[0];
        rep(j, 5){
            s[j] = max(0, s[j]-1);
        }
        if(count[i] >= 24)ans += s[4];//25no toki
        if(count[i] >= 14) ans += s[3];//15no toki
        ans += s[2] + s[3]*(max(0, s[4]-1));//5no toki
        ans += s[1];// + max(s[3]*(s[3]-1), 0)/2;//3no toki
        rep(i, s[3])ans += i;
        //cout << " :" << s[2] + s[3]*(max(0,s[4]-1)) << "&" << s[1] + s[3]*(s[3]-1) << endl;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256