akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <fstream>
#include <sstream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <string.h>
#include <iomanip>
using namespace std;


#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;i>=0;i--)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
typedef long long ll;

int main() {

    ll Q,H,S,D; cin >> Q >> H >> S >> D;
    ll N; cin >> N;

    Q *= 4;
    H *= 2;

    vector<ll> a(3);
    a[0] = Q;
    a[1] = H;
    a[2] = S;
    sort(a.begin(),a.end());

    ll ans = 0;
    if (a[0] * 2 > D) {
    	ans = (N / 2) * D;
    	ans += (N % 2) * a[0];
    } else {
    	ans = N * a[0];
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;

constexpr ll mod = 1e9 + 7;

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

/*-------------------------------------------*/

int n, m;
vector<int> e[55];

int par[55], dep[55];
int u[20], v[20], lca[20];
int num[55];

bool used[55];
void dfs(int x) {
    used[x] = true;
    for(const auto &y : e[x]) {
        if(!used[y]) {
            par[y] = x;
            dep[y] = dep[x] + 1;
            dfs(y);
        }
    }
}

int dfs2(int x) {
    used[x] = true;
    int ret = 0;
    for(const auto &y : e[x]) {
        if(!used[y]) {
            ret += dfs2(y);
            num[x] += num[y];
        }
    }
    if(num[x] == 0) ret++;
    return ret;
}

int LCA(int a, int b) {
    if(dep[a] > dep[b]) swap(a, b);
    while(dep[a] < dep[b])
        b = par[b];

    while(a != b) {
        a = par[a];
        b = par[b];
    }

    return a;
}

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

    cin >> n;
    rep(i, n - 1) {
        int a, b;
        cin >> a >> b;
        e[a].push_back(b);
        e[b].push_back(a);
    }

    dfs(1);

    cin >> m;
    rep(i, m) {
        cin >> u[i] >> v[i];
        lca[i] = LCA(u[i], v[i]);
    }

    ll ans = 0;
    FOR(i, 1, 1 << m) {
        rep(j, n + 1) {
            used[j] = false;
            num[j] = 0;
        }
        rep(j, m) if((i >> j) & 1) {
            num[u[j]]++;
            num[v[j]]++;
            num[lca[j]] -= 2;
        }
        int cnt = dfs2(1) - 1;
        ans += (__builtin_popcount(i) & 1 ? 1LL : -1LL) << cnt;
    }

    cout << (1LL << n - 1) - ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <map>

using namespace std;

const int MX = 150500;

int a[MX];

int main()
{
    //freopen("in.txt","r", stdin);
    ios_base::sync_with_stdio(false);
    int n, t;
    cin >> n >> t;
    for(int i = 0; i < n; i++)
        cin >> a[i];
    int max_ans = -1;
    int curr_min = a[0];
    int ans = -1;
    for(int i = 1; i < n; i++){
        if(a[i] < curr_min) curr_min = a[i];
        if(a[i] - curr_min > max_ans) {max_ans = a[i] - curr_min; ans = 0;}
        if(a[i] - curr_min == max_ans) {ans++;}
    }
    cout << ans << endl;
    return 0;
}


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

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rept(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(int)(n);(i)++)
#define repst(i,s,n) for(int (i)=(s);(i)<=(int)(n);(i)++)
#define repr(i,n) for(int (i)=(n);(i)>=0;(i)--)
#define each(itr,v) for(auto (itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp(x,y) make_pair((x),(y))
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln "\n"
#define show(x) cout << #x << " = " << x ln
#define dbg(x) cout<<#x"="<<x ln

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<int> > mat;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int inf = (int)1e9;
const ll linf = (ll)1e18;
const int mod = (int)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

int n, a, cnt[111111];

int main() {
	cin >> n;
	rep(i,n) {
		cin >> a;
		if (a>0) cnt[a-1]++;
		cnt[a]++, cnt[a+1]++;
	}
	int mx = 0;
	repst(i,1,100001) if (mx<cnt[i]) mx = cnt[i];
	cout << mx << ln;
}

Measured memory_bytes: 640
# https://atcoder.jp/contests/abc142/tasks/abc142_d
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

def nC2(n):
    return n * (n - 1) // 2

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

A = set(prime_factorize(a))
B = set(prime_factorize(b))

common = A & B
common.add(1)
ans = len(common)
print(ans)

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

using namespace std;

#define intt long long
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const int N = 200005;

int n, q;

bool used[N];

intt sum[N];


vector <vector <int>> g;

void dfs (int v, int par) {
	used[v] = true;
	sum[v] += sum[par];
	for (int to : g[v]) {
		if (!used[to]) {
			dfs(to, v);
		}
	}
}

int main() {

	FAST;

	cin >> n >> q;
	g.resize(n + 1);
	for (int i = 0; i < n - 1; i ++) {
		int x, y;
		cin >> x >> y;
		g[x].push_back(y);
		g[y].push_back(x);
	}
	while (q -- ) {
		int x, y;
		cin >> x >> y;
		sum[x] += y;
	}
	dfs(1, 0);
	for (int i = 1; i <= n; i ++) {
		cout << sum[i] << ' ';
	}
	return 0;
}

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

using ll = long long;
const int INF = INT_MAX;//2147483647
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
#ifdef LOCAL_ENV
	#define debug(var) std::cout<<#var" = "<<var<<std::endl
#else
	#define debug(var)
#endif
#define p(var)  std::cout<<var<<std::endl
#define PI (acos(-1))
#define rep(i, n)   for(int i=0, i##_length=(n); i< i##_length; ++i)
#define repeq(i, n) for(int i=1, i##_length=(n); i<=i##_length; ++i)
#define all(a) (a).begin(), (a).end()
#define pb push_back
inline double isnatural(double a) { return a>=0 && ceil(a)==floor(a); }
template<typename T> inline T gcd(T a, T b) { return b ? gcd(b,a%b) : a; }
template<typename T> inline T lcm(T a, T b) { return a / gcd(a,  b) * b; }
template<typename T1, typename T2>inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template<typename T1, typename T2>inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
	for (int i = 0, len = v.size(); i < len; ++i){
		s << v[i]; if (i < len - 1) s << "\t";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
	for (int i = 0, len = vv.size(); i < len; ++i){
		s << vv[i] << endl;
	}
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s, const map<T1, T2>& m) {
	s << "{" << endl;
	for (typeof(m.begin()) itr = m.begin(); itr != m.end(); ++itr){
		s << "\t" << (*itr).first << " : " << (*itr).second << endl;
	}
	s << "}" << endl;
	return s;
}

/*-----8<-----8<-----*/

int main() {
	int N,q;
	cin >> N >> q;
	string s;
	cin >> s;
	
	//平方分割してみる
	//1バケットに入っている要素数
	int bucket_num=floor(sqrt(N));
	//バケットの個数
	int bucket_size = (N + bucket_num - 1) / bucket_num;
	//バケット　バケット内に入っている2017っぽい数の個数
	vector<int> bucket(bucket_size,0);

	vector<int> aclist(N,0);
	repeq(i,N-1){
		if(s[i-1]=='A' && s[i]=='C'){
			aclist[i]++;
		}
	}
	//バケットを作る
	repeq(i,N-1){
		if(aclist[i]){
			bucket[i/bucket_num]++;
		}
	}

	debug(" ");
	debug(bucket_num);
	debug(bucket_size);
	debug(bucket);
	debug(aclist);

	vector<int> answerlist(q,0);
	rep(i,q){
		int x,y;
		cin >> x >> y;
		x--;y--;
		int answer=0;
		//バケットを走査
		// [x, y]の値を取得します　[x, y)がほしい場合はy-=1にしておいてね
		for (int i = 0; i < bucket_size; i++) {
			//bucket[i]の始点と終点
			int l = i * bucket_num;
			int r = (i + 1) * bucket_num - 1;
			//バケットの範囲外の場合はcontinue
			if (r < x || y < l){
				continue;
			}
			if (x <= l && r <= y) {
				//バケットが全て収まっている場合→バケットの値をそのまま使う
				answer += bucket[i];
			} else {
				//バケットの途中の場合→対象範囲を地道に調べる
				for (int j = max(x, l); j <= min(y, r); j++) {
					if(aclist[j]){
						answer++;
					}
				}
			}
		}
		if(x>0 && s[x-1]=='A' && s[x]=='C')answer--;
		answerlist[i]=answer;
	}

	rep(i,q)p(answerlist[i]);
	return 0;
}



Measured memory_bytes: 1792
N=int(input())
H=list(map(int,input().split()))

ans = 0
c = 0
for i,h in enumerate(H[:-1]):
  if h >= H[i+1]:
    c += 1
  else:
    ans = max(ans,c)
    c = 0
ans = max(ans,c)
print(ans)

Measured memory_bytes: 20416
#include<cstdio>
#include<cstdlib>
#include<cassert>
#include<iostream>
#include<set>
using namespace std;

inline int read()
{
	int x=0; bool f=1; char c=getchar();
	for(;!isdigit(c);c=getchar()) if(c=='-') f=0;
	for(; isdigit(c);c=getchar()) x=(x<<3)+(x<<1)+(c^'0');
	if(f) return x;
	return -x;
}

const int N = 2e5;
int a[N+3];
int uf[N+3];
set<int> s;
int n,m;

int findfa(int u) {return u==uf[u]?u:uf[u]=findfa(uf[u]);}
int unionfa(int u,int v) {int uu = findfa(u),vv = findfa(v); if(uu!=vv) uf[uu] = vv;}

int main()
{
	scanf("%d%d",&n,&m);
	for(int i=0; i<=n; i++) uf[i] = i;
	for(int i=1; i<=n; i++) scanf("%d",&a[i]); int cur = 0;
	for(int i=1; i<=m; i++) {s.insert(a[i]); if(i>1) {cur += (a[i-1]<a[i]);}}
	for(int i=m; i<=n; i++)
	{
		if(i<n)
		{
			if(((*s.begin())==a[i-m+1]) && ((*s.rbegin())<a[i+1]))
			{
				unionfa(i-m+2,i-m+1);
			}
		}
		if(i>m) {cur -= (a[i-m]<a[i-m+1]);}
		if(cur==m-1) {unionfa(i-m+1,0);}
		cur += (a[i]<a[i+1]);
		s.erase(a[i-m+1]);
		s.insert(a[i+1]);
	}
	int cnt = 0,ans = 0;
	for(int i=0; i<=n-m+1; i++) {if(uf[i]==i) ans++; if(i&&findfa(i)==findfa(0)) cnt++;}
	if(cnt) printf("%d\n",ans);
	else printf("%d\n",ans-1);
	return 0;
}

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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define POSSIBLE cout << ((n) ? "POSSIBLE\n" : "IMPOSSIBLE\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)
#define mp make_pair

template<int64 mod>
struct ModInt{
  int64 x;
  constexpr ModInt(int64 y = 0):x((y%mod+mod)%mod){}
  constexpr ModInt& operator+=(const ModInt& a){
    if((x += a.x) >= mod) x -= mod;
    return *this;
  }
  constexpr ModInt& operator-=(const ModInt& a){
    if((x -= a.x) < 0)x += mod;
    return *this;
  }
  constexpr ModInt& operator*=(const ModInt& a){
    x = x * a.x % mod;
    return *this;
  }
  constexpr ModInt& operator/=(const ModInt& a){
    *this *= a.inv();
    return *this;
  }
  constexpr ModInt operator-() const {
    return ModInt(-x);
  }
  constexpr ModInt operator+(const ModInt& a) const {
    return ModInt(*this) += a;
  }
  constexpr ModInt operator-(const ModInt& a) const {
    return ModInt(*this) -= a;
  }
  constexpr ModInt operator*(const ModInt& a) const {
    return ModInt(*this) *= a;
  }
  constexpr ModInt operator/(const ModInt& a) const {
    return ModInt(*this) /= a;
  }
  constexpr ModInt operator++(){
    *this += ModInt(1);
    return *this;
  }
  constexpr ModInt operator++(int){
    ModInt old = *this;
    ++*this;
    return old;
  }
  constexpr ModInt operator--(){
    *this -= ModInt(1);
    return *this;
  }
  constexpr ModInt operator--(int){
    ModInt old = *this;
    --*this;
    return old;
  }
  constexpr bool operator==(const ModInt& a) const {
    return x == a.x;
  }
  constexpr bool operator!=(const ModInt& a) const {
    return x != a.x;
  }
  constexpr ModInt pow(int64 r) const {
    if(!r)return 1;
    ModInt res = pow(r>>1);
    res *= res;
    if(r & 1) res *= *this;
    return res;
  }
  constexpr ModInt inv() const {
    return pow(mod-2);
  }
  friend istream& operator>>(istream& is, ModInt& a){
    int64 t;
    is >> t;
    a = ModInt(t);
    return is;
  }
  friend ostream& operator<<(ostream& os, const ModInt& a){
    return os << a.x;
  }
};
using mint = ModInt<MOD>;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int32 n,m;
    cin >> n >> m;
    map<int32,int32> broken;
    REP(i,m){
        int32 a;
        cin >> a;
        broken[a]++;
    }
    vector<mint> dp(n+1,0);
    dp[0] = 1;
    REP(i,n+1){
        if(broken[i] == 1)continue;
        if(i-2>=0)dp[i] += dp[i-2];
        if(i-1>=0)dp[i] += dp[i-1];
    }
    ANS(dp[n]);
    return 0;
}

Measured memory_bytes: 7296
import bisect as bi

li6 = [6 ** i for i in range(7)]
li9 = [9 ** i for i in range(6)]

def s69(n):
    if n < 6:
        return n
    else:
        s6 = li6[bi.bisect(li6, n) - 1]
        s9 = li9[bi.bisect(li9, n) - 1]
        return min(n // s6 + s69(n % s6), 1 + s69(n - s9))


print(s69(int(input())))

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

void dpf(int n, const vector<vector<pair<int, int>>>& graph, vector<int>& seen) {
	for (int i = 0; i < graph[n].size(); i++) {
		if (seen[graph[n][i].first] != -1) continue;
		if (graph[n][i].second % 2 == 0) {
			seen[graph[n][i].first] = seen[n];
			dpf(graph[n][i].first, graph, seen);
		}
		else {
			seen[graph[n][i].first] = abs(seen[n] - 1);
			dpf(graph[n][i].first, graph, seen);
		}
	}
}

int main() {
	int N;
	cin >> N;
	vector<vector<pair<int, int>>> graph(N);
	int u, v, w;
	for (int i = 0; i < N - 1; i++) {
		cin >> u >> v >> w;
		graph[u - 1].push_back(make_pair(v - 1, w));
		graph[v - 1].push_back(make_pair(u - 1, w));
	}
	vector<int> seen(N, -1);
	seen[0] = 0;
	dpf(0, graph, seen);
	for (int i = 0; i < N; i++) {
		cout << seen[i] << endl;
	}
}

Measured memory_bytes: 10796
def nosereru?(p, k, a)
    sum = 0
    cnt = 1
    for i in 0..a.length-1
        return false if a[i] > p
        # printf("%d番目の積み荷　重量%d\n", i, a[i])
        sum += a[i]
        # printf("積み荷合計 %d\n", sum)
        if sum > p then
            # printf("積載量オーバー (積載量 = %d)\n", p)
            cnt += 1
            # printf("\nトラック%d台目開始\n", cnt)
            sum = a[i]
            # printf("積み荷合計 %d\n", sum)
        end
    end
    if cnt <= k then
        # printf("%d台以下で積載可能\n\n", k)
        return true
    else
        # printf("%d台以下では積載不可\n\n", k)
        return false
    end
end

n, k = gets.split.map(&:to_i)
a = []
n.times{
    a.push(gets.to_i)
}

left = 0
right = 100000*10000
# printf("検討対象 は %s 〜 %s\n", left, right)

until right == left
    mid = (left + right) / 2
    # printf("mid = %dで検討\n", mid)
    if nosereru?(mid, k, a) then
        right = mid
        # printf("検討対象 は %s 〜 %s\n", left, right)
    else
        left = mid + 1
        # printf("検討対象 は %s 〜 %s\n", left, right)
    end
end

puts right


Measured memory_bytes: 9336
import sys
 
sys.setrecursionlimit(10000)

N,K,L = map(int, input().split())

#print(N,K,L,D,T)

class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n+1)]
        self.rank = [0] * (n+1)

    # 検索
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    # 併合
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
        else:
            self.par[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    # 同じ集合に属するか判定
    def same_check(self, x, y):
        return self.find(x) == self.find(y)

def execOne(num, uf):
    for _ in range(num):
        d0, d1 = map(int, input().split())
        d0 = d0 - 1
        d1 = d1 - 1
        uf.union(d0, d1)

uf_D = UnionFind(N)
uf_T = UnionFind(N)

execOne(K, uf_D)
execOne(L, uf_T)


pairs = []
for i in range(N):
    pairs.append((uf_D.find(i), uf_T.find(i)))

pairs_count = {}
for p in pairs:
    if not p in pairs_count:
        pairs_count[p] = 1
    else:
        pairs_count[p] += 1

res = [0] * N
for i in range(N):
    res[i] = pairs_count[pairs[i]]
#print(*(res[i] for i in range(N)))
print(" ".join([str(i) for i in res]))

Measured memory_bytes: 66712
from fractions import gcd
N, X = map(int, input().split())
x = list(map(int, input().split()))
l = []
for xx in x:
    l.append(abs(xx - X))
 
g = l[0]
 
for i in range(1, len(l)):
    g = gcd(g, l[i])
 
print(g)

Measured memory_bytes: 16280
#include<iostream>
#include<cstdlib>
#include<utility>
#include<tuple>
#include<string>
#include<vector>
#include<numeric>
#include<algorithm>
#include<queue>
#include<deque>
#include<bitset>
#include<cmath>
#include<map>
#include<iomanip>
using namespace std;
using ll = long long int;
const ll mod = 1e9 + 7;
#define rep(i, a, b) for(int i = a; i < b; i++)

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

	cout << a * b << endl;

	return 0;
}

Measured memory_bytes: 3636
mod  = 998244353
MAX = 2*10**5 + 100

inv=[0]*(MAX+1)
inv[1]=1
for i in range(2,MAX+1):
    inv[i]=-(mod//i)*inv[mod%i]%mod

g1=[1,1]
g2=[1,1]
for i in range(2,MAX+1):
    num_1=g1[-1]*i%mod
    g1.append(num_1)
    g2.append(g2[-1]*inv[i]%mod)
    
def cmb(n,r):
    return g1[n]*g2[r]*g2[n-r]%mod


N, M, K = map(int,input().split())

ans = 0
for i in range(K+1):
    num = M * pow(M - 1, N - i - 1, mod) % mod
    num = num * cmb(N - 1, i) % mod 
    ans = (ans + num) % mod
    
print(ans)

Measured memory_bytes: 100168
class Element {
    constructor(key){
        this.key = key;
        this._prev = null;
        this._next = null;
    }

    getPrev(){
        return this._prev;
    }

    getNext(){
        return this._next;
    }

    setPrev(ele){
        this._prev = ele;
    }

    setNext(ele){
        this._next = ele;
    }
}

class DoublyLinkedList {
    constructor(ele) {
        this.ele = ele;
        this.ele.setNext(this.ele);
        this.ele.setPrev(this.ele);
    }

    insert(key){
        const newEle = new Element(key);
        newEle.setNext(this.ele.getNext());
        this.ele.getNext().setPrev(newEle);
        this.ele.setNext(newEle);
        newEle.setPrev(this.ele);
    }

    listSearch(key){
        let cur = this.ele.getNext();
        while(cur.key !== null && cur.key !== key){
            cur = cur.getNext();
        }
        return cur;
    }

    delete(key){
        const elehaskey = this.listSearch(key);
        this.deleteNode(elehaskey);
    }

    deleteNode(ele){
        if(ele.key === null) return;
        ele.getPrev().setNext(ele.getNext());
        ele.getNext().setPrev(ele.getPrev());
    }

    deleteFirst(){
        this.deleteNode(this.ele.getNext())
    }

    deleteLast(){
        this.deleteNode(this.ele.getPrev())
    }

    showList(){
        let cur = this.ele.getNext();
        const list = [];
        while(cur.key !== null){
            list.push(cur.key);
            cur = cur.getNext();
        }
        return list;
    }

    export(){
        let cur = this.ele.getNext();
        let list = '';
        while(cur.key !== null){
            list += list.length ? ' ' : '';
            list += cur.key.toString();
            cur = cur.getNext();
        }
        console.log(list);
    }

}


function main(stdin) {
    const _inputs = stdin.split("\n");
    const total = parseInt(_inputs.shift(),10);
    const orders = _inputs.filter((e, i) => i < total).map(ele => ele.split(' '));

    const dll = new DoublyLinkedList(new Element(null));
    for(const order of orders){
        if(order[0] === 'insert'){
            dll.insert(order[1]);
        }
        else if(order[0] === 'delete'){
            dll.delete(order[1]);
        }
        else if(order[0] === 'deleteFirst'){
            dll.deleteFirst();
        }
        else if(order[0] === 'deleteLast'){
            dll.deleteLast();
        }
    }
    dll.export();
}



main(require("fs").readFileSync("/dev/stdin", "utf8"));



Measured memory_bytes: 481092
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
#define double long double
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<ll> vec;
typedef vector<vec> mat;
const ll inf=1e9+7;
const ll mod=1e9+7;
int main(){
    ll n;cin>>n;
    string s;cin>>s;
    mat dp(n,vec(n+1));
    dp[0][0]=1;
    rep(i,n-1){
        REP(j,1,n){
            dp[i][j]=(dp[i][j]+dp[i][j-1])%inf;
        }
        rep(j,n){
            ll k=n-1-i;
            if(s[i]=='<'){
                dp[i+1][j]=(dp[i+1][j]+dp[i][j])%inf;
                dp[i+1][k]=(dp[i+1][k]-dp[i][j])%inf;
            }else{
                dp[i+1][0]=(dp[i+1][0]+dp[i][j])%inf;
                dp[i+1][j]=(dp[i+1][j]-dp[i][j])%inf;
            }
        }
    }
    REP(i,1,n)dp[n-1][i]=(dp[n-1][i]+dp[n-1][i-1])%inf;
    ll ans=0;
    rep(i,n){
        ans=(ans+dp[n-1][i])%inf;
    }
    if(ans<0)ans+=inf;
    cout<<ans<<endl;
}

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

#define N 25

class Node {
public:
    int parent = -1;
    int left;
    int right;
};

void Preorder(Node *, int);
void Inorder(Node *, int);
void Postorder(Node *, int);

int main() {

    int n;
    cin>>n;
    int id, l, r;
    Node list[25];
    
    for(int i = 0; i < n;  i++) {
        cin>>id>>l>>r;
        list[id].left = l;
        list[id].right = r;
        if(l != -1) {
            list[l].parent = id;
        }
        if(r != -1) {
            list[r].parent = id;
        }
    }
    
    int root;
    for(root = 0; list[root].parent != -1; root++);
    
    cout<<"Preorder"<<endl;
    Preorder(list, root);
    cout<<endl;
    
    cout<<"Inorder"<<endl;
    Inorder(list, root);
    cout<<endl;
    
    cout<<"Postorder"<<endl;
    Postorder(list, root);
    cout<<endl;


  return 0;
}

void Preorder(Node *list, int a) {
    cout<<' '<<a;
    if(list[a].left != -1) Preorder(list, list[a].left);
    if(list[a].right != -1) Preorder(list, list[a].right);
}

void Inorder(Node *list, int a) {
    if(list[a].left != -1) Inorder(list, list[a].left);
    cout<<' '<<a;
    if(list[a].right != -1) Inorder(list, list[a].right);
}

void Postorder(Node *list, int a) {
    if(list[a].left != -1) Postorder(list, list[a].left);
    if(list[a].right != -1) Postorder(list, list[a].right);
    cout<<' '<<a;
}



Measured memory_bytes: 3092
n = int(input())
p = list(map(int, input().split()))
memo = 0
for i in range(n-2):
  if((p[i]>p[i+1] and p[i+1]>p[i+2]) or (p[i]<p[i+1] and p[i+1]<p[i+2])):
    memo+=1
print(memo)

Measured memory_bytes: 9088
#ifdef LOCAL
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <queue>
#else
#include <bits/stdc++.h>
#endif
using namespace std ;

typedef long long ll ;
#define rep(i , n ) for ( int i =0; i < n ; i++)
#define _sort(arg) sort(begin(arg), end(arg))
#define MOD 1000000007
#define pb push_back
#define DEBUG(x) cout << #x <	< ": " << x << endl;

/*
__attribute__((constructor))
void initial()
{
	cin.tie(NULL);
	ios::sync_with_stdio(false);
}
*/
int dp[55][55];
int dx[4] = {-1, 0, 1, 0};
int dy[4] = {0, 1, 0, -1}; 

string s[55];
int visited[55][55];

int bfs(int h, int w)
{
	queue<pair<int, int> > q;

	q.push(make_pair(0,0));

	visited[0][0] = 1;

	while(!q.empty())
	{
		pair<int, int> top_p = q.front(); 
		q.pop();
		int tx, ty;
		tie(tx, ty) = top_p;


		if ((tx == w-1) && (ty == h-1))
		{
			return dp[ty][tx];
		}
		rep(i, 4)
		{
			
				int xx = dx[i] + tx;
				int yy = dy[i] + ty;
				if( (xx < w) && (xx >= 0) && (yy < h) && (yy >= 0) && (!visited[yy][xx]) && (s[yy][xx] == '.') )
				{
					dp[yy][xx] = dp[ty][tx] + 1; 
					visited[yy][xx] = 1;
					q.push(make_pair(xx, yy));
				}
			
		}
	}
	return 0;
}

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

	int H, W;

	cin >> H >> W;
	
	int black = 0;

	rep(i ,H)
	{
		cin >> s[i];
		rep(j, W)
		{
			if (s[i][j] == '#')
			{
				black++;
			}
		}
	}

	int ret = bfs(H, W);
	//cout << "ret = " << ret << endl;
	if (!ret)
	{
		cout << -1 << endl;
	}
	else
	{
		cout << H * W - black - ret - 1 << endl;
	}
	

	return 0;
}


Measured memory_bytes: 256
/**
 *    author:  tourist
 *    created: 26.11.2019 11:43:41       
**/
#include <bits/stdc++.h>

using namespace std;

class dsu {
 public:
  vector<int> p;
  int n;

  dsu(int _n) : n(_n) {
    p.resize(n);
    iota(p.begin(), p.end(), 0);
  }

  inline int get(int x) {
    return (x == p[x] ? x : (p[x] = get(p[x])));
  }

  inline bool unite(int x, int y) {
    x = get(x);
    y = get(y);
    if (x != y) {
      p[x] = y;
      return true;
    }
    return false;
  }
};

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m, k;
  cin >> n >> m >> k;
  vector<int> c(n);
  for (int i = 0; i < n; i++) {
    cin >> c[i];
    --c[i];
  }
  vector<tuple<int, int, int>> e(m);
  for (int i = 0; i < m; i++) {
    int x, y, z;
    cin >> x >> y >> z;
    --x; --y;
    if (c[x] != -1) {
      x = n + c[x];
    }
    if (c[y] != -1) {
      y = n + c[y];
    }
    e[i] = make_tuple(z, x, y);
  }
  sort(e.begin(), e.end());
  long long ans = 0;
  int cnt = 0;
  dsu d(n + k);
  for (auto& ee : e) {
    int z = get<0>(ee);
    int x = get<1>(ee);
    int y = get<2>(ee);
    if (d.unite(x, y) && cnt < k - 1) {
      ++cnt;
      ans += z;
    }
  }
  cout << (cnt < k - 1 ? -1 : ans) << '\n';
  return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
#define IOS cin.tie(0),ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
typedef std::pair<ll, ll> P;
template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }
template<class Type>struct is_vector : std::false_type {};
template<class ValueType, class Alloc>struct is_vector<std::vector<ValueType, Alloc>> : std::true_type {};
template <typename T> inline std::ostream& operator << (std::ostream& out, const std::vector<T>& v) {
	if (v.empty())return out;
	constexpr bool is_vector_v = is_vector<T>::value;
	if (is_vector_v)for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? "\n" : "");
	else for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? " " : "");
	return out;
}
inline void put() {}
template<class T> inline void put(const T& first) { std::cout << first << "\n"; }
template<class T, class... N> inline void put(const T& first, const N& ... rest) { std::cout << first << " "; put(rest...); }
inline void putn() {}
template<class T, class... N> inline void putn(const T& first, const N& ... rest) { std::cout << first << "\n"; putn(rest...); }


