akhauriyash/Code-Regression huggingface dataset:
//大文字->小文字 tolower(),逆はtoupper()
//int a = stoi(c); 文字列をintへ
//途中の出力をそのまま残さない
//数値計算 個数以外はdouble
//map<キー,値> p は辞書。p[キー] = 値
//map 全探索
//auto begin = p.begin(), end = p.end();
//for (auto it = begin; it != end; it++) {}
//mapのキー：it->first mapのバリュー：it->second
//絶対値 abs()
//入力は空白で切れる
//大文字判定 isupper(文字) 小文字判定 islower(文字)
//do{}while(next_permutation(ALL(配列)))
//while(N)で回すとき、Nはコピーを作っておく
//小文字に対応する文字コード：S[i] - 'a'
//文字コード→小文字：(char)(数字+'a')
//グラフの距離:隣接行列で扱う
//等価なものに変換する思考
//bool型　初期値はTrue
//島渡りの問題：中間ノードに着目
//配列はvector<>を使う：意味わからないエラーがなくなる。
//背反な事象にちゃんとわける
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
using namespace std;

// K進数でのNの桁数
ll dig(ll N, ll K) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= K;
	}
	return dig;
}
// a,bの最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}

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

//nC2の計算
ll C(ll N) {
	return N * (N - 1) / 2;
}

//円周率
const double PI = 3.14159265358979323846;

int main() {
	ll H, W; cin >> H >> W;
	char a[H][W]; rep(i, H)rep(j, W)cin >> a[i][j];
	
	map<int, bool> p1 = {};
	for (int i = 0; i < H;i++) {
		ll cnt = 0;
		for (int j = 0; j < W; j++) {
			if (a[i][j] == '.') cnt++;
			if (cnt == W) {
				p1[i] = true;
			}
		}
	}

	map<int, bool> p2 = {};
	for (int j = 0; j < W; j++) {
		ll cnt = 0;
		for (int i = 0; i < H; i++) {
			if (a[i][j] == '.') cnt++;
			if (cnt == H) {
				p2[j] = true;
			}
		}
	}

	for (int i = 0; i < H; i++) {
		if (p1[i]) continue;
		for (int j = 0; j < W; j++) {
			if (p2[j])continue;
			cout << a[i][j];
		}
		cout << endl;
	}
}

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

using namespace std;

int main() {
    string s;
    cin >> s;

    int ans = INT_MAX;
    for (int i = 0; i < 26; ++i) {
        int ma = 0, cnt = 0, temp_max = 0;
        for (int j = 0; j < s.size(); ++j) {
            if (s[j] != i + 'a') {
                cnt++;
            } else cnt = 0;
            temp_max = max(temp_max, cnt);
        }
        ma = max(ma, temp_max);
        ans = min(ans, ma);
    }

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

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <algorithm>
#include <functional>
#include <chrono>
#include <random>
#include <vector>
#include <string>
#include <cmath>
#include <bitset>
#include <list>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cassert>

#define sq(x) ((x) * (x))
#define err(x) cerr << "["#x"]  " << (x) << "\n";
#define errp(x) cerr << "["#x"]  {" << ((x).first) << ", " << ((x).second) << "}\n";
#define errv(x) {cerr << "["#x"]  [";for(const auto& ___ : (x)) cerr << ___ << ", "; cerr << "]\n";}
#define errvn(x, n) {cerr << "["#x"]  [";for(auto ___ = 0; ___ < (n); ++___) cerr << (x)[___] << ", "; cerr << "]\n";}
#define errf() cerr << "\n\n";

//#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast, unroll-loops", "omit-frame-pointer","inline")
#pragma GCC option("arch=native","tune=native","no-zero-upper")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native,avx2")

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int getrnd(int l, int r) {
    return uniform_int_distribution<int>(l, r)(rng);
}

ll getrndll(ll l, ll r) {
    return uniform_int_distribution<ll>(l, r)(rng);
}

template <typename T1, typename T2>
inline bool relax(T1& a, const T2& b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}

template <typename T1, typename T2>
inline bool strain(T1& a, const T2& b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}

// :::::::::::::::::::::::::::::::

ll get(int n, vector<pair<int, int>>& a) {
    ll ret = 0;
    set<int> free;
    for (int i = 1; i <= n; ++i)
        free.insert(i);
    
    for (auto [cost, k] : a) {
        auto pos = free.upper_bound(k);
        if (pos != free.begin()) {
            ret += cost;
            free.erase(--pos);
        }
    }
    
    return ret;
}

void solve() {
    int n;
    cin >> n;
    
    ll ans = 0;
    vector<pair<int, int>> pos, neg;
    for (int i = 0; i < n; ++i) {
        int k, l, r;
        cin >> k >> l >> r;
        
        ans += min(l, r);
        if (l >= r)
            pos.emplace_back(l - r, k);
        else
            neg.emplace_back(r - l, n - k);
    }
    sort(pos.rbegin(), pos.rend());
    sort(neg.rbegin(), neg.rend());
    
    cout << ans + get(n, pos) + get(n, neg) << '\n';
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr); cout.tie(nullptr);
    srand(time(0));
    
    int t = 1;
    cin >> t;
    while (t--)
        solve();
    
    return 0;
}


