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

int main() {
	int a, b, c,check = 0;
	cin >> a >> b >> c;
	for (int i = 1; i <= 10000; i++) {
		check += a;
		if (check % b == c) {
			cout << "YES" << endl;
			return 0;
		}
	}
	cout << "NO" << endl;
}

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

#define fix(n)          cout<<fixed<<setprecision(n)
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define sort(a)         sort((a).begin(), (a).end())
#define uniq(a)         sort(a);(a).erase(unique((a).begin(), (a).end()), (a).end())
#define reverse(a)      reverse((a).begin(), (a).end())
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d)
#define outl(d)         std::cout<<(d)<<"\n"
#define YES()           cout << "YES" << endl
#define NO()            cout << "NO" << endl
#define Yes()           cout << "Yes" << endl
#define No()            cout << "No" << endl
#define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }

using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;

const ll MOD = 1000000007; // 10^9 + 7

int count(string s1, string s2) {
  int ret = 0;
  for (char c = 'a'; c <= 'z'; c++) {
    if (s1.find(ctos(c)) != string::npos && s2.find(ctos(c)) != string::npos) ret++;
  }
  return ret;
}

void solve() {
  int n; cin >> n;
  string s; cin >> s;

  int ans = 0;
  for (int i = 1; i < n; i++) {
    string s1 = s.substr(0, i);
    string s2 = s.substr(i, n - i);
    // debug2(s1, s2);
    ans = max(ans, count(s1, s2));
  }
  outl(ans);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12);

  solve();
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 310

ll dist[SIZE][SIZE];
ll dist2[SIZE][SIZE];

int main(){
  int N, M, L;

  cin >> N >> M >> L;

  for (int i=0; i<N; i++)
    for (int j=0; j<N; j++)
      dist[i][j] = i == j ? 0 : LLINF;

  for (int i=0; i<M; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    a--; b--;

    dist[a][b] = dist[b][a] = c;
  }

  for (int k=0; k<N; k++)
    for (int i=0; i<N; i++)
      for (int j=0; j<N; j++)
        dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);

  for (int i=0; i<N; i++) {
    for (int j=0; j<N; j++) {
      dist2[i][j] = (dist[i][j] <= L) ? 1 : LLINF;
    }
    dist2[i][i] = 0;
  }

  for (int k=0; k<N; k++)
    for (int i=0; i<N; i++)
      for (int j=0; j<N; j++)
        dist2[i][j] = min(dist2[i][j], dist2[i][k] + dist2[k][j]);


  int Q;

  cin >> Q;

  for (int i=0; i<Q; i++) {
    int s, t;

    cin >> s >> t;

    ll ans = dist2[s-1][t-1] - 1;

    if (ans == LLINF - 1) ans = -1;

    cout << ans << endl;
  }


  return 0;
}


Measured memory_bytes: 2048
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>
#include <stdio.h>
#include <numeric>
#include <cstring>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define MOD 1000000007 //10^9+7
using namespace std;
using ll = long long;
using PII = pair<int, int>;
const int INF = numeric_limits<int>::max();

// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

//greatest common divisor
long long gcd(ll a, ll b) 
{
    if (a % b == 0) {
        return b;
    } else {
        return gcd(b, a % b);
    }
}

//least common multiple
long long lcm(ll a, ll b)
{
    return a / gcd(a, b) * b ;
}

int main()
{
    int n;
    cin >> n;
    vector<int> a(n), b(n), c(n);
    rep(i,n) {
        cin >> a[i] >> b[i] >> c[i];
    }

    vector<int> dpa(n, -1), dpb(n, -1), dpc(n, -1);
    dpa[0] = a[0]; dpb[0] = b[0]; dpc[0] = c[0];
    rep1(i,n) {
        dpa[i] = max(dpb[i-1], dpc[i-1]) + a[i];
        dpb[i] = max(dpa[i-1], dpc[i-1]) + b[i];
        dpc[i] = max(dpb[i-1], dpa[i-1]) + c[i];
    }

    cout << max(dpa[n-1], max(dpb[n-1], dpc[n-1])) << endl;

    return 0;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 1 + 1e5;
typedef long long LL;
typedef pair < int, int > II;
typedef pair < int, II > III;

int n, a[MAXN], gt = 1;
double x[MAXN], y[MAXN], ans = 0;

double dis(int i, int j){
    return sqrt( (x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j]) );
}

void solve(){
    for (int i = 1; i < n; i++){
        ans += dis(a[i], a[i+1]);
    }
}

int main()
{
    #define TASK "ABC"
  //  freopen(TASK".inp","r",stdin);
//    freopen(TASK".out","w",stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    cin >> n;
    for (int i = 1; i <= n; i++){
        cin >> x[i] >> y[i];
        a[i] = i;
        gt *= i;
    }
    do{
        solve();
    }while(next_permutation(a + 1, a + 1 + n));
    printf("%0.9f", double(ans / gt));
    return 0;
}




Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <array>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <iomanip>

#define FOR(i, a, b) for(decltype(b) i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;

using namespace std;

#ifdef INPUT
#include <sstream>
stringstream input(R"(
5 7
)");
#define cin input
#endif

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

	cout << (a - 1) * (b - 1) << endl;

	return 0;
}


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