int main() {
	IOS;
	int a, b;
	cin >> a >> b;
	string r1="", r2="";
	REP(i, a) {
		r1 += (char)b + '0';
	}
	REP(i, b) {
		r2+= (char)a + '0';
	}
	if (r1 < r2) {
		put(r1);
	} else {
		put(r2);
	}
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<algorithm>
#include<vector>
#include<map>

using namespace std;

int main() {
   int N;
   cin >> N;
   int a[N];
   for (int i = 0; i < N; i++) {
      cin >> a[i];
   } 
   sort(a, a + N);
   int alice = 0;
   int bob = 0;
   for (int i = 0; i < N; i++) {
      if (i % 2 == 0) alice += a[N - 1 - i];
      else bob += a[N - 1 - i];
   }
   
   cout << alice - bob << endl;
   return 0;
}


Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(unused_variables)]

use itertools::Itertools;
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        s: usize, w: usize,
    }

    println!("{}", if w >= s { "unsafe" } else { "safe" });
}


Measured memory_bytes: 2152
import sys
input = sys.stdin.readline
# 文字列をinput()した場合、末尾に改行が入るので注意
def main():
  n,m=map(int,input().split())
  a=sorted(list(map(int,input().split())))
  import bisect
  # 解説の二分探索
  # あるXを定め、X以上になる握手の組み合わせが何通りあるか計算。M個以上になる最大のXを探す
  # [l,r)半開区間
  l,r=0,a[-1]*2+1
  while r-l>1:
    x=(l+r)//2
    cnt=0
    for ai in a:
      cnt+=n-bisect.bisect_left(a,x-ai)
    # x以上がm個以上ある->x~r-1に求めるものがある
    if cnt>=m:
      l=x
    else:# x以上がm個未満ある->l~x-1に求めるものがある
      r=x
  x=(l+r)//2
  ans=0
  cnt=0
  a_=0
  cs_a=[0]
  for ai in a:
    a_+=ai
    cs_a.append(a_)
  for ai in a:
    bi=bisect.bisect_right(a,x-ai)
    cnt+=n-bi
    ans+=cs_a[-1]-cs_a[bi]+(n-bi)*ai
  print(ans+(m-cnt)*x)