Measured memory_bytes: 14300
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef long long LL;
typedef vector<int> VI;
typedef pair<int,int> PII;
typedef pair<double,int> PDI;
const double eps=1e-12;
const int INF=0x3f3f3f3f;
const LL inf=1e18;
const double pi=acos(-1.0);
const int mod=1e9+7;
//LL powmod(LL a,LL b) {LL res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
struct node{
    LL c,v;
}a[5];
bool cmp(node a,node b){
    return a.c*b.v<b.c*a.v;
}
int main(){
//    freopen("in.txt","r",stdin);
//    freopen("outt.txt","w",stdout);
    int t;
    LL q,h,s,d,n;
    for(int i=0;i<4;i++){
        cin>>a[i].c;
    }
    a[0].v=1;
    a[1].v=2;
    a[2].v=4;
    a[3].v=8;
    sort(a,a+4,cmp);
    cin>>n;
    n*=4;
    LL ans=0;
    for(int i=0;i<4;i++){
//        cout<<a[i].c<<endl;
        ans+=n/a[i].v*a[i].c;
        n%=a[i].v;
    }
    cout<<ans<<endl;
    return 0;
}


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

namespace Volume0004
{
    class Program
    {

        static void Main(string[] args)
        {
             string _coefficients;
            

            while ((_coefficients = Console.ReadLine()) != null)
            {
                decimal[] _arrayCoefficients = new decimal[6];
                decimal _x;
                decimal _y;
                _arrayCoefficients = _coefficients.Split(' ').Select(decimal.Parse).ToArray();
                decimal a = _arrayCoefficients[0];
                decimal b = _arrayCoefficients[1];
                decimal c = _arrayCoefficients[2];
                decimal d = _arrayCoefficients[3];
                decimal e = _arrayCoefficients[4];
                decimal f = _arrayCoefficients[5];
                _y = (c * d - a * f) / (b * d - a * e);
                _x = (c - b * _y) / a; ;
                Console.WriteLine(_x.ToString("F3") + " " + _y.ToString("F3"));
            }
        }
    }
}


Measured memory_bytes: 14264
c = [int(input()) for _ in range(5)]

last = 10

idx = 0

for i in range(5):
    if c[i] % 10 ==  0:
        continue
    else:
        if last > c[i] % 10:
            last = c[i] % 10
            idx = i
    
ans = 0


for i in range(5):
    if i == idx:
        ans = ans + c[i]
    else:
        if c[i] % 10 == 0:
            ans = ans + c[i]
        else:
            ans= ans + ( c[i] // 10 + 1 ) * 10


print(ans)

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define vi vector<ll>
#define sll(x) scanf("%lld",&x)
#define prll(x) printf("%lld ",x)
#define pri(x) printf("%d ",x)
#define si(x) scanf("%d",&x)
#define el printf("\n")
#define pb push_back
#define f first
#define s second
#define arrondi(a) (long long)floor(a+0.5);
#define NIL -1
ll N=500005;
ll MAX=9223372036854775807;
ll MOD=1000000007;
long double PI =4*atan(1);

int main()
{
	IOS;
    cout.precision(30);
    int n,D; cin >> n >> D;
    cout << n/(2*D+1) + (n%(2*D+1)!=0);
    /*ll rep=1e9; ll ans=0;
    for (int i=1;i<=D+1 && i<=n;i++)
    {
        ans=1;
        for (int j=i+D+1;j<=n;j+=2*D)
        {
            ans++; cout << j << " " <<ans << endl;
        }
        rep=min(ans,rep);
    }
    cout << rep;*/
    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 30;
const int MOD = 1e9 + 7;

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


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		long n = scan.nextLong();

		long total = 0;

		for(int i = 1; i <= n; i++) {

			if(i % 3 != 0 && i % 5 != 0 ) {
				total += i;
			}
			
		}

		System.out.println(total);
	}
}

Measured memory_bytes: 27136
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <map>
#include <cstdlib>
#include <sstream>
#include <bitset>
using namespace std;

typedef long long ll;

int main()
{
    int N;
    cin >> N;
    vector<ll> A(N);
    ll sum=0;
    for(int i=0; i<N; i++){
        cin >> A[i];
        sum+=A[i];
    }

    ll tmp=A[0];
    ll ans = abs(sum-2*tmp);
    for(int i=1; i<N-1; i++){
        tmp+=A[i];
        ans = min(ans, abs(sum-2*tmp));
    }
    cout << ans << endl;




    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
#define FORV(i, v) for (auto i = v.begin(); i != v.end(); i++)
using namespace std;

using ll = long long;
using P = pair<int, int>;

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; }
template<class T> inline void dump(vector<T> v) { for (auto& x : v) cerr << x << " "; cerr << endl; }
template<class T> inline void dump(vector<pair<T, T>> v) { for (auto& p : v) cerr << p.first << " " << p.second << endl; }
template<class T> inline void dump(vector<vector<T>> vv) { for (auto& v : vv) {for (auto& x : v) cerr << x << " "; cerr << endl;} }

const ll INF = 1e9;
const long long INFL = 1LL<<60;

int main() {
  int d;
  cin >> d;

  if (d == 22) {
    puts("Christmas Eve Eve Eve");
  } else if (d == 23) {
    puts("Christmas Eve Eve");
  } else if (d == 24) {
    puts("Christmas Eve");
  } else {
    puts("Christmas");
  }

  return 0;
}


Measured memory_bytes: 3572
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<string>
#define INF 1000000000ll
#define MOD 1000000007ll
#define EPS 1e-10
#define REP(i,m) for(long long i=0; i<m; i++)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define DUMP(a) for(long long dump=0; dump<(ll)a.size(); dump++) { cout<<a[dump]; if(dump!=(ll)a.size()-1) cout<<" "; else cout<<endl; }
#define ALL(v) v.begin(),v.end()
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string n;
	cin>>n;
	if(n[0]==n[1]&&n[1]==n[2]) {
		cout<<"Yes"<<endl;
	} else if(n[1]==n[2]&&n[2]==n[3]) {
		cout<<"Yes"<<endl;
	} else cout<<"No"<<endl;
}


