akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <climits>
#include <ctime>
#include <cmath>
#include <cstdlib>
#include <iomanip>
#include <cstring>

// ---------- PBDS -----------------

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#include <ext/pb_ds/detail/standard_policies.hpp>

// ----------------------------------

using namespace std;
using namespace __gnu_pbds; 

#define MEM(a, b) memset(a, (b), sizeof(a))
#define ALL(a) a.begin(), a.end()
#define MP(a, b) make_pair(a, b)
#define PB(a) push_back(a)
#define EB(a) emplace_back(a) 
#define boost ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0),cout << fixed << setprecision(10);
// #define ll long long int
#define int long long int

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
	*this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
// debug & operator << (debug & dd, P p) { dd << "(" << p.x << ", " << p.y << ")"; return dd; }
#define deb(x) debug() << imie(x)

void solve(){
    
    double d, t, s;
    cin >> d >> t >> s;
    //cout << d/s << '\n';
    if((t - (d/s) >= 0)){
        cout << "Yes";
    }else{
        cout << "No";
    }
    
}

int32_t main(){

	boost;

	int T;
	
	//cin >> T;
	 T = 1;
	
	for(int i = 1; i <= T; ++i){
		solve();
		cout << "\n";
	}

	return 0;
}



Measured memory_bytes: 3724
private data class Path(val a: Int, val b: Int)

fun main(args: Array<String>) {
    val (n, m) = readLine()!!.split(" ").map { it.toInt() }

    // 区間の区切れがいくつあるかを求めれば良い
    var routes = mutableListOf<Path>()
    for ( i in 0 until m) {
        val (a, b) = readLine()!!.split(" ").map { it.toInt() }
        routes.add(Path(a, b))
    }

    // ソート
    routes.sortBy { it.a }

    // 区間が区切れる数を求める（区切れる手前で切る

    // WA かぶっている限り，区間を縮小していく -> かぶらないものが出てきたらリセット & cnt+1

    var start = routes[0].a
    var end = routes[0].b
    var cnt = 0

    for(i in 1 until routes.size) {
        // ソートされている前提

        // 区間に含まれている場合，縮小
        // 区間が接している場合は別とみなすことに注意
        if( (routes[i].a< start && routes[i].b > start)
            || (routes[i].a < end && routes[i].b > end)
            || (routes[i].a >= start && routes[i].b <= end)) {
            start = Math.min(start, routes[i].a)
            end = Math.min(end, routes[i].b)
        } else {
            start = routes[i].a
            end = routes[i].b
            cnt += 1
        }
    }

    // 最後の分
    cnt += 1

    println(cnt)

}

Measured memory_bytes: 76816
nums = []
nums << gets.chomp.split(" ").map(&:to_i)
nums << gets.chomp.split(" ").map(&:to_i)
nums << gets.chomp.split(" ").map(&:to_i)
nums.flatten!
hash = {}
nums.each do |num|
    if hash[num]
        hash[num] += 1
    else
        hash[num] = 1
    end
end

if hash.find {|k,v| v >= 3 }
    puts "NO"
else
    puts "YES"
end


Measured memory_bytes: 3836
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int A = sc.nextInt();
        int B = sc.nextInt();

        if(N*A<=B){
            System.out.println(N*A);
        }
        else if(B<N*A){
            System.out.println(B);
        }
    }
}

Measured memory_bytes: 21844
fun main(args: Array<String>) {
    val (a, b, c) = readIntList()

    for (i in 1..b) {
        if ((a * i) % b == c) {
            println("YES")
            return
        }
    }
    println("NO")
}

// Tools
fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntList() = readLine()!!.split(" ").map(String::toInt)

Measured memory_bytes: 36432
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

H, W = map(int, readline().split())
# 行方向の除去…入力時に省く
# 列方向の除去…フラグを用意して、#が含まれている列のフラグを立てる
# 最終的にフラグが立っている列のみ出力
grid = []
black = [0] * W
for i in range(H):
    a = readline().decode().rstrip()
    if a.count('#') != 0:
        grid.append(a)
        for j in range(W):
            if a[j] == '#':
                black[j] = 1

# フラグが立っている列のみ文字列を結合していき、出力
for a in grid:
    s = ''
    for j in range(W):
        if black[j] == 1:
            s += a[j]
    print(s)


Measured memory_bytes: 9268
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

const int MOD = 998244353;

int main() {
	int n; scanf("%d", &n); std::vector<int> a(n);
	for(int i = 0; i < n; i++) scanf("%d", &a[i]);
	sort(begin(a), end(a));
	
	int s = 0;
	for(auto v: a) s += v;
	
	auto dp = make_v<i64>(n + 1, s + 1); dp[0][0] = 1;
	for(int i = 0; i < n; i++) {
		for(int j = 0; j < s; j++) {
			if(!dp[i][j]) continue;
			(dp[i + 1][j + a[i]] += dp[i][j]) %= MOD;
			(dp[i + 1][j] += dp[i][j]) %= MOD;
			(dp[i + 1][j] += dp[i][j]) %= MOD;
		}
	}
	
	i64 ans = 1;
	for(int i = 0; i < n; i++) (ans *= 3LL) %= MOD;
	
	i64 sub = 0;
	for(int i = (s + 1) / 2; i <= s; i++) (sub += dp[n][i]) %= MOD;
	
	if(!(s & 1)) {
		auto dp2 = make_v<i64>(n + 1, s + 1); dp2[0][0] = 1;
		for(int i = 0; i < n; i++) {
			for(int j = 0; j < s; j++) {
				if(!dp2[i][j]) continue;
				(dp2[i + 1][j + a[i]] += dp2[i][j]) %= MOD;
				(dp2[i + 1][j] += dp2[i][j]) %= MOD;
			}
		}
		
		(sub -= dp2[n][s / 2] - MOD) %= MOD;
	}
	printf("%lld\n", (ans - 3 * sub % MOD + MOD) % MOD);
	return 0;
}


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

N, M = map(int, input().split())
dic = {}
for _ in range(M):
    a, b = map(int, input().split())
    if not a in dic.keys():
        dic[a] = 1
    else:
        dic[a] += 1
    if not b in dic.keys():
        dic[b] = 1
    else:
        dic[b] += 1