if __name__=='__main__':
  #import datetime
  #print(datetime.datetime.now())
  main()
  #print(datetime.datetime.now())


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

using namespace std;
using LL = long long;
using P = pair<int, int>;
using Tapris = tuple<int, int, int>;

#define REP(i, n) for(LL i = 0; i < n; ++i)
#define FOR(i, a, n) for(LL i = a; i < n; ++i)
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e15;
const int MOD = 1e9 + 7;

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

//#define int long long

/*************** using variables ***************/
int n, d, x;
int p[15][15];
int dp[100005];
/**********************************************/

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

    cin >> n >> d >> x;
    REP(i, d)REP(j, n) cin >> p[i][j];
    

    int cur = x;
    REP(i, d-1){
        REP(j, cur+1) dp[j] = j;
        REP(j, n){
            REP(k, cur+1){
                if(k - p[i][j] >= 0){
                    dp[k] = max(dp[k], dp[k-p[i][j]] + p[i+1][j]);
                }
            }
        }
        int _next = 0;
        REP(j, cur+1) _next = max(_next, dp[j]);
        cur = _next;
    }
    cout << cur << endl;
}



Measured memory_bytes: 3216
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef vector<ll> vi;
typedef long double td;
typedef vector<td> vd;
typedef pair<ll,ll> ii;
typedef vector<ii> vii; typedef vector<bool> vb;
#define FIN ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define forr(i, a, b) for(ll i = ll(a); i < (ll)(b); i++)
#define forn(i, n) forr(i, 0, n)
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define DBG(x) cerr << #x << " = " << (x) << endl
#define show(v,n) cerr << #v << " = "; forn(i,n) cerr << v[i] << " "; cerr << endl;
#define esta(x,c) ((c).find(x) != (c).end())
#define RAYA cerr << "===============================" << endl
int MAXN = 500005;
ll INF = (ll)(1e18+7);