int main() {
    string N;
    cin >> N;
    bool is_odd  = true;
    long ans = 0;
    if(N.size() % 2 == 0) is_odd = false;
    long num = atoi(N.c_str());

    if(is_odd)
    {
         ans += num - pow(10,N.size() - 1) + 1;
    }

    for(int i = 0;i < N.size() / 2; i++) ans += 9 * pow(10,i * 2);
    
    cout << ans << endl;
}

Measured memory_bytes: 256
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG //FOR THE DEBUG! COMMENT OUT THIS WHEN SUBMITTING!
#endif
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
//#include <unordered_set> //unordered_set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
#define endl "\n";
//It is so troublesome that I include bits/stdc++.h !
using namespace std;

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; }
const long long INF = 10010010010010;
const long long MOD = 1000000007;
typedef pair<int,int> P;

//Solve N^M. This, mod_pow use Iterative Square Method.
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}

long long gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
    return a / gcd(a, b) * b ;
}

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

    int N;cin >> N;
    vector<int> diff(N);
    for(int i = 0;i<N;i++) cin >> diff.at(i);
    int M;cin >> M;
    vector<int> pset(M);
    for(int i = 0;i<M;i++) cin >> pset.at(i);

    sort(diff.begin(),diff.end());
    sort(pset.begin(),pset.end());

    int prv = 0;
    bool ok = false;
    for(int i = 0;i<M;i++){
        for(int j = prv;j<N;j++){
            if(diff.at(j) == pset.at(i)){
                prv = j+1;
                ok = true;
                break;
            }
        }
        if(!ok) {
            cout << "NO" << endl;
            return 0;
        }
        ok = false;
    }
    cout << "YES" << endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define all(x) (x).begin(),(x).end()
using namespace std;
int main() {
    int a,b,c;
    cin>>a>>b>>c;
    string ans=(a<=c&&c<=b ? "Yes" : "No");
    cout<<ans<<endl;
}


Measured memory_bytes: 256
import std.algorithm, std.conv, std.range, std.stdio, std.string;
import std.math;

void main()
{
  auto s = readln.chomp;

  auto hi = new int[](s.length + 1);
  foreach (i, c; s)
    hi[i + 1] = hi[i] + c.predSwitch('\\', -1, '_', 0, '/', 1);
  auto maxH = hi.reduce!(max);

  auto fs1 = hi.findSplitBefore([maxH]), hiL = fs1[0], hiMR = fs1[1];
  if (!hiL.empty) hiL ~= maxH;

  hiMR.reverse();
  auto fs2 = hiMR.findSplitBefore([maxH]), hiR = fs2[0], hiM = fs2[1];
  if (!hiR.empty) hiR ~= maxH;

  auto aiL = hiL.calcAreas;
  auto aiM = hiM.calcAreas; aiM.reverse();
  auto aiR = hiR.calcAreas; aiR.reverse();
  auto ai = aiL ~ aiM ~ aiR;

  writeln(ai.sum);
  write(ai.length);
  ai.each!(a => write(" ", a));
  writeln;
}

int[] calcAreas(int[] hi)
{
  int[] areas;
  int maxH = int.min, area = 0;
  foreach (i, h; hi) {
    if (h < maxH) {
      area += 2 * (maxH - h) + (hi[i - 1] - h).sgn;
    } else if (h == maxH) {
      if (area > 0) {
        areas ~= area / 2;
        area = 0;
      }
    } else {
      maxH = h;
    }
  }
  return areas;
}

Measured memory_bytes: 2700
n,m = map(int,input().split())
ball = [1]*n
ans = [0]*n
ans[0] = 1

for i in range(m):
    x,y = map(int,input().split())
    x -= 1
    y -= 1
    ball[x] -= 1
    ball[y] += 1
    if ans[x] == 1:
        ans[y] = 1
    if ball[x] == 0:
        ans[x] = 0

a = 0
for an in ans:
    if an == 1:
        a += 1

print(a)

Measured memory_bytes: 4596
#define DEBUG 1
#include <bits/stdc++.h>
#define loop(n) for (lint ngtkana_is_a_genius = 0; ngtkana_is_a_genius < lint(n); ngtkana_is_a_genius++)
#define rep(i, begin, end) for (lint i = lint(begin); (i) < lint(end); i++)
#define all(v) v.begin(), v.end()
#define rand(l, r) std::uniform_int_distribution<>(l, r)(mt)
using lint = long long;
auto mt = std::mt19937_64(std::random_device{}());
auto cmn = [](auto&& a, auto b){ if (a > b) {a = b; return true;} return false; };
auto cmx = [](auto&& a, auto b){ if (a < b) {a = b; return true;} return false; };
void debug_impl() { std::cerr << std::endl; }
template <typename Head, typename... Tail>
void debug_impl(Head head, Tail... tail) { std::cerr << " " << head; debug_impl(tail...); }
#if DEBUG
#define debug(...)\
  do {\
    std::cerr << std::boolalpha << "[" << #__VA_ARGS__ << "]:";\
    debug_impl(__VA_ARGS__);\
    std::cerr << std::noboolalpha;\
  } while (false)
#else
#define debug(...) {}
#endif

template < typename Container, typename Value = typename Container::value_type, std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr>
std::istream& operator>> (std::istream& is, Container& v)
  { for (auto & x : v) { is >> x; } return is; }