ok = True
for l in dic.values():
    if l % 2 != 0:
        ok = False

if ok:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 9064
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
 
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<ii, null_type, less<ii>, rb_tree_tag, tree_order_statistics_node_update> pbds;

const int MOD = 998244353;
int add(int a, int b)
{
	a+=b;
	while(a>=MOD) a-=MOD;
	return a;
}
int mult(int a, int b)
{
	return (a*1LL*b)%MOD;
}
int modpow(int a, int b)
{
	int r=1;
	while(b)
	{
		if(b&1) r=mult(r,a);
		a=mult(a,a);
		b>>=1;
	}
	return r;
}

void radd(int &x, int y)
{
	x=add(x,y);
}

typedef bitset<350> b100;

b100 mini(b100 a, b100 b)
{
	for(int i=332;i>=0;i--)
	{
		if(a[i]!=b[i])
		{
			if(a[i]) return b;
			else return a;
		}
	}
	return a;
}

struct gausselim
{
	ll cnt[333][2];
	int rank;
	b100 cyc[333];
	void init()
	{
		for(int i = 0; i < 333; i++)
		{
			cyc[i] = cnt[i][0] = cnt[i][1] = 0;
		}
		rank = 0;
	}
	void addval(b100 x)
	{
		for(int i = 0; i < 333; i++)
		{
			cnt[i][x[i]]++;
		}
	}
	void add(b100 x)
	{
		for(int i = 332; i >= 0; i--)
		{
			if(x[i])
			{
				if(cyc[i]==0)
				{
					cyc[i] = x;
					rank++;
					break;
				}
			}
			x = mini(x, (x^cyc[i]));
		}	
	}
};



int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n,m; cin>>n>>m;
	gausselim g; g.init();
	for(int i=0;i<n;i++)
	{
		b100 b; b.reset();
		for(int j=0;j<m;j++)
		{
			int x; cin>>x;
			if(x) b.set(j,1);
		}
		g.add(b);
	}
	cout<<mult(modpow(2,m-1),add(modpow(2,n),MOD-modpow(2,n-g.rank)))<<'\n';
}


Measured memory_bytes: 256
n,a,b = map(int, input().split())
s = input()
c = 0
d = 1
for i in range(n):
    if s[i] == "a" and c <(a+b):
        print("Yes")
        c += 1
    elif s[i] == "b" and c < (a+b) and d <= b:
        print("Yes")
        c += 1
        d += 1
    else:
        print("No") 

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

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