vector < vector <ll> > dp(500,vector<ll>(500,INF));
vector < vector <bool> > visto(500,vector <bool>(500));
vector <ll> acum(500,0);

ll f(int a, int b, vector <ll> &v)
{
	if(a==b) return 0LL;
	if(visto[a][b]==true) return dp[a][b];
	forr(i,a,b)
	{
		dp[a][b]=min(dp[a][b],f(a,i,v)+f(i+1,b,v)+acum[b+1]-acum[a]);
	}
	visto[a][b]=true;
	return dp[a][b];
}

 
int main()
{ 	
	FIN;
	#ifdef input
		//("T1.txt", "r", stdin);
	#endif
	
	int n;
	cin >> n;
	vector <ll> v(n);
	forn(i,n) cin >> v[i];
	forr(i,1,n+1) acum[i]=acum[i-1]+v[i-1];
	cout << f(0,n-1,v) << "\n";
	
    return 0;
}


Measured memory_bytes: 5728
from bisect import bisect_left
n = int(input())
nums = sorted([int(i) for i in input().split()])

ans = 0
for i in range(n-2):
    for j in range(i+1, n-1):
        tmp = nums[i] + nums[j]
        idx = bisect_left(nums, tmp)
        ans += idx - j - 1
print(ans)


Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	int n;
	cin>>n;
	ll sum1=0,sum2=0;
	int cnt1=0,cnt2=0;
	vector<int>arr(n+1);
	for(int i=1; i<=n; i++){
		cin>>arr[i];
		if(arr[i]==0)
		 cnt1++;
		else if(arr[i]<0){
			cnt2++;
			sum1+=(-arr[i]);
		}
		else
		 sum2+=arr[i];
	}
	if(cnt2%2==0){
		cout<<sum2+sum1;
	}
	else if(cnt1){
		cout<<sum2+sum1;
	}
	else{
		int mn1=1e5,mn2=1e5;
		for(int i=1; i<=n; i++){
			if(arr[i]<0){
				mn1=min(mn1,-arr[i]);
			}
			else
			 mn2=min(mn2,arr[i]);
		}
		if(mn1>mn2){
			cout<<sum2+sum1-2*mn2;
		}
		else
		 cout<<sum1+sum2-2*mn1;
	}
	
	return 0;
	
}

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