template < typename Container, typename Value = typename Container::value_type, std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr >
std::ostream& operator<< (std::ostream& os, Container const& v) {
 os << "{";
  for (auto it = v.begin(); it != v.end(); it++)
    {os << (it != v.begin() ? "," : "") << *it;}
  return os << "}";
}

int main() {
  std::cin.tie(0); std::cin.sync_with_stdio(false);
  int n; std::cin >> n;
  std::vector<int> a(n); std::cin>>a;
  int sum = std::accumulate(all(a),0);
  for (int & x : a) {
    x = sum - x * n;
    if (x < 0) x = -x;
  }
  // debug(a);
  int ans = std::min_element(all(a)) - a.begin();
  std::cout << ans << std::endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)
int main() {
    string s;
    cin >> s;
    string s_req = "CODEFESTIVAL2016";
    int ans = 0;
    rep(i, s.length()) {
        if ( s[i] != s_req[i] ) ++ans;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
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; }

const ll INF=(1LL<<60);
const int mod=1000000007;

int main(void){
    int H,W,K; cin >> H >> W >> K;
    vector<vector<int>> dp(H+1, vector<int>(W,0)); dp[0][0]=1;

    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
            for(int k=0; k<1<<(W-1); k++){

                bool ok=true;
                for(int l=0; l<W-2; l++){
                    if(k&1<<l && k&1<<(l+1)) ok=false;
                }

                if(ok){
                    if(j>=1 && 1&k>>(j-1)){
                        dp[i+1][j-1]+=dp[i][j];
                        dp[i+1][j-1]%=mod;
                    }
                    else if(1&k>>j){
                        dp[i+1][j+1]+=dp[i][j];
                        dp[i+1][j+1]%=mod;
                    }
                    else{
                        dp[i+1][j]+=dp[i][j];
                        dp[i+1][j]%=mod;
                    }
                }
            }
        }
    }

    cout << dp[H][K-1] << endl;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef string str;

#define all(x)                      (x).begin(),(x).end()
#define Sort(x)                     sort(all((x)))
#define X                           first
#define Y                           second
#define Mp                          make_pair
#define pb(x)                       push_back(x)
#define pf(x)                       push_front(x)
#define sep                         ' '
#define endl                        '\n'
#define debug(x)                    cerr << #x << " = " << x << endl
#define SZ(x)                       ll(x.size())
#define fast_io                     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

const ll MAXN = 1e5 + 10;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;

ll poww(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));
}

ll dp[MAXN] , a[MAXN] , b[MAXN] , k[MAXN];

int main(){

    ll n , m;
    cin >> n >> m;
    for(int i = 1; i <= n; i++){
        cin >> a[i];
    }
    dp[0] = 1;
    for(int i = 1; i <= m; i++){
        cin >> b[i];
        dp[i] = 1;
    }
    k[0] = 0;
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= m; j++){
            k[j] = k[j - 1];
            if(a[i] == b[j]){
                k[j] = (k[j] + dp[j - 1]) % MOD;
            }
        }
        for(int j = 1; j <= m; j++){
            dp[j] = (dp[j] + k[j]) % MOD;
        }
    }
    cout << dp[m];

}


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

int main() {
	char b;
	for(int i=0;i<5;i++){
		char a;
		cin>>a;
		cout<<a;
	}
	cin>>b;
	cout<<" ";
	for(int i=0;i<7;i++){
		char a;
		cin>>a;
		cout<<a;
	}
	cin>>b;
	cout<<" ";
	for(int i=0;i<5;i++){
		char a;
		cin>>a;
		cout<<a;
	}
	cout<<endl;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
lst = [x for x in range(n)]
dic = {}
not_found = False
special_case = False
for i in range(m):
    a, b = map(int, input().split())
    if str(a) not in list(dic.keys()):
        dic[str(a)] = b
    else:
        if dic[str(a)] != b:
            not_found = True
    lst[a - 1] = b
if m == 0:
    special_case = True
if not_found:
    print(-1)
elif special_case:
    if n == 1:
        print(0)
    elif n == 2:
        print(10)
    else:
        print(100)
else:
    for i in range(n):
        if str(i + 1) not in list(dic.keys()):
            if i + 1 == 1:
                lst[i] = 1
            else:
                lst[i] = 0
    lst = list(map(str, lst))
    res = ''.join(lst)
    if res[0] == '0' and len(res) > 1:
        print(-1)
    else:
        print(int(res))
        

Measured memory_bytes: 3064
#include<stdio.h>
#include<string.h>
int main()
{
    int a,b,i,j;
    scanf("%d %d",&a,&b);
    char s[a],s1[b];
    for(i=0;i<a;i++)
    {
        s[i]=(char)(b+48);
    }
    s[i]='\0';
    for(i=0;i<b;i++)
    {
        s1[i]=(char)(a+48);
    }
    s1[i]='\0';

    if(strcmp(s1,s)<=0)
        printf("%s\n",s1);
    else if(strcmp(s,s1)<0)
        printf("%s\n",s);
    return 0;
        }


Measured memory_bytes: 1584
import java.util.Scanner;

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

        int N = sc.nextInt();
        int ans = 0;
        for (int i = 0; i < N; i++) {
            if (i * i > N) {
                ans = i;
                break;
            }
        }
        System.out.println((ans - 1)*(ans - 1));
    }
}


Measured memory_bytes: 21844
#include <algorithm>
#include <climits>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <vector>

const int mod = 1e9 + 7;
const int kmax = 510000;