Measured memory_bytes: 764
#include <iostream>
#include <fstream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <sstream>
#include <array>
#include <cmath>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <stack>

template <typename T, typename U>
inline std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) {
    os << p.first << ' ' << p.second;
    return os;
}
template <typename T, typename U>
inline std::istream& operator>>(std::istream& os, std::pair<T, U>& p) {
    os >> p.first >> p.second;
    return os;
}
template <typename T>
inline std::ostream& operator<<(std::ostream& os, const std::vector<T>& v) {
    if (v.empty()) {
        return os;
    }
    if (v.begin() != v.end()) {
        os << v.front();
    }
    for (auto it = ++v.begin(); it != v.end(); ++it) {
        os << ' ' << *it;
    }
    return os;
}
template <typename T>
inline std::istream& operator>>(std::istream& is, std::vector<T>& v) {
    for (auto& i : v) {
        is >> i;
    }
    return is;
}

template <typename T>
struct TreeNode {
    T value;
    TreeNode *left = nullptr;
    TreeNode *right = nullptr;

    bool operator<(const TreeNode& rhs) const {
        return value < rhs.value;
    }
};
void Solve(std::istream& is, std::ostream& os) {
    int n;
    is >> n;
    std::vector<int> input(n);
    is >> input;
    int min_elem = *std::min_element(input.begin(), input.end()),
        max_elem = *std::max_element(input.begin(), input.end());

    uint64_t min = std::numeric_limits<uint64_t>::max(), current = min;
    for (int i = min_elem; i <= max_elem; ++i) {
        current = 0;
        for (auto&& elem : input) {
            current += (elem - i) * (elem - i);
        }
        min = std::min(min, current);
    }
    os << min;
}

int main() {
    std::ios_base::sync_with_stdio(0);
    std::cin.tie(0);
    Solve(std::cin, std::cout);
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <boost/optional.hpp>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define REP(i, n) for(int i = 0, i##_MACRO = (n); i < i##_MACRO; i++)
#define RANGE(i, a, b) for(int i = (a), i##_MACRO = (b); i < i##_MACRO; i++)
#define EACH(e, a) for(auto&& e : a)
#define ALL(a) std::begin(a), std::end(a)
#define RALL(a) std::rbegin(a), std::rend(a)
#define FILL(a, n) memset((a), n, sizeof(a))
#define FILLZ(a) FILL(a, 0)
#define INT(x) (static_cast<int>(x))

using namespace std;

using ll = long long;
using VI = vector<int>;
using VI2D = vector<vector<int>>;

constexpr int INF = 2e9;
constexpr double EPS = 1e-10;
constexpr double PI = acos(-1.0);

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

template <typename T>
constexpr int sign(T x) {
	return x < 0 ? -1 : x > 0 ? 1 : 0;
}

template <>
constexpr int sign(double x) {
	return x < -EPS ? -1 : x > EPS ? 1 : 0;
}

template <typename T, typename U>
constexpr void chmax(T& m, U x) {
	m = max(m, x);
}

template <typename T, typename U>
constexpr void chmin(T& m, U x) {
	m = min(m, x);
}

template <typename T>
constexpr T square(T x) {
	return x * x;
}

// UnionFind(disjoint set)
class UnionFind {
	public:
	std::vector<size_t> parents;
	std::vector<size_t> rank;

	UnionFind(size_t size) : parents(size), rank(size, 0) {
		std::iota(this->parents.begin(), this->parents.end(), 0);
	}

	// 併合
	bool merge(size_t a, size_t b) {
		size_t ar = this->root(a);
		size_t br = this->root(b);
		if(ar == br) {
			return false;
		}
		if(this->rank[ar] < this->rank[br]) {
			std::swap(ar, br);
		}
		if(this->rank[ar] == this->rank[br]) {
			this->rank[ar]++;
		}
		return this->parents[br] = ar;
	}
	bool unite(size_t a, size_t b) { return this->merge(a, b); }

	// 同集合か判定
	bool is_same(size_t a, size_t b) { return this->root(a) == this->root(b); }
	bool is_union(size_t a, size_t b) { return this->is_same(a, b); }

	private:
	size_t root(int n) {
		if(this->parents[n] == n) {
			return n;
		}

		return this->parents[n] = this->root(this->parents[n]);
	}
};

int main() {
	int n, m;
	cin >> n >> m;
	UnionFind uf(n);
	VI x(m);
	VI y(m);
	VI z(m);
	REP(i, m) {
		cin >> x[i] >> y[i] >> z[i];
		uf.merge(x[i] - 1, y[i] - 1);
	}
	int result = 0;
	REP(i, n) {
		if(uf.parents[i] == i) {
			result++;
		}
	}
	cout << result << endl;
}


Measured memory_bytes: 5868
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

import java.util.*;

public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);

        int N = in.nextInt();
        int T = in.nextInt();
        int[] A = new int[N];
        for (int i=0;i<N;i++) {
            A[i] = in.nextInt();
        }

        int[] max = new int[N];
        max[N-1]=A[N-1];
        for (int i=N-2;i>=0;i--) {
            max[i] = Math.max(A[i], max[i+1]);
        }

        int max_diff=0;
        for (int i=0;i<N-1;i++) {
            if (max_diff<max[i+1]-A[i]) {
                max_diff=max[i+1]-A[i];
            }
        }

        int ans=0;
        for (int i=0;i<N-1;i++) {
            if (max_diff==(max[i+1]-A[i])) {
                ans++;
            }
        }
        out.println(ans);

        out.close();
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

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

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

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

    }
}