#define rep(i,z) for(int i = 0; i<(int)(z); i++)
#define rep1(i,z) for(int i = 1; i<=(int)(z); i++)
 
using namespace std;

typedef long long ll;
const ll MOD=1e9+7;
using pear = pair<int,int>;

int main(){
  int n; cin>>n;
  ll a[n], ans=0,sum[n-1];
  rep(i,n){
    cin>>a[i];
    a[i]%=MOD;
  }
  sum[n-2]=a[n-1];
  for(int i=n-3;i>=0;i--) sum[i]=(sum[i+1]%MOD+a[i+1]%MOD)%MOD;
  for(int i = 0;i <n-1;i++){
    ans+= a[i]*sum[i]%MOD;
    ans%=MOD;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 6744
#include <stdio.h>
#include <string.h>

typedef struct {
    int num[6], temp;
} dice_struct;
dice_struct dice;

void setting(int d[]) {
    for (int i = 0; i < 6; i++) {
        dice.num[i] = d[i];
    }
}

void throw(char order) {
    switch (order) {
        case 'E':
            dice.temp = dice.num[0];
            dice.num[0] = dice.num[3];
            dice.num[3] = dice.num[5];
            dice.num[5] = dice.num[2];
            dice.num[2] = dice.temp;
            break;
        case 'S':
            dice.temp = dice.num[0];
            dice.num[0] = dice.num[4];
            dice.num[4] = dice.num[5];
            dice.num[5] = dice.num[1];
            dice.num[1] = dice.temp;
            break;
        case 'W':
            dice.temp = dice.num[0];
            dice.num[0] = dice.num[2];
            dice.num[2] = dice.num[5];
            dice.num[5] = dice.num[3];
            dice.num[3] = dice.temp;
            break;
        case 'N':
            dice.temp = dice.num[0];
            dice.num[0] = dice.num[1];
            dice.num[1] = dice.num[5];
            dice.num[5] = dice.num[4];
            dice.num[4] = dice.temp;
            break;            
    }
        
}


int main(int argc, char const *argv[]) {

    int number[6];
    for (int i = 0; i < 6; i++) {
        scanf("%d", &number[i]);
    }
    setting(number);


    char direction[101];
    scanf("%s", direction);
    int len = strlen(direction);

    for(int i = 0; i < len; i++) {
        throw(direction[i]);
    }

    printf("%d\n", dice.num[0]);

    return 0;
}


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

int compare_int(const void *a,const void *b){
  if(*(long long*)a-*(long long*)b > 0) return 1;
  return -1;
}

int main(void){
  int N;
  scanf("%d",&N);

  long long A[N],B[N];
  for (int i = 0; i < N; i++) {
    scanf("%lld",&A[i]);
    B[i] = A[i]-i;
  }

  qsort(B,N,sizeof(long long),compare_int);

  int b = B[N/2];
  long long ans = 0;
  for (int i = 0; i < N; i++) {
    ans += abs(B[i]-b);
  }

  printf("%lld\n",ans);

  return 0;
}

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

int main()
{
    int m, f, r;
    while (cin >> m >> f >> r) {
        if (m == -1 && f == -1 && r == -1) break;

        if (m == -1 || f == -1) {
            cout << 'F' << endl;
            continue;
        }

        int sum = m + f;
        char c;
        if (sum < 30) c = 'F';
        else if (sum >= 80) c = 'A';
        else if (sum >= 65) c = 'B';
        else if (sum >= 50) c = 'C';
        else {
            if (r >= 50) c = 'C';
            else c = 'D';
        }
        cout << c << endl;
    }
}



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

int main() {
  string S ; 
  cin >> S ; 
  
  for(int i = 0 ; i < S.size() ; i++){
    S.at(i) = 'x' ; 
  }
  
  cout << S << endl ; 
  
  
}

Measured memory_bytes: 3632
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] x = new int[n];
		int[] y = new int[n];
		int[] h = new int[n];
		int H = 0, a = 0;
		for(int i = 0; i < n; i++) {
			x[i] = sc.nextInt();
			y[i] = sc.nextInt();
			h[i] = sc.nextInt();
			if(h[i] > 0) a = i;
		}
		LOOP:for(int i = 0; i <= 100; i++) {
			for(int j = 0; j <= 100; j++) {
				boolean isok = true;
				H = h[a] + Math.abs(x[a]-i) + Math.abs(y[a]-j);
				for(int k = 0; k < n; k++) {
					if(h[k] != Math.max(H - Math.abs(x[k]-i) - Math.abs(y[k]-j), 0)) {
							isok = false;
							break;
					}
				}
				if(isok) {
					System.out.println(i + " " + j + " " + H);
					break LOOP;
				}
			}
		}
	}

}