long long fact[kmax], fact_inv[kmax], inv[kmax];

void init_comb()
{
    fact[0] = fact[1] = 1;
    fact_inv[0] = fact_inv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < kmax; i++) {
        fact[i] = fact[i - 1] * i % mod;
        inv[i] = mod - inv[mod % i] * (mod / i) % mod;
        fact_inv[i] = fact_inv[i - 1] * inv[i] % mod;
    }
}

long long comb(int n, int r)
{
    if (n < r) {
        return 0;
    }

    if (n < 0 || r < 0) {
        return 0;
    }

    return fact[n] * (fact_inv[r] * fact_inv[n - r] % mod) % mod;
}

template <typename T, T N>
class UnionFind {
    T parent_[N];
    T rank_[N];
    T size_[N];

public:
    UnionFind();
    T Root(T idx);
    bool IsSame(T x, T y);
    void Unite(T x, T y);
    T GetSize(T idx);
};

template <typename T, T N>
UnionFind<T, N>::UnionFind()
{
    for (T i = 0; i < N; i++) {
        parent_[i] = i;
        rank_[i] = 0;
        size_[i] = 1;
    }
}

template <typename T, T N>
T UnionFind<T, N>::Root(T idx)
{
    return parent_[idx] == idx ? idx : parent_[idx] = Root(parent_[idx]);
}

template <typename T, T N>
bool UnionFind<T, N>::IsSame(T x, T y)
{
    return Root(x) == Root(y);
}

template <typename T, T N>
void UnionFind<T, N>::Unite(T x, T y)
{
    x = Root(x);
    y = Root(y);
    if (x == y) {
        return;
    }

    if (rank_[x] < rank_[y]) {
        parent_[x] = y;
        size_[y] += size_[x];
    } else {
        parent_[y] = x;
        size_[x] += size_[y];
        if (rank_[x] == rank_[y]) {
            rank_[x]++;
        }
    }
}

template <typename T, T N>
T UnionFind<T, N>::GetSize(T idx)
{
    return size_[Root(idx)];
}

long long pow_mod(long long n, long long p, long long m)
{
    if (p == 0) {
        return 1;
    }

    if (p % 2 == 0) {
        long long t = pow_mod(n, p / 2, m);
        return t * t % m;
    }
    return n * pow_mod(n, p - 1, m) % mod;
}

long long nCr_mod(long long n, long long r)
{
    long long x = 1;
    for (long long i = n - r + 1; i <= n; i++) {
        x *= i;
        x %= mod;
    }

    long long a = 1;
    for (long long i = 1; i <= r; i++) {
        a *= i;
        a %= mod;
    }

    long long y = pow_mod(a, mod - 2, mod) % mod;

    return x * y % mod;
}

int main()
{
    long long n, m;
    std::cin >> n >> m;

    std::vector<bool> from(n);
    std::vector<bool> to(n);

    for (int i = 0; i < m; i++) {
        long long a, b;
        std::cin >> a >> b;
        a--;
        b--;

        if (a == 0) {
            from[b] = true;
        } else if (b == n - 1) {
            to[a] = true;
        }
    }

    for (int i = 0; i < n; i++) {
        if (from[i] && to[i]) {
            std::cout << "POSSIBLE" << std::endl;
            return 0;
        }
    }

    std::cout << "IMPOSSIBLE" << std::endl;
}


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