Measured memory_bytes: 35856
let input = require('fs').readFileSync('/dev/stdin', 'utf8')
// let input = require('fs').readFileSync('./sample_d.txt', 'utf8')
.split(/\n| /)
.slice(0 ,-1)
.map(item => parseInt(item))

const [N, M, ..._pair] = input

let r = new Array(N).fill(-1)

const root = x => {
    if (r[x] < 0) return x
    return r[x] = root(r[x])
}

const unite = (x, y) => {
    x = root(x)
    y = root(y)
    if (x == y) return false
    if (r[x] > r[y]) [x, y] = [y, x]
    r[x] += r[y]
    r[y] = x
    return true
}

const size = x => {
    return -r[root(x)]
}


for (let i=0; i<_pair.length; i+=2){
    unite(_pair[i]-1, _pair[i+1]-1)
}
 
//最大の友達集合を求める
let ans = 0
for ( let i=0; i<N; i++){
    ans = Math.max(ans, size(i));
}

console.log(ans)

// const [N, M, ..._pair] = input
// const pair = []
// for(let i=0; i<N; i++){
//     pair.push(new Array(N-i).fill(true))
// }

// for(let i=0; i<_pair.length; i+=2){
//     const a = [_pair[i], _pair[i+1]].sort()
//     pair[a[0]-1][a[1]-a[0]] = false
// }


// const member = [ new Set() ]

// pair[0].forEach( (item, index) => {
//     if(item) member[0].add(index+1)
//     else{
//         member.push(new Set())
//         member[member.length-1].add(index+1)
//     }
// } )

// for( let i=1; i<N; i++){
//     for( let j=1; j<pair[i].length; j++){
//         if(!pair[i][j]){
//             member.forEach( (sample, index) => {
//                 if( sample.has(i+1) && sample.has(i+j+1) ){
//                     sample.delete(i+j)
//                     if(member.length - 1 <= index) member.push(new Set())
//                     member[index+1].add(i+j)
//                 }
//             })
//         }
//     }
// }

// console.log(member.length)

Measured memory_bytes: 92364
#include <bits/stdc++.h>
using namespace std;
int n;
int main() {
    cin >> n;
    vector<int> d(n);
    for(int i = 0; i < n; ++i) {
        cin >> d.at(i);
    }

    int sum = 0;

    for(int i = 0; i < n; ++i) {
        for(int j = i+1; j < n; ++j) {
            sum += d.at(i) * d.at(j);
        }
    }

    cout << sum << endl;
}

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;
using P = pair<int, int>;
const int INF = 1 << 29;
 
int main() {
	int n, m;
	cin >> n >> m;
	vector<vector<int>> g(n);
	rep(i, m) {
		int a, b; cin >> a >> b;
		g[a-1].push_back(b-1);
		g[b-1].push_back(a-1);
	}
	rep(i, n) {
		cout << g[i].size() << endl;
	}
	return 0;
}

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

int n;
int t,x,y;
int main()
{
	cin>>n;
  	for(int i=0;i<n;i++) 
	{
    	int tt,xx,yy;
		cin>>tt>>xx>>yy;
    	int d=abs(xx-x)+abs(yy-y);
    	if(tt-t<d||(tt-t)%2!=d%2) 
		{
    	    cout<< "No";
    	  	return 0;
    	} 
  	}
  cout<<"Yes";
  return 0;
}



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

int main()
{
	int a, b, c, d, e;
	while (cin >> a >> b >> c >> d >> e, a || b || c || d || e) {
		int f[100];
		for (int k = 0; k < a; k++)scanf("%d", &f[k]);
		int sum = 0;
		for (int i = 0; i <= 10000; i++) {
			if (e == f[sum]) {
				if (sum + 1 == a) { cout << i << endl; goto l; }
				sum++;
			}
			e = (e*b + c) % d;
		}
		puts("-1");
	l:;
	}
}

Measured memory_bytes: 3152
#include <bits/stdc++.h>
#define pi 3.14159
using namespace std;

int main()
 {
 	int n,i,x,d,c=1,s=0;
 	int ans=INT_MAX;
 	cin>>n;
 	int a[n],b[n];
 	for(i=0;i<n;i++)
 		cin>>a[i];
 	 for(int t = 0; t < n - 1; t++)
	   {
			int s1 = 0, s2 = 0;
			for (int i = 0; i < n; i++)
			 {
				if (i <= t) 
					s1 += a[i];
				else
					 s2 += a[i];
			}
		ans = min(ans, abs(s1 - s2));
		}
 	cout<<ans<<endl;
 	}

Measured memory_bytes: 3596
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
A, V = map(int, readline().split())
B, W = map(int, readline().split())
T = int(readline())
if W >= V:
  print('NO')
  sys.exit()
if (abs(A-B)/(V-W)) <= T: 
  print('YES')
else:
  print('NO')

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

ll n,k;

