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

int main()
{

        int sx, sy;
        int tx, ty;
        cin >> sx >> sy >> tx >> ty;

        int dx = abs(sx - tx);
        int dy = abs(sy - ty);

        for (int i = 0; i < dy; ++i) {
                cout << 'U';
        }
        for (int i = 0; i < dx; ++i) {
                cout << 'R';
        }
        for (int i = 0; i < dy; ++i) {
                cout << 'D';
        }
        for(int i = 0;i < dx; ++i) {
                cout << 'L';
        }
        cout << 'L';
        for (int i = 0; i < dy+1; ++i) {
                cout << 'U';
        }
        for (int i = 0; i < dx+1; ++i) {
                cout << 'R';
        }
        cout << 'D';
        cout << 'R';
        for (int i = 0; i < dy+1; ++i) {
                cout << 'D';
        }
        for(int i = 0; i < dx+1; ++i) {
                cout << 'L';
        }
        cout << 'U';
}


Measured memory_bytes: 256
//Md Fahad
// CSE 18

#include<bits/stdc++.h>


using  namespace  std;

#define PI              acos(-1.0)
#define lcm(a,b)        (a * (b / __gcd(a,b)))
#define en '\n'

#define READ_IN freopen("Input.txt","r",stdin);
#define READ_OUT freopen("Output.txt","w",stdout);
#define Infi                0x3f3f3f3f

const int fx[] = {+1,-1,+0,+0};                         // 4 X directions
const int fy[] = {+0,+0,+1,-1};                         // 4 Y directions
const int fx8[] = {+0,+0,+1,-1,-1,+1,-1,+1};            // King X Moves
const int fy8[] = {-1,+1,+0,+0,+1,+1,-1,-1};            // King Y Moves
const int kx[] = {-2, -2, -1, -1,  1,  1,  2,  2};      // Knight X Moves
const int ky[] = {-1,  1, -2,  2, -2,  2, -1,  1};      // Knight Y Moves



int  Set    (int N,int pos) {return N=N | (1<<pos);}    /// turn a bit on
int  reset  (int N,int pos) {return N= N & ~(1<<pos);}  /// turn a bit off
bool check  (int N,int pos) {return (bool)(N & (1<<pos));} /// check, if a bit is on or not

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define trace(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define trace(x...)
#endif


typedef long long int           ll;
typedef unsigned long long int  llu;

int main(void)
{
    //READ_IN;
    string s; cin >> s;

    map<char,int> m;

    for(int i=0;i<s.size();i++){
        m[s[i]]++;
    }

    if(m.size()>1){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
h, n = map(int,input().split())
ab = [list(map(int,input().split())) for i in range(n)]
#(a,b):=(ダメージ,消費魔力)

dp = [float('inf')] * (h + 1)
dp[0] = 0

for i in range(h + 1):
    for j in range(n):
        if dp[i] == float('inf'):continue
        temp_a = i + ab[j][0] if i + ab[j][0] < h else h
        temp_b = dp[i] + ab[j][1]

        dp[temp_a] = min(dp[temp_a], temp_b)

print(dp[-1])
#print(dp)


Measured memory_bytes: 74368
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int (i)=(m);(i)<(n);++(i))
#define rREP(i,m,n) for(int (i)=(n)-1;(i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;
template<class T>inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T>inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int main() {
	init();

	int N; cin >> N;
	vector<tuple<int, int, int>>vec(N);
	rep(i, 0, N) {
		int a, b, c; cin >> a >> b >> c;
		vec[i] = make_tuple(c, a, b);
	}
	sort(all(vec), greater<tuple<int, int, int>>());
	rep(Cx, 0, 101) {
		rep(Cy, 0, 101) {
			int cnt = INF;
			bool ok = true;
			rep(i, 0, N) {
				int x = get<1>(vec[i]), y = get<2>(vec[i]), h = get<0>(vec[i]);
				if (cnt == INF) {
					cnt = h + abs(x - Cx) + abs(y - Cy);
				}
				else {
					int tmp = max(cnt - abs(x - Cx) - abs(y - Cy), 0);
					if (tmp != h)ok = false;
				}
			}
			if (ok) {
				cout << Cx << " " << Cy << " " << cnt << "\n";
			}
		}
	}

	return 0;
}

Measured memory_bytes: 256
# time complexity: O(√M + (lgM)^2)
# space complexity: O(lgM)

from collections import defaultdict


def prime_factorize(num):
    prime_numbers = defaultdict(int)
    i = 2
    while i * i <= num:
        if num % i == 0:
            while num % i == 0:
                prime_numbers[i] += 1
                num //= i
        i += 1
    if num != 1:
        prime_numbers[num] += 1
    return prime_numbers


MOD = 10**9 + 7
N, M = [int(elem) for elem in input().split()]

prime_numbers = prime_factorize(M)

num_sequences = 1
for exponent in prime_numbers.values():
    denomimator = 1
    numerator = 1
    for i in range(1, exponent + 1):
        denomimator *= (N + exponent - i)
        numerator *= i
    num_sequences *= denomimator // numerator
    num_sequences %= MOD

print(num_sequences)



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

const int MAXN = 3005;

ll dp[MAXN][MAXN], S[MAXN];

int A[MAXN];

int N;

int main() {
	ios::sync_with_stdio(false);

	cin >> N;
	for(int i = 1; i <= N; i++) {
		cin >> A[i];
		S[i] = S[i-1] + A[i];
		dp[i][i] = A[i];
	}

	for(int l = 2; l <= N; l++)
		for(int s = 1, e = l; e <= N; s++, e++)
			dp[s][e] = (S[e]-S[s-1]) - min(dp[s+1][e], dp[s][e-1]);

	cout << dp[1][N]*2 - S[N] << endl;
	return 0;
}

Measured memory_bytes: 70016
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int n = scan.nextInt();
		int[] X = new int[n];
		int sum = Integer.MAX_VALUE;

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

			X[i] = scan.nextInt();
		}

			for(int j=1;j<=100;j++) {

				int hp = 0;
				for(int i:X) {
				hp += (i-j)*(i-j);
			}
				sum = Math.min(hp,sum);
			}

		System.out.println(sum);

		scan.close();

	}

}


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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}

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

ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

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

    ll N;
    cin >> N;

    ll ans = 0;
    ll tmp_N;
    tmp_N = N;
    while(tmp_N>0){
        ans += tmp_N % 10;
        tmp_N /= 10;
    }

    if(N % ans == 0){
        cout << "Yes" << endl;
    }else{
        cout << "No"  << endl;
    }
    

    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <functional>