int main() {
    int n;
    cin >> n;
    vector<vector<int>> a(n, vector<int>(3));
    rep(i, n) rep(j, 3) cin >> a[i][j];
    vector<vector<ll>> dp(n+1, vector<ll>(3));
    
    rep(i, n) {
        rep(j, 3) {
            rep(k, 3) {
                if (j==k) continue;
                chmax(dp[i+1][k], dp[i][j]+a[i][k]);
            }
        }
    }

    ll ans = 0;
    rep(j, 3) chmax(ans, dp[n][j]);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 11136
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include <bits/stdc++.h>
using namespace std;
using i32 = int; using i64 = long long int; using f64 = double; using str = string;
template <typename T> using vec = vector<T>;
template <typename T> using heap = priority_queue<T, vec<T>, greater<T>>;
#define times(n, i) for (i32 i = 0; i < (n); ++i)
#define range(a, b, i) for (i32 i = (a); i < (b); ++i)
#define upto(a, b, i) for (i32 i = (a); i <= (b); ++i)
#define downto(a, b, i) for (i32 i = (a); i >= (b); --i)
#define all(xs) (xs).begin(), (xs).end()
#define sortall(xs) sort(all(xs))
#define reverseall(xs) reverse(all(xs))
#define uniqueall(xs) (xs).erase(unique(all(xs)), (xs).end())
#define even(x) (((x) & 1) == 0)
#define odd(x) (((x) & 1) == 1)
#define append emplace_back
const i64 MOD = 1000000007;

i32 n, t, a[100000];

i32 main()
{
    cin >> n >> t;
    i32 cnt = 0;
    i32 mina = INT_MAX;
    i32 maxd = 0;
    times(n, i) {
        cin >> a[i];
        mina = min(mina, a[i]);
        i32 d = a[i] - mina;
        if (d == maxd) {
            cnt++;
        }
        if (d > maxd) {
            maxd = d;
            cnt = 1;
        }
    }

    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <string.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define forn(i,a,b) for(int i=a;i<=b;i++)
#define INF 2147483647
#define LLINF 9223372036854775807
using namespace std;
int main(){
	int n;
	cin>>n;
	long long cnt=0,ans=0;
	long long a,b;
	for(int i=0;i<n;i++){
		cin>>a>>b;
		long long t1=1;
		long long t2=1;
		if(!i){
			cnt=a;
			ans=b;
			continue;
		}
		t1=cnt/a;
		if(cnt%a)t1++;
		t2=ans/b;
		if(ans%b)t2++;
		cnt=a*max(t1,t2);
		ans=b*max(t1,t2);
	}
	cout<<cnt+ans<<endl;
	return 0;
}


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

const int N = 100010;

int n, a[N];
int cnt[N];

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	cin >> n;
	for (int i = 1; i <= n; ++i) {
		cin >> a[i];
		if (a[i] > 0) cnt[a[i]-1]++;
		cnt[a[i]]++;
		cnt[a[i]+1]++;
	}

	int mx = 0;
	for (int i = 0; i < N; ++i) mx = max(mx, cnt[i]);
	cout << mx << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define pii pair<int,int>
#define pll pair<long,long>
#define pdd pair<double,double>
#define ff first
#define ss second
#define w(x) int x; cin>>x; while(x--)
using namespace std;
void ffast(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}
int main()
{
    ffast();
    string a,b;
    cin>>a>>b;
    int n = a.size();
    int m = b.size();
    int dp[n+1][m+1];
    for(int i=0;i<=n;i++) dp[i][0] = 0;
    for(int j=0;j<=m;j++) dp[0][j] = 0;
    for(int i=1;i<=n;i++){
    	for(int j=1;j<=m;j++){
    		if(a[i-1]==b[j-1])
    			dp[i][j] = 1 + dp[i-1][j-1];
    		else
    			dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
    	}
    }
    string ans = "";
    int i=n,j=m;
    while(i>0 and j>0){
    	if(dp[i][j]==dp[i-1][j])
    		i--;
    	else if(dp[i][j]==dp[i][j-1])
    		j--;
    	else{
    		ans += a[i-1];
    		i--;
    		j--;
    	}
    }
    reverse(ans.begin(), ans.end());
    cout<<ans;
}

Measured memory_bytes: 38828
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <bits/stdc++.h>
#define FOR(i, a, b) for(int (i)=(a);(i)<(b);++(i))
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) FOR(i, 1, n+1)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define LEN(x) (int)(x).size()
#define DUMP(x) cout<<#x<<"="<<(x)<<endl;
#define pb push_back
#define eb emplace_back
using namespace std;
typedef long long lint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
typedef vector<int> vi;
typedef vector<lint> vl;
typedef vector<char> vc;
typedef vector<vector<int>> vii;
typedef vector<vector<lint>> vll;
typedef vector<vector<char>> vcc;

void chmax(lint &a, lint b){
    a = max(a, b);
}

void chmin(lint &a, lint b){
    a = min(a, b);
}

class CMakeARectangle {
public:
    int N;
    map<lint, lint> mp;

    void input(std::istream& in, std::ostream& out){
        ios_base::sync_with_stdio(false);
        in>>N;
        REP(i, N){
            int a;
            in>>a;
            mp[a]++;
        }
    }

    void solve(std::istream& in, std::ostream& out){
        input(in, out);
        lint ans = 0;
        for(auto p : mp){
            if(p.second>=4){
                chmax(ans, p.first*p.first);
            }
        }

        lint a = -1;
        for(auto p : mp){
            if(p.second>=2){
                if(a!=-1) chmax(ans, a*p.first);
                a = p.first;
            }
        }

        out<<ans<<'\n';
    }
};


int main() {
	CMakeARectangle solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 6528
/*
 * @Author: AsilenceBTF
 * @Buff: ︿(￣︶￣)︿  芜湖塔台 起飞
 * @Date: 2019-06-28 16:29:41
 * @LastEditTime: 2020-09-03 15:19:39
 */
#include <bits/stdc++.h>
using namespace std;

#define sz(x) int(x.size())
#define ALL(x) x.begin(), x.end()
#define INF 0x3f3f3f3f
#define endl '\n'
typedef long long ll;

const int N = 1e6 + 105;
const int MOD = 1e9 + 7;

int main(){
    int n; cin >> n;
    map<ll, ll> ma;
    ll ans = 0;
    for(int i = 1; i <= n; ++i){
        ll x; cin >> x;
        ans += ma[-(x - i)];
        ma[i + x]++;
    }
    cout << ans << endl;
    // system("pause");
}

Measured memory_bytes: 26208
S = input()
N = len(S)
mod = 10 ** 9 + 7

# dp[i][j]: i番目までの文字までで、状態jになる組み合わせ数
dp = [[0 for _ in range(4)] for _ in range(N + 1)]
dp[0][0] = 1

for i in range(N):
    if S[i] in ['A', '?']:
        for j in range(4):
            dp[i + 1][j] += dp[i][j]
        dp[i + 1][1] += dp[i][0]
    if S[i] in ['B', '?']:
        for j in range(4):
            dp[i + 1][j] += dp[i][j]
        dp[i + 1][2] += dp[i][1]
    if S[i] in ['C', '?']:
        for j in range(4):
            dp[i + 1][j] += dp[i][j]
        dp[i + 1][3] += dp[i][2]

    for j in range(4):
        dp[i + 1][j] %= mod

print(dp[N][3])

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

int f(int x) { // 整数kの約数の個数
    int r = 1;
    for (int i = 2; i * i <= x; i++) {
        if (x % i == 0) {
            int cnt = 1;
            while (x % i == 0) {
                x /= i;
                cnt++;
            }
            r *= cnt;
        }
    }
    if (x != 1) {
        r *= 2;
    }
    return r;
}

int main() {
    int n;
    cin >> n;
    ll sum = 0;
    // for (ll i = 1; i <= n; i++) {
    //     sum += i * f(i);
    // }
    // cout << sum << endl;
    for (ll i = 1; i <= n; i++) {
        sum += (1 + n / i) * (n / i) / 2 * i;
    }
    cout << sum << endl;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define sp ' '
#define nyan "(=^・ω・^=)"
#define mkp make_pair
#define lP pair<ll,ll>
#define iP pair<int,int>

typedef long long ll;
using namespace std;
const int mod = 1e9 + 7;

int N, A, B, C;

int main(){
	cin >> N >> A >> B >> C;
	cout << N - A - B + C << endl;
	return 0;
}



Measured memory_bytes: 3104
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=505;
int l,r,ans,b[10005];
signed main()
{
	ans=1e18;
	cin>>l>>r;
	for(int i=l;i<=min(r,l+20000);i++)b[i%2019]++;
	for(int i=0;i<2019;i++)
	{
		if(!b[i])continue;
		for(int j=0;j<2019;j++)
		{
			if(i==j&&b[i]==1)continue;
			if(!b[j])continue;
			ans=min(ans,i*j%2019);
		}
	}
	cout<<ans;
}

Measured memory_bytes: 256
n = int(input())
p = list(map(int, input().split()))

l = []
l.append(p[0])
temp = p[0]
for i in range(0, n-1):
  if p[i+1] < temp:
    temp = p[i+1]
    l.append(p[i+1])
    
print(len(l))

Measured memory_bytes: 26012
use std::collections::HashSet;
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

// 重複を取り除く別解
fn exe_other(n: usize, a: Vec<u64>) -> String {
    let mut uniq: Vec<&u64> = a.iter().collect();
    uniq.sort();
    uniq.dedup();
    if n == uniq.len() {
        "YES".to_string()
    } else {
        "NO".to_string()
    }
}

fn exe(n: usize, a: Vec<u64>) -> String {
    let uniq: HashSet<u64> = a.into_iter().collect();
    if n == uniq.len() {
        "YES".to_string()
    } else {
        "NO".to_string()
    }
}

fn main() {
    input! {
        n: usize,
        a: [u64; n],
    }
    let ans = exe_other(n, a);
    println!("{}", ans);
}

#[test]
fn test() {
    assert_eq!(exe(5, vec![2, 6, 1, 4, 5]), "YES");
    assert_eq!(exe(6, vec![4, 1, 3, 1, 6, 2]), "NO");
    assert_eq!(exe(2, vec![10000000, 10000000]), "NO");

    assert_eq!(exe_other(5, vec![2, 6, 1, 4, 5]), "YES");
    assert_eq!(exe_other(6, vec![4, 1, 3, 1, 6, 2]), "NO");
    assert_eq!(exe_other(2, vec![10000000, 10000000]), "NO");
}


Measured memory_bytes: 10492
#include<stdio.h>
#include<stdlib.h>
#define infinity 1000000000
int min(int a,int b){
    return a<b?a:b;
}
int main()
{
    int n,k;
    scanf("%d %d",&n,&k);
    int a[n],dp[n];
    for(int i=0;i<n;i++){scanf("%d",&a[i]);dp[i]=infinity;}
    dp[0]=0;
    for(int i=1;i<n;i++)
    {
        if(i-k<0)
        {
            for(int j=i-1;j>=0;j--)
            dp[i]=min((dp[j]+abs(a[i]-a[j])),dp[i]);
        }
        else
        {
            for(int j=i-1;j>=i-k;j--)
            dp[i]=min((dp[j]+abs(a[i]-a[j])),dp[i]);
        }
    }
    printf("%d",dp[n-1]);
}

Measured memory_bytes: 2452
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using vec=vector<ll>;
using mat=vector<vec>;
#define For(i,a,b) for(i=a;i<b;i++)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define mod 1000000007

typedef struct costmap{
  vector<vector<pair<long long,long long>>> tree;
  vector<pair<pair<long long,long long>,long long>> edges;
  vector<long long> dist;
  vector<long long> decycle;
  costmap(long long N) :tree(N){
    dist.resize(N);
    decycle.resize(N);
    for(long long i=0;i<N;i++)dist[i]=LLONG_MAX;
  }
  void inputmap(long long M){
    long long a,b,c,i;
    edges.resize(M);
    for(i=0;i<M;i++){
      cin>>a>>b>>c;
      a--;b--;
      tree[a].push_back(make_pair(b,-c));
      edges[i]=make_pair(make_pair(a,b),-c);
    }
  }
  void inputtree(long long M){
    long long a,b,c,i;
    for(i=0;i<M;i++){
      cin>>a>>b>>c;
      a--;b--;
      tree[a].push_back(make_pair(b,c));
      tree[b].push_back(make_pair(a,c));
    }
  }
  void dijkstra(long long start){
    long long i,N=dist.size(),cnt=1;
    pair<long long,long long> x;
    dist[start]=0;
    priority_queue<pair<long long,long long>,vector<pair<long long,long long>>,greater<pair<long long,long long>>> que;
    for(i=0;i<(long long)tree[start].size();i++){
      que.push(make_pair(tree[start][i].second,tree[start][i].first));
    }
    while(cnt<N){
      x=que.top();que.pop();
      if(dist[x.second]!=LLONG_MAX)continue;
      dist[x.second]=x.first;
      cnt++;
      for(i=0;i<(long long)tree[x.second].size();i++){
        if(dist[tree[x.second][i].first]==LLONG_MAX){
          que.push(make_pair(dist[x.second]+tree[x.second][i].second,tree[x.second][i].first));
        }
      }
    }
  }

  void bellmanford(long long start){
    long long i,j,N=dist.size(),E=edges.size();
    dist[start]=0;
    for(i=0;i<N;i++){
      for(j=0;j<E;j++){
        if(dist[edges[j].first.first]!=LLONG_MAX){
          dist[edges[j].first.second]=min(dist[edges[j].first.second],dist[edges[j].first.first]+edges[j].second);
        }
      }
      decycle[i]=0;
    }

    for(j=0;j<E;j++){
      if(dist[edges[j].first.first]!=LLONG_MAX&&dist[edges[j].first.second]>dist[edges[j].first.first]+edges[j].second){
        decycle[edges[j].first.second]=1;
      }
    }
    for(i=0;i<N;i++){
      for(j=0;j<E;j++){
        if(decycle[edges[j].first.first])decycle[edges[j].first.second]=1;
      }
    }
  }
};

int main(){
  ll N,M;
  cin>>N>>M;
  costmap tree(N);

  tree.inputmap(M);

  tree.bellmanford(0);

  if(tree.decycle[N-1]){
    cout<<"inf"<<endl;
  }else{
    cout<<-tree.dist[N-1]<<endl;
  }
  return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <utility>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
#define rep(i,a,n)	for(int i=a;i<n;i++)
#define rrep(i,a,n)	for(int i=a;i>=n;i--)
#define mp make_pair
#define pb push_back
#define mt make_tuple
#define fst first
#define scn second
int main(){
	string str;	cin>>str;
	bool n=false,w=false,s=false,e=false;
	for(int i=0;i<str.size();i++){
		if(str[i]=='N')	n=true;
		else if(str[i]=='W')	w=true;
		else if(str[i]=='S')	s=true;
		else if(str[i]=='E')	e=true;
	}
	if(n^s||e^w){
		cout<<"No"<<endl;
	}
	else cout<<"Yes"<<endl;
	return 0;
}


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

string s;
bool f = 1;

int main()
{
	cin >> s;

	for (int i = 0; i < s.size(); i++) {
		if (s[i] == 'U' || s[i] == 'D')
			continue;
		else if (i % 2 == 0 && s[i] == 'R')
			continue;
		else if (i % 2 == 1 && s[i] == 'L')
			continue;
		else {
			f = 0;
			break;
		}
	}

	if(f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
typedef vector<ld> vld;
typedef vector<string> vstr;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef priority_queue<ll, vector<ll>, greater<ll>> spqll;  // 小さい順に取り出し
typedef priority_queue<ll, vector<ll>, less<ll>> bpqll;     // 大きい順に取り出し

#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define IREP(i, v) for (auto i = (v).begin(); i != (v).end(); ++i)
#define TS to_string
#define NP next_permutation
#define ALL(v) (v).begin(), (v).end()
#define endl "\n"

ll INF = 1e9;
ll MOD = 1000000007;
ll LINF = 1e18;
ld EPS = 1e-9;
ld PI = M_PI;
vll dx = {1, 0, -1, 0, 1, -1, -1, 1};
vll dy = {0, 1, 0, -1, 1, 1, -1, -1};
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a;} //最大公約数
ll lcm(ll a, ll b) { return a / gcd(a, b) * b;}     //最小公倍数

void yes(){ cout << "Yes" << endl;}
void no(){ cout << "No" << endl;}

//-----------------------------------------
//-----------------------------------------
int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  ll n;
  cin >> n;
  vll a(n);
  REP(i,n) cin >> a[i];
  ll m;
  cin >> m;
  vll b(m);
  REP(i,n) cin >> b[i];
  cout << (a < b) <<endl;
    
  return 0;
}




Measured memory_bytes: 3232
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<deque>
#include<cassert>

using namespace std;

#define sz(x) (int)(x.size())
#define fi(a,b) for(int i=a;i<b;++i)
#define fj(a,b) for(int j=a;j<b;++j)
#define fo(a,b) for(int o=a;o<b;++o)
#define fdi(a,b) for(int i=a-1;i>=b;--i)
#define fdj(a,b) for(int j=a-1;j>=b;--j)
#define fdo(a,b) for(int o=a-1;o>=b;--o)
#define pb push_back
#define mp make_pair
typedef pair<int, int> pii;
typedef long long ll;
/////////////////////////////////

ll n, x;
ll ans;

void solve(){
	ans = n;
	ll a = x;
	ll b = n-x;
	while(a && b){
		if(b < a){
			swap(a, b);
			continue;
		}
		ll q = b / a;
		ans += q * 2 * a;
		b %= a;
		if(b == 0) ans -= a;
	}
}

int main(){
#ifdef _DEBUG
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif

	scanf("%lld %lld",&n,&x);
	
	solve();
	
	printf("%lld\n",ans);

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <limits.h>
int main(void)
{
    long int a[10000], ans=0, n, i;
    scanf("%ld", &n);
    for(i=0;i<n;i++){
        scanf("%ld", &a[i]);
    }

    i=0;
    while(i<n){
        if(a[i]%2==0){
            a[i]=a[i]/2;
            ans++;
        }
        else i++;
    }

    printf("%ld\n", ans);
    return 0;
}


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

int main(){
    int n,p;
    while (true) {
        cin >> n >> p;
        if(n==0 && p==0) break;
        int currentp = p;
        vector<int> candidate;
        rep(i,n) candidate.push_back(0);
        int turn=0;
        while(true){
            if(currentp==0){
                currentp=candidate[turn];
                candidate[turn]=0;
            }else{
                candidate[turn]++;
                currentp--;
                if(currentp==0 && candidate[turn]==p) break;
            }
            turn=(turn+1)%n;
        }
        cout << turn << endl;
    }
  return 0;
}

Measured memory_bytes: 3104
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

int dp[123][2][5];

int main() {
  string s;
  int k;
  cin >> s >> k;
  int n = s.size();
  dp[0][0][0] = 1;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j <= k; ++j) {
      for (int m = 0; m <= 9; ++m) {
        if (m < s[i] - '0') {
          dp[i + 1][1][j + (m != 0)] += dp[i][0][j];
          dp[i + 1][1][j + (m != 0)] += dp[i][1][j];
        } else if (m == s[i] - '0') {
          dp[i + 1][0][j + (m != 0)] += dp[i][0][j];
          dp[i + 1][1][j + (m != 0)] += dp[i][1][j];
        } else {
          dp[i + 1][1][j + (m != 0)] += dp[i][1][j];
        }
      }
    }
  }
  cout << dp[n][0][k] + dp[n][1][k] << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <limits>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <functional>

using namespace std;

using ll = long long;
using vll = std::vector<ll>;
using vvll = std::vector<vll>;
using vvvll = std::vector<vvll>;
#define reps(i, S, E) for (ll i = (S); i <= (E); i++)
#define rep(i, N) reps(i, 0, N-1)
#define deps(i, E, S) for (ll i = (E); i >= (S); i--)
#define dep(i, N) deps(i, N-1, 0)
const ll MOD = 1000000007;
const ll INF = 1LL << 60;


//AtCoder Beginner Contest 135 - B
int main() {
	ll N;
	scanf("%lld", &N);
	vector<ll> p(N);
	for (ll i = 0; i < N; i++) {
		scanf("%lld", &p[i]);
	}

	ll err = 0;
	rep(i, N) {
		if (p[i] != i + 1) {
			err++;
		}
	}

	if (err <= 2) {
		printf("YES\n");
	}
	else {
		printf("NO\n");
	}
}


//AtCoder Beginner Contest 135 - A
/*
int main() {
	ll A;
	scanf("%lld", &A);
	ll B;
	scanf("%lld", &B);

	if (abs(A - B) % 2 == 1) {
		printf("IMPOSSIBLE\n");
		return 0;
	}

	ll ans = abs(A - B) / 2;
	ll result = min(A, B) + ans;

	printf("%lld\n", result);
}
*/

//AtCoder Beginner Contest 126 - B
/*
int main() {
	char s[101010];
	scanf("%s", s);
	ll len = strlen(s);

	ll front = (s[0] - '0') * 10 + (s[1] - '0');
	ll back = (s[2] - '0') * 10 + (s[3] - '0');

	if ((front > 12 && back > 12) || (front > 12 && back == 0) || (back > 12 && front == 0) || (back == 0 && front == 0)) {
		printf("NA\n");
	}
	else if (front > 12 || front == 0) {
		printf("YYMM\n");
	}
	else if (back > 12 || back == 0) {
		printf("MMYY\n");
	}
	else {
		printf("AMBIGUOUS\n");
	}
}
*/

//AtCoder Beginner Contest 126 - A
/*
int main() {
	ll N;
	scanf("%lld", &N);
	ll K;
	scanf("%lld", &K);
	char s[101010];
	scanf("%s", s);
	ll len = strlen(s);

	s[K - 1] = s[K - 1] - 'A' + 'a';

	printf("%s\n", s);
}
*/

Measured memory_bytes: 256
import sys

import bisect

from collections import Counter, deque, defaultdict

# import copy
# from heapq import heappush, heappop, heapify
# from fractions import gcd
# import itertools
# from operator import attrgetter, itemgetter
# import math


# import numpy as np

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    s = input()
    t = input()

    sd = defaultdict(list)

    sl = len(s)

    for i in range(sl):
        c = s[i]
        sd[c].append(i+1)

    tl = len(t)
    prev = 0

    ans = 0

    for i in range(tl):
        c2 = t[i]
        appear = sd[c2]
        if len(appear) == 0:
            print(-1)
            sys.exit()

        appear_max = appear[-1]
        if appear_max <= prev:
            nxt = appear[0]
        else:
            nxt = appear[bisect.bisect_right(appear, prev)]
        forward = nxt - prev
        if forward <= 0:
            forward += sl
        ans += forward
        prev = nxt

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 46192
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll GCD(ll x,ll y){
    if(y == 0) return x;
    else return GCD(y,x%y);
}

ll LCM(ll a,ll b){
    return a / GCD(a,b) * b;
}

const int MOD = 1000000007;

int main() {
    int n,k; cin >> n >> k;
    vector<int> vec;
    for(int i = 0;i < n;i++){
        vec.push_back(0);
    }
    for(int i = 0; i < k;i++){
        int x; cin >> x;
        for(int j = 0;j < x;j++){
            int y; cin >> y;
            vec[y-1]++;
        }
    }
    int ans = 0;
    for(int i = 0;i < n;i++){
        if(vec[i] == 0) ans++;
    }
    cout << ans;
}




Measured memory_bytes: 3624
#include <stdio.h>

int main(){
    int N;
    scanf("%d", &N);
    int r;
    r = N % 10;
    if(r==3){
        puts("bon");
    }else if(r==0 || r==1 || r==6 || r==8){
        puts("pon");
    }else{
        puts("hon");
    }
    return 0;
}

Measured memory_bytes: 1648
// In the name of God

#include <bits/stdc++.h>

using namespace std;

#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL);
#define debug(x) cout << #x ": " << x << endl;

int dp[3005][3005];

int main() {
	IOS
	string s, t, ans="";
	cin >> s >> t;
	for(int i=1; i<=s.length(); i++) {
		for(int j=1; j<=t.length(); j++) {
			if(s[i-1]==t[j-1]) dp[i][j] = dp[i-1][j-1] + 1;
			else dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
		}
	}
	int i=s.length(), j=t.length();
	while(i>0 && j>0) {
		if(dp[i][j] == dp[i-1][j]) {
			i--;
		}
		else if(dp[i][j] == dp[i][j-1]) {
			j--;
		}
		else {
			ans += s[i-1];
			i--;
			j--;
		}
	}
	for(int i=ans.length()-1; i>=0; i--) cout << ans[i];
 	return 0;
}


Measured memory_bytes: 35456
//recursion dfs

#include <stdio.h>

#define N 100
#define white 0
#define gray 1
#define black 2

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

//recursion

void dfs_visit(int u) {
	int v;
	color[u] = gray;
	d[u] = tt++;
	for (v = 0; v < n; v++) {
		if (M[u][v] && color[v] == white) {
			dfs_visit(v);
		}
	}
	color[u] = black;
	f[u] = tt++;
}

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

	}

	for (u = 0; u < n; u++) {
		if (color[u] == white) dfs_visit(u);
	}

	for (u = 0; u < n; u++) {
		printf("%d %d %d\n", u+1, d[u], f[u]);
	}
}
int main() {
	int u, v, k;

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

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

	dfs();
	return 0;
}


Measured memory_bytes: 2036
import heapq


class Edge:
    def __init__(self, dst, weight):
        self.dst, self.weight = dst, weight

    def __lt__(self, e):
        return self.weight > e.weight


class Graph:
    def __init__(self, V):
        self.V = V
        self.E = [[] for _ in range(V)]

    def add_edge(self, src, dst, weight):
        self.E[src].append(Edge(dst, weight))


class ShortestPath:
    """Dijkstra's algorithm : find the shortest path from a vertex
       Complexity: O(E + log(V))
       used in GRL1A(AOJ)
    """

    def __init__(self, G, INF=10**9):
        """ V: the number of vertexes
            E: adjacency list (all edge in E must be 0 or positive)
            start: start vertex
            INF: Infinity distance
        """
        self.G, self.INF = G, INF

    class Node:
        def __init__(self, v, cost):
            self.v, self.cost = v, cost

        def __lt__(self, n):
            return self.cost < n.cost

    def dijkstra(self, start, goal=None):
        que = list()
        self.dist = [self.INF] * self.G.V  # distance from start
        self.dist[start] = 0
        heapq.heappush(que, self.Node(start, 0))

        while len(que) > 0:
            n = heapq.heappop(que)
            if self.dist[n.v] < n.cost:
                continue
            if goal is not None and n.v == goal:
                return
            for e in self.G.E[n.v]:
                if self.dist[n.v] + e.weight < self.dist[e.dst]:
                    self.dist[e.dst] = self.dist[n.v] + e.weight
                    heapq.heappush(que, self.Node(e.dst, self.dist[e.dst]))

V, E, start = map(int, input().split())
G = Graph(V)
for _ in range(E):
    s, t, d = map(int, input().split())
    G.add_edge(s, t, d)
INF = 10**9
sp = ShortestPath(G, INF)
sp.dijkstra(start)
for i in range(G.V):
    print("INF" if sp.dist[i] == INF else sp.dist[i])

Measured memory_bytes: 149804
#include <iostream>

using namespace std;

int main()
{
    int a,b;
    cin>>a>>b;
    if(a>b){
        a=a*a*b;
    }
    if(b>a){
       b=b*b*a;
    }
    if(a%2==0 || b%2==0){
        cout<<"No";
    }
    else{
        cout<<"Yes";
    }
}


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

const int MAX = 200;
int top;
int S[210];

void initialize() {
	top = 0;
}

bool isFull() {
	return top > MAX - 1;
}

bool isEmpty() {
	return top == 0;
}

void push(int x) {
	if (isFull()) return;
	top++;
	S[top] = x;
}

int pop() {
	if (isEmpty()) return 0;
	top--;
	return S[top+1];
}

int main() {
	int a, b;
	char s[100];
	initialize();
	
	while (scanf("%s", s) != EOF) {
		if (s[0] == '+') {
			a = pop();
			b = pop();
			push(a + b);
		}
		else if (s[0] == '-') {
			a = pop();
			b = pop();
			push(b - a);
		}
		else if (s[0] == '*') {
			a = pop();
			b = pop();
			push(a * b);
		}
		else {
			push(atoi(s));
		}
	}
	printf("%d\n", pop());
}



Measured memory_bytes: 2756
def main():
    a,b,c,d = map(int,input().split())
    count = 0
    while True:
        if count%2 == 0:
            c -= b
        else:
            a -= d

        count += 1
        if a <= 0:
            print('No')
            return

        if c <= 0:
            print('Yes')
            return

main()


Measured memory_bytes: 9176
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <deque>
#include <set>
#include <iomanip>
#include <utility>
typedef long long ll;
typedef long double ld;
using namespace std;

int main() {
	int A, B, C;
	cin >> A >> B >> C;
	if(A==B && B!=C) cout << "Yes" << endl;
	else if(A==C && B!=C) cout << "Yes" << endl;
	else if(B==C && A!=B) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

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

bool IsPrime(long long n){
    if(n < 2) return false;
    else if(n == 2) return true;
    else if(n % 2 == 0) return false;
    for(long long i = 3; i * i <= n; i += 2){
        if(n % i == 0){
            return false;
        }
    }
    return true;
}

int main()
{
	int q;
	cin >> q;
	vector<int> a(100001);
	for(int i = 1; i < 100001; i++){
		if(IsPrime(i) && IsPrime((i + 1) / 2) && i % 2) a[i] = 1;
		a[i] += a[i - 1];
	}
	for(int i = 0; i < q; i++){
		int l, r;
		cin >> l >> r;
		cout << a[r] - a[l - 1] << endl;
	}
	return 0;
}

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

using namespace std;

#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define fore(i,a) for(auto &i:a)
typedef long long ll;
typedef pair <int, int> P;
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
const int  INF = 2147483647;
const ll INFL = 9223372036854775807;
const ll mod = 1000000007;




int v[100010][2];
VI d[100010];
int id;

void dfs(int a, int b = -1) {
	if (b != -1)v[a][id] = v[b][id] + 1;

	for (int i : d[a])if (i != b)dfs(i, a);
}


int main() {
	int n;
	cin >> n;
	REP(i, n-1) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		d[a].push_back(b);
		d[b].push_back(a);
	}
	id = 0;
	dfs(0);
	id = 1;
	dfs(n - 1);

	int res = 0;
	REP(i, n) {
		if (v[i][0] <= v[i][1])res++;
	}
	if (res >= n / 2 + 1)cout << "Fennec" << endl;
	else cout << "Snuke" << endl;

}

Measured memory_bytes: 11136
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
  int x,y,a,b,c;
  cin>>x>>y>>a>>b>>c;
  vector<ll> a1(a),b1(b),c1(c);
  for(int i=0;i<a;i++)
    cin>>a1[i];
  for(int i=0;i<b;i++)
    cin>>b1[i];
  for(int i=0;i<c;i++)
    cin>>c1[i];
  sort(a1.begin(),a1.end(),greater<ll>());
  vector<ll> f;
  for(int i=0;i<x;i++)
    f.push_back(a1[i]);
  sort(b1.begin(),b1.end(),greater<ll>());
  for(int i=0;i<y;i++)
    f.push_back(b1[i]);
  for(int i=0;i<c;i++)
    f.push_back(c1[i]);
  sort(f.begin(),f.end(),greater<ll>());
  ll sum=0;
  for(int i=0;i<x+y;i++)
    sum+=f[i];
  cout<<sum;
  return 0;
}

Measured memory_bytes: 8560
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <tuple>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(perm),end(perm)
#define showall(obj) for(auto x:obj)cout<<x<<endl;
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
typedef vector<int> vint;
typedef vector<ll> vll;
const int inf = 537427207;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int main(){
    string s; cin>>s;
    map<char,int> m;
    rep(i,s.size()){
        m[s[i]]++;
    }
    for(auto x:m){
        if(x.second%2){cout<<"No"<<endl; return 0;}
    }
    cout<<"Yes"<<endl; return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
#define fi first
#define se second
#define pb push_back
#define forn(i,n) for(int i=0;i<(n);i++)
#define for1(i,n) for(int i=1;i<=n;i++)
#define forr(i,n) for(int i=n;i>=0;i--)
#define all(x) x.begin(), x.end()
const int MAXN = 1e5 +5;

void fio(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}

int main(){
  fio();
  LL x, y; cin>>x>>y;
  forn(i,x+1){
  	if( i*2 + (x-i)*4 == y){
  		cout<<"Yes"<<endl;
  		return 0;
  	}
  }
  cout<<"No"<<endl;
  return 0;
}

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int64 N;
	string s;
	cin >> N >> s;
	vector<int64> sum(N+1, 0);
	REP(i, N) sum[i+1] += sum[i] + (s[i] == '#');
	int64 res = sum[N];
	int64 cnt = 0;
	for (int64 i = N-1; i >= 0; i--) {
		cnt += (s[i] == '.');
		res = min(res, cnt + sum[i]);
	}
	cout << res << endl;
}


Measured memory_bytes: 2196
#include<stdio.h>

int main(void)
{
	int a,b;
	char g;
	
	for(g='A';g!='?';){
		
		scanf("%d %c %d",&a,&g,&b);
		
		if(g=='+'){
			
			printf("%d\n",a+b);
			
		}
		else if(g=='-'){
			
			printf("%d\n",a-b);
			
		}
		else if(g=='*'){
			
			printf("%d\n",a*b);
			
		}
		else if(g=='/'){
			
			printf("%d\n",a/b);
			
		}
	}
		
	return 0;
}

Measured memory_bytes: 2660
#include<iostream>
using namespace std;
#define SENTINEL 2000000000
int cnt = 0;
//my merge sort
/*void merge(int* arr, int left, int mid, int right) {
	int len1 = mid - left + 1;
	int len2 = right - mid;
	int* tempL = new int[len1];
	int* tempR = new int[len1];
	for (int i = 0; i < len1; i++) tempL[i] = arr[left + i];
	for (int i = 0; i < len2; i++)tempR[i] = arr[mid + 1 + i];
	int i = 0, j = 0;
	for (int k = left; k <= right; k++) {
		cnt++;
		if (i < len1 && (j >= len2 || tempL[i] <= tempR[j]))
			arr[k] = tempL[i++];
		else
			arr[k] = tempR[j++];
	}
	delete[]tempL;
	delete[]tempR;
}
void mergeSort(int* arr, int left, int right) {
	int mid = (left + right) / 2;
	if (left < mid) {
		mergeSort(arr, left, mid);
		mergeSort(arr, mid + 1, right);
	}
	merge(arr, left, mid, right);
}*/
//merge sort of the book
void merge(int* arr, int left,int mid, int right) {
	int len1 = mid - left;//one for infinate
	int len2 = right - mid;//right originally one for infinate
	int* L = new int[len1 + 1];
	int* R = new int[len2 + 1];
	for (int i = 0; i < len1; i++)L[i] = arr[left + i];
	for (int i = 0; i < len2; i++)R[i] = arr[mid + i];
	L[len1] = R[len2] = SENTINEL;
	int i = 0, j = 0;
	for (int k = left; k < right; k++) {
		cnt++;
		if (L[i] <= R[j])
			arr[k] = L[i++];
		else
			arr[k] = R[j++];
	}
}
void mergeSort(int* arr, int left, int right) {
	if (left + 1 < right) {
		int mid = (left + right) / 2;
		mergeSort(arr, left, mid);
		mergeSort(arr, mid, right);
		merge(arr, left, mid, right);
	}
}
int main() {
	int len;
	cin >> len;
	int* arr = new int[len];
	for (int i = 0; i < len; i++)
		cin >> arr[i];
	//mergeSort(arr, 0, len-1);
	mergeSort(arr, 0, len);
	for (int i = 0; i < len; i++)
		if (i)
			cout << " " << arr[i];
		else
			cout << arr[i];
	cout << endl;
	cout << cnt << endl;
	delete[]arr;
	return 0;
}


Measured memory_bytes: 65572
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define MP make_pair
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define PLI pair<ll, int>
#define PIL pair<int, ll>
#define STR string
#define Fst first
#define Snd second
#define SHN 1e9
#define LSHN 1e18
using namespace std;
int n,m;
int a[100010];
vector<int> v[100010]; 
int res=0;
int main()
{
	scanf("%d%d",&n,&m);
	for (int i=0;i<n;i++) scanf("%d",&a[i]);
	for (int i=0;i<m;i++)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		x--,y--;
		v[x].push_back(y);
		v[y].push_back(x);
	}
	for (int i=0;i<n;i++)
	{
		int t=1;
		for (int j=0;j<v[i].size();j++) if (a[i]<=a[v[i][j]]) t=0;
		res+=t;
	}
	printf("%d",res);
	return 0;
}