int main(){
    cin >> n >> k;
    ll res=0;
    for(ll b=1;b<=n;b++){
        if(b<=k) continue;
        res+=(b-k)*(n/b)+max(n%b-k+1,0LL);
    }
    if(k==0) res-=n;
    cout << res << endl;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define forE(i,x) for(int i=head[x];i!=-1;i=ne[i])
using namespace std;
typedef long long i64;
typedef unsigned long long u64;
typedef unsigned u32;
typedef pair<int,int> pin;
#define mk(a,b) make_pair(a,b)
#define lowbit(x) ((x)&(-(x)))
#define sqr(a) ((a)*(a))
#define clr(a) (memset((a),0,sizeof(a)))
#define ls ((x)<<1)
#define rs (((x)<<1)|1)
#define mid (((l)+(r))>>1)
#define pb push_back
#define w1 first
#define w2 second
inline void read(int &x){
	x=0;int f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	x*=f;
}
inline void judge(){
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
}
/*******************************head*******************************/
const int maxn=1000005;
int head[maxn],t[maxn<<1],ne[maxn<<1],num,n;
inline void addedge(int x,int y){
	ne[++num]=head[x];head[x]=num;t[num]=y;
	ne[++num]=head[y];head[y]=num;t[num]=x;
}
int sg[maxn];
inline void dfs(int x,int f){
	forE(i,x)if(t[i]!=f){
		dfs(t[i],x);
		sg[x]^=sg[t[i]]+1;
	}
}
int main(){
	read(n);
	rep(i,1,n)head[i]=-1;
	rep(i,1,n-1){
		int x,y;read(x);read(y);
		addedge(x,y);
	}
	dfs(1,-1);
	puts(sg[1]?"Alice":"Bob");
	return 0;
}


Measured memory_bytes: 13184
require 'set'; require 'prime'
INF=Float::INFINITY
a,b,c,d = gets.chomp.split.map(&:to_i)

cd = c.lcm(d)
a-=1
aa = a -a/c - a/d + a / cd
bb = b -b/c - b/d + b / cd

ans = bb - aa
# ans+= 1 unless a%c==0 and a%d==0
puts ans

Measured memory_bytes: 2172
#include <vector>
#include <iostream>
#include <cmath>
#include <iomanip>
#include <string>
#include <utility>
#include <stack>
#include <numeric>
#include <random>
#include <algorithm>
#include <queue>
#include <functional>
#include <iterator>
#include <list>
#include <unordered_map>
#include <deque>
using namespace std;

#define rep(i, b, e) for(i = b; i < e; ++i)
#define repr(i, b, e) for (i = b; i >= e; --i)
#define ull unsigned long long int
#define ll long long int
#define pint pair<int, int>

#define M_DEBUG 1
#define PI 3.141592653589793

#define E '\n'

#define print(x) cout << (x) << endl;
#define printa(x,n) for(int i = 0; i < n; i++){ cout << (x[i]) << "\n";}
#define INF (1e18)

const ll MAX = 1000000000;
const ll MOD = 1e9 + 7;

ull a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z;

ll aabs(ll a) {
    if (a < 0) return -a;
    return a;
}

//fast power
ll calc(ll a, ll b) {
    if (b == 0) return 1;
    else if (b % 2 == 0) {
        ll d = calc(a, b / 2);
        return (d * d) % MOD;
    }
    else return (a * calc(a, b - 1)) % MOD;
}

//fast combination
ll comb(ll n, ll a) {
    ll b = 1, c = 1;
    for (ll i = 1; i <= a; ++i) {
        b = b * i % MOD;
        c = c * (n - i + 1) % MOD;
    }

    return c * calc(b, MOD - 2) % MOD;
}

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

    cin >> a >> b >> m;
    vector<int> aa(a);
    vector<int> bb(b);
    
    rep (i, 0, a) cin >> aa[i];
    rep (i, 0, b) cin >> bb[i];

    ll min = 100000000000;
    rep (i, 0, m) {
        cin >> x >> y >> c;
        t = aa[x - 1] + bb[y - 1] - c;
        if (t < min) {
            min = t;
        }
    }

    sort(aa.begin(), aa.end());
    sort(bb.begin(), bb.end());

    if (aa[0] + bb[0] < min) min = aa[0] + bb[0];

    cout << min << endl;



    return 0;
}



Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
#define REP(i, limit) for(int i=0; i< limit; ++i)
#define LINT long long

int main(){
  int N;
  cin >> N;
  if(N%4 == 0 || N%7 == 0){
    cout << "Yes" << endl;
    return 0;
  }

  int work = N/4;
  for(int i=0; i<work; ++i){
    if((N-i*4)%7 == 0){
      cout << "Yes" << endl;
      return 0;
    }
    else continue;
  }

  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define sp(n) cout << fixed << setprecision(n)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
using namespace std;
int main(void){
    ll n;cin>>n;
    map<string,int> mp;
    mp["AC"]=0;
    mp["WA"]=0;
    mp["RE"]=0;
    mp["TLE"]=0;
    rep(i,n){
        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;
}


Measured memory_bytes: 3576
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <vector>
#include <list>
#include <queue>
#include <stack>

using namespace std;


int main() {
	int a;
	cin >> a;
	if (a == 1)cout << 0;
	else cout << 1;



	return 0;
}


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

int sx, sy, tx, ty;

void xmove(int start, int goal) {
	for (int x = start; x != goal; ) {
		if (goal - x < 0) {
			cout << 'L';
			x--;
		}
		else {
			cout << 'R';
			x++;
		}
	}
}

void ymove(int start, int goal) {
	for (int y = start; y != goal; ) {
		if (goal - y < 0) {
			cout << 'D';
			y--;
		}
		else {
			cout << 'U';
			y++;
		}
	}
}


signed main() {
	cin >> sx >> sy >> tx >> ty;

	xmove(sx, tx);
	ymove(sy, ty);
	xmove(tx, sx);
	ymove(ty, sy);

	cout << 'D';
	xmove(sx, tx + 1);
	ymove(sy - 1, ty);
	cout << 'L';
	cout << 'U';
	xmove(tx, sx - 1);
	ymove(ty + 1, sy);
	cout << 'R';

	cout << endl;
}



Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstddef>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

// clang-format off
template <typename T> T gcd(T a, T b) { return b == 0 ? a : gcd(b, a % b); }
template <typename T> T lcm(T a, T b) { return a * b / gcd(a, b); }
template <typename T> T clamp(T val, T min, T max) { return val < min ? min : (max < val ? max : val); }
template <typename T> size_t max_index(T begin, T end) { return distance(begin, max_element(begin, end)); }
template <typename T> size_t min_index(T begin, T end) { return distance(begin, min_element(begin, end)); }
// clang-format on

#define int long long
#define YES "Yes"
#define NO  "No"

using namespace std;

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

  int num = 0;

  int n; cin >> n;
  
  vector<int> a(5);
  for (auto it = a.begin(); it != a.end(); ++it) cin >> *it;

  int b = a[0];
  for (auto it = a.begin(); it != a.end(); ++it) b = min(b, *it);

  num = 4 + n / b;
  if (n % b != 0) num += 1;

  cout << num << endl;
  
  return 0;
}


Measured memory_bytes: 256
def main():
    s = "0" + input()
    ans = []
    f = True
    for i in range(len(s)//2):
        if s[i] != s[len(s)-1-i]:
            f = False
            break
    if s[1] == "0" or s[-2] == "0":
        f = False
    if f:
        ans = []
        p = len(s)-1
        for i in reversed(range(1, len(s)-1)):
            c = s[i]
            ans.append([i, p])
            if c == "1":
                p = i
        for u, v in ans:
            print(u, v)
    else:
        print(-1)

if __name__ == "__main__":
    main()

Measured memory_bytes: 21072
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)
	s := next()
	t := next()

	a := nextInt()
	b := nextInt()

	u := next()

	switch u {
	case s:
		a--
	case t:
		b--
	}

	fmt.Printf("%d %d\n", a, b)
}

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}


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