int main()
{
 string s;
  cin >> s;
  
  bool f = true;
  for (int i = 1;i <= s.length(); i++)
  {
   if (i%2 && s[i-1] == 'L')
     f = false;
    else if (!(i%2) && s[i-1] == 'R')
      f= false;
  }
  
  if (f)
    cout << "Yes" << endl;
  else
    cout  << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <algorithm>
using namespace std;

typedef long long int ll;

int main () {
    string tmp; cin >> tmp;
    if (tmp[2] == tmp[3] && tmp[4] == tmp[5]) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

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

#define _GLIBCXX_DEBUG
#define all(v) (v).begin(),(v).end()

using namespace std;

using ll=long long;
using pii=pair<int, int>;
using vi=vector<int>;
using vii=vector<vector<int>>;

const ll LINF=1LL<<60;
const int INF=1<<29;
const ll MOD=1e9+7;


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

Measured memory_bytes: 3568
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
int N;

int main(){
	int A,B;
	cin>>A>>B;
	cout<<6-A-B<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
struct Rest{
	int score;
	string s;
	int index;
};
bool comp(Rest a, Rest b){
	if(((a.s).compare(b.s) < 0)){
		return true;
	}
	else if(((a.s).compare(b.s) == 0)){
		if(a.score>b.score)
			return true;
		else return false;
	}
	else return false;
}
int main(){
	int n;
	cin>>n;
	Rest a[n];
    for(int i=0;i<n;i++){
    	cin>>a[i].s>>a[i].score;
    	a[i].index=i+1;
	}
	sort(a, a+n, comp);
	for(int i=0;i<n;i++){
		cout<<a[i].index<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        //切り出しする文字列
        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        int K = sc.nextInt();
        if(A >= K){
            System.out.println(K);
        }else if(A + B >= K){
            System.out.println(A);
        }else{
            System.out.println(A - (K - A - B));
        }
    }
}


Measured memory_bytes: 35588
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long A, B, C, X, Y;
    cin >> A >> B >> C >> X >> Y;
    long long ans = 0;
    /*
    if ((A + B) / 2 >= C)
    {
        long long min_num = min(X, Y);
        if (A <= 2 * C || B <= 2 * C)
        {
            ans += min_num * 2 * C;
            X -= min_num;
            Y -= min_num;
            ans += A * X + B * Y;
        }
        else
        {
            ans += min_num * 2 * C;
            X -= min_num;
            Y -= min_num;
            ans += max(X, Y) * 2 * C;
        }
    }
    else
    {
        ans += A * X + B * Y;
    }
    */
   if(A+B<2*C){
    ans=A*X+B*Y;
  }
  else
  {
    ans+=2*C*min(X,Y);
    if(X>Y){
      ans+=(X-Y)*min(A,C*2);
    }else{
      ans+=(Y-X)*min(B,C*2);
    }
  }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

#define REP(i,n) for (int i = 0; i < n; i++)
typedef long long ll;

int main ()
{

    int X,Y;
    cin >> X >> Y;
    cout << X + Y / 2 << endl;

    return 0;
}



Measured memory_bytes: 256
def sieve_of_eratosthenes(N):
    prime_list = [True] * (N + 1)
    prime_list[0] = prime_list[1] = False
    ans_list = [0] * (N + 1)
    for i in range(2, N+1):
        if prime_list[i]:
            for j in range(i*2, N+1, i):
                prime_list[j] = False
    for i in range(1, N+1):
        ans_list[i] = ans_list[i - 1]
        if i % 2 != 0:
            j = (i + 1) // 2
            if prime_list[i] and prime_list[j]:
                ans_list[i] += 1
    return ans_list

def main():
    ans_list = sieve_of_eratosthenes(10 ** 5)
    Q = int(input())
    for i in range(Q):
        l, r = map(int, input().split())
        print(ans_list[r] - ans_list[l - 1])

if __name__ == '__main__':
    main()


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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef long long ll;

typedef pair<int, int> P;

int INF = 100100100;

int main() {
    int N;
    cin >> N;
    vector<P> R(N);
    vector<P> B(N);
    rep(i, N) cin >> R[i].first >> R[i].second;
    rep(i, N) cin >> B[i].first >> B[i].second;

    sort(R.begin(), R.end());
    sort(B.begin(), B.end());

    int ans = 0;
    vector<bool> used(N, false);
    rep(i, N) {
        int r_index = -1;
        int max_height = -1;
        rep(j, N) {
            if (used[j]) continue; // この赤い点は使用済み
            if (R[j].first < B[i].first && R[j].second < B[i].second && max_height < R[j].second) {
                r_index = j;
                max_height = R[j].second;
            }
        }

        if (r_index != -1) {
            ans++;
            used[r_index] = true;
        }
    }

    cout << ans << endl;
}


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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll;
const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12;
void tostr(ll x,string& res){while(x)res+=('0'+(x%10)),x/=10; reverse(ALL(res)); return;}
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; }
//template end



int main(){
   int n; scanf("%d",&n);
   vector<int> a(n);
   rep(i,0,n)scanf("%d",&a[i]);
   sort(ALL(a)); bool f=0;
   rep(i,0,n-1)if(a[i]==a[i+1])f=1;
   printf(f?"NO":"YES");
   return 0;
}

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

int main() {
    int n, ans = 0;
    cin >> n;
    int a[n];
    int t;
    string s, x, kyoku;
    vector<pair<string, int>> st;
    for(int i = 0; i < n; ++i) {
        cin >> s >> t;
        st.push_back(make_pair(s, t));
    }
    int f = 0;
    cin >> x;
    for(int i = 0; i < n; ++i) {
        kyoku = st[i].first;
        if(kyoku == x) {
            f = 1;
            continue;
        }
        if(f == 1) {
            ans += st[i].second;
        }
    }
    cout << ans << '\n';
}



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

int main() {
	int a,b,c,d;
  	cin>>a>>b>>c>>d;int i=0;
  	while(c>0 && a>0){
  	    if(i%2){a-=d;}
  	    else{c-=b;}
  	    i++;
  	}
  	if(c<=0){cout<<"Yes";}
  	else{cout<<"No";}
	return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ll long long
#define MOD 1000000007
#define MAX 200010
#define test(a,n) REP(i,n) cout << a[i] << " ";
using namespace std;


//fac=n!, finv=1/n!
ll fac[MAX], finv[MAX], inv[MAX];
 
void facmod() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

int main(){
  int n,k;
  cin >> n >> k;
  ll sum1, sum2, sum=0;

  facmod();
  int nk = min(n,k+1);
  REP(m,nk){
    sum1 = fac[n] * (finv[m] * finv[n-m] % MOD) % MOD;
    sum2 = fac[n-1] * (finv[n-m-1] * finv[m] % MOD) % MOD;
    sum += sum1 * sum2 % MOD;
    sum %= MOD;
  }
  
  cout << sum % MOD;
  return 0;
}

Measured memory_bytes: 4992
#include<iostream>
#include<string>
#include<vector>
#include<cmath>

using namespace std;

int main() {

	uint64_t A, B, N;

	cin >> A >> B >> N;


	if (N >= B) {
		N = B - 1;
		cout << floor(A*N / B) - A * floor(N / B);
		return 0;
	}
	else {
		cout << floor(A*N / B) - A * floor(N / B);
		return 0;
	}



}

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

const int maxn = 3e5 + 10;

int n, a[maxn];

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

	for (int i = 1; i <= n * 3; ++i)
		scanf ("%d", &a[i]);

	sort (a + 1, a + 1 + n * 3);

	long long ans = 0;

	for(int i = 1, j = n * 3; i <= n; ++i, j -= 2)
		ans += a[j - 1];

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

Measured memory_bytes: 1408
#include<stdio.h>
int main(){
  int n,i,count=0;
  scanf("%d",&n);
  int v[n+1],c[n+1];
  for(i=0;i<n;i++)
    scanf("%d",&v[i]);
  for(i=0;i<n;i++)
    scanf("%d",&c[i]);
  for(i=0;i<n;i++)
    if(v[i]>c[i])
      count+=v[i]-c[i];
  printf("%d\n",count);
  return 0;
}


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

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

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



int main(){
	int d,g,p[11],c[11];
	cin>>d>>g;
	for (int i = 0; i < d; i++){
		cin>>p[i]>>c[i];
	}

	int ans=1e+9;
	for (int i = 0; i < pow(2,d); i++){
		int s=0,num=0,res=-1;
		for (int j = 0; j < d; j++){
			if(i&(1<<j)){
				s+=100*(j+1)*p[j]+c[j];
				num+=p[j];
			}else{
				res=j;
			}
		}
		if(s<g){
			int s1=100*(res+1);
			int need=(g-s+s1-1)/s1;
			if(need>=p[res])continue;
			num+=need;
		}
		ans=min(ans,num);
	}

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

Measured memory_bytes: 384
// Created by Nandu Vinodan
#include <bits/stdc++.h>

#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define rep(i,a,n) for(int i=a;i<=(n);++i)
#define repD(i,a,n) for(int i=a;i>=(n);--i)
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define vi vector<int>
#define pi pair<int, int>
#define INF INT_MAX
#define _INF INT_MIN
#define TC 0 

using namespace std;
using ll = long long;

#define MAXN   100001 
  
int spf[MAXN]; 
  
void sieve() 
{ 
    spf[1] = 1; 
    for (int i=2; i<MAXN; i++)
        spf[i] = i; 

    for (int i=4; i<MAXN; i+=2) 
        spf[i] = 2; 
  
    for (int i=3; i*i<MAXN; i++) 
    { 
        if (spf[i] == i) 
        { 
            for (int j=i*i; j<MAXN; j+=i) 
                if (spf[j]==j) 
                    spf[j] = i; 
        } 
    } 
} 
  
vector<int> getFactorization(ll x) 
{ 
    vector<int> ret; 
    while (x != 1) 
    { 
        ret.push_back(spf[x]); 
        x = x / spf[x]; 
    } 
    return ret; 
} 

vector<ll> primeFactors(ll n)  { 
	vector<ll> res;
    while (n % 2 == 0)  {  
    	res.push_back(2);
        n = n/2;  
    }  
    for (ll i = 3; i * i <= n; i = i + 2)  {   
        while (n % i == 0)  {  
            res.push_back(i);
            n = n/i;  
        }  
    }  
    if (n > 2)  
        res.push_back(n);
    return res; 
}  

void testcase() {
	//sieve();
    ll n; cin >> n;
    vector<ll> fac = primeFactors(n);
    sort(fac.begin(), fac.end());
    int m = fac.size();

    int i=0;
    int res = 0;
    while (i < m) {
    	ll cur = fac[i];
    	int ct = 0;
    	while (i < m && cur == fac[i]) {
    		ct++;
    		i++;
    	}
    	int sum = 0, c = 0;
    	while (true) {
    		sum += c; 
    		if (sum  > ct) {
    			c--;
    			break;
    		}
    		c++;
    	}
    	res += c;
    }
    cout << res;

}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    if (TC)
        cin>>t;
    while(t--) {
        testcase();
    }
    return 0;
}

Measured memory_bytes: 3660
#include <iostream>
using namespace std;
int main() 
{
	int a, b, tmp, count;
    while (1) {
    	cin >> a >> b;
        if (a == 0 && b == 0) {
            break;
        }
        if(a < b) { 
                    tmp = b; 
                    b = a; 
                    a = tmp; 
                    } 
        count = 0; 
        do {
            a = a % b;
            tmp = b;
            b = a;
            a = tmp;
            count++;
        } while (b != 0);
        cout << a << " " << count << endl;
    }
	return 0;
}


Measured memory_bytes: 3096
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s[7]={"MON","TUE","WED","THU","FRI","SAT","SUN"},t;cin>>t;
  for(int i=0;i<7;i++)if(s[i]==t)cout<<(-i-1)%7+7;
}


Measured memory_bytes: 256
import collections
import sys

if __name__ == "__main__":
    N, K = [int(x) for x in input().split(" ")]
    A = [int(x) for x in input().split(" ")]
    counts = dict(collections.Counter(A))
    counts = {k: v for k, v in sorted(counts.items(), key=lambda item: item[1])}

    if len(counts) <= K:
        print(0)
        sys.exit(0)
    nums = len(counts) - K
    res = 0

    for key in counts:
        if nums <= 0:
            break
        res += counts[key]
        nums -= 1
    print(res)


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

int main() {
  int n;
  cin>>n;
  vector<tuple<string,int,int>>book(n);
  for(int i=0;i<n;i++) {
    cin>>get<0>(book[i])>>get<1>(book[i]);
    get<2>(book[i])=i+1;
    get<1>(book[i])*=-1;
  }
  sort(book.begin(),book.end());
  for(int i=0;i<n;i++) cout<<get<2>(book[i])<<endl; 
}


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

#define ll long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define mod 1000000007


int main()
{
    FAST
    int n,s = 0,a[4000];
    cin >> n;
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i];
        s+= a[i] - 1;
    }
    cout << s;
    return 0;
}



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

