akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using Library;
using static Library.Input;

namespace AtCoderTemplate
{
    class ProgramB
    {
        static void Main()
        {
            long x = NextLong;
            int count = 0;
            long tmp = 100;

            while(tmp < x)
            {
                count++;
                tmp += tmp / 100;
            }

            System.Console.WriteLine(count);
        }
    }
}

namespace Library
{
    class Input
    {
        static IEnumerator<string> enumerator = new string[] { }.AsEnumerable().GetEnumerator();

        public static string Line => Console.ReadLine();

        public static string[] StrArr => Line.Split(' ');

        public static int NextInt => int.Parse(NextWord());

        public static long NextLong => long.Parse(NextWord());

        public static List<int> IntList => StrArr.Select(int.Parse).ToList();

        public static List<long> LongList => StrArr.Select(long.Parse).ToList();

        public static IEnumerable<long[]> TakeLine(int N)
        {
            return Enumerable.Repeat(0, N).Select(_ => Console.ReadLine().Split(' ').Select(long.Parse).ToArray());
        }

        public static string NextWord()
        {
            while (!enumerator.MoveNext())
            {
                enumerator = StrArr.AsEnumerable().GetEnumerator();
            }
            return enumerator.Current;
        }
    }
}


Measured memory_bytes: 27668
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i = 0; i < (ll)(n); i++)
#define repi(i,a,b) for(ll i = (ll)(a); i < (ll)(b); i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF = 1LL << 60;

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

ll lcm(ll a, ll b){
    return a*b/gcd(a,b);
}
int main(){
    ll a,b; cin >> a >> b;

    cout << lcm(a,b) << endl;
    return 0;
}

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

#define REP(i, n) for(int i = 0; i < n; i++)
using namespace std;

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

    int num = 0, tmp = N;
    while (tmp != 0) {
        num += tmp % 10;
        tmp /= 10;
    }

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

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author SimplyDivine
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, FastReader in, PrintWriter out) {
            int n = in.nextInt();
            int a[] = new int[n];
            int f = 0, t = 0, o = 0;
            for (int i = 0; i < n; i++) {
                a[i] = in.nextInt();
                if (a[i] % 4 == 0) f++;
                else if (a[i] % 2 == 0) t++;
                else o++;
            }
            if (f >= o) {
                out.println("Yes");
            } else {
                if (f == o - 1) {
                    if (t == 0) {
                        out.println("Yes");
                        return;
                    }
                }
                out.println("No");
            }

        }

    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader(InputStream i) {
            br = new BufferedReader(new
                    InputStreamReader(i));
        }

        public String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

    }
}



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

struct Exam {
    long b, l, u, x;
    bool operator<(const Exam& exam) {
        return (x - b) * u + b * l < (exam.x - exam.b) * exam.u + exam.b * exam.l;
    }
};

int main() {
    int n;
    long x;
    cin >> n >> x;
    long b_sum = 0;
    Exam exams[n];
    for (int i = 0; i < n; i++) {
        long b, l, u;
        cin >> b >> l >> u;
        exams[i] = Exam {b, l, u, x};
        b_sum += b;
    }

    long lb = -1, ub = b_sum;
    sort(exams, exams + n);
    long plus_acc[n + 1], minus_acc[n + 1];
    plus_acc[0] = minus_acc[0] = 0;
    for (int i = 1; i <= n; i++) {
        Exam e = exams[i - 1];
        plus_acc[i]  = plus_acc[i - 1]  + (x - e.b) * e.u;
        minus_acc[i] = minus_acc[i - 1] - e.b * e.l;
    }
    while (ub - lb > 1) {
        long mid = (lb + ub) / 2;
        long diff = -b_sum;
        int q = (int) (mid / x);
        long r = mid % x;
        for (int i = 0; i < n; i++) {
            Exam e = exams[i];
            long d = ((r >= e.b) ? e.u : e.l) * (r - e.b);
            if (i < n - q)
                d += plus_acc[n] - plus_acc[n - q] + minus_acc[n - q] - minus_acc[i + 1] + minus_acc[i] - minus_acc[0];
            else
                d += plus_acc[n] - plus_acc[i + 1] + plus_acc[i] - plus_acc[n - q - 1] + minus_acc[n - q - 1] - minus_acc[0];
            diff = max(d, diff);
        }
        if (diff >= 0) {
            ub = mid;
        } else {
            lb = mid;
        }
        //cout << ub << endl;
    }
    cout << ub << endl;
    return 0;
}


Measured memory_bytes: 4992
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
using namespace std;
typedef long long int ll;

// clang-format off
#ifdef _DEBUG_
#define dump(...) do{ cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; PPPPP(__VA_ARGS__); cerr << endl; } while(false)
template<typename T> void PPPPP(T t) { cerr << t; }
template<typename T, typename... S> void PPPPP(T t, S... s) { cerr << t << ", "; PPPPP(s...); }
#else
#define dump(...)
#endif
template<typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
template<typename T>
bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false;}
template<typename T>
bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false;}
// clang-format on

ll digit(ll n) {
    while (n >= 10) {
        ll t = 0;
        while (n != 0) {
            t += n % 10;
            n /= 10;
        }
        n = t;
    }
    return n;
}