int main() {
  double N;
  cin>>N;
  
  double count =0;
  for(int i = 1; i < N+1; i += 2){
  	count ++;
  }
    cout << fixed << setprecision(10);
  double Ans = count/N;
  cout << Ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a[3][3];
    for(int i = 0;i < 3;i++){
        for(int j = 0;j < 3;j++){
            cin >> a[i][j];
        }
    }
    
    int x[3],y[3];
    x[0]=0;
    for(int i = 0;i < 3;i++) y[i] = a[0][i] - x[0];
    for(int i = 0;i < 3;i++) x[i] = a[i][0] - y[0];
    
    bool good = true;
    for(int i = 0;i < 3;i++){
        for(int j = 0;j < 3;j++){
            if(x[i]+y[j]!=a[i][j]){
                good = false;
            }
        }
    }
    if(good)cout << "Yes";
    else cout <<"No";
    
    
}


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

int main()
{
  int n;
  cin >> n;
  int n2 = 1 << n;
  vector<int> a(n2);
  rep(i, n2) cin >> a[i];
  sort(a.begin(), a.end());
  vector<int> s;
  s.push_back(a.back());
  a.back() = -1;
  rep(i, n){
    vector<int> p = s;
    sort(p.begin(), p.end());
    int ai = n2-1;
    while(p.size() > 0 && ai >= 0){
      if (a[ai] == -1){
        --ai;
        continue;
      }
      //cout << "ai:" << ai << endl;
      //cout << a[ai] << " " << p.back() << endl;
      if (a[ai] < p.back()){
        s.push_back(a[ai]);
        p.pop_back();
        a[ai] = -1;
      }
      --ai;
    }
    //cout << i << " " << s.size() << " " << p.size() << endl;
    if (p.size() > 0){
  	  puts("No");
      return 0;
    }
  }
  puts("Yes");
  return 0;
    
}


Measured memory_bytes: 3060
import java.util.*
import kotlin.math.*
import java.io.BufferedReader
import java.io.InputStreamReader


private var fs = BufferedReader(InputStreamReader(System.`in`))
private fun readLn() = fs.readLine()!! // string line
private fun readStrings() = readLn().split(" ") // list of strings
private fun readLong() = readLn().toLong()
private fun readLongs() = readStrings().map { it.toLong() } // list of ints
private fun readInt() = readLn().toInt() // single int
private fun readInts() = readStrings().map { it.toInt() } // list of ints

fun main() {
    solveAtc()
}
fun solveAtc() {
    var n = readInt()
    var str  = readLn().toCharArray()
    var ans =0
    var w = str.filter{it -> it=='W'}.count()
    var r = str.filter{it -> it=='R'}.count()
    if(w != 0 && r != 0){
        for (i in 0 until r) {
            if (str[i] == 'W') {
                ans++
            }
        }
    }
    println(ans)
}

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

def main():
    sp = [int(e) for e in input().split(" ")]
    a = sp[0]
    b = sp[1]
    k = sp[2]

    big = max(a, b)

    idx = 1
    for i in range(big):
        if a%(big-i) == 0 and b%(big-i) == 0:
            if idx == k:
                print(big-i)
            idx+=1

main()


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

// @@ !! LIM()

int main(/* int argc, char *argv[] */) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  ll N; cin >> N;
  ll ans = 0;
  ll carry = 0;
  for (ll i = 0; i < N; i++) {
    ll a; cin >> a;
    if (a == 0) {
      carry = 0;
    }else {
      ll d = a + carry;
      ans += d / 2;
      carry = d % 2;
    }
  }
  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 3620
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define eb emplace_back
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll) (x).size()
#define pq priority_queue<ll>
#define pqg priority_queue<ll,vector<ll>,greater<ll>>
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
#define int ll
// #define ll int
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[4] ={1,0,-1,0} , dy[4] ={0,1,0,-1};

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