#include <ctime>
#include <fstream>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iomanip>
#include <float.h>
#include <math.h>
#include <cassert>
#pragma warning (disable: 4996)
using namespace std;

using ll = long long;
unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

ll ll_gcd(ll a, ll b) {
    if (a < b) return ll_gcd(b, a);
    ll r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

struct UnionFind {
    vector <ll> par;
    vector <ll> siz;
    UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    ll root(ll x) {
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) {
        return root(x) == root(y);
    }

    ll size(ll x) {
        return siz[root(x)];
    }
};

long long modpow(long long a, long long n, long long mod) {
    if (n < 0)return 0;
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}

ll merge_cnt(vector<ll>& a) {
    int n = a.size();
    if (n <= 1) { return 0; }

    ll cnt = 0;
    vector<ll> b(a.begin(), a.begin() + n / 2);
    vector<ll> c(a.begin() + n / 2, a.end());

    cnt += merge_cnt(b);
    cnt += merge_cnt(c);

    int ai = 0, bi = 0, ci = 0;
    while (ai < n) {
        if (bi < b.size() && (ci == c.size() || b[bi] <= c[ci])) {
            a[ai++] = b[bi++];
        }
        else {
            cnt += n / 2 - bi;
            a[ai++] = c[ci++];
        }
    }
    return cnt;
}

int main() {
    ll a, b;
    cin >> a >> b;
    if (abs(a - b) <= 1)cout << "Brown" << endl;
    else cout << "Alice" << endl;
}

Measured memory_bytes: 3612
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.run();
    }
    
    // 変数一覧
    int n;

    public void run() {
        // 入力情報取得
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        sc.close();

        // 解答処理
        solve();
    }
    
    private void solve() {
        boolean flg = false;
        for(int i=0;i<3;i++) {
            if (n % 10 == 7) {
                System.out.println("Yes");
                flg = true;
                break;
            }    
            n /= 10;
        }
        if (flg == false) {
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 35664
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>

using namespace std;
#define MAXS 32768
#define MOD 1000000007
#define rint register int
#define gc() getchar()
inline int read(rint ans = 0, rint sgn = ' ', rint ch = gc())
{
	for(; ch < '0' || ch > '9'; sgn = ch, ch = gc());
	for(; ch >='0' && ch <='9';(ans*=10)+=ch-'0', ch = gc());
	return sgn-'-'?ans:-ans;
}
#define BUF_SIZE 1000000
#define _END fwrite(_Ob,1,_O-_Ob,stdout), _O = _Ob
#define Outc(a) (*_O++ = a)
char _Ob[BUF_SIZE+5], *_O = _Ob, _Os[25], *_Ot;
template <typename T> inline void Out(T x)
{
	if(!x){Outc('0'); return;} if(x < 0) Outc('-'), x = -x;
	for(_Ot = _Os; x; *_Ot++ = x%10+'0', x /= 10);
	for(; _Ot != _Os; Outc(*--_Ot)); if(_O-_Ob >= BUF_SIZE-50) _END;
}
int n, m, E, g[20], f[MAXS+5], b[405], c[MAXS+5];
int main()
{
	n = read(), m = read(), E = 1<<n; for(rint i = 1; i < E; c[i] = c[i-(i&-i)]+1, i++);
	b[0] = f[0] = 1; for(rint i = 1; i <= n*n; b[i] = b[i-1]<<1, b[i]<MOD?:b[i]-=MOD, i++);
	for(rint i = 1, u, v; i <= m; u = read(), v = read(), g[u] |= 1<<~-v, i++);
	for(rint S = 1, T, U, i, s; S < E; S++)
		if((S&1) == ((S>>1)&1))
			for(U = S; U; U = (U-1)&S)
				if((U&1) == ((U>>1)&1))
				{
					for(T = S^U, s = 1, i = 1; i <= n; i++)
						(S>>~-i)&1 ? s = 1ll*s*((T>>~-i)&1 ? b[c[g[i]&U]]-1 : b[c[g[i]&T]])%MOD : 0;
					f[S] = (f[S]+1ll*f[T]*s)%MOD;
				}	printf("%d\n",(b[m]+MOD-f[~-E])%MOD); return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<vector>

using namespace std;

int main(){
  int N,t=0,ele;
  cin>>N;
  vector<int> a(N);
  for(int i=0;i<N;i++){
    cin>>a.at(i);
    t+=a.at(i);
  }
  ele=*max_element(a.begin(),a.end());
  if(ele<t-ele){
    cout<<"Yes"<<endl;
  }
  else cout<<"No"<<endl;
  return 0;
}


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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  int start = max(A, C);
  int end = min(B, D);
  int ec_time = max(0, end - start);
  cout << ec_time << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>
#include <deque>
#include <complex>
#include <bitset>

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<long long, long long> pll;
typedef vector<pll> vpll;

typedef long double ld;
typedef vector<ld> vld;

typedef vector<bool> vb;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, n) for (ll i = 1; i <= (n); i++)
#define rrep(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rreps(i, n) for (ll i = (n); i >= 1; i--)
#define all(v) (v).begin(), (v).end()

template <class T> void chmin(T& a, T b) { a = min(a, b);}
template <class T> void chmax(T& a, T b) { a = max(a, b);}

constexpr int INF = 1 << 30;
constexpr ll INFL = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr ld EPS = 1e-12;
ld PI = acos(-1.0);

void solve() {
    ll n;
    cin >> n;
    vll a(n);
    rep(i, n) cin >> a[i];

    ll now = a[0];
    rep(i, n) now = __gcd(now, a[i]);
    if(now > 1) {
        cout << "not coprime" << endl;
        return;
    }

    const ll amax = 1000000;
    vll div(amax+1);    // 割り切れる最小の数. div[4]=div[6]=2等
    for(ll i = 2; i <= amax; ++i) {
        if(div[i] != 0) continue;
        for(ll j = i; j <= amax; j += i) {
            if(div[j] != 0) continue;
            div[j] = i;
        }
    }
    map<ll, ll> mp;
    rep(i, n) {
        ll b = a[i];
        set<ll> s;
        while(b > 1) {
            s.insert(div[b]);
            b /= div[b];
        }
        for(auto i = s.begin(); i != s.end(); ++i) {
            if(mp[*i] > 0) {
                cout << "setwise coprime" << endl;
                return;
            }
            ++mp[*i];
        }
    }
    cout << "pairwise coprime" << endl;
    return;
}

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

Measured memory_bytes: 18728
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Text;
using System.Text.RegularExpressions;
using System.Linq;
using System.IO;

class Program
{ 
    static void Main(string[]args)
    {
        Magatro m = new Magatro();
        m.Scan();
        m.Solve();
    }
}

public class Scanner
{
    private StreamReader Sr;
    private string[] S;
    private int Index;

    private const char Separator=' ';

    public Scanner()
    {
        Index = 0;
        S = new string[0];
        Sr = new StreamReader(Console.OpenStandardInput());
    }

    private string[] Line()
    {
        return Sr.ReadLine().Split(Separator);
    }

    public string Next()
    {
        string result;
        if (Index >= S.Length)
        {
            S = Line();
            Index = 0;
        }
        result = S[Index];
        Index++;
        return result;
    }
    public int NextInt()
    {
        return int.Parse(Next());
    }
    public double NextDouble()
    {
        return double.Parse(Next());
    }
    public long NextLong()
    {
        return long.Parse(Next());
    }
    public string[] StringArray(int index = 0)
    {
        Next();
        Index = S.Length;
        return S.Skip(index).ToArray();
    }
    public int[] IntArray(int index = 0)
    {
        return StringArray(index).Select(int.Parse).ToArray();
    }
    public long[]LongArray(int index = 0)
    {
        return StringArray(index).Select(long.Parse).ToArray();
    }

    public bool ScanToEnd(ref string s)
    {
        if (Sr.EndOfStream)
        {
            return false;
        }
        else
        {
            s = Sr.ReadLine();
            return true;
        }
    }
}

public class Magatro
{
    private int A, B, C, D;

    public void Scan()
    {
        Scanner sc = new Scanner();
        A = sc.NextInt();
        B = sc.NextInt();
        C = sc.NextInt();
        D = sc.NextInt();
    }

    public void Solve()
    {
        Console.WriteLine(Math.Max(A * B, C * D));
    }
}



Measured memory_bytes: 2648
S=input()
N=len(S)+1

x=[0]*N
y=0

for i in range(N-1):
  if S[i]=="<":
    x[i+1]=x[i]+1
for j in range(N-1):
  i=N-2-j
  if S[i]==">":
    x[i]=max([x[i],x[i+1]+1])
print(sum(x))

Measured memory_bytes: 46792
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Int32;

class Program
{
    static void Main(string[] args)
    {
        label:
        ReadLine();
        var txt = ReadLine();
        // 一番左をリーダーにした時の答え
        int result = 0;
        for (int i = 1; i < txt.Length; ++i)
        {
            if (txt[i] == 'E') ++result;
        }
        int nowCount = result;
        for (int i = 0; i < txt.Length - 1; ++i)
        {
            if (txt[i] == 'W') ++nowCount;
            if (txt[i + 1] == 'E') --nowCount;
            result = Math.Min(result, nowCount);
        }
        WriteLine(result);
    }
}


Measured memory_bytes: 13116
#include <bits/stdc++.h>
using namespace std;
#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 pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define vec vector
#define sz(x) ((int) x.size())
#define rd(type, ...) type __VA_ARGS__; sc(__VA_ARGS__)
#define rdv(type, v, n) vector<type> v(n); rep(i, 0, n) cin >> v[i]
#define prv(v) rep(i, 0, v.size()) {if (i) cout << ' '; cout << v[i];} cout << '\n'
#define rdm(type, v, h, w) vector<vector<type>>(h, vector<type>(w)) v; rep(i, 0, h) rep(j, 0, w) cin >> v[i][j]
#define prm(v) rep(i, 0, v.size()) {rep(j, 0, v[i].size()) {if (j) {cout << ' ';} cout << v[i][j];} cout << '\n';}
typedef long long ll;
void solve();
int main() {ios::sync_with_stdio(false); cin.tie(0); solve(); return 0;}
template<typename T> void sc(T& x) {cin >> x;}
template<typename Head, typename... Tail> void sc(Head& head, Tail&... tail) {cin >> head; sc(tail...);}
template<typename T> void pr(const T& x) {cout << x << '\n';}
template<typename Head, typename... Tail> void pr(const Head& head, const Tail&... tail) {cout << head << ' '; pr(tail...);}

void solve() {
  rdv(int, v, 3);
  sort(v.begin(), v.end());
  pr(v[0] + v[1]);
}

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

int main(){
  int n;
  cin>>n;
  if(n<10){
    cout<<n<<endl;
  }
  else if(n<100){
    cout<<9<<endl;
  }
  else if(n<1000){
    cout<<n-90<<endl;
  }
  else if(n<10000){
    cout<<909<<endl;
  }
  else if(n<100000){
    cout<<n-90-9000<<endl;
  }
  else{
    cout<<99999-90-9000<<endl;
  }
}

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

int main()
{
    long long n,i,j,march[5] = {0};
    long long ans = 0;
    char s[100000][11];

    scanf("%lld",&n);
    for (i = 0; i < n; i++)scanf("%s",s[i]);

    for (i = 0; i < n; i++)
    {
        switch (s[i][0])
        {
        case 'M':
            march[0]++;
            break;
        case 'A':
            march[1]++;
            break;
        case 'R':
            march[2]++;
            break;
        case 'C':
            march[3]++;
            break;
        case 'H':
            march[4]++;
            break;
        }
    }
    ans += march[0] * march[1] * march[2];
    ans += march[0] * march[1] * march[3];
    ans += march[0] * march[1] * march[4];
    ans += march[0] * march[2] * march[3];
    ans += march[0] * march[2] * march[4];
    ans += march[0] * march[3] * march[4];
    ans += march[1] * march[2] * march[3];
    ans += march[1] * march[2] * march[4];
    ans += march[1] * march[3] * march[4];
    ans += march[2] * march[3] * march[4];
    printf("%lld",ans);
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define Speed ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
using namespace std;

#define st              first
#define nd              second
#define pb              push_back
#define pf              push_front
#define all(a)          (a).begin(), (a).end()
#define lwb             lower_bound
#define upb             upper_bound
#define vvll            vector<vector<ll> >
#define Mset(s, n)      memset(s, n, sizeof(s))
#define Sz(a)           int((a).size())
#define Max(a, b, c)    max(max((ll)(a), (ll)(b)), (ll)(c))
#define Min(a, b, c)    min(min((ll)(a), (ll)(b)), (ll)(c))
#define Unique(a)       sort(all(a)); (a).resize(unique(all(a)) - (a).begin())

typedef long double ld;
typedef pair<int, int> pii;
typedef long long ll;
typedef unsigned long long ull;

const ll MOD = 1e9 + 7;
const int oo = 2e9;
const ld PI = acos((ld) -1);
int Getbit(ll x, int k){return (x >> (k - 1)) & 1;}
ll Lcm(ll a, ll b) {return a / __gcd(a, b) * b;}
bool isPrime(ll n){for(ll i = 2; i * i <= n; i++){if(n % i == 0) return 0;} return (n > 1) ? 1 : 0;}
ll Powmod(ll n, ll k, ll p = MOD) {ll r = 1; for(; k; k /= 2, n = n * n % p){if(k & 1) r = r * n % p;} return r;}

const int N = 6e3 + 5;


ll n, m, query;

int a[N];
int ans = 0;

void Solve(){
    int a, b, c;
    cin >> a >> b >> c;
    if(a + b + c == 5 + 7 + 5) cout << "YES\n"; else cout << "NO\n";
}

int main(){
//    Speed;
    int query = 1;
//    cin >> query;
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout)
    while(query--){
        Solve();
    }
}






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

int main() {
    string S;
    cin >> S;
    
    if (S=="SUN") cout << 7 << endl;
    if (S=="MON") cout << 6 << endl;
    if (S=="TUE") cout << 5 << endl;
    if (S=="WED") cout << 4 << endl;
    if (S=="THU") cout << 3 << endl;
    if (S=="FRI") cout << 2 << endl;
    if (S=="SAT") cout << 1 << endl;
}

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

ll gcd(ll a,ll b){
	if(b == 0)
		return a;
	return gcd(b,a%b);
}

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

int main(){
	ll A,B,C,D,ans;
	cin >> A >> B >> C >> D;
	ll E = lcm(C,D);
	ans = B-A+1;
	ans -= B/C - (A-1)/C;
	ans -= B/D - (A-1)/D;
	ans += B/E - (A-1)/E;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define pb push_back
#define fst first
#define snd second
#define INF 0x7fffffff
#define INFLL 0x7FFFFFFFFFFFFFFF
#define lenA(ar) sizeof(ar)/sizeof(*ar)
#define fill(a,c) memset(&a, c, sizeof(a))
#define fore(i,x,y) for(int i=x;i<y;i++)
#define foreI(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define FIN ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define sl "\n";
#define ii pair<ll,ll>
#define mk make_pair
 
 
typedef long long ll;
typedef unsigned long long ull;
 
using namespace std;
const int MAXN = 1010;
ll dp[MAXN][MAXN];
char grid[MAXN][MAXN];
int n,m;
ll ans=0;
const int mod =1e9+7;
int main() {FIN;
   
    cin>>n>>m;
    fore(i,0,n)fore(j,0,m)cin>>grid[i][j];
    memset(dp,0,sizeof(dp));
    fore(i,0,n){if(grid[i][0]!='#')dp[i][0]=1;else break;}
     fore(i,0,m){if(grid[0][i]!='#')dp[0][i]=1;else break;}
 
     fore(i,1,n){
        fore(j,1,m){
            if(grid[i][j]=='.'&&i-1>-1)dp[i][j]+=dp[i-1][j]%mod;
            if(grid[i][j]=='.'&&j-1>-1)dp[i][j]+=dp[i][j-1]%mod;
        }
     }
    cout<<dp[n-1][m-1]%mod<<sl;
    return 0;
}

Measured memory_bytes: 12568
from collections import Counter
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
li()
def ns(): return stdin.readline().rstrip()

S = ns()
c = Counter(S)
if c["R"] > c["B"]:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3444
import java.util.*;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		HashSet<Long> hs = new HashSet<Long>();
		String cmd, str;
		long hc;

		for(int i=0; i<n; i++){
			cmd = sc.next();
			str = sc.next();
			hc = 0;
			for(int j=0; j<str.length(); j++){
				hc += str.charAt(j) * Math.pow(31, j);
			}
			if(cmd.equals("insert")){
				hs.add(hc);
			} else if(cmd.equals("find")){
				if(hs.contains(hc)) System.out.println("yes");
				else                System.out.println("no");
			}
		}
	}
}

Measured memory_bytes: 222084
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    double a, b, c, d;
    double pi = 180/acos(-1.0);
    while(cin >> a >> b >> c >> d, b > -0.1){
        a /= pi; b /= pi; c /= pi; d /= pi;
        printf("%.0lf\n", 6378.1*acos(sin(a)*sin(c)+cos(a)*cos(c)*cos(d-b)));
    }
    return 0;
}


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