int n;
set<pair<int, bool> > edges[100001];

int main() {
	stack<pair<int, int> > stk;
	scanf("%d", &n);
	for (int i = 1; i < n; ++i) {
		int x, y;
		scanf("%d%d", &x, &y), --x, --y;
		edges[x].insert(make_pair(y, 0));
		edges[y].insert(make_pair(x, 0));
	}
	for (int i = 1; i < n; ++i) {
		int x, y;
		scanf("%d%d", &x, &y), --x, --y;
		edges[x].insert(make_pair(y, 1));
		edges[y].insert(make_pair(x, 1));
		stk.push(make_pair(x, y));
	}
	int cnt = 0;
	while (!stk.empty()) {
		pair<int, int> edge = stk.top();
		stk.pop();
		int x = edge.first, y = edge.second;
		auto it = edges[x].find(make_pair(y, 0));
		if (it != edges[x].end()) {
			__typeof(it) it2 = it;
			++it2;
			if (it2 != edges[x].end() && it2->first == y) {
				if (edges[x].size() < edges[y].size()) swap(x, y);
				++cnt;
				edges[x].erase(make_pair(y, 0));
				edges[x].erase(make_pair(y, 1));
				edges[y].erase(make_pair(x, 0));
				edges[y].erase(make_pair(x, 1));
				for (auto it3 = edges[y].begin(); it3 != edges[y].end();) {
					stk.push(make_pair(x, it3->first));
					edges[it3->first].erase(make_pair(y, it3->second));
					edges[it3->first].insert(make_pair(x, it3->second));
					edges[x].insert(*it3);
					it3 = edges[y].erase(it3);
				}
			}
		}
	}
	puts(cnt == n - 1 ? "YES" : "NO");
}