Measured memory_bytes: 23764
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#include <regex>
#include <map>
#include <set>
using namespace std;
int main(){
    string S;
    cin >> S;
    
    int C1=0,C2=0,ans=0;
    for(int i=0;i<S.length();i++){
        if(S[i]== '0'){
            C1++;
        }else{
            C2++;
        }
    }
    
    ans = min(C1,C2)*2;
    
    cout << ans << endl;
    return 0;
}



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

int main() {
    int n; cin >> n;
    vector<int> h(n);

    for (int i = 0; i < n; i++) {
        cin >> h[i];
    }

    int num = h[n - 1];
    for (int i = n - 1; i >= 0; i--) {
        if (h[i] - 1 > num) {
            cout << "No" << endl;
            return 0;
        }
        num = min(num, h[i]);
    }
    cout << "Yes" << endl;
    return 0;
}


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

 bool is_prime(int x){
 if(x<=1) return false;
 for(int i=2;i*i<=x;i++)
 if(x%i==0) return false;
 return true;
 }

 signed main(){
   int x;
cin>>x; int p=x;
while(!is_prime(p)) p++;

 cout<<p<<endl;
 return 0; }

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

int Y[101];
bool ok[101];
int N,A,B,C,X;

int main() {
    while(cin>>N>>A>>B>>C>>X, N|A|B|C|X) {
        for(int i=0; i<N; ++i) {
            cin>>Y[i];
            ok[i] = false;
        }

        int f = 0;
        int pushed = 0;
        while(f <= 10000) {
            if(Y[pushed] == X) pushed++;
            if(pushed == N) break;
            X = (A*X+B)%C;
            f++;
        }

        if(f > 10000) cout<<-1<<endl;
        else cout<<f<<endl;
    }
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#define MOD 1000000007
using namespace std;
int n, k;
vector<int> v[100000];
int w[100000];
long long f(int x, int y){
    long long res = k;
    if(y != -1){
        res = k - w[y];
        if(res < 1)return 0;
        //res *= w[y]--;
        w[y]--;
    }
    w[x]--;
    for(int i=0;i<v[x].size();i++){
        if(v[x][i] != y){
            long long t = f(v[x][i], x);
            if(t == 0)return 0;
            res *= t;
            res %= MOD;
        }
    }
    return res % MOD;
}
int main(void){
    cin >> n >> k;
    fill(w, w+n, 1);
    for(int i=0;i<n-1;i++){
        int a, b;
        cin >> a >> b;
        w[--a]++;
        w[--b]++;
        v[a].push_back(b);
        v[b].push_back(a);
    }
    cout << f(0, -1) << endl;
}


Measured memory_bytes: 10752
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        try (Scanner sc = new Scanner(System.in)){
            while (sc.hasNextInt()) {
                int n = sc.nextInt();
                for (int i=0;i<n;i++){
                    double x1 = sc.nextDouble();
                    double y1 = sc.nextDouble();
                    double x2 = sc.nextDouble();
                    double y2 = sc.nextDouble();
                    double x3 = sc.nextDouble();
                    double y3 = sc.nextDouble();
                    double G = ( y2*x1-y1*x2 +y3*x2-y2*x3 +y1*x3-y3*x1 );
                    double Xc = ((x1*x1+y1*y1)*(y2-y3)+(x2*x2+y2*y2)*(y3-y1)+(x3*x3+y3*y3)*(y1-y2))/(2*G);
                    double Yc =-((x1*x1+y1*y1)*(x2-x3)+(x2*x2+y2*y2)*(x3-x1)+(x3*x3+y3*y3)*(x1-x2))/(2*G);
                    double r = Math.sqrt( (x1 - Xc) * (x1 - Xc) + (y1 - Yc) * (y1 - Yc) );
                    System.out.println(String.format("%.3f %.3f %.3f",Xc, Yc, r));
                }
            }
        }
    }
}