typedef long long int ll;

int main(){
    int d,n;
    scanf("%d %d",&d,&n);
    if(n==100) n++;
    if(d==0) printf("%d\n",n);
    else if(d==1) printf("%d\n",n*100);
    else printf("%d\n",n*100*100);
    return 0;
}


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

int main(){
  int a, b; cin>>a>>b;
  int c;
  if(a>b) c=a-b;
  else c=b-a;
  
  if(c%2==1) cout<<"IMPOSSIBLE"<<endl;
  else cout<<min(a+c/2, b+c/2)<<endl;
}

Measured memory_bytes: 256
n,k=map(int,input().split())
p=list(map(int,input().split()))
def g(x):
  return (1+x)/2

a=[]
ans=0
f=0
for i in range(k):
  f+=g(p[i])
a.append(f)
ans=f
for i in range(n-k):
  a.append(a[i]+g(p[k+i])-g(p[i]))
  ans=max(ans,a[i+1])
  
print(ans)

  
  


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

ll gcd(ll a,ll b){
  if(b == 0) return a;
  return gcd(b, a % b);
}

using Graph = vector<vector<int>>;

ll calc(ll a, ll b, ll p){//aのb乗をpで割った余り
  if(b == 0) return 1;

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

typedef pair<int,int> P;

bool is_prime(int n){//nが素数であるかどうか判定 iで割り切れると素数でない
    if(n == 1) return false;//1は例外
    for(int i = 2;i*i <= n;i++){
        if(n%i == 0) return false;
    }
    
    return true;
}
int factorial(int a){
  int res = 1;
  while(a){
    res *= a;
    a--;
  }
  return res;
}

//r本再利用されない時、N本から再利用して売れる本数
int rec(int m,int n,int N,int r){
  if(N == 0) return 0;

  int k = N/m * n;//新たに作り出す本数
  r = N%m;//再利用されない本数
  int res = N + k;//売った本数
  
  while(1){
    k = k/m * n;//k本からk/m本再利用
    res += k;
    r += k%m;
    if(k < m){//k本で再利用できなくなったら
      k += r;
      res += rec(m,n,k,r);
    }
  }
}

int main(){
  int X;
  cin >> X;
  int q = X/100;
  int r = X%100;
  int c5 = r/5;//105の使用回数
  
  int c;//101~104のいずれかの使用回数
  if(r%5) c = 1;
  else c = 0;
  //101~105を何個かずつ使ってrを作る
  //その時の101~105の和で100で割った商がq以下であればok
  
  if(r%5 == 1 && (105*c5 + 101)/100 <= q) cout << 1 << endl;
  else if(r%5 == 2 && (105*c5 + 102)/100 <= q) cout << 1 << endl;
  else if(r%5 == 3 && (105*c5 + 103)/100 <= q) cout << 1 << endl;
  else if(r%5 == 4 && (105*c5 + 104)/100 <= q) cout << 1 << endl;
  else if(r%5 == 0 && (105*c5)/100 <= q) cout << 1 << endl;
  else cout << 0 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INT long long
#define oo 99999999987654231ll
#define MOD 998244353
using namespace std;

INT q, a, b;

int main()
{
    ios::sync_with_stdio(false);
    cin>>q;
    while( q-- )
    {
        cin>>a>>b;
        INT c = a*b, lb = 1, ub = 1000000000, md, ans;
        while( lb < ub )
        {
            md = (lb+ub+1)/2;
            if( md*md >= c ) ub = md-1;
            else lb = md;
        }
        ans = ub*2-1;
        if( a <= ub ) ans--;
        if( b <= ub ) ans--;
        if( a == ub and b == ub ) ans++;
        if( ub*(ub+1) < c ) ans++;
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct point{
	int x,y;
	point operator - (const point p){
		point pp;
		pp.x=x-p.x;
		pp.y=y-p.y;
		return pp;
	}
}p0,p1,p2;
double waiji(point p1,point p2){
	return p1.x*p2.y-p1.y*p2.x;
}
double neiji(point p1,point p2){
	return p1.x*p2.x+p1.y*p2.y;
}
void solve(){
	double xc=waiji(p1-p0,p2-p0);	
	if(xc>0){cout<<"COUNTER_CLOCKWISE"<<endl;return;}
	if(xc<0){cout<<"CLOCKWISE"<<endl;return;}
	if(neiji(p1-p0,p2-p0)<0){cout<<"ONLINE_BACK"<<endl;return;}
	if(abs(p1.x-p0.x)<abs(p2.x-p0.x)||abs(p1.y-p0.y)<abs(p2.y-p0.y)){cout<<"ONLINE_FRONT"<<endl;return;}
	cout<<"ON_SEGMENT"<<endl;
}
int main(){
	cin>>p0.x>>p0.y;
	cin>>p1.x>>p1.y;
	int T; cin>>T;
	while(T--){
		cin>>p2.x>>p2.y;
		solve();
	}
	return 0;
}



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

using namespace std;

int main()
{
    ios::sync_with_stdio(false); cin.tie(0);
    int n;
    cin >> n;
    vector<int> d(n);
    for (int i = 0; i < n; i++)
        cin >> d[i];
    sort(d.begin(), d.end());
    cout << d[n / 2] - d[n / 2 - 1] << endl;
    return 0;
}


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

int main() {
  vector<double> x(2), y(2);
  cin >> x.at(0) >> y.at(0);
  cin >> x.at(1) >> y.at(1);
  double distx = x.at(0) - x.at(1);
  double disty = y.at(0) - y.at(1);
  cout << fixed << setprecision(8) << sqrt(distx * distx + disty * disty)
       << endl;
}


Measured memory_bytes: 3276
def main():
    n, d = map(int, input().split())
    ps = [[*map(int, input().split())] for _ in range(n)]
    square = [i**2 for i in range(1, 127)]
    cnt = 0
    for i in range(n-1):
        for j in range(i+1, n):
            if sum([(ps[i][k] - ps[j][k]) ** 2 for k in range(d)]) in square:
                cnt += 1
    print(cnt)

if __name__ == "__main__":
    main()

Measured memory_bytes: 9152
//package atcoder;

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in  = new Scanner(System.in);
	        int N = in.nextInt();
	     
	        for(int  i=1;i<=9;i++){
	        		if( N % i == 0 ){
	        			int j = N / i;
	        			if( j>=1 && j<=9){
	        				System.out.println("Yes");
	        				return;
	        			}
	        		}
	        }
	        System.out.println("No");
	}

}


Measured memory_bytes: 23764
# coding: utf-8
# Your code here!
def main():
        
    n = int(input())
    a = list(map(int,input().split()))
    
    if 0 in a:
        print(0)
        return
    
    sum = 1
    for b in a:
        sum *= b
        if sum > 1000000000000000000:
            print(-1)
            return
    
    print(sum)

main()        

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

int main() {
	int n;
	cin >> n;
	int d11,d12,d21,d22,d31,d32;
	string s = "No";
	cin >> d11 >> d12 >> d21 >> d22;
	for(int i=0;i<n-2;i++)
	{
		int a,b;
		cin >> a >> b;
		if(i>0)
		{
			d11=d21;
			d12=d22;
			d21=d31;
			d22=d32;
			d31=a;
			d32=b;
		}
		else
		{
			d31=a;
			d32=b;
		}
		if(d11==d12&&d21==d22&&d31==d32)
		{
			s="Yes";
		}
	}
	cout << s << endl;
	return 0;
}


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

typedef long long ll;
ll N;
map<ll, ll, greater<ll>> S;
multiset<ll, greater<ll>> Ks;

bool solve() {
  Ks.insert(N);
  for (auto valcnt : S) {
    ll cnt = valcnt.second;
    if (cnt > Ks.size()) return false;
    vector<ll> next;
    for (ll i = 0; i < cnt; ++i) {
      auto it = Ks.begin();
      ll k = *it;
      Ks.erase(it);
      for (ll j = 0; j <= k - 1; ++j) next.push_back(j);
    }
    for (ll j : next) Ks.insert(j);
  }
  return true;
}
int main() {
  cin >> N;
  for (ll i = 0; i < (1 << N); ++i) {
    ll s;
    cin >> s;
    ++S[s];
  }
  cout << (solve() ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 22784
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;
 
int main() {
    ll N; cin >> N;
    ll A, B; cin >> A >> B;

    if(abs(B - A) % 2 == 0) {
        cout << abs(B - A) / 2 << endl;
    }
    else {
        ll ans = LONGINF;
        
        // 1 まで
        ans = min(ans, max(A - 1, B - 1));
        
        // N まで
        ans = min(ans, max(N - A, N - B));

        // どっちかが端で調整
        // A が調整
        ans = min(ans, A + (B - A - 1) / 2);

        // B が調整
        ans = min(ans, N - B + 1 + (N - (A + N - B + 1)) / 2);
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main ()
{
	long long N,K,Q,i,B[100000],c[100000];
	scanf("%lld %lld %lld",&N,&K,&Q);
	
	for(i=0;i<N;i++)
	{
		c[i]=K-Q;
	}
	for(i=0;i<Q;i++)
	{
		scanf("%lld",&B[i]);
		c[B[i]-1]+=1;
	}
	for(i=0;i<N;i++)
	{
		if(c[i]>0)
		{
			printf("Yes\n");
		}
		else
		{
			printf("No\n");
		}
	}
	return 0;
}

Measured memory_bytes: 2048
#include <iostream> 
#include <bits/stdc++.h>
#include <vector> 
#include <algorithm> 
#include <string>
#include <cmath>
#include <iomanip> 
#include<climits> 
#include <utility>   
#include <set>
#include <numeric> 
#include <iterator>
#include <map> 
using namespace std; 
#define ll long long int
//typedef pair<ll,ll> p; 

int main() {
	
ll n,a,b;
cin>>n>>a>>b;
ll p=a+b;
ll q=n%p;
ll s=n/p;
if(q<=a)
cout<<s*a + q<<endl;
else
cout<<s*a + a<<endl;
}

Measured memory_bytes: 256
//g++ -std=c++14 test.cpp -o test.out
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <map> 
#include <utility>
#include <limits.h>
using namespace std;

#define LL long long int

int A,B,C;

string ans = "";

void solve(){
	if(
		(A==B && A!=C) ||
		(A==C && A!=B) ||
		(B==C && A!=B)
	){
		ans = "Yes";
	}else ans="No";
}
 
int main(){
	cin >> A >> B >> C;
 
	solve();

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


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <limits>
#include <queue>
#include <iomanip>
#include <set>
//#include <bits/stdc++.h>
template<typename T> bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<typename T> bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}
using namespace std;
#define ALL(X) X.begin(),X.end()
using ll = long long int;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
const int MOD=1000000007;
//const int MOD=998244353;
const int INTMAX=2147483647;
const ll LLMAX=9223372036854775807;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    string S;
    cin>>S;
    
    ll g=0,p=0;
    ll ans=0;
    for(ll i=0;i<S.size();i++){
        if(S[i]=='g'){
            if(p==g){
                g++;
            }else{
                p++;
                ans++;
            }
        }else{
            if(p==g){
                g++;
                ans--;
            }else{
                p++;
            }
        }
    }
    cout<<ans<<endl;
    
    return 0;
}


Measured memory_bytes: 512
from bisect import bisect_right
import numpy as np
def main():
    N, M, K = map(int, input().split())
    A = np.array([0] + list(map(int, input().split())), dtype=np.int64)
    B = np.array([0] + list(map(int, input().split())), dtype=np.int64)

    As = np.cumsum(A)
    Bs = np.cumsum(B)

    count = 0

    for i, a in enumerate(As):
        if a > K:
            break
        j = bisect_right(Bs, K-a)
        #print(f"i={i} j={j} Bs={Bs} cost={K-a}")
        count = max(count, (i+j-1))

    print(count)

if __name__ == '__main__':
    main()

Measured memory_bytes: 53996
N = int(input())
x = [0 for _ in range(N)]; y = [0 for _ in range(N)]
for i in range(N):
    x[i], y[i] = map(int, input().split())

def dist(x1, x2, y1, y2):
    return ((x1-x2)**2+(y1-y2)**2)**(1/2)

def factorial(n):
    if n==1:
        return 1
    else:
        return n*factorial(n-1)

total = 0
for i in range(N):
    for j in range(i+1, N):
        total += dist(x[i], x[j], y[i], y[j])

line_num = N*(N-1)/2 #線分の数
path_num = (N-1)*factorial(N)/line_num #ある線分が経路に含まれている数=1つの経路の線分の数×全経路数÷一意の線分の数

print(path_num*total/factorial(N))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
using namespace std;

int main() {
  int n, a=0, ans=-1;
  cin >> n;
  vector<int> h(n);
  rep(i, n) cin >> h.at(i);
  for(int i = 0; i < n-1; i++) {
    if(h.at(i) >= h.at(i+1)) a++;
    else {
      ans = max(ans, a);
      a=0;
    }
  }
  ans = max(ans, a);
  cout << ans;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fast_IO ios::sync_with_stdio(false);
#define DEBUG fprintf(stderr,"Running on Line %d in Function %s\n",__LINE__,__FUNCTION__)
//mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define fir first
#define sec second
#define mod 1000000007
#define int long long
#define inf 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f3f
inline int read()
{
	char ch=getchar(); int nega=1; while(!isdigit(ch)) {if(ch=='-') nega=-1; ch=getchar();}
	int ans=0; while(isdigit(ch)) {ans=ans*10+ch-48;ch=getchar();}
	if(nega==-1) return -ans;
	return ans;
}
typedef pair<int,int> pii;
inline int add(int x,int y){return x+y>=mod?x+y-mod:x+y;}
inline int add(int x,int y,int z){return add(add(x,y),z);}
inline int sub(int x,int y){return x-y<0?x-y+mod:x-y;}
inline int mul(int x,int y){return 1LL*x*y%mod;}
inline int mul(int x,int y,int z){return mul(mul(x,y),z);}
int qpow(int x,int y)
{
	int ans=1;
	while(y)
	{
		if(y&1) ans=mul(ans,x);
		x=mul(x,x);
		y>>=1;
	}
	return ans;
}
int Inv(int x){return qpow(x,mod-2);}
#define N 2005
int fa[N];
int find(int u){return fa[u]==u?u:fa[u]=find(fa[u]);}
struct Edge
{
	int u,v,w,id;
};
Edge a[N],b[N];
int n,m,x;
bool cmp(Edge x,Edge y)
{
	return x.w<y.w;
}
bool vis[N];
int get(int id)
{
	for(int i=1;i<=m;i++) b[i]=a[i];
	sort(b+1,b+m+1,cmp);
	int sum=0;
	for(int i=1;i<=n;i++) fa[i]=i;
	for(int i=1;i<=m;i++)
	{
		if(b[i].id==id)
		{
			fa[b[i].u]=b[i].v;
			sum+=b[i].w;
		}
	}
	for(int i=1;i<=m;i++)
	{
		int u=find(b[i].u),v=find(b[i].v);
		if(u!=v)
		{
			fa[u]=v;
			sum+=b[i].w;
		}
	}
	return sum;
}
signed main()
{
	cin>>n>>m>>x;
	for(int i=1;i<=m;i++) a[i].u=read(),a[i].v=read(),a[i].w=read(),a[i].id=i;
	int res=get(0);
	if(res>x) {cout<<0<<endl; return 0;}
	int cnt1=0,cnt2=0;
	for(int i=1;i<=m;i++)
	{
		int tmp=get(i);
		if(tmp==x) cnt1++;
		if(tmp>x) cnt2++;
	}
	if(res==x) cout<<mul(qpow(2,cnt1)-2,qpow(2,cnt2))<<endl;
	else cout<<mul(qpow(2,cnt1+1)-2,qpow(2,cnt2))<<endl;
	return 0;
}




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

int main (){
    int X, N;
    cin >> X >> N;
    vector<int> p(N);
    rep(i, N){
        cin >> p.at(i);
    }
    
    int num = X;
    bool flag;
    bool first = false;
    rep(i, N){
        if(num == p.at(i)){
            first = true;
        }
    }
    int count = 0;
    while(first){
        count ++;
        flag = false;
        num = X - count;
        rep(i, N){
            if(num == p.at(i)){
                flag = true;
                break;
            }
        }
        if(!flag){
            break;
        }

        flag = false;
        num = X + count;
        rep(i, N){
            if(num == p.at(i)){
                flag = true;
                break;
            }
        }
        if(!flag){
            break;
        }
    }
    cout << num << endl;
}

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

using namespace std;

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

int main() {
    int h, w;   cin >> h >> w;
    string *s = new string[h];
    for (int i = 0; i < h; i++)
        cin >> s[i];
    
    bool can = true;

    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (s[i][j] == '#') {
                bool can_ = false;
                for (int k = 0; k < 4; k++) {
                    int nx = i + dx[k];
                    int ny = j + dy[k];
                    if (nx < 0 || h <= nx || ny < 0 || w <= ny || s[nx][ny] == '.')
                        continue;
                    can_ = true;
                }
                if (!can_)
                    can = false;
            }
        }
    }
    if (can)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
class Node
  attr_reader :id, :siblings
  attr_accessor :state, :parent

  def initialize(id)
    @id = id
    @siblings = []
    @distances = {}
    @state = :white
    @parent = nil
  end

  def add(sibling, distance)
    @siblings << sibling
    @distances[sibling.id] = distance
  end

  def distance_from(other)
    @distances[other.id]
  end
end

if $PROGRAM_NAME == __FILE__
  n = gets.to_i

  nodes = []

  n.times do |id|
    nodes[id] ||= Node.new(id)
    node = nodes[id]

    distances = gets.chomp.split.map(&:to_i)

    distances.each_with_index do |distance, sibling_id|
      next if distance == -1

      nodes[sibling_id] ||= Node.new(sibling_id)
      sibling = nodes[sibling_id]

      node.add(sibling, distance)
    end
  end

  distances = Array.new(n, Float::INFINITY)

  distances[0] = 0

  loop do
    current = nil
    min = Float::INFINITY

    nodes.each do |node|
      next if node.state == :black

      distance = distances[node.id]

      if distance < min
        min = distance
        current = node
      end
    end

    break unless current

    current.state = :black

    current.siblings.each do |sibling|
      next if sibling.state == :black

      distance_from_current = sibling.distance_from(current)

      if distance_from_current < distances[sibling.id]
        distances[sibling.id] = distance_from_current
        sibling.parent = current
        sibling.state = :gray
      end
    end
  end

  sum = 0

  nodes.each do |node|
    next unless node.parent
    sum += node.distance_from(node.parent)
  end

  puts sum
end

Measured memory_bytes: 9240
#include <bits/stdc++.h>
using namespace std;
using ll         = long long;
constexpr ll MOD = 1000000007;
#define REP(i, n) for (ll i = 0; i < (n); i++)
#define REP2(i, x, n) for (ll i = x; i < (n); i++)
#define PR(x) cout << (x) << "\n"
#define PS(x) cout << (x) << " "
const long long INF = numeric_limits<long long>::max();
int main() {
    ll N, M;
    cin >> N >> M;

    ll p   = 1U << M;
    ll ans = (1900 * M + (N - M) * 100) * p;
    PR(ans);

    return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h> 
using namespace std;
typedef long long ll;
const int INF=0x3f3f3f3f;
const int N=2e5+5;
int n;
string str;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	cin>>n;
	for(int i=0;i<n;i++){
		int k;
		cin>>k;
		if(k%2==0){
			if(k%5!=0 && k%3!=0){
				puts("DENIED");
				return 0;
			}
		}
	}
	puts("APPROVED");
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<string>
#include<vector>
#include<list>
#include<set>
#include<cctype>
#define ld long double
#define ll long long int
#define ull unsigned long long int
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const long long INF=1LL<<60;
//set<set>::iterator it;

int main(void){
	ios::sync_with_stdio(false); cin.tie(0);
	
	set<int> s;
	int n,i,a;
	set<int>::iterator it;
	cin>>n;
	for(i=0;i<n;i++){
		cin>>a;
		s.insert(a);
//		cout<<i<<endl;
	}
	int ans=0;
	for(it=s.begin();it!=s.end();it++){
		ans++;
	}
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 256
using System;
class ProgramB
    {
        static void Main(string[] args)
        {
            string input = Console.ReadLine();
            int n = int.Parse(input);
            
            if(n <= 9)
                Console.WriteLine(n);
            else if(n <= 99)
                Console.WriteLine("9");
            else if(n <= 999)
                Console.WriteLine(n -90);
            else if(n <= 9999)
                Console.WriteLine("909");
            else if(n <= 99999)
                Console.WriteLine(n -9090);
            else
                Console.WriteLine("90909");
        }
    }

Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

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

    if((b+c) %2 ==0 ){
        cout << (c-b)/2 << endl;
        return 0;
    }

    cout << min(b-1,a-c) +1 +((c-b-1)/2) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
using namespace std;
void func(int,int);
int n,m,k,d[10000],ans,t;

int main(){
  while(1){
    cin>>n>>m>>k;
    if(!n&&!m&&!k) break;
    for(int i=0;i<10000;i++) d[i]=0;
    func(0,0);
    t=1;
    for(int i=0;i<n;i++) t*=m;
    ans=0;
    for(int i=0;i<10000;i++) ans+=i*d[i];
    printf("%.8f\n",1.0*ans/t);
  }
}

void func(int x,int r){
  if(x==n){
    if(r-k<=0) d[1]++;
    else d[r-k]++;
  }else
    for(int i=1;i<=m;i++) func(x+1,i+r);
}

Measured memory_bytes: 1232