ll calc(int d, ll c) {
    if (c == 1) {
        return 0;
    }
    if (c % 2 == 0) {
        ll r = 0;
        ll t = d * 2;
        if (t >= 10) {
            t = (t / 10) + (t % 10);
            r += c / 2;
        }
        r += calc(t, c / 2) + c / 2;
        return r;
    } else {
        ll t = digit(d * (c - 1));
        ll ans = 1;
        if ((t % 10) + d >= 10) {
            ans++;
        }
        return ans + calc(d, c - 1);
    }
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int m;
    cin >> m;
    vector<int> d(m);
    ll ans = 0;
    REP(i, 0, m) {
        ll dd, cc;
        cin >> dd >> cc;
        ans += calc(dd, cc);
        dump(ans);
        d[i] = digit(dd * cc);
    }
    int sum = d[0];
    REP(i, 1, m) {
        sum += d[i];
        if (sum >= 10) {
            sum = digit(sum);
            ans++;
        }
        ans++;
    }
    cout << ans << endl;

    return 0;
}


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

int main() {
  
  int N; string S, T; cin >> N >> S >> T;
  
  for (int i = 0; i < N; i++) {
    cout << S.at(i) << T.at(i);
  }
  
  cout << endl;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
#ifdef DEBUG
#define line() cerr << "[" << __LINE__ << "] ";
#define dump(i) cerr << #i ": " << i << " ";
#define dumpl(i) cerr << #i ": " << i << endl;
#else
#define line(i)
#define dump(i)
#define dumpl(i)
#endif
using namespace std;
bool isprime(int n)
{
    int k = 2;
    while (k * k <= n)
    {
        if (n % k == 0)
        {
            return false;
        }
        k++;
    }
    return true;
}

int main(int argc, char const *argv[])
{
    int a[101010];
    a[0] = a[1] = 0;
    rep(i, 2, 101010)
    {
        if (i % 2 == 0)
        {
            a[i] = a[i - 1];
        }
        else
        {
            if (isprime(i) && isprime((i + 1) / 2))
            {
                a[i] = a[i - 1] + 1;
            }
            else
            {
                a[i] = a[i - 1];
            }
        }
    }
    int q;
    cin >> q;
    rep(i, q)
    {
        int l, r;
        cin >> l >> r;
        cout << a[r + 1] - a[l - 1] << endl;
    }
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <sstream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include <assert.h>
#include <deque>
using namespace std;

typedef unsigned long long UL;
typedef long long LL;
typedef long double LD;
#define LP(i, a, b) for (LL i = int(a); i < int(b); i++)
#define LPE(i, a, b) for (LL i = int(a); i <= int(b); i++)
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef vector<vector<PII> > WAL;
typedef vector<vector<int> > SAL;
#define Ep 1e-8
#define INF 1e9
#define LINF 1e18

LL const MOD = 1e9 + 7;
LL const MaxSize = 1e5 + 5;
//LL const MOD = 998244353;

/*

 https://atcoder.jp/contests/abc110/tasks/abc110_c
 #C - String Transformation
 */

//NOTE WORKS ONLY WHEN MOD IS PRIME
//test case, either = 1 or all = 1
int N;
int ss[MaxSize];
int found = -1;

int pg(int i) {
	if (ss[i] >= 0)
		return ss[i];

	cout << i << endl;
	cout.flush();
	string s;
	cin >> s;
	int state = 2;

	if (s == "Male")
		state = 0;
	else if(s == "Female")
		state = 1;

	ss[i] = state;
	if (state == 2)
		found = i;

	return state;
}

void find(int si, int ei) {
	if (si > ei)
		return;

	int mid = (si + ei) / 2;

	pg(mid);
	if (found >= 0) {
		cout << found << endl;
		cout.flush();
		return;
	}

	if (mid == si) {
		find(mid + 1, ei);
		return;
	}

	int d = mid - si;

	if (d % 2) {
		if (ss[mid] ^ ss[si])
			find(mid, ei);
		else
			find(si, mid - 1);
	} else {
		if (ss[mid] ^ ss[si])
			find(si, mid - 1);
		else
			find(mid, ei);
	}
}

int main() {
	ios_base::sync_with_stdio(false);
	//freopen("/Users/georgeli/A_1.in", "r", stdin);
	cin >> N;
	memset(ss, -1, sizeof(ss));

	pg(0);
	if (found >= 0){
		cout << found << endl;
		cout.flush();
	}
	else
		find(0, N - 1);

	return 0;
}


Measured memory_bytes: 1236
#include <stdio.h>

#define N	2000
#define MD	1000000007

int main() {
	static int dp[N + 1];
	int n, k, i, j, ans;

	scanf("%d%d", &n, &k);
	dp[0] = 1;
	for (i = 0; i < k - 1; i++) {
		for (j = i + 1; j <= n; j++)
			dp[j] = (dp[j] + dp[j - 1]) % MD;
		dp[i] = 0;
	}
	ans = 0;
	for (j = 0; j < n; j++)
		ans = (ans + dp[j]) % MD;
	for (i = k; i < n - 1; i++)
		ans = ans * 2 % MD;
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 1728
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>

// Acknowledgement: Special thanks to kyomukyomupurin, who developed this
// template.
template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) {
  return os << '(' << p.first << ", " << p.second << ')';
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) {
  int n = 0;
  for (auto e : vec) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::set<T>& st) {
  int n = 0;
  for (auto e : st) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) {
  int n = 0;
  for (auto e : mp) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T>
std::istream& operator>>(std::istream& is, std::vector<T>& vec) {
  for (T& e : vec) is >> e;
  return is;
}

#ifdef LOCAL
#define debug(...) \
  std::cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}
using namespace std;
using int64 = long long;

int64 cnt(int64 N, int64 X) {
  if (N == 0) return 1;
  int64 all_prev = pow(2LL, N + 1) - 3;
  int64 p_prev = pow(2LL, N) - 1;
  if (X <= 1) return 0;
  if (X <= 1 + all_prev) return cnt(N - 1, X - 1);
  if (X == 2 + all_prev) return p_prev + 1;
  if (X <= all_prev * 2 + 2) return p_prev + 1 + cnt(N - 1, X - all_prev - 2);
  return p_prev * 2 + 1;
}

int main() {
  int64 N, X;
  cin >> N >> X;
  int64 ans = cnt(N, X);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4060
ans'' i (h0,w0) (h1,w1) =
  let d = minimum [abs(h1-h0),abs(w1-w0)]
  in
    d * ((i!!(h1-1))!!(w1-1))

ans' i (h,w) (h0,w0) =
  let p = concat $ map (\h0 -> map (\w0 -> (h0,w0)) [1..w]) [1..h]
  in
    sum $ map (ans'' i (h0,w0)) p

ans h w i =
  let p = concat $ map (\h0 -> map (\w0 -> (h0,w0)) [1..w]) [1..h]
  in
    minimum $ map (ans' i (h,w)) p
    
main = do
  l <- getLine
  c <- getContents
  let [h,w] = map read $ words l :: [Int]
      i = map (map read) $ map words $ lines c :: [[Int]]
      o = ans h w i
  print o



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

using namespace std;

int main(){
  int N; long long D;
  while(scanf("%d%lld", &N, &D) > 0){
    int ans = 0;
    
    for(int i = 0; i < N; i++){
      long long X, Y;
      scanf("%lld%lld", &X, &Y);

      if(X*X + Y*Y <= D*D){
	ans++;
      }
    }

    printf("%d\n", ans);
  }
}


Measured memory_bytes: 3820
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define G  1100000
#define mod 1000000007
LL pri[G];
LL ni[G],ans;
LL pow(LL a,int b)
{
    LL ans=1,base=a;
    while (b>0)
    {
        if (b%2==1)
            ans=(base*ans)%mod;
        base=(base*base)%mod;
        b/=2;
    }
    return ans;
}
void s()   //打表
{
    pri[0]=1;
    ni[0]=1;
    for (int i=1;i<G ;i++)
    {
        pri[i]=pri[i-1]*i%mod;  //N！
        ni[i]=pow(pri[i],mod-2);
    }
}
LL ANS(LL n,LL m)
{
    LL ans;
    ans=((pri[n]*ni[m]%mod)*ni[n-m])%mod;
    return ans%mod;
}
int main()
{
    //cout<<(22183738317301)%mod<<endl;
    s();
    LL H,W,A,B;
    scanf("%lld%lld%lld%lld",&H,&W,&A,&B);
    LL ans=0;
    for(LL i=B+1;i<=W;i++)
    {
        ans+=(LL)(ANS(H-A+i-2,H-A-1)*ANS(W+A-i-1,A-1)%mod)%mod;
    }
    printf("%lld\n",ans%mod);
    /*
    int t,n,b,k=1;
	//scanf("%d",&t);
    while (t--)
    {
        //scanf("%d%d",&n,&b);
        //ans=((pri[n]*ni[b]%mod)*ni[n-b])%mod; // C（n，m）= n！/（m！*（n-m）！）
        printf("Case %d: %lld\n",k++,ans);
    }
    return 0;  */

}


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

int main()
{
	int a, i, b;

	cin >> a;

	for (i = 0; i < 3; i++) {
		b = a % 10;
		a = a / 10;

		if (b == 7) {
			cout << "Yes";
			break;
		}
		else if (i == 2 && b != 7) {
			cout << "No";
		}
	}




	return 0;
}

Measured memory_bytes: 3100
#!/usr/bin/env python3
import sys


def solve(N: int, K: int):

    N = N%K

    s = set()

    while N not in s:
        s.add(N)
        N = abs(N-K)

    print(min(s))
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    solve(N, K)

if __name__ == '__main__':
    main()


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

int A, B;

int main() {
  cin >> A >> B;
  if (A < 10 && B < 10) {
      cout << A * B << endl;
  } else {
      cout << -1 << endl;
  }
}


Measured memory_bytes: 256
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop;

void main() {
    auto s = readln.split.map!(to!int);
    auto N = s[0];
    auto K = s[1];
    long ans = 0;

    if (K == 0) {
        writeln(1L * N * N);
        return;
    }
    
    foreach (b; K+1..N+1) {
        int M = N / b + (N % b > 0);
        ans += (b - K) * M;
        if (N % b != 0) ans -= min(b - K, M * b - N - 1);
    }

    ans.writeln;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e18;

int main() {
  ll n,m;
  cin >> n >> m;
  ll sum=0;
  for(ll i=0;i<m;i++) {
    ll tmp;
    cin >> tmp;
    sum+=tmp;
  }
  if(sum>n) {
    cout << -1 <<endl;
  }
  else {
    cout << n-sum << endl;
  }
}

Measured memory_bytes: 3632
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <string>

using namespace std;
int main(){
    int n;
    string str;

    cin >> n;
    cin.clear();
    cin.ignore();

    std::getline(cin, str);

    int max=0;
    for(int i=1; i<n-1; i++){
        
    int r[26]={0};
    int l[26]={0};
    int x[26]={0};

        string a = str.substr(0,i);
        string b = str.substr(i,n);

        for(char c : a){
            r[c-'a'] = 1;
        }
        for(char c : b){
            l[c-'a'] = 1;
        }
        for(int i=0; i<26; i++){
            x[i] = r[i]*l[i];
        }
        int sum = accumulate(begin(x), end(x), 0);
        max = (max < sum)? sum : max;
    }

    cout << max << 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

const int N = 200005;
int a[N];

int main() {
    int n, k;
    scanf("%d %d", &n, &k);
    for (int i = 1; i <= n; i++) {
        scanf("%d", &a[i]);
        a[i] += a[i-1];
        a[i] %= k;
    }
    map <int, int> mp;
    mp[0] = 1;
    mp[-k] = 1;
    ll res = 0;
    for (int i = 1; i <= n; i++) {
        if (i - k >= 0) {
            mp[a[i-k]-i+k]--;
            mp[a[i-k]-i]--;
        }
        if (mp.count(a[i] - i)) {
            res += mp[a[i]-i];
        }
        /*
        if (mp.count(a[i] - i + k)) {
            res += mp[a[i]-i+k];
        }*/
        mp[a[i]-i]++;
        mp[a[i]-i-k]++;
    }
    printf("%lld", res);
    return 0;
}


Measured memory_bytes: 23256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
  public static void main(String[] args) {
    System.out.println(solve());
  }
  
  private static int solve() {
    FastReader fr = new FastReader();
    int N = fr.nextInt();
    int result = 0;
    int current = -9999; // value of current character in Int
    String S = fr.next();
    for (int i = 0; i < N; i++) {
      int checking = S.charAt(i) - 'a';
      if (current == checking) continue; // if found the same color, it will slime to the near by color
      current = checking; // change current color
      result++; // and also add one to result since we found a new color that can not be fused
    }
    
    return result;
  }
}

class FastReader {
  BufferedReader br;
  StringTokenizer st;

  public FastReader() {
    br = new BufferedReader(new
        InputStreamReader(System.in));
  }

  String next() {
    while (st == null || !st.hasMoreElements())
    {
      try
      {
        st = new StringTokenizer(br.readLine());
      }
      catch (IOException e)
      {
        e.printStackTrace();
      }
    }
    return st.nextToken();
  }

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

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

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

  String nextLine() {
    String str = "";
    try {
      str = br.readLine();
    }
    catch (IOException e) {
      e.printStackTrace();
    }
    return str;
  }
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,a,b) for(int i=(a);i<(b);i++)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second

using vint=vector<int>;
using pint=pair<int,int>;
using vpint=vector<pint>;

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<class A,class B>
ostream& operator<<(ostream& ost,const pair<A,B>&p){
	ost<<"{"<<p.first<<","<<p.second<<"}";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost,const vector<T>&v){
	ost<<"{";
	for(int i=0;i<v.size();i++){
		if(i)ost<<",";
		ost<<v[i];
	}
	ost<<"}";
	return ost;
}

struct UnionFindTree{
	vector<int>par,sz;
	UnionFindTree(int n){
		par.resize(n);
		sz.resize(n);
		for(int i=0;i<n;i++){
			par[i]=i;
			sz[i]=1;
		}
	}
	int find(int x){
		return x==par[x]?x:par[x]=find(par[x]);
	}
	void unite(int x,int y){
		x=find(x);y=find(y);
		if(x==y)return;
		if(sz[x]<sz[y])swap(x,y);
		sz[x]+=sz[y];
		par[y]=x;
	}
	bool areSame(int x,int y){
		return find(x)==find(y);
	}
	int size(int x){
		return sz[find(x)];
	}
};

signed main(){
	int N;
	cin>>N;
	vint A(N),B(N);
	rep(i,N)cin>>A[i];
	rep(i,N)cin>>B[i];
	vint ordA(N);iota(all(ordA),0);
	vint ordB(N);iota(all(ordB),0);
	sort(all(ordA),[&](int i,int j){
		return A[i]<A[j];
	});
	sort(all(ordB),[&](int i,int j){
		return B[i]<B[j];
	});


	rep(i,N){
		if(A[ordA[i]]>B[ordB[i]]){
			cout<<"No"<<endl;
			return 0;
		}
	}


	UnionFindTree uf(N);
	rep(i,N)uf.unite(ordA[i],ordB[i]);
	if(uf.size(0)!=N){
		cout<<"Yes"<<endl;
		return 0;
	}

	rep(i,N-1){
		if(A[ordA[i+1]]<=B[ordB[i]]){
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	cout<<"No"<<endl;
	return 0;
}

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

#define forn(i,n) for(int i=0;i<(int)(n);i++)
#define si(c) ((int)(c).size())
#define forsn(i,s,n) for(int i = (int)(s); i<((int)n); i++)

typedef long long int ll;

const int N = 1e5 + 100;

ll n, a[N], use[N];

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

    auto k = sum / n2;
    vector<ll> b(2*n+10);
    forn(i,n) {
        auto dif = a[i%n] - a[(i+n-1)%n];
        use[i] = max(0LL,min(k,(k-dif)/n));
        b[i] += use[i];
        b[i+n] -= (n+1)*use[i];
        b[i+n+1] += n*use[i];
    }

    forn(_,2) forn(i,si(b)-1) b[i+1] += b[i];
    forsn(i,n,si(b)) b[i%n] += b[i];


    bool res = true;
    forn(i,n) res &= a[i] == b[i];
    cout << (res ? "YES" : "NO") << endl;

    return 0;
}


Measured memory_bytes: 3328
#include<cstdio>
#include<cmath>
#include<iostream>
using namespace std;
#define EPS 1.0e-6
#define F(I,J,N) for(int I=J;I<N;I++)

class point{
public:
	double x,y;
	point(){}
	point(double x,double y){
		this->x=x;
		this->y=y;
	}
	double len(point &p){
		return sqrt((x-p.x)*(x-p.x)+(y-p.y)*(y-p.y));
	}
	double len(){
		return sqrt(x*x+y*y);
	}
	point operator*(double d){
		point p(x*d,y*d);
		return p;
	}
	point operator/(double d){
		point p(x/d,y/d);
		return p;
	}
	point operator+(const point &o){
		point p(x+o.x,y+o.y);
		return p;
	}
	point operator-(const point &o){
		point p(x-o.x,y-o.y);
		return p;
	}
	point& operator=(const point &o){
		this->x=o.x;
		this->y=o.y;
		return *this;
	}
	bool operator==(const point &o){
		return (x==o.x && y==o.y);
	}
	bool operator!=(const point &o){
		return !(x==o.x && y==o.y);
	}
};

int main(){
	int n;
	point *p;
	int ans;
	point c,ce,h;
	while(cin>>n){
		c=ce;
		if(n==0) break;
		p=new point[n];
		ans=0;
		F(i,0,n) cin>>p[i].x>>p[i].y;
		F(i,0,n-1){
			F(j,i+1,n){
				if(p[i].len(p[j])<2+EPS){
					c=(p[i]+p[j])/2;
					h.x=-(p[i]-p[j]).y;
					h.y=(p[i]-p[j]).x;
					double len=p[i].len(p[j]);
					len=sqrt(1-len*len/4);
					h=h*(len/h.len());

					ce=c+h;
					int cnt=0;
					F(k,0,n) if(ce.len(p[k])<1+EPS) cnt++;
					ans=max(ans,cnt);

					ce=c-h;
					cnt=0;
					F(k,0,n) if(ce.len(p[k])<1+EPS) cnt++;
					ans=max(ans,cnt);
				}
			}
		}
		if(ans==0) ans=1;
		cout<<ans<<endl;
		delete []p;
	}
	return 0;
}

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

const int N = 100344;
int n, m;
vector<int> G[N];

int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    G[x].push_back(y);
    G[y].push_back(x);
  }
  int cnt4 = 0, cnt6 = 0;
  for (int i = 1; i <= n; i++) {
    if ((int) G[i].size() & 1) {
      puts("No");
      return 0;
    } else if ((int) G[i].size() == 4) {
      cnt4++;
    } else if ((int) G[i].size() >= 6) {
      cnt6++;
    }
  }
  if (cnt6 || cnt4 >= 3) {
    puts("Yes");
    return 0;
  }
  if (cnt4 == 2) {
    for (int i = 1; i <= n; i++) {
      if (G[i].size() == 2) {
        int x = G[i][0], y = G[i][1];
        if (x == y) {
          puts("Yes");
          return 0;
        }
        for (auto &t : G[x]) if (t == i) {t = y; break;}
        for (auto &t : G[y]) if (t == i) {t = x; break;}
      }
    }
  }
  puts("No");
}


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

using namespace std;

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

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

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

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

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

  ll K;
  cin >> K;
  vector<ll> base;

  ll modK = K % 50;
  
  for(int i = 0; i < 50-modK; i++){
    base.push_back(49-modK);
  }
  for(int i = 0; i < modK; i++){
    base.push_back(100-modK);
  }

  for(int i = 0; i < 50; i++){
    base[i] += K / 50;
  }

  cout << 50 << endl;
  for(int i = 0; i < 50; i++){
    cout << base[i] << " ";
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
    int a, b;
    cin >> a >> b;
    if(a > b){
        cout << "a > b" << endl;
    }else if(a == b){
        cout << "a == b" << endl;
    }else{
        cout << "a < b" <<endl;
    }
    return 0;
}

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

using namespace std;

typedef long long ll;

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

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

ll solve(const ll x) {
    if (x == 1) {
        return 1;
    } else {
        return solve(x / 2) * 2 + 1LL;
    }
}

int main(void) {
    ll H;
    cin >> H;
    cout << solve(H) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define INF 1145141919
int dy[] = {0, 0, 1, -1};
int dx[] = {1, -1, 0, 0};
int ny, nx;
typedef long long int ll;
using namespace std;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

ll lcm(ll m, ll n)
{
    if ((0 == m) || (0 == n))
        return 0;
    return ((m / gcd(m, n)) * n);
}

ll llpow(ll x, ll y)
{
    ll ans = 1;
    REP(i, y)
    ans *= x;
    return ans;
}

int ctoi(char c)
{
    if (c >= '0' && c <= '9')
    {
        return c - '0';
    }
    return 0;
}

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

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

int N;
ll W, weight[110], value[110];
ll dp[110][100010] = {0};

////////////////////////////////////////////////////////////////////
int main()
{

    cin >> N >> W;
    REP(i,N) cin >> weight[i] >> value[i];

    REP(i,N){
        REP(sum_w, W+1){
            if(sum_w-weight[i]>=0){
                chmax(dp[i+1][sum_w], dp[i][sum_w-weight[i]]+value[i]);
            }
            chmax(dp[i+1][sum_w], dp[i][sum_w]);
        }
    }

    cout << dp[N][W] << endl;

    return 0;
}


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

using namespace std;

#define REP(i, n)   for(int i = 0; i < (n); i++)
#define REPS(i, n)  for(int i = 1; i <= (n); i++)
#define RREP(i, n)  for(int i = (n)-1; i >= 0; i--)
#define RREPS(i, n) for(int i = (n); i > 0; i--)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define mp make_pair
#define mt make_tuple
#define pb push_back

using ll  = long long;
using pi  = pair<int, int>;
using pl  = pair<ll, ll>;
using vi  = vector<int>;
using vl  = vector<ll>;
using vs  = vector<string>;
using vb  = vector<bool>;
using vvi = vector<vi>;

const int MOD = 1e9 + 7;
const int INF = 1e9 + 7;
const ll  INFL = 1e18;
const double PI = 3.141592653589793;
const double EPS = 1e-9;

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

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

    ll x, k, d; cin >> x >> k >> d;
    ll n = abs(x) / d;
    x = abs(x) - min(k, n) * d;
    k -= min(k, n);
    ll ans = INFL;
    if(k & 1)
    {
        chmin(ans, abs(x - d));
    }
    else
    {
        chmin(ans, abs(x));    
    }
    cout << ans << endl;
}

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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

LL a, b;

int main() {
	cin >> a >> b;
	
	cout << (a * b % 2 == 0 ? "Even" : "Odd") << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cmath>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define been(ix) (ix).begin(),(ix).end()
using namespace std;
typedef long long ll; 
typedef vector<int> vi;
typedef vector<long long> vl;
const ll INF = 1e18;
#define foreach(ix,a) for(auto& (ix) : (a)
typedef long double ld;
int main(){
  ll n;
  cin>>n;
  ll ans =INF;
  for(int i=1; i<=sqrt(n);i++){
    if(n%i==0)ans = min(ans,i+(n/i)-2);
  }
  cout<<ans<<endl;
  
  
}

Measured memory_bytes: 256
def main():
    n=int(input())
    x=list(map(int,input().split()))
    y=sorted(x)
    c1,c2=y[n//2-1],y[n//2]
    if c1==c2:
        for i in range(n):
            print(c1)
    else:
        for i in range(n):
            if x[i]<=c1:
                print(c2)
            else:
                print(c1)

if __name__=="__main__":
    main()

Measured memory_bytes: 25228
#include<cstdio>
#include<cstring>
#include<cmath>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<queue>

using namespace std;

using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
using vll=vector<ll>;
using vvll=vector<vll>;
using vpii=vector<pii>;

#define PI 3.1415926535897932384626433832795

int main(void)
{
	char t[200000+2];
	while(scanf("%200000[PD?]\n", t)==1)
	{
		for(int i=0;t[i];i++)
		{
			if(t[i]=='?') t[i]='D';
		}

		printf("%s\n", t);
	}
	return 0;
}


Measured memory_bytes: 1852
#include<stdio.h>
#define N 100001

int linersearch(int * ,int ,int);

int main (){
  int n,i,S[N],q,key,num=0;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&S[i]);
  }
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&key);
    //if(linersearch(S,n,key)!=0)
    num=num+linersearch(S,n,key);
  }
  printf("%d\n",num);
 
  return 0;
}

int linersearch(int A[],int n,int key){
  int i=0;
  A[n]=key;
  while(i!=n){
    if(A[i]==key)
      break;
    i++;
  }
  if(i==n)return 0;
  else return 1;

}



Measured memory_bytes: 2108
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	cin>>s;
	int cnt=0;
	string s1=s;
	reverse(s1.begin(),s1.end());
	for(int i=0;i<s.length()/2;i++)
	{
		if(s[i]!=s1[i])
			cnt++;
	}
	cout<<cnt<<endl;
}

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

using namespace std;

#define FOR(i, n) for(int i = 0; i < (int) n; i++)
#define PB push_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define F first
#define S second

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

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

	int n; cin >> n;
	map<int, int> m;
	ll sum = 0;
	FOR(i, n){
		int x; cin >> x;
		m[x]++;
		sum += x;
	}

	int q; cin >> q;
	FOR(i, q){
		int a, b; cin >> a >> b;
		ll d = m[a];
		sum -= 1LL*d*a;
		sum += 1LL*d*b;
		m[b] += d;
		m[a] = 0;
		cout << sum << '\n';
	}

	return 0;
}