Measured memory_bytes: 28608
package main

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

func scanInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func scanInt64() int64 {
	sc.Scan()
	i, _ := strconv.ParseInt(sc.Text(), 10, 64)
	return i
}

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func scanInts64(n int) []int64 {
	res := make([]int64, n)
	for i := range res {
		res[i] = scanInt64()
	}
	return res
}

func scanText() string {
	sc.Buffer([]byte{}, math.MaxInt64)
	sc.Scan()
	return sc.Text()
}

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)
	m := map[int]int{}

	x, n := scanInt(), scanInt()
	for i := 0; i < n; i++ {
		idx := scanInt()
		m[idx]++
	}
	for i := 0; i <= 100; i++ {
		if m[x-i] == 0 {
			fmt.Println(x - i)
			return
		}
		if m[x+i] == 0 {
			fmt.Println(x + i)
			return
		}
	}

}


Measured memory_bytes: 1760
import math
k=int(input())
#print(k)
ans_list=[]
for i in range(1,k+1):
  for j in range(1,k+1):
    gcd_ij=math.gcd(i,j)
    #print(gcd_ij)
    for k in range(1,k+1):
      ans_list.append(math.gcd(gcd_ij,k))
      #print(ans_list)
print(sum(ans_list))

Measured memory_bytes: 71344
#include<iostream>
#include<cstdio>
#include<cstring>
namespace Math
{
	typedef long long ll;
	const int N=200010,M=525000,MOD=924844033;
	ll qpow(ll a,ll b){ll c=1;for(;b;b>>=1,a=a*a%MOD)if(b&1)c=c*a%MOD;return c;}
	int dec[M];
	void getdec(int n){dec[0]=0;for(int i=1;i<n;i++)dec[i]=(dec[i>>1]>>1)+((i&1)?(n>>1):0);}
	void ntt(ll *y,int n,int rag)
	{
		for(int i=0;i<n;i++)
			if(dec[i]<i)std::swap(y[i],y[dec[i]]);
		for(int len=2;len<=n;len<<=1)
		{
			int h=len>>1;
			ll delta=qpow(5,(MOD-1)/len),x,*y0,*y1,ny0,ny1;

			if(rag<0)delta=qpow(delta,MOD-2);

			for(int p=0;p<n;p+=len)
			{
				y0=y+p,y1=y0+h,x=1;
				for(int i=0;i<h;i++,x=x*delta%MOD)
				{
					ny0=(y0[i]+x*y1[i])%MOD;
					ny1=(y0[i]-x*y1[i])%MOD;
					y0[i]=ny0;
					y1[i]=ny1;
				}
			}
		}
	}
	ll A[M],B[M];
	int m;
	void multi()
	{
		getdec(m);
		ntt(A,m,1),ntt(B,m,1);
		for(int i=0;i<m;i++)
			A[i]=A[i]*B[i]%MOD;
		ntt(A,m,-1);
		ll tmp=qpow(m,MOD-2);
		for(int i=0;i<m;i++)
			A[i]=(A[i]*tmp%MOD+MOD)%MOD;
	}