Measured memory_bytes: 24448
N,M = map(int,input().split())
AB = [tuple(map(int,input().split())) for i in range(M)]

es = [[] for _ in range(N)]
for a,b in AB:
    a,b = a-1,b-1
    es[a].append(b)

from collections import deque

mindist = N
ans = None
for g in range(N):
    for s in es[g]:
        q = deque([s])
        dist = [N]*N
        dist[s] = 0
        prev = [-1]*N
        while q:
            v = q.popleft()
            if v==g:
                break
            for to in es[v]:
                if dist[to] <= dist[v] + 1: continue
                dist[to] = dist[v] + 1
                prev[to] = v
                q.append(to)
        else:
            continue
        if dist[g] >= mindist: continue
        mindist = dist[g]
        v = g
        tmp = [v+1]
        while prev[v] >= 0:
            v = prev[v]
            tmp.append(v+1)
        ans = tmp

if ans:
    print(len(ans))
    print(*ans, sep='\n')
else:
    print(-1)

Measured memory_bytes: 3828
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B,C,K;
  cin >> A >> B >> C >> K;
 
  for (int i = 0; i < K; i++) {
    if (A >= B){
      B *= 2;
    }
    else if (B >= C){
      C *= 2;
    }
    if (A < B && B < C){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}



Measured memory_bytes: 3628
import java.util.*;
import java.io.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        System.out.println(b/c - (a-1)/c);
    }
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

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

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

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

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

    public double nextDouble() {
         return Double.parseDouble(next());
    }
    
    public String[] nextArray(int n) {
        String[] a = new String[n];
        for (int i = 0; i < n; i++)
            a[i] = next();
        return a;
    }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    } 
}


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

int main(){
  int b=0,w=0;
  string s;
  cin>>s;
  for(int i=0;i<s.size();i++){
    if(i%2==0){
		if(s[i]=='0'){
          w++;
        }else{
          b++;
        }
    }else{
      if(s[i]=='1'){
          w++;
        }else{
          b++;
        }
    }
  }
  cout<<min(b,w)<<endl;
  return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <unordered_set>
#include <cmath>
using namespace std;
typedef long long ll;
typedef unordered_set<int> uset;

int main( int argc, char* argv[] ){
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  if( abs(a-c) <= d ){
    cout << "Yes" << endl;
  } else if( abs(a-b) <= d && abs(b-c) <= d ){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  ll n, k, a;
  vector<ll> c(100009, 0);
  in(n);
  rep(i, n){
    in(a);
    c[a - 1]++;
  }
  a = 0;
  k = 0;
  rep(i, 100009){
    if(c[i] != 0){
      a++;
      if(c[i] % 2 == 0)
        k++;
    }
  }
  if(k % 2 == 1)
    a--;
  out(a);
  memi;
}

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

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int k = stdIn.nextInt();
		int s = stdIn.nextInt();
		int cnt = 0;
		for(int i = 0; i <= k; i++) {
			for(int j = 0;j <= k; j++) {
				if(0 <= s-(i+j) && s-(i+j) <= k) {
					cnt++;
				}
			}
		}
		System.out.println(cnt);
		
	}

}