struct Timer{
    chrono::system_clock::time_point start, end;
    Timer(){ start = chrono::system_clock::now(); }
    ~Timer(){
        end = chrono::system_clock::now();
        auto msec = chrono::duration_cast<chrono::milliseconds>(end - start).count();
        cerr<<"time : "<<msec<<" ms"<<endl;
    }
};



void solve(){
    string a,b;
    cin>>a>>b;
    reverse(all(b));
    if(a==b) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;

}


signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    // Timer TM;
    
    solve();

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
typedef struct{
  int u;
  int k;
  int v[101];
  int d;
  int f;
  int h;
}Graph;

void dfs(int);
int count=1;
 Graph node[101];
main(){
  int i,j,n;
 
  scanf("%d",&n);

  for(i=1;i<=n;i++){
    scanf("%d",&node[i].u);
    scanf("%d",&node[i].k);
    node[i].d=0;
    node[i].f=0;
    node[i].h=0;
    for(j=1;j<=node[i].k;j++)scanf("%d",&node[i].v[j]);
  }
  
  for(i=1;i<=n;i++){
    dfs(node[i].u);
  
  }
  for(i=1;i<=n;i++){
    printf("%d %d %d\n",node[i].u,node[i].d,node[i].f);
  }
  return 0;
}


void dfs(int x){
  int i;
  if(node[x].h==0){
    node[x].h=1;
    node[x].d=count;
    count++;
  }
  for(i=1;i<=node[x].k;i++){
    if(node[node[x].v[i]].h==0)dfs(node[x].v[i]);
  }
  if(node[x].h==1){
    node[x].h=2;
    node[x].f=count;
    count++;
  }
}

Measured memory_bytes: 636
import java.util.Scanner;

public class Main {
	public static void main(String[]args){
		Scanner s = new Scanner(System.in);
		int x = s.nextInt();
		System.out.println(Cube(x));
	}

	public static int Cube(int x){
		int ans = 1;
		for(int i = 0; i < 3; i++){
			ans *= x;
		}
		return ans;
	}
}

Measured memory_bytes: 26196
#include <iostream>
using namespace std;
int main(){
  int x,y;
  cin >> x >> y;

  for(int i=0;i<=x;i++){
    if(2*i+4*(x-i)==y){
      cout << "Yes\n";
      return 0;
    }
  }

  cout << "No\n";
}

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

typedef long long 			ll;
typedef unsigned long long 	ull;

const int N = 100 + 20;
const int MAXN = 100 * 1000 + 20;

//ll a[N];

