akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <sstream>
#define MAX 100000
using namespace std;

struct Queue{
    int head;
    int tail;
    int q[MAX];

    void initialize(){
        head = 0;
        tail = 0;
    }
    bool isEmpty(){
        return (head == tail);
    }
    bool isFull(){
        return (head == (tail+1)%MAX);
    }
    void enqueue(int x){
        if(isFull()){
            cout << "queue overflow\n";
            //exit(0);
        }
        q[tail] = x;
        if(tail == MAX-1){
            tail = 0;
        }
        else{
            tail += 1;
        }
    }
    int dequeue(){
        if(isEmpty()){
            cout << "queue underflow\n";
            //exit(0);
        }
        int x = q[head];
        if(head == MAX-1){
            head = 0;
        }
        else{
            head += 1;
        }
        return x;
    }
};

void calc(Queue q_name, string name[], Queue q_time, int quantum){
    int t_sum = 0;
    while(q_name.head != q_name.tail){
        if(q_time.q[q_time.head] <= quantum){
            t_sum += q_time.dequeue();
            cout << name[q_name.dequeue()] << " " << t_sum << '\n';
        }
        else{
            t_sum += quantum;
            q_name.enqueue(q_name.q[q_name.head]);
            q_time.enqueue(q_time.q[q_time.head]-quantum);

            if(q_name.head == MAX-1){
                q_name.head = 0;
                q_time.head = 0;
            }
            else{
                q_name.head += 1;
                q_time.head += 1;
            }
        }
    }
}

int main(){
    Queue q_name, q_time;
    int num, quantum;
    string name[MAX];
    int t;

    q_name.initialize();
    q_time.initialize();

    cin >> num >> quantum;
    for(int i=0; i<num; i++){
        cin >> name[i] >> t;
        q_name.enqueue(i);
        q_time.enqueue(t);
    }

    calc(q_name, name, q_time, quantum);

    return 0;
}


Measured memory_bytes: 7348
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

using std::string;
using std::vector;
using std::set;
using std::map;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

typedef boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000>> cpp_dec_float_1000;

constexpr char CRLF = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;

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; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }

void solve(void)
{
  ui N{}; cin >> N;

  using Pos = pair<ll, ll>;
  vector<pair<Pos, ll>> height(N);
  boost::for_each(height, [](auto& p){ std::cin >> p.first.first >> p.first.second >> p.second; });

  Pos C{ -1, -1 }; ll ans{};
  for(ll c_x = 0; c_x < 101; ++c_x)
  {
    for(ll c_y = 0; c_y < 101; ++c_y)
    {
      bool res{true}; ll H{};
      for(const auto& p0 : height)
      {
        if(p0.second < 1) continue;

        H = p0.second + std::abs(p0.first.first - c_x) + std::abs(p0.first.second - c_y);
        for(const auto& p : height)
        {
          if(p.second != std::max(H - std::abs(p.first.first - c_x) - std::abs(p.first.second - c_y), (ll)0))
          {
            res = false;
            break;
          }
        }
        if(!res) break;
      }

      if(res)
      {
        C = {c_x, c_y};
        ans = H;
        goto finish;
      }
    }
  }

finish:
  assert(ans != 0);
  assert(C.first >= 0 && C.second >= 0);
  std::cout
    << C.first << SPACE
    << C.second << SPACE
    << ans << CRLF;

  return;
}