Measured memory_bytes: 21844
#include <stdio.h>
int main(void){
    int n;
    int s;
    int S=0;
    int m=100;
    int i=0;
    
    for(;~scanf("%d",&s);){
        i&&s%10&&(m=fmin(m,s));
        i++&&(S+=s);
    }
    
    m>=100&&(S=m);
    printf("%d",S%10?S:S-m);
}


Measured memory_bytes: 2156
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <cctype>
#define itn int
#define gI gi

using namespace std;

inline int gi()
{
	int f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') { if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') { x = x * 10 + c - '0'; c = getchar();}
	return f * x;
}

int n, m, ans;

int main()
{
	n = gi(), m = gi();
	for (int i = max(-1000000, m - n + 1); i <= min(1000000, m + n - 1); i+=1) printf("%d ", i);
	puts("");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(register ll i=(a);i<(b);i++)
typedef long long ll;
inline ll read(){ll sign=1; ll x=0; char ch; while(!isdigit(ch=getchar())) if(ch=='-') sign=-1; while(isdigit(ch)) x=x*10+ch-'0',ch=getchar(); return x*sign;}
inline void write(ll k){ if(k<0) putchar('-'),k*=-1; char ch[20]; int num=0; while(k)ch[++num]=k%10,k/=10; if(num==0) ch[++num]=0; while(num)putchar(ch[num--]+'0');}
const ll INF=1ll<<62;
const ll MOD=1000000007;
ll a,b,c,ans;
int main() {
	a=read(); b=read(); c=read();
	ans=a*b*(c%2);
	ans=min(ans,b*c*(a%2));
	ans=min(ans,c*a*(b%2));
	write(ans);
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{

	public static void main (String[] args) {

		Scanner sc = new Scanner (System.in);

		int N = sc.nextInt();
		int X = sc.nextInt();
		int[] list = new int[N];
		for (int index=0; index<N; index++) {
			list[index]=sc.nextInt();
		}
		int now = 0;
		int count= 0;

		for (int index=0; index<N; index++) {
			if (index==0&&list[index]>X) {
				count++;
				break;
			}
			now+=list[index];
			if (now>X) {
				count++;
				break;
			} else if (index+1==N) {
				count+=2;
				break;
			} else {
				count++;
			}

		}

		System.out.println(count);
	}
}


Measured memory_bytes: 21844
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
    public static void main(String args[]) throws IOException{
        process();
    }
    public static void process() throws IOException{
        BufferedReader in=new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st=new StringTokenizer(in.readLine());
        int n=Integer.parseInt(st.nextToken());
        int m=Integer.parseInt(st.nextToken());
        ArrayList<ArrayList<Integer>> graph=new ArrayList<>();
        for(int i=0;i<=n;i++)
            graph.add(new ArrayList<>());
        for(int i=0;i<m;i++){
            st=new StringTokenizer(in.readLine());
            int x=Integer.parseInt(st.nextToken());
            int y=Integer.parseInt(st.nextToken());
            graph.get(x).add(y);
            graph.get(y).add(x);
        }
        int solution[]=new int[n+1];
        Queue<Integer> q=new LinkedList<>();
        boolean visited[]=new boolean[n+1];
        q.add(1);
        visited[1]=true;
        while(!q.isEmpty()){
            int start=q.remove();
            int t=graph.get(start).size();
            for(int i=0;i<t;i++){
                int x=graph.get(start).get(i);
                if(!visited[x]){
                    q.add(x);
                    visited[x]=true;
                    solution[x]=start;
                }
            }
        }
        boolean flag=true;
        for(int i=1;i<=n;i++)
            if(!visited[i]){
                flag=false;
                break;
            }
        if(!flag)
            System.out.println("No");
        else{
            System.out.println("Yes");
            for(int i=2;i<=n;i++)
                System.out.println(solution[i]+" ");
        }
    }
}


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

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  int ans = 0;
  for (int i = 1; i < N; i++) {
    ans += a[i] - a[i-1];
  }
  cout << ans << endl;
}

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

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;
typedef long long LL;
using Graph = vector<vector<int>>;

static long long INF = (1LL<<62);

long long N, M;
vector<long long> A, B;


int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(false);

	cin >> N;
	B.assign(N+1, 0);
	A.push_back(0);
	for(int i=1; i<=N; i++){
		long long a;
		cin >> a;
		A.push_back(a);
	}
	for(int i = N; i>= N/2 + 1; i--){
		B[i] = A[i];
	}
	for(int i = N/2; i>=1; i--){
		long long sum = 0;
		for(int j= 2; (i * j) <= N; j++){
			sum += B[i*j];
		}
		B[i] = sum - A[i];
		B[i] %= 2;
		if(B[i] < 0) B[i] += 2;
	}
	long long sumA = 0, sumB = 0;
	for(int i=1; i<=N; i++){
		M += B[i];
	}
	if((M % 2) != A[1]){
		printf("-1\n");
	}
	else{
		printf("%lld\n", M);
		if(M > 0){
			int cont = 0;
			for(int i=1; i<=N; i++){
				if(B[i] != 0){
					if(cont == 0){
						printf("%d", i);
						cont = 1;
					}
					else{
						printf(" %d", i);
					}
				}
			}
			printf("\n");
		}
	}
	return 0;
}

Measured memory_bytes: 6748