Measured memory_bytes: 9220
x=input()
L=len(x)
N=[]
for l in range(L):
  N.append(int(x[l]))
N.insert(0,0) 
K=int(input())
dp0=[]
dp1=[]
for l in range(L+1):
  dp0.append([0]*(K+1))
  dp1.append([0]*(K+1))
dp1[0][0]=1
for l in range(1,L+1):
  dp0[l][0]=1
for i in range (1,L+1):
  for j in range(1,K+1):
    if N[i]==0:
      dp0[i][j]=dp0[i-1][j]+9*dp0[i-1][j-1]
      dp1[i][j]=dp1[i-1][j]
    else:
      dp0[i][j]=dp0[i-1][j]+9*dp0[i-1][j-1]+(N[i]-1)*dp1[i-1][j-1]+dp1[i-1][j]
      dp1[i][j]=dp1[i-1][j-1]
print(dp0[L][K]+dp1[L][K])      

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

int main() {
    int64_t n, wa;
    cin >> n >> wa;
    int64_t maxVal = -1;
    int64_t w[n];
    int64_t v[n];
    for (int64_t i = 0; i < n; i++) {
        cin >> w[i] >> v[i];
        maxVal = max(maxVal, v[i]);
    }
    int64_t dp[n*maxVal+1];
    int64_t mx = n*maxVal;
    for (int64_t i = 0; i <= mx; i++) {
        dp[i] = -1;
    }
    dp[0] = 0;
    for (int64_t i = 0; i < n; i++) {
        for (int64_t j = mx; j >= 0; j--) {
            if (j + v[i] > mx || dp[j] == -1) {
                continue;
            }
            //cout << "assigning" << endl;
            if (dp[j+v[i]] == -1) {
                dp[j+v[i]] = w[i] + dp[j];
            } else {
                dp[j+v[i]] = min(dp[j+v[i]], w[i] + dp[j]);
            }
        }
    }
    int64_t out = 0;
    for (int64_t i = 0; i <= mx; i++) {
        //cout << i << ' ' << dp[i] << endl;
        if (dp[i] <= wa && dp[i] != -1) {
            out = max(out, i);
        }
    }
    cout << out << endl;
}

Measured memory_bytes: 1024