int main(void)
{
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(0);

  solve();

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<cstring>
#include<functional>
#include<stack>
#include<queue>
#include<iomanip>
#include<map>
#include<limits>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<deque>
#include<utility>
#include<complex>
#include<cstdlib>
#include<set>
#include<cctype>

using namespace std;

#define DBG cerr << '!' << endl;
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(ll (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(ll (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(10)
#define MOD 1000000007

typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;

int main()
{
	int s;cin >> s;
	
	ll ans = 0;
	int cou = 1;
	int tc = 1,tnxt = 10,tp = 1;
	int uc = 1,unxt = 10,up = 1;
	
	if(cou == s)
	{
		ans++;
	}

		
	while(uc < 9999999)
	{
		while(cou < s)
		{
			tc++;
			if(tc == tnxt)
			{
				tnxt *= 10;
				tp++;
			}
			cou += tp;
			if(cou == s)
			{
				ans++;
			}
		}
		
		while(cou >= s && uc < 9999999)
		{
			cou -= up;
			uc++;
			if(uc == unxt)
			{
				unxt *= 10;
				up++;
			}
			if(cou == s)
			{
				ans++;
			}
		}
	}
	//cout << ans << endl;
	for(int i = 1;i <= s/8;i++)
	{
		if(s % i == 0)
		{
			int tmp = s / i;
			ll num1 = 1;
			ll num2 = 1;
			REP(j,tmp-1)num2 = (num2 * 10)%MOD;
			num1 = num2*10%MOD;
			num1 = (num1 - num2 + MOD ) % MOD;
			num1 = (num1 - i + MOD ) % MOD;
			ans = (ans + num1)%MOD;
		}
		ans = (ans + 1) % MOD;
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 384
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from bisect import bisect_right, bisect_left
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor, gamma, log
from operator import mul
from functools import reduce
from copy import deepcopy

sys.setrecursionlimit(2147483647)
INF = 10 ** 20
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 10 ** 9 + 7


n = I()
A = LI()
A.sort()
if all([a > 0 for a in A]):
    now = min(A)
    print(sum(A) - now * 2)
    A.remove(now)
    last = A.pop()
    while A:
        nxt = A.pop()
        print(now, nxt)
        now -= nxt
    print(last, now)
elif all([a < 0 for a in A]):
    now = max(A)
    print(-sum(A) + now * 2)
    A.remove(now)
    while A:
        nxt = A.pop()
        print(now, nxt)
        now -= nxt
else:
    print(sum([abs(i) for i in A]))
    minus = []
    plus = []
    for a in A:
        if a > 0:
            plus += [a]
        elif a < 0:
            minus += [a]
        else:
            if not plus:
                plus += [a]
            else:
                minus += [a]
    ret = minus[-1]
    for j in range(len(plus) - 1):
        print(ret, plus[j])
        ret -= plus[j]
    print(plus[-1], ret)
    ret = plus[-1] - ret
    for k in range(len(minus) - 1):
        print(ret, minus[k])
        ret -= minus[k]

Measured memory_bytes: 62488
#include <bits/stdc++.h>
#define int long long
#define f first
#define s second
using namespace std;
const int N=509;
int n,a[N],k,sum=0;
int f(int x){
	int b[n],sum=0;
	for(int i=0;i<n;i++){
		b[i]=a[i]%x;
		sum+=b[i];
	}
	int r=n-sum/x,res=0;
	sort(b,b+n);
	for(int i=0;i<r;i++)
		res+=b[i];
	return res;
}
int32_t main(){
    ios::sync_with_stdio(0),cin.tie(0);
    cin >> n >> k;
    for(int i=0;i<n;i++){
    	cin >> a[i];
    	sum+=a[i];
    }
    vector <int> d;
    d.push_back(sum);
    for(int i=1;i*i<=sum;i++){
    	if(sum%i)continue;
    	d.push_back(i),d.push_back(sum/i);
    }
    sort(d.rbegin(),d.rend());
    for(auto i:d){
    	if(f(i)<=k){
    		cout << i << " ";
    		break;
    	}
    }
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <iterator>
#include <map>
#include <math.h>
#include <numeric>
#include <string>
#include <utility>
#include <vector>
using namespace std;
typedef long long ll;

int main(){
    double A, B;
    double p;
    ll ans;

    cin >> A >> B;

    p = ceil(A / 0.08);
    while(p * 0.1 < B){
        p += 1.0;
    }
    if(floor(p * 0.08) == A && floor(p * 0.1) == B){
        cout << (int)p << endl;
    }else{
        cout << -1 << endl;
    }

    return 0;
}


Measured memory_bytes: 256
n = int(input())

max_n = -float('inf')
for i in range(n):
    num = int(input())
    if i == 0:
        min_n = num
    else:
        if num - min_n > max_n:
            max_n = num - min_n
        if num < min_n:
            min_n = num
print(max_n)

    
    



Measured memory_bytes: 5620
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <sstream>
#include <complex>
#include <ctime>
#include <cassert>
#include <functional>

using namespace std;

typedef long long ll;
typedef vector<int> VI;
typedef pair<int,int> PII;

#define REP(i,s,t) for(int i=(s);i<(t);i++)
#define FILL(x,v) memset(x,v,sizeof(x))

const int INF = (int)1E9;
#define MAXN 100005

int main() {
  int N, P;
  cin >> N >> P;
  int odd = 0, even = 0;
  REP(i,0,N) {
    int x;
    cin >> x;
    if (x&1) odd++;
    else even++;
  }
  ll ans = (1ll<<(odd-1)) * (1ll<<even);
  if (odd == 0) {
    if (P == 1) ans = 0;
    else ans = 1ll<<even;
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;

#define rep(i, n) for(int i = 0; i < n; ++i)
#define all(s) s.begin(), s.end()

int main(int argc, char** argv) {
  int n, a, b;
  cin >> n;
  cin >> a;
  cin >> b;

  if ((n * a) > b) {
    cout << b << endl;
  } else {
    cout << n * a;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef unsigned long long ull;
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; }
const ll INF=1e18;
const ll MOD=1e9+7;
const double pi=acos(-1);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);  
  
  int ans=0;
  rep(i,4){
    int t;
    cin >> t;
    ans+=t;
  }
  cout << ans/60 << endl;
  ans-=(ans/60)*60;
  cout <<ans << endl;
}



Measured memory_bytes: 3184
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

typedef long long ll;

const int MAX_N=100000,MAX_Q=100000;

int N,Q;
int p[MAX_N];
char q[MAX_Q+1];
int v[MAX_Q];

int colored[MAX_N];	//?????????????????°

vector<ll> out;

int find(int i){
	//?????????i?????????????????????????????????????????????
	if (colored[i]){
		return i;
	}
	return p[i]=find(p[i]);
}

ll solve(){
	//?????¨?????????????????????
	fill(colored,colored+N,0);
	colored[0]=1;	//????????????????????????????????????
	for (int i=0;i<Q;i++){
		if (q[i]=='M'){
			colored[v[i]]++;
		}
	}
	ll sum=0;
	for (int i=Q-1;i>=0;i--){
		if (q[i]=='M'){
			colored[v[i]]--;
		}
		else{
			sum+=find(v[i])+1;
		}
	}
	return sum;
}

int main(){
	do{
		scanf("%d %d",&N,&Q);
		if (N || Q){
			p[0]=0;
			for (int i=0;i<N-1;i++){
				scanf("%d",&p[i+1]);
				p[i+1]--;
			}
			for (int i=0;i<Q;i++){
				scanf(" %c %d",&q[i],&v[i]);
				v[i]--;
			}
			out.push_back(solve());
		}
	}while(N || Q);
	for (int i=0;i<out.size();i++){
		printf("%lld\n",out[i]);
	}
	return 0;
}

Measured memory_bytes: 2472
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int R = sc.nextInt();
    String ans;
    if (R < 1200) {
      ans = "ABC";
    } else if (R <2800) {
      ans = "ARC";
    } else {
      ans = "AGC";
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 23764
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<P,ll> PPI;
typedef pair<ll,P> PIP;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vp;
#define PQ(T) priority_queue<T,vector<T>,greater<T>>
#define PQ2(T) priority_queue<T>
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define REP(i,a,b) for(ll (i)=a;(i)<(ll)(b);++(i))
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n+1)
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(x,y) ((x)=min((x),(y)))
#define chmax(x,y) ((x)=max((x),(y)))
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
#define DEBUG(x) cerr<<"line ("<<__LINE__<<")  "<<#x<<": "<<x<<endl;
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

ll f(ll a, ll k){
	while(true){
		//cerr<<a<<" "<<k<<endl;
		if(a%k==0||a<k){
			//cerr<<a/k<<endl;
			return a/k;
		}
		if(a<k) return 0;
		ll t = a/k;
		a = t*k+(a+k)%(t+1);
		if(a%k) a -= t+1;
	}
	return a/k;
}

int main(){
	ll n;
	cin>>n;
	ll x = 0;
	rep(i, n){
		ll a, k;
		cin>>a>>k;
		x ^= f(a, k);
	}
	cout<<(x==0?"Aoki":"Takahashi")<<endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    ArrayList<Integer> primes = new ArrayList<>();
    for (int i = 2; i < 300000; i++) {
      if (i % 7 != 6 && i % 7 != 1) {
        continue;
      }
      boolean ok = true;
      for (int p : primes) {
        if (i % p == 0) {
          ok = false;
          break;
        }
      }
      if (!ok) {
        continue;
      }
      primes.add(i);
    }
    while (true) {
      int n = sc.nextInt();
      if (n == 1) {
        break;
      }
      System.out.print(n + ":");

      for (int p : primes) {
        if (n % p == 0) {
          System.out.print(" " + p);
        }
        if (n == 1) {
          break;
        }
      }
      System.out.println();
    }
  }
}

Measured memory_bytes: 34464
#include <bits/stdc++.h>
#define LL long long 
#define N 1000005
using namespace std;
LL int n,ar[N],sum,a;
char c[N];
pair<int,int> p[N];
int main()
{
	scanf("%lld",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&p[i].first),p[i].second=i;
	sort(p+1,p+n+1);	
	for(int i=1;i<=n;i++)
	{
		a=fabs(p[i].second-i);
		if(a%2==1)
		sum++;
	}	
	
	printf("%lld",sum/2);
}


Measured memory_bytes: 3072
def add_edge(s, d, edges):
    if s in edges:
        edges[s].append(d)
    else:
        edges[s] = [d]


N, M = [int(x) for x in input().split()]
edges = {}
for _ in range(M):
    s, d = [int(x) for x in input().split()]
    add_edge(s*3 + 0, d*3 + 1, edges)
    add_edge(s*3 + 1, d*3 + 2, edges)
    add_edge(s*3 + 2, d*3 + 0, edges)
S, T = [int(x)*3 + 0 for x in input().split()]

reached = set()
curs = [S]
count = 0
success = False

while curs:
    if T in curs:
        success = True
        break
    nexts = []
    for c in curs:
        if not c in edges:
            continue
        ns = edges[c]
        for n in ns:
            if not n in reached:
                reached.add(n)
                nexts.append(n)
    curs = nexts
    count += 1

if success:
    print(count // 3)
else:
    print(-1)


Measured memory_bytes: 77688
#include<bits/stdc++.h>
#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 fore(i,a) for(auto &i:a)
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/


int N;
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N;
    int ans = 0;
    rep(i, 0, N) {
        int L, R; cin >> L >> R;
        ans += R - L + 1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>

using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < int(n);i++)

int dp[100001];

int main(){
    int n;
    cin >> n;
    for (int i = 0; i < 100001;i++) dp[i] = n;
    dp[0] = 0;
    for (int i = 1;i <= n; i++){
        for (int pow6 = 1; pow6 <= i; pow6*=6) dp[i] = min(dp[i],dp[i-pow6]+1);
        for (int pow9 = 1; pow9 <= i; pow9*=9) dp[i] = min(dp[i],dp[i-pow9]+1);
    }
    cout << dp[n] << endl;
    

    return 0;

}


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

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

const lint MOD = (lint)1e9 + 7;

struct mint {
    lint x;
    mint(lint x=0):x((x%MOD+MOD)%MOD){}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += MOD-a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= MOD;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(lint t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    mint inv() const {
        return pow(MOD-2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res/=a;
    }
    friend ostream& operator<<(ostream& out, const mint& a){
        return out<<a.x;
    }
};

typedef vector<mint> vm;
typedef vector<vector<mint>> vmm;


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

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

class DIrohaAndAGrid {
public:
    lint H, W, A, B;
    vm fact, fact_inv;

    void input(std::istream& in, std::ostream& out){
        ios_base::sync_with_stdio(false);
        in>>H>>W>>A>>B;

    }

    mint comb(int x, int r){
        if(x<r) return 0;
        if(x<0 or r<0) return 0;
        return fact[x] * fact_inv[x-r] * fact_inv[r];
    }

    void solve(std::istream& in, std::ostream& out){
        input(in, out);
        fact = vm(H+W+1, 1), fact_inv = vm(H+W+1, 1);
        RREP(i, H+W){
            fact[i] = fact[i-1] * i;
        }
        fact_inv[H+W] = fact[H+W].inv();
        for(int i=H+W;0<i;i--){
            fact_inv[i-1] = fact_inv[i] * i;
        }
        mint ans = comb(H+W-2, H-1);
        REP(i, B){
            ans -= comb(A+W-i-2, A-1) * comb(H-A+i-1, i);
        }
        out<<ans<<'\n';
    }
};


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


Measured memory_bytes: 3328
f=lambda:map(int,input().split())
n,k=f()
d={c:v for c,v in zip('spr',f())}
t=input()
l=[1]*n
a=0
for i in range(n):
  if l[i-k] or t[i]!=t[i-k]:
    a+=d[t[i]]; l[i]=0
print(a)

Measured memory_bytes: 4084
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first.first
#define yy first.second
#define __V vector
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define oit ostream_iterator
#define mod 1000000007ll
using namespace __gnu_pbds;
using namespace std;
void doin() {
	cin.tie();
	cout.tie();
	ios::sync_with_stdio(0);
#ifdef LOCALc
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
template<typename T, typename l>
void getv(T& a, int n, l f) {
	a.resize(n);
	for (auto& i : a)
		cin >> i, f(i);
}
template<typename T>
void getv(T& a, int n) {
	a.resize(n);
	for (auto& i : a)
		cin >> i;
}
typedef unsigned long long ull;
typedef long long ll;
typedef double ld;
typedef ll _I;
typedef pair<_I, _I> pi;
typedef pair<ld, ld> pd;
typedef map<_I, _I> mii;
typedef __V <_I> vi;
typedef __V <char> vc;
typedef __V <ld> vd;
typedef __V <vd> vvd;
typedef __V <pi> vpi;
typedef __V <__V<_I>> vvi;
typedef __V <__V<char>> vvc;
typedef __V <__V<pi>> vvpi;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int n, x, y;
vvi g, dp;

void dfs(int v = 1, int p = 1) {
	for(auto i : g[v]) {
		if(i == p) continue;
		dfs(i, v);
		dp[v][0] *= (dp[i][0]+dp[i][1])%mod;
		dp[v][0] %= mod;
		dp[v][1] *= dp[i][0];
		dp[v][1] %= mod;
	}
}

int main() {
//	doin();
	cin >> n;
	g.resize(n+1);
	dp.resize(n+1, vi(2, 1));
	for(int i = 1; i < n;i++)
		cin >> x >> y, g[x].pb(y), g[y].pb(x);
	dfs();
	cout << (dp[1][0]+dp[1][1])%mod;
}


Measured memory_bytes: 15104
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <bitset>
#include <set>
#include <map>
#include <stack>
#include <list>

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,b,n) for(int i=b;i<n;i++)
#define SORT(c) sort((c).begin(),(c).end())
#define DESCSORT(c) sort(c.begin(), c.end(), greater<int>())

const float PI = 3.1415926;
static const int INFTY = (1<<30);

using namespace std;

typedef long long ll;
typedef long double ld;

ll x, y, n, T, A, k;

void solve(){
  ll tx, ty;
  if(x % T == 0)
    tx = x/T;
  else
    tx = x/T+1;
  if(y % A == 0)
    ty = y/A;
  else
    ty = y/A+1;

  if(tx > ty)
    k = tx;
  else
    k = ty;
}

int main() {
  cin >> n;
  cin >> x >> y;

  rep(i, n-1) {
    cin >> T >> A;
    solve();
    x = T*k;
    y = A*k;
  }

  cout << x+y << endl;
  
  return 0;
}


Measured memory_bytes: 256
program name
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int32):: c(3,3),i,j
    integer(int32):: a12,a23,a13,b12,b23,b13

    do i=1,3
        read*, c(:,i)
    end do

    a12 = c(1,1) - c(1,2)
    a23 = c(1,2) - c(1,3)
    a13 = c(1,1) - c(1,3)
    
    do i=2,3
        if(c(i,1)-c(i,2) /= a12 .or. c(i,2)-c(i,3) /= a23 .or. c(i,1)-c(i,3) /= a13) then
            print*, 'No'
            stop 
        end if
    end do

    b12 = c(1,1) - c(2,1)
    b23 = c(2,1) - c(3,1)
    b13 = c(1,1) - c(3,1)
    
    do i=2,3
        if(c(1,i)-c(2,i) /= b12 .or. c(2,i)-c(3,i) /= b23 .or. c(1,i)-c(3,i) /= b13) then
            print*, 'No'
            stop 
        end if
    end do

    print*, 'Yes'
    
end program name

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define LLINF 9223372036854775807
#define MOD ll(1e9+7)

int main(){
    int x;
    cin >> x;
    if(x==3 || x==5 || x==7){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }

    return 0;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define pb push_back
#define ll long long
#define maxn 300005
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define ms(i) memset(i,0,sizeof(i));
#define ms1(i) memset(i,-1,sizeof(i));
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define pii pair<int,int>
const int mod = 1e9 + 7;
set<int>st;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    ll x , k;
    cin >> x >> k;
    int ans = 0;
    while (x) {
        ans++;
        x /= k;
    }
    cout << ans << '\n';
}


Measured memory_bytes: 256
var
    a,b,c:integer;
function f(x:integer;y:integer;z:integer):integer;
    begin
        if x=y then f:=z
        else if x=z then f:=y
        else if y=z then f:=x
        else f:=0;
    end;
    
begin
    read(a);
    read(b);
    readln(c);
    writeln(f(a,b,c));
end.

Measured memory_bytes: 128
import java.util.*;

public class Main {
    static Scanner scanner = new Scanner(System.in);

    public static void main(String[]$) {
        String s = scanner.next();
        int t = Integer.MAX_VALUE;
        for (int i = 1; i < s.length(); i++) {
            if (s.charAt(i - 1) != s.charAt(i)) {
                t = Math.min(t, Math.max(i, s.length() - i));
            }
        }
        System.out.println(t == Integer.MAX_VALUE ? s.length() : t);
    }
}

Measured memory_bytes: 23508
n,m=map(int,input().split())
l=[[] for _ in range(n)]
for _ in range(m):
  a,b=input().split()
  l[int(a)-1].append(b)
  
wacnt=0
accnt=0

for rl in l:
  cnt = 0
  for r in rl:
    if r == 'WA':
      cnt+=1
    elif r == 'AC':
      wacnt+=cnt
      accnt+=1
      break
      
print(accnt, wacnt)

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

#include <math.h>
#include <stdlib.h>


#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;



int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int h, n;
    cin >> h >> n;

    for(int i = 0;i < n; i++) {
        int a ; cin >> a;
        h -= a;
    }
    
    if(h > 0) cout << "No" << endl;
    else cout << "Yes" << endl;

    return 0;
}


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

int main() {
  int A;
  int B;
  int count = 0;
  int n1, n2, n4, n5;
  cin >> A >> B;
  for (int i = A; i <= B; i++) {
    n1 = (i-i%10000)/10000;
    n2 = (i%10000-i%1000)/1000;
    n4 = (i%100-i%10)/10;
    n5 = i%10;
    if (n1 == n5 && n2 == n4)
      count += 1;
  }
    cout << count << endl;
}




Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <complex>
#include <map>
#include<unordered_map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include<bitset>
#include<deque>
#include<string>
#include<list>
#include<iterator>
#include<sstream>
#include <algorithm>
#include <numeric>
#include <math.h>

#define user spaesk
#define pi acos(-1)
#define lli long long int
#define ld long double
#define ff first
#define ss second
#define lower(a) transform(a.begin(),a.end(),a.begin(),::tolower);

using namespace std;

const int N = 3e5 + 500;
const long long mod = 1e9 + 7;
const long long cmod = 998244353 ;
const long long inf = 1LL << 61;
const int M = 1e6 + 500;
const lli ths = 1LL << 40;
const int NN = 5e3 + 6;

lli n, m;
vector<lli> g[N];

lli cache[N];

lli dfs(lli u) {

    lli &ans = cache[u];

    if(ans != -1)
        return ans ;

    ans = 0;

    for(auto it : g[u])
        ans = max(ans, 1 + dfs(it));

    return ans ;

}


void solve()
{

    cin>>n>>m;

    memset(cache, -1, sizeof cache);

    for(int i = 1; i <= m; i ++) {
        lli a, b;
        cin>>a>>b;
        g[a].push_back(b);
    }

    lli ans = 0;
    for(int i = 1; i <= n; i ++) {
        ans = max(ans, dfs(i));
    }

    cout<<ans;

    cout<<'\n';
    return ;
}

/*
*/

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

    int t = 1;
//    cin>>t;
    while(t --)
    {
        solve();
    }
    return 0;
}



Measured memory_bytes: 14208
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var arr=input.trim().split("\n");
var dn=arr.shift().split(" ").map(Number);
var d=dn[0];
var n=dn[1];
var D=[];
for(var i=0;i<d;i++)D.push(arr.shift()-0);
var N=[];
for(var i=0;i<n;i++)N.push(arr.shift().split(" ").map(Number));
var dp=[];
for(var i=0;i<d;i++){
   dp[i]=[];
   for(var j=0;j<n;j++){
      dp[i][j]=-Infinity;
   }
}
for(var j=0;j<n;j++){
   var now=D[0];
   var a=N[j][0];
   var b=N[j][1];
   if(a<=now && now<=b)dp[0][j]=0;
}
for(var i=1;i<d;i++){
   var now=D[i];
   for(var j=0;j<n;j++){
      var a=N[j][0];
      var b=N[j][1];
      if(a<=now && now<=b){
         for(var k=0;k<n;k++){
            dp[i][j]=Math.max(dp[i][j],dp[i-1][k]+Math.abs(N[j][2]-N[k][2]));
         }
      }
   }
}
var ans=0;
dp[d-1].forEach(function(v){
   ans=Math.max(ans,v);
});
console.log(ans);

Measured memory_bytes: 21248
// "header" {{{
#include <iostream>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <string>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cstring>
#include <iomanip>
#include <tuple>

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 all(x) (x).begin(),(x).end()
#define pii pair<int,int> 
#define int long long
#define setout(n,x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10)
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const long long mod = 1000000007;

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;

inline double sqrt( const double &x) 
{
	double         xHalf = 0.5 * x;
	int64_t  tmp   = 0x5FE6EB50C7B537AAl - ( *(int64_t*)&x >> 1);
	double         xRes  = * (double*)&tmp;

	xRes *= ( 1.5 - ( xHalf * xRes * xRes ) );
	xRes *= ( 1.5 - ( xHalf * xRes * xRes ) );
	xRes *= ( 1.5 - ( xHalf * xRes * xRes ) );
	xRes *= ( 1.5 - ( xHalf * xRes * xRes ) );
	return xRes * x;
}
// }}}


signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,m;
	cin >> n >> m;
	vector<vector<int> > g(n+1);
	vector<int> a(m),b(m);
	int ans = 0;
	rep(i,m){
		cin >> a[i] >> b[i];
		g[a[i]].emplace_back(b[i]);
		g[b[i]].emplace_back(a[i]);
	}
	rep(i,m){
		vector<int> visited(n+1);
		queue<int> que;
		que.emplace(a[i]);
		visited[a[i]] = true;
		int cnt = 0;
		while(!que.empty()){
			int now = que.front();
			que.pop();
			rep(j,g[now].size()){
				if(!visited[g[now][j]]){
					if(g[now][j] == b[i]) ++cnt;
					else{
						que.emplace(g[now][j]);
						visited[g[now][j]] = true;
					}
				}
			}
		}
		if(cnt == 1) ++ans;
	}

	cout << ans << '\n';

	return 0;	
}


Measured memory_bytes: 256
// template version 1.5
// {{{ define basic macro
using namespace std;
#include <iostream>
#include <bits/stdc++.h>
// varibable settings
#define int long long
#define INF 1000000000000000000LL
// #define INF 2147483647
#define MOD 1000000007LL
#define infile "../test/sample-1.in"

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)(b-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ten(n) ((int)1e##n)
template<class T, size_t N> size_t sza(const T (&array)[N]) { return N; }
template<class T> inline void chmax(T &a, const T &b) { if(a < b) a = b; }
template<class T> inline void chmin(T &a, const T &b) { if(a > b) a = b; }
template<class T=int> T in() {T x; cin>>x; return (x);}
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

// dump macro
#ifdef PCM
  #include "dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;
template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
int dx[]={1, -1, 0, 0};
int dy[]={0, 0, 1, -1};
#define fi first
#define se second

// }}}

int n;
int a[200005];

bool check(vi& cnt, int x){
  int j = 0;
  while (x>0){
    if (cnt[j] and (x%2)) return false;
    x /= 2;
    j++;
  }
  return true;
}

void add(vi& cnt, int x){
  int i = 0;
  while (x>0){
    cnt[i] ^= (x%2);
    x /=2;
    i++;
  }
}

int solve(){
  cin>>n;
  rep(i, n) {cin>>a[i];}

  int r = 0;
  int res = 0;
  vi cnt(25, 0);
  add(cnt, a[0]);
  for (int l = 0; l < n; ++l) {
    while (r < n-1 && check(cnt, a[r+1])) {
      ++r;
      add(cnt, a[r]);
    }
    dump(l, r);

    res += (r - l +1);
    if (r == l){
      ++r;
      add(cnt, a[r]);
    }
    add(cnt, a[l]);
  }

  cout << res << endl;

  return 0;
}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
  solve();
  return 0;
} //}}}


Measured memory_bytes: 1792
n=int(input())

tree={}
root=None

def insert(tree,number):
    y=None
    x=root
    while x!=None:
        y=x
        if number<x:
            x=tree[y][0]
        else:
            x=tree[y][1]

    if number<y:
        tree[y][0]=number
    else:
        tree[y][1]=number

def preorder(tree,i):
    if i==None:
        return
    print(" {}".format(str(i)),end="")
    preorder(tree,tree[i][0])
    preorder(tree,tree[i][1])

def inorder(tree,i):
    if i==None:
        return
    inorder(tree,tree[i][0])
    print(" {}".format(str(i)),end="")
    inorder(tree,tree[i][1])

for i in range(n):
    tmp=list(input().split())
    if tmp[0]=="insert":
        number=int(tmp[1])
        if root==None:
            root=number
            tree[root]=[None,None]
        else:
            tree[number]=[None,None]
            insert(tree,number)
    
    else:
        inorder(tree,root)
        print()
        preorder(tree,root)
        print()


Measured memory_bytes: 81988
#include<bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
using ull=unsigned long;
int main(){
    unsigned x,y,z,K;
    scanf("%u %u %u %u",&x,&y,&z,&K);
    ull a[x],b[y],c[z];
    for(unsigned i=0;i<x;i++)scanf("%lu",&a[i]);
    for(unsigned i=0;i<y;i++)scanf("%lu",&b[i]);
    for(unsigned i=0;i<z;i++)scanf("%lu",&c[i]);
    priority_queue<ull,vector<ull>,greater<ull>>q;
    for(unsigned i=0;i<x;i++)for(unsigned j=0;j<y;j++)for(unsigned k=0;k<z;k++){
        if(q.size()<K)q.push(a[i]+b[j]+c[k]);
        else if(q.top()<a[i]+b[j]+c[k]){
            q.pop();
            q.push(a[i]+b[j]+c[k]);
        }
    }
    ull ans[K];
    for(unsigned i=K;i--;){
        ans[i]=q.top();
        q.pop();
    }
    for(unsigned i=0;i<K;i++)printf("%lu\n",ans[i]);
}


Measured memory_bytes: 512
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	a := make([]int, n)
	for i := range a {
		fmt.Scan(&a[i])
	}

	m := make(map[int]int) // 累積
	for _, v := range a {
		m[v]++
	}

	var total int
	for _, v := range m {
		total += v * (v - 1) / 2
	}

	for i, v := range a {
		if i != 0 {
			fmt.Println()
		}
		var cnt int
		w := m[v]
		cnt = total - w*(w-1)/2 + (w-1)*(w-2)/2
		fmt.Print(cnt)
	}
}


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

int main() {
    ll n;
    cin >> n;
    vector<pair<ll,ll>> p;
    ll x,l;
    for (int i=0;i<n;i++) {
        cin >> x >> l;
        p.push_back(make_pair(x+l,x-l));
    }
    sort(p.begin(),p.end());
    ll ans=1;
    ll r=p[0].first;
    for (int i=1;i<n;i++) {
        if (p[i].second>=r) {
            ans++;
            r=p[i].first;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 2420
#include<stdio.h>
#include<string.h>
int main()
{
	int n;
	int a[200];
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
	}
	int m=0;
	int flag=0;
	while(flag==0)
	{
		for(int i=0;i<n;i++)
		{
			if(a[i]%2==0)
			a[i]/=2;
			else
			flag=1;
		}
		if(flag==0)
		m++;
	}
	printf("%d\n",m);
}

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

using namespace std;
using ll = long long;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll N;
  cin >> N;
  vector<ll> D;
  for (ll i = 1; i * i <= N; i++) {
    if (N % i == 0) {
      D.emplace_back(i);
      D.emplace_back(N / i);
    }
  }
  ll res = 0;
  for (ll d : D) {
    ll k = d - 1;
    if (k == 0) continue;
    if (k > 0 && N / k == N % k) res += k;
  }
  cout << res << '\n';
  return 0;
}


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

int main()
{
  int N, M; cin >> N >> M;
  vector<bool> a(N, false), b(N, false);
  for (int i = 0; i < M; ++i) {
    int ai, bi; cin >> ai >> bi;
    ai--, bi--;
    if (ai == 0) a[bi] = true;
    if (bi == N-1) b[ai] = true;
  }

  for (int i = 0; i < N; ++i) {
    if (a[i] && b[i]) {
      cout << "POSSIBLE" << endl;
      return 0;
    }
  }

  cout << "IMPOSSIBLE" << endl;
}

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

#define rep(i, b) for(int i = 0; i < b; i++)
#define repi(i, a, b) for(int i = a; i < b; i++)
#define all(c) c.begin(),c.end()
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define MAX_V 1001
#define MAX_E 401
#define INF INT_MAX
#define MOD 1000000007
#define EPS 1e-7
typedef long long ll;
inline int toInt(std::string s) { int v; std::istringstream sin(s); sin >> v; return v; }
template<class T> inline std::string toString(T x) { std::ostringstream sout; sout << x; return sout.str(); }
using namespace std;

typedef double D;      // 座標値の型。doubleかlong doubleを想定
typedef complex<D> P;  // Point
typedef pair<P, P> L;  // Line
#define X real()
#define Y imag()
typedef pair<int, int> pii;

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

	if (abs(a - c) <= d)
	{
		cout << "Yes" << endl;
		return 0;
	}
	if (abs(a - b) <= d && abs(b - c) <= d)
	{
		cout << "Yes" << endl;
		return 0;
	}
	cout << "No" << 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 N = sc.nextInt();
        int K = sc.nextInt();
		int array[] = new int[N];
      
      for(int i = 0; i < N; i++){
      	array[i] = sc.nextInt();
      }

      
      //判定
      int cnt = 0;
      for(int i = 0; i < N; i++){
      	if(array[i] >= K){
        	cnt++;
        }
      }
      
      System.out.println(cnt);
    }
}

Measured memory_bytes: 48056
use proconio::{input, fastout};

#[fastout]
fn main() {
    input! {
        (n, c, k): (i64, i64, i64),
        mut t: [i64; n]
    }
    t.sort();

    let mut ely: i64 = 1000000001;
    let mut cnt = 0;
    let mut ans = 0;
    for x in t {
        if x>ely+k {
            ans += 1;
            cnt = 0
        }

        if cnt==0 {
            ely = x;
        }
        cnt += 1;

        if cnt==c {
            ans += 1;
            cnt = 0;
            ely = 1000000001;
        }
    }
    if cnt>0 {
        ans += 1;
    }
    println!("{}", ans);
}


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

		public static void main(String[] args) {
			Scanner teclado = new Scanner (System.in);
			int trem = teclado.nextInt();
			int taxi = teclado.nextInt();
			int minimo= teclado.nextInt();
			
			int cal= trem*taxi;
			
			if (trem*taxi<minimo) {
				System.out.println(trem*taxi);
			} else {
				System.out.println(minimo);
						
					}
			
}
}

Measured memory_bytes: 21844
str = list(input())  # 一文字ずつ格納
ans = 1000

for i in range(len(str) - 2):
    sa = abs(int(str[i]) * 100 + int(str[i+1]) * 10 + int(str[i + 2]) - 753)
    ans = min(ans, sa)

print(ans)


Measured memory_bytes: 2940
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

ll posi[101010];
ll imos[101010];

int main(){

	ll N, K;
	cin >> N >> K;
	for(ll i = 1; i <= N; i++){
		cin >> imos[i];
		if(imos[i] > 0)posi[i] = imos[i];
		imos[i] += imos[i - 1];
		posi[i] += posi[i - 1];
	}
	ll ans = 0;
	for(ll l = 1; l <= N; l++){
		ll r = l + K - 1;
		if(r > N)break;
		ll tmp = max(0LL, imos[r] - imos[l - 1]);
		tmp += (posi[N] - posi[r]);
		tmp += (posi[l - 1] - posi[0]);
		ans = max(ans, tmp);
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1792
n, a, b, c, d = [int(item) for item in input().strip().split(" ")]
s = input().strip()

def h(a,b,c,d,s):
    if "##" in s[a-1:c]:
        return False
    if "##" in s[b-1:d]:
        return False
    if c < d:
        return True
    if "..." in s[b-2:d+1]:
        return True
    return False

if h(a,b,c,d,s):
    print("Yes")
else:
    print("No")


Measured memory_bytes: 40816
from collections import deque
import sys
sys.setrecursion = 10000000

n = int(input())
alpha = "abcdefghijklmnopqrstuvwxyz"
def dfs(str,letter):
  if len(str) == n:
    print(str)
  else:
    length = len(set(str))
    for let in range(length+1):
      dfs(str+alpha[let],let)

def solve(): 
  query = deque([])
  dfs("a",1)


solve()

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

int main() {
  
  int H, W; cin >> H >> W;
  
  char table[H][W];
  
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> table[i][j];
    }
  }
  
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cout << table[i][j];
    }
    cout << endl;
    for (int j = 0; j < W; j++) {
      cout << table[i][j];
    }
    cout << endl;
  }
  
}

Measured memory_bytes: 256
using System.Collections.Generic;
using System;

public class Hello
{
	public static void Main()
	{
		var n = int.Parse(Console.ReadLine().Trim());
		var d = new Dictionary<string, int>();
		for (int i = 0; i < n; i++)
		{
			var s = Console.ReadLine().Trim();
			var sa = s.ToCharArray();
			Array.Sort(sa);
			var sb = new string(sa);
			if (d.ContainsKey(sb)) d[sb]++;
			else d[sb] = 1;
		}
		getAns(d);
	}
	static void getAns(Dictionary<string, int> d)
	{
		var ans = 0L;
		foreach (var x in d)
			ans += (x.Value) * ((long)x.Value - 1) / 2L;
		Console.WriteLine(ans);
	}
}

Measured memory_bytes: 30168
#include<iostream>
#include<vector>

long long int mergecount(std::vector<int> &a) {
	long long int count = 0;
	int n = a.size();
	if (n > 1) {
		std::vector<int> b(a.begin(), a.begin() + n / 2);
		std::vector<int> c(a.begin() + n / 2, a.end());
		count += mergecount(b);
		count += mergecount(c);
		for (int i = 0, j = 0, k = 0; i < n; ++i)
			if (k == c.size())       a[i] = b[j++];
			else if (j == b.size())  a[i] = c[k++];
			else if (b[j] <= c[k])   a[i] = b[j++];
			else { a[i] = c[k++]; count += n / 2 - j; }
	}
	return count;
}

int main() {
	int n;
	std::cin >> n;
	std::vector<int> a(n,0);

	
	for (int i = 0; i<n; i++) {
		std::cin >> a[i];
	}
	std::cout << mergecount(a) << std::endl;
		return 0;
}

Measured memory_bytes: 5276
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const int64_t LINF=8931145141919364364,LMOD=998244353;
// const int dy[]={0,-1,0,1,1,-1,-1,1};
// const int dx[]={1,0,-1,0,1,1,-1,-1};

int main() {
	const double pi = acos(-1);
	double a, b; cin >> a >> b;
	double h, m; cin >> h >> m;
	double H = 30 * h + m / 2;
	double M = 6 * m;
	double Hy = a * sin(H / 180 * pi);
	double Hx = a * cos(H / 180 * pi);
	double My = b * sin(M / 180 * pi);
	double Mx = b * cos(M / 180 * pi);
	// cout << Hy << " " << Hx << '\n';
	double ans = sqrt((Hy - My) * (Hy - My) + (Hx - Mx) * (Hx - Mx));
	printf("%.15f\n", ans);
	return 0;
}

Measured memory_bytes: 4128
using System;
class Program
{
  static void Main(string[] args)
  {
    string abc = Console.ReadLine();
    string aa = abc.Substring(0,1);
    string bb = abc.Substring(1,1);
    string cc = abc.Substring(2,1);
    int a = int.Parse(aa);
    int b = int.Parse(bb);
    int c = int.Parse(cc);
    int count = 0;
    if (a == 1)
    {
      count++;
    }
    if (b == 1)
    {
      count++;
    }
    if (c == 1)
    {
      count++;
    }
    Console.WriteLine(count);
  }
}

Measured memory_bytes: 11220
from fractions import gcd
from math import sqrt
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)


def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])   

    return arr