Measured memory_bytes: 8028
#include <cstdio>
#include <algorithm>
#include <iostream>

using namespace std;

int main() {
  int n;
  scanf("%d", &n);
  int mn = 2'000'000'000;
  long long tot = 0;
  for (int i = 0; i < n; ++i) {
    int x, y;
    scanf("%d %d", &x, &y);
    tot += x;
    if (x > y) {
      mn = min(mn, y);
    }
  }
  if (mn == 2'000'000'000) {
    puts("0");
  } else {
    printf("%lld\n", tot - mn);
  }
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int gcd(int m,int n){if(m%n==0)return n;else return gcd(n,m%n);}
int num(int a,int b,int c)
{
	if(a==b&&b==c)return 1;
	else if(a==b||b==c||c==a)return 3;
	else return 6;
}
int main()
{
	long s=0,n;cin>>n;
	for(long i=1;i<=n;i++)if(i%3&&i%5)s+=i;
	cout<<s<<'\n';
	return 0;
}

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

#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define endl '\n'
#define fcin ios::sync_with_stdio(false); cin.tie(nullptr);
#define INF 0x3f3f3f3f
#define all(x) x.begin(), x.end()
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef long long ll;
typedef pair<int, int> pii;

const ll MOD = 1e9 + 7;

const int N = 5e5 + 15;
ll fat[N];

void init(){
    fat[0] = 1LL;
    for(ll i = 1; i < N; i++) fat[i] = (fat[i-1] % MOD * i % MOD) % MOD;
}

ll fastp(ll a, ll p){
    if(p == 1) return a % MOD;
    if(p&1) return (a % MOD * fastp(a, p-1) % MOD) % MOD;
    ll x = p / 2;
    ll t = fastp(a, x) % MOD;
    return (t % MOD * t % MOD) % MOD;
}

ll nck(ll n, ll k){
    if(k < 0 or k > n) return 0;

    ll top = fat[n];
    ll fatk = fastp(fat[k], MOD - 2);
    ll fatnk = fastp(fat[n-k], MOD - 2);

    top = (top % MOD * fatk % MOD) % MOD;
    return (top % MOD * fatnk % MOD) % MOD;
}

int main(){
    fcin;
    ll n, k;
    cin >> n >> k;
    
    init();
    ll ans = nck(2*n-1, n-1);

    for(ll i = k + 1; i < n; i++){
        ans = (ans + MOD - (nck(n, i) % MOD * nck(n-1, n-i-1) % MOD) % MOD) % MOD;
    }

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


Measured memory_bytes: 4224
import java.io.*;
import java.util.*;

public class Main {

	BufferedReader br;
	PrintWriter out;
	StringTokenizer st;
	boolean eof;
	
	int[] p;
	
	int get(int v) {
		return p[v] == v ? v : (p[v] = get(p[v]));
	}
	
	void unite(int a, int b) {
		a = get(a);
		b = get(b);
		
		if (a != b) {
			if (((a + b) & 1) == 1) {
				p[a] = b;
			} else {
				p[b] = a;
			}
		}
	}

	void solve() throws IOException {
		int n = nextInt();
		int m = nextInt();
		
		p = new int[n + m];
		
		for (int i = 0; i < n + m; i++) {
			p[i] = i;
		}
		
		for (int i = 0; i < n; i++) {
			int k = nextInt();
			for (int j = 0; j < k; j++) {
				int lang = nextInt() - 1 + n;
				
				unite(i, lang);
				
			}
		}
		
		int who0 = get(0);
		for (int i = 0; i < n; i++) {
			if (get(i) != who0) {
				out.println("NO");
				return;
			} 
		}
		
		out.println("YES");
	}

	Main() throws IOException {
		br = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		solve();
		out.close();
	}

	public static void main(String[] args) throws IOException {
		new Main();
	}

	String nextToken() {
		while (st == null || !st.hasMoreTokens()) {
			try {
				st = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				eof = true;
				return null;
			}
		}
		return st.nextToken();
	}

	String nextString() {
		try {
			return br.readLine();
		} catch (IOException e) {
			eof = true;
			return null;
		}
	}

	int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}
}

Measured memory_bytes: 37448
import java.util.Scanner;

public class Main {
  	public static void main(String...args) {
      	Scanner sc = new Scanner(System.in);
      	long a = sc.nextLong();
      	long b = sc.nextLong();
		long o = 0L;
      
      	if (a % 2 == 1) {
          a = a -1;
          o = a;
        }
      
      	long sub = b - a;
      	if (sub % 4 == 0) {
          System.out.println(b ^ o);
        } else if (sub % 4 == 1) {
          System.out.println(b ^ (b-1) ^ o);
        } else if (sub % 4 == 2) {
          System.out.println(b ^ 1 ^ o);
        } else if (sub % 4 == 3) {
          System.out.println(b ^ (b-1) ^ 1 ^ o);
        }
    }
}

Measured memory_bytes: 21844
#pragma GCC optimize("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target ("avx2")
#include <bits/stdc++.h>
using namespace std ;
#define ll long long
void FastInputOutput(){
    ios_base :: sync_with_stdio( 0 ) ;
    cin.tie( 0 ) ;
    cout.tie( 0 ) ;
}

inline int D(){
    int t ;
    scanf( "%d" , &t ) ;
    return t ;
}
inline ll LLD(){
    ll t ;
    scanf( "%lld" , &t ) ;
    return t ;
}

ll power(ll x, ll p, ll m){
    ll res = 1;
    while(p){
        if(p&1)    res = (res * x)%m;
        x = (x * x)%m;
        p >>= 1;
    }
    return res;
}


const int N = 1e5 + 5;
int n, m;

int main(){
    n = D(), m = D();
    for(int i = 0; i * 10000LL <= m; ++i){
        for(int j = 0; i * 10000LL + j * 5000LL <= m; ++j){
            if((m - (i * 10000LL + j * 5000LL)) % 1000LL != 0)
                continue;
            int k = (m - (i * 10000LL + j * 5000LL)) / 1000LL;
            if(k < 0)
                break;
            if(i + j + k == n && i * 10000LL + j * 5000LL + k * 1000LL == m){
                return printf("%d %d %d\n", i, j, k), 0;
            }
        }
    }
    printf("-1 -1 -1");
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define INF 1e9;
using namespace std;
typedef long long ll;
int main() {
  int N, M;
  cin >> N >> M;
  int X[M];
  REP(i, M) { cin >> X[i]; }
  sort(X, X + M);
  vector<int> diff;
  REP(i, M - 1) { diff.push_back(X[i + 1] - X[i]); }
  sort(diff.begin(), diff.end());

  int ans = 0;
  REP(i, M - N) { ans += diff[i]; }
  cout << ans;
  return 0;
}

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

int main() {
    string a, b, c;
    cin >> a >> b >> c;
    queue<char> aa, bb, cc;
    rep (i, a.size()) {
        aa.push(a.at(i));
    }
    rep (i, b.size()) {
        bb.push(b.at(i));
    }
    rep (i, c.size()) {
        cc.push(c.at(i));
    }
    char tmp = 'a';
    bool k = true;
    char ans;
    while (k) {
        if (tmp == 'a') {
            if (0 == aa.size()) {
                ans = 'A';
                k = false;
            }
            tmp = aa.front(); aa.pop();
        }
        else if (tmp == 'b') {
            if (0 == bb.size()) {
                ans = 'B';
                k = false;
            }
            tmp = bb.front(); bb.pop();
        }
        else if (tmp == 'c') {
            if (0 == cc.size()) {
                ans = 'C';
                k = false;
            }
            tmp = cc.front(); cc.pop();
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
from heapq import heappop, heappush

# 入力の受付
X, Y, Z, K = map(int, input().split())
a_list = list(map(int, input().split()))
b_list = list(map(int, input().split()))
c_list = list(map(int, input().split()))

# 入力配列のソート(降順: 大きい値が先頭)
a_list.sort(reverse = True)
b_list.sort(reverse = True)
c_list.sort(reverse = True)

# 優先度付きキューの定義
hq = []

# キューの管理リスト
arg_hash = {}

# キューの初期値
val = -(a_list[0] + b_list[0] + c_list[0])
heappush(hq, (val, 0, 0, 0))

# 答えを格納する配列
ans_arr = []

# 最大値を取り出していく．
# 以下をK回繰り返す
# 1. -(A+B+C)を要素とするキューの中の最小値を取り出す．(i番目に小さい数) この最小値は(A,B,C)の各リストの(p,q,r)番目のリストに含まれる値．
# 2．このキューに対して(p+1, q, r), (p, q+1, r), (p, q, r+1)のそれぞれが含まれているかどうかを確認
#     ない場合には，キューの管理リストに追加 & キューにその要素を追加
#     ある場合には，特に何もせず．
for i in range(K):
    # キューから最小値を取り出す(負なので実際は最大値を取り出している)
    ans_val, p, q, r = heappop(hq)
    ans_arr.append(-ans_val)
    
    # (p+1, q, r), (p, q+1, r), (p, q, r+1)のそれぞれが含まれているかどうかを確認
    arg_a = (p+1, q, r)
    arg_b = (p, q+1, r)
    arg_c = (p, q, r+1)

    # キューの管理リストに対して，上の要素が存在するかどうかの探索と処理
    # a < X-1 は，全要素がキューに入っている場合に，さらに次のインデックスの要素を追加しないようにするための検索条件
    # p+1 用
    if (p < X-1) and (arg_a not in arg_hash):
        # キュー管理リストに(p+1, q, r)のタプルを登録（辞書キーとして）
        arg_hash[arg_a] = 1
        # キューに値を登録
        heappush(hq, (-(a_list[p+1] + b_list[q] + c_list[r]), ) + arg_a)
    # q+1 用
    if (q < Y-1) and (arg_b not in arg_hash):
        # キュー管理リストに(p+1, q, r)のタプルを登録（辞書キーとして）
        arg_hash[arg_b] = 1
        # キューに値を登録
        heappush(hq, (-(a_list[p] + b_list[q+1] + c_list[r]), ) + arg_b)
    # r+1 用
    if (r < Z-1) and (arg_c not in arg_hash):
        # キュー管理リストに(p+1, q, r)のタプルを登録（辞書キーとして）
        arg_hash[arg_c] = 1
        # キューに値を登録
        heappush(hq, (-(a_list[p] + b_list[q] + c_list[r+1]), ) + arg_c)

# 結果出力
for i in range(len(ans_arr)):
    print(ans_arr[i])
    

Measured memory_bytes: 10408
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  int w = (c-1)/b+1;
  int s = (a-1)/d+1;
  if (w<=s) cout << "Yes\n";
  else cout << "No\n";
  return 0;
}

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


int n,x,a,b,c;

int main(){
	cin >> n;
	for(int i=0;i<n;i++){
		cin >> x;
		if(x%4==0) a++;
		else if(x%2==0) b++;
		else c++;
	}
	
	if(b==0){
		if(a+1>=c) cout << "Yes" << endl;
		else cout << "No" << endl;
		return 0;
	}
	
	
	if(a>=c) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
//大文字->小文字 tolower(),逆はtoupper()
//int a = stoi(c); 文字列をintへ
//途中の出力をそのまま残さない
//数値計算 基本はdouble
//map<キー,値> p は辞書。p[キー] = 値
#include <bits/stdc++.h>
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
using namespace std;

// Nの桁数
ll dig(ll N) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= 10;
	}
	return dig;
}
// x,yの最大公約数
ll gcd(ll x, ll y) {
	ll r;
	while (x%y) {
		r = x % y;
		x = y;
		y = r;
	}
	return y;
}

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

	cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <algorithm>
#include <ctime>
#include <vector>
#include <set>
#include <queue>
using namespace std;

#define PI 3.14159265358979323846264338327950L

string res;

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

    int card[3][3];
    int N, B;
    for (int i = 0; i < 3; i++)
    {
        for (int j = 0; j < 3; j++)
        {
            cin >> card[i][j];
        }
    }
    cin >> N;
    for (int i = 0; i < N; i++)
    {
        cin >> B;
        for (int i = 0; i < 3; i++)
        {
            for (int j = 0; j < 3; j++)
            {
                if (card[i][j] == B)
                {
                    card[i][j] = 0;
                }
            }
        }
    }
    if (
        card[0][0] == 0 && card[0][1] == 0 && card[0][2] == 0 ||
        card[1][0] == 0 && card[1][1] == 0 && card[1][2] == 0 ||
        card[2][0] == 0 && card[2][1] == 0 && card[2][2] == 0 ||
        card[0][0] == 0 && card[1][0] == 0 && card[2][0] == 0 ||
        card[0][1] == 0 && card[1][1] == 0 && card[2][1] == 0 ||
        card[0][2] == 0 && card[1][2] == 0 && card[2][2] == 0 ||
        card[0][0] == 0 && card[1][1] == 0 && card[2][2] == 0 ||
        card[0][2] == 0 && card[1][1] == 0 && card[2][0] == 0)
    {
        res = "Yes";
    }
    else
    {
        res = "No";
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
	int a[4];
	int b[2];
	int i=0;
	int j=0;
	int s=0;
	int h=0;
	
	for(i=0;i<4;i++){        
		cin>>a[i];
	}
	for(i=0;i<2;i++){
		cin>>b[i];
	}
	for(i=0;i<4;i++){
		if(a[j]>a[i]){
			j=i;
		}
		s=s+a[i];
	}
	s=s-a[j];
	if(b[0]>b[1]){
		s=s+b[0];
	}else{
		s=s+b[1];
	}
	cout<<s<<endl;
}

Measured memory_bytes: 3104