int main() {
	ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
	string s, t;
	cin >> s >> t;
	for (int i = 0; i < t.size(); i++)
		cout << t[i];
	for (int i = 0; i < s.size(); i++)
		cout << s[i];
	cout << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#define  boost ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ull unsigned long long
#define d1(x) cout<<#x<<" "<<x<<endl;
#define d2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;
#define d2i(x,y,i) cout<<#x<<i<<" "<<x<<" "<<#y<<i<<" "<<y<<endl;

#define fr(i,l,r) for(ll i=l;i<r;i++)
#define mems(a,x) memset(a,x,sizeof(a))
#define mod 1000000007
#define ff first
#define ss second
#define pb(x) push_back(x)
#define vll vector<ll>
#define pbp(x,y) push_back(make_pair(x,y))
#define  mat vector<vector<ll>>
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

void solve(){
ll x;
cin>>x;
ll k=x/500;
 x=x%500;
 cout<<k*1000+(x/5)*5;



}

int main(){
    ll t=1;
  /// cin>>t;
    while(t--){
        solve();
        cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
n = int(input())
a = [int(i) for i in input().split()]
count=0
for i in range(n):
    if i >=1 and i < n-1:
        if (a[i-1] < a[i] and a[i] < a[i+1]) or (a[i+1] < a[i] and a[i] < a[i-1]):
            count = count + 1

print(count)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <ctime>
#include <cassert>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define fs first
#define sc second
#define INF 1000000000
#define MOD 1000000007
#define EPS 0.00000001

vector<vector<int>> E;
vector<bool> visited;
void dfs(int s){
    visited[s] = true;
    for(int &to:E[s]){
        if(!visited[to]) dfs(to);
    }
    return;
}

int main() {
    int N, M; cin >> N >> M;
    E.resize(N+M);
    visited.resize(N+M);
    vector<int> L;
    for(int i=0; i<N; i++){
        int k; cin >> k;
        for(int j=0; j<k; j++){
            int l; cin >> l;
            l--;
            E[i].push_back(N+l);
            E[N+l].push_back(i);
        }
    }
    
    dfs(0);
    
    for(int i=0; i<N; i++){
        if(visited[i]==false){
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    
    
    
    return 0;
}


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

al=['a','b','c','d','e','f','g','h','i','j']

ans=[]

st='a'

temp=0
now=0

def dfs(st,n,now,temp):
  if now==n-1:
    ans.append(st)
  else:
    for f in range(0,temp+2):
      if f==temp+1:
        dfs(st+al[f],n,now+1,temp+1)
      else:
        dfs(st+al[f],n,now+1,temp)
    
dfs(st,n,0,0)

for h in ans:
  print(h)

      

Measured memory_bytes: 17068
import math
import fractions

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a


a,b = list(map(int, input().split()))

aa = prime_factorize(a)
bb = prime_factorize(b)

#print(aa,bb)
a = set(aa)
b = set(bb)
a = a.intersection(b)

#print(a)

print(len(a)+1)

Measured memory_bytes: 64108
#include <iostream>

using namespace std;
int N,M;

int main(){
  cin >> N >> M;
  int L[M];
  int R[M];
  int MIN = 100000;
  int MAX = -1;
  for(int i=0; i<M; i++){
    cin >> L[i] >> R[i];
    MAX = max(MAX, L[i]);
    MIN = min(MIN, R[i]);
  }
  if(MIN >= MAX){
    cout << MIN - MAX + 1 << endl;
  }else{
    cout << 0 << endl;
  }
  return 0;
}


Measured memory_bytes: 1024
def factorial(num):
    res = 1
    for i in range(num):
        res *= i + 1
    return res


N = int(input())
p = [list(map(int, input().split())) for _ in range(N)]

total = 0

for i in range(N - 1):
    xi = p[i][0]
    yi = p[i][1]
    for j in range(i + 1, N):
        xj = p[j][0]
        yj = p[j][1]
        distance = ((xi - xj) ** 2 + (yi - yj) ** 2) ** 0.5
        total += distance * factorial(N - 1) * 2

ans = total / factorial(N)

print(ans)


Measured memory_bytes: 3188
#include<cstdio>
#include<vector>
#include<algorithm>
#define INF 1000000000
using namespace std;
vector<int> neg, pos;
int n, k;
int main() {
	int i;
	scanf("%d%d", &n,&k);
	for (i = 1; i <= n; i++) {
		int a;
		scanf("%d", &a);
		if (a < 0) neg.push_back(-a);
		else pos.push_back(a);
	}
	sort(neg.begin(), neg.end());
	sort(pos.begin(), pos.end());
	int ans=INF;
	if (pos.size() >= k) ans = pos[k - 1];
	for (i = 0; i < neg.size(); i++) {
		int npos = k-i-1;
		if (pos.size() >= npos && 0<=npos) {
			int valpos = 0;
			if (npos > 0) valpos = pos[npos - 1];
			ans = min(ans, neg[i] + valpos * 2);
			ans = min(ans, neg[i] * 2 + valpos);
		}
	}
	printf("%d", ans);
	return 0;
}

Measured memory_bytes: 1020
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
int main(void)
{
	int x1,y1,x2,y2,a,b,c,d,e,f;
	
	cin>>x1>>y1>>x2>>y2;
	e=x2-x1;
	f=y2-y1;
	
	a=x2-f;
	b=y2+e;
	c=x1-f;
	d=y1+e;
	
	cout<<a<<' '<<b<<' '<<c<<' '<<d;
	
	return 0;
}


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

// alias templates
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;

// alias declaration
using ll = long long;
using str = string;

using vll = V<ll>;
using vvll = V<vll>;
using vs = V<str>;

// loops
#define FOR(i, a, b)  for (ll i = (a); i <= (ll)(b); i++) // [a,b]
#define rFOR(i, a, b) for (ll i = (b); i >= (ll)(a); i--) // [b,a]
#define REP(i, a) FOR((i), 0, (ll)(a)-1) // [0,a-1]

// for debug
#define dbg(a) cerr << "  " << (#a) << ": " << (a) << "\n";

// procon common constants
const ll MOD_BIG = 1e9 + 7;

int main(void){
    ll a, b;

    cin >> a >> b;

    cout << max(a+b,max(a-b,a*b)) << endl;
}

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

int main(){
    ll N;
    cin >> N;
    vector<ll> vec(N);
    rep(i,N){
        cin >> vec[i];
    }
    vector<ll> start(N,0);
    rep(i,N){
        if (i + vec[i] >= N){
            continue;
        }
        else{
            start[i + vec[i]]++;
        }
    }
    ll ans;
    ans = 0;
    rep(i,N){
        if (i - vec[i] <= -1){
            continue;
        }
        else{
            ans += start[i - vec[i]];
        }
    }
    cout << ans << endl;
}


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

typedef long long   ll;
const ll mod = 1e9 + 7;

#define speedup_IO      ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define forn(i,a,n)     for(ll i = a; i < n; i++)
#define ford(i,n,a)     for(ll i = n-1; i >= a; i--)
#define pb              push_back
#define lb              lower_bound
#define ub              upper_bound
#define pll             pair<ll,ll>
#define all(a)          (a).begin(),(a).end()
#define reset(a,x)      memset(a,x,sizeof(a))

ll mypow(ll base, ll exp) {ll res = 1; while (exp) {if (exp & 1) res = (res * base) % mod; exp >>= 1, base = (base * base) % mod;} return res;}
ll gcd(ll a, ll b)  { return b ? gcd(b, a % b) : a;            }
ll mult(ll a, ll b) { if (a < 0) {a += mod;} if (b < 0) {b += mod;} return ((a % mod) * (b % mod)) % mod; }
ll add(ll a, ll b)  { if (a < 0) {a += mod;} if (b < 0) {b += mod;} return (a % mod + b % mod) % mod;        }
ll sub(ll a, ll b)  { if (a < 0) {a += mod;} if (b < 0) {b += mod;} return (a % mod + mod - b % mod) % mod;  }

const ll inf = 1e18;
const int nax = 1e5 + 5;

int main()
{
	speedup_IO;
	ll h,n;
	cin>>h>>n;

	ll a[n];
	ll sum = 0;
	forn(i,0,n)
	{
		cin>>a[i];
		sum+=a[i];
	}

	if(sum>=h)
		cout<<"Yes";
	else
		cout<<"No";

	return 0;
}

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

int main()
{
 char s[20];
  scanf("%s", s);
  if(strcmp(s, "Sunny") == 0)
    printf("Cloudy");
  if(strcmp(s, "Rainy") == 0)
    printf("Sunny");
  if(strcmp(s, "Cloudy") == 0)
    printf("Rainy");
}

Measured memory_bytes: 128