def main():
    a, b = map(int, input().split())
    print(len(factorization(gcd(a, b))) + 1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 5048
#include<bits/stdc++.h>
using namespace std;
#define lli long long int 
lli maxi(lli a,lli b){
    if(a>=b)return a;
    return b;
}
lli mini(lli a,lli b){
    if(a<=b)return a;
    return b;
}

int main(){
    int n,k;
    cin>>n;
    vector<lli> arr(n,0);
    lli sum=0;
    for(int i=0;i<n;i++){
        cin>>arr[i];
        sum=sum+arr[i];
        //cout<<arr[i]<<endl;
        
    }
     
    lli table[n][n]; 
  
    // Fill table using above recursive formula. Note  
    // that the table is filled in diagonal fashion (similar 
    // to http:// goo.gl/PQqoS), from diagonal elements to 
    // table[0][n-1] which is the result. 
    for (int gap = 0; gap < n; ++gap) { 
        for (int i = 0, j = gap; j < n; ++i, ++j) { 
  
            // Here x is value of F(i+2, j), y is F(i+1, j-1) and 
            // z is F(i, j-2) in above recursive formula 
            lli x = ((i + 2) <= j) ? table[i + 2][j] : 0; 
            lli y = ((i + 1) <= (j - 1)) ? table[i + 1][j - 1] : 0; 
            lli z = (i <= (j - 2)) ? table[i][j - 2] : 0; 
  
            table[i][j] = maxi(arr[i] + mini(x, y), arr[j] + mini(y, z)); 
        } 
    } 
  
     lli fs =table[0][n - 1]; 
    //cout<<fs<<endl;
    sum=sum-fs;
    cout<<fs-sum<<endl;
}

Measured memory_bytes: 70272