	ll fact[N],ifact[N];
	void calc(int *b,int *ans,int n)
	{
		for(m=1;m<=n+n;m<<=1);
		for(int i=fact[0]=1;i<=n;i++)fact[i]=fact[i-1]*i%MOD;
		ifact[n]=qpow(fact[n],MOD-2);
		for(int i=n;i;i--)ifact[i-1]=ifact[i]*i%MOD;

		for(int i=1;i<=n;i++)A[i]=b[i]*fact[i]%MOD;
		for(int i=0;i<=n;i++)B[i]=ifact[n-i];
		multi();

		for(int i=1;i<=n;i++)
			ans[i]=(A[n+i]*ifact[i]%MOD+MOD)%MOD;
	}
}
namespace O_O
{
	typedef long long ll;
	const int N=201000,M=N*2,MOD=924844033;
	int begin[N],next[M],to[M];
	int cnt[N],ans[N];
	int n,e;
	void add(int x,int y,bool k=1)
	{
		to[++e]=y;
		next[e]=begin[x];
		begin[x]=e;
		if(k)add(y,x,0);
	}
	void initialize()
	{
		scanf("%d",&n);
		for(int i=1,u,v;i<n;i++)
			scanf("%d%d",&u,&v),add(u,v);
	}

	int dfs(int p=1,int h=0)
	{
		int sizp=1,x;
		for(int i=begin[p],q;i;i=next[i])
			if((q=to[i])!=h)
			{
				sizp+=(x=dfs(q,p));
				cnt[x]--;
				cnt[n-x]--;
			}
		return sizp;
	}
	void solve()
	{
		initialize();
		dfs();
		cnt[n]=n;
		Math::calc(cnt,ans,n);
		for(int i=1;i<=n;i++)
			printf("%d\n",ans[i]);
	}
}
int main()
{
	O_O::solve();
	return 0;
}


Measured memory_bytes: 29056
#include <bits/stdc++.h>
using namespace std;
int INF = 1000000;
int main(){
  int N;
  cin >> N;
  vector<pair<int, int>> R(N);
  for (int i = 0; i < N; i++){
    int a, b;
    cin >> a >> b;
    R[i] = make_pair(a, b);
  }
  vector<pair<int, int>> B(N);
  for (int i = 0; i < N; i++){
    int c, d;
    cin >> c >> d;
    B[i] = make_pair(c, d);
  }
  int V = N * 2 + 2;
  vector<set<int>> E(V);
  for (int i = 1; i <= N; i++){
    E[0].insert(i);
  }
  for (int i = N + 1; i <= N * 2; i++){
    E[i].insert(N * 2 + 1);
  }
  for (int i = 0; i < N; i++){
    for (int j = 0; j < N; j++){
      if (R[i].first < B[j].first && R[i].second < B[j].second){
        E[i + 1].insert(N + 1 + j);
      }
    }
  }
  int F = 0;
  while (1){
    vector<int> d(V, INF);
    vector<int> prev(V, -1);
    d[0] = 0;
    queue<int> Q;
    Q.push(0);
    while (!Q.empty()){
      int v = Q.front();
      Q.pop();
      for (int w : E[v]){
        if (d[w] == INF){
          d[w] = d[v] + 1;
          prev[w] = v;
          Q.push(w);
        }
      }
    }
    if (d[V - 1] == INF){
      break;
    } else {
      vector<int> path;
      path.push_back(V - 1);
      while (path.back() != 0){
        path.push_back(prev[path.back()]);
      }
      reverse(path.begin(), path.end());
      int L = path.size();
      for (int i = 0; i < L - 1; i++){
        E[path[i]].erase(path[i + 1]);
        E[path[i + 1]].insert(path[i]);
      }
      F++;
    }
  }
  cout << F << endl;
}

Measured memory_bytes: 384
#include<stdio.h>
int main(void)
{
	int H,W,i,j;
	while(1)
	{
		scanf("%d %d",&H,&W);
		if(H==0&&W==0)
			break;
		for(i=0;i<H;i++)
		{
			for(j=0;j<W;j++)
			{
				if(j==0||j==W-1||i==0||i==H-1)
				printf("#");
				else
				printf(".");
			}
			printf("\n");
		}
		printf("\n");
	}
return 0;
}

Measured memory_bytes: 1804
#include<stdio.h>

int main(){
	int a,b,i,j;
	for(i=0;i<9;i++){
		a=i+1;
		for(j=0;j<9;j++){
			b=j+1;
			printf("%dx%d=%d\n",a,b,a*b);
		}
	}

    return 0;
}

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

int main(int argc,char* argv[]){
    int a,b,c,d;
    int flg=0;

    cin>>a>>b>>c>>d;

    while(1){
        c-=b;
        if(c<=0){
            flg=1;
            break;
        }
        a-=d;
        if(a<=0){
            flg=2;
            break;
        }
    }
    if(flg==1){
        cout<<"Yes"<<endl;
    }
    else cout<<"No"<<endl;
    return 0;
}

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

ll exponential (int a, int n) {
    ll b = 1;
    if (n == 0) return b;
    else {
        for (int i=0; i<n; ++i) {
            b = b * a;
        }
        return b;
    }
}

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

    ll e = exponential(k-1, n-1);
    ll res = k * e;
    cout << res << endl;    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0;i<n;i++)
int main() {
    string s;
    cin>>s;
    int ans=0;
    rep(i,3){
        if (s[i]=='1'){
            ans+=1;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256