akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
 
#define ff              first
#define ss              second
#define int             long long int 
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define from(i,n)       for(int i=0;i<(int)n;i++)
#define from_j(i,j,n)   for(int i=j;i<(int)n;i++)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());
 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
 
 
void c_p_c()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}
 
int32_t main()
{
    c_p_c();
    int n; cin>>n;
    double p[n];
    from(i,n)cin>>p[i];
    double heads[n+1]; 
    heads[0]= 1.0-p[0];
    heads[1]= p[0];
    
    from_j(i,2,n+1){
        heads[i] = heads[i-1]*p[i-1];
        for(int j=i-1;j>0;j--){
            heads[j] = heads[j]*(1-p[i-1]) + heads[j-1]*p[i-1];
        }
        heads[0] *=(1-p[i-1]);
    }
    double ans =0;
    for(int i=0;i<=n;i++){
        // cout<<i<<" "<<ps(heads[i],10)<<endl;
        if(2*i>=n){
            ans +=heads[i];
        }
    }
    cout<<ps(ans,10);
    
    
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())
#define int long long
#define INF 1000000000000000
using namespace std;

typedef pair<int, int> Pii;

template<typename T>
void readvec(vector<T> &a);
void readindex(vector<int> &a);



signed main(){

    string s;
    cin >> s;
    int p = 0;
    REP(i, s.size()){
        if(s[i] == 'p') p++;
    }
    int p2 = s.size() / 2;

    cout << p2 - p;

    return 0;
}


template<typename T>
void readvec(vector<T> &a){
    REP(i, a.size()){
        cin >> a[i];
    }
}
void readindex(vector<int> &a){
    REP(i, a.size()){
        cin >> a[i];
        a[i]--;
    }
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
int main() {
    // ifstream in("data1.txt");
    // cin.rdbuf(in.rdbuf());
    while (true){
        int h, w;
        cin >> h >> w;
        if (h == 0 && w == 0){
            return 0;
        }

        for (int i = 0; i < h; i++){
            for (int j = 0; j < w; j++){
                printf("%c", '#');
            }
            printf("\n");
        }

        printf("\n");
    }
}



Measured memory_bytes: 3020
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main
{
  public static void main(String[] args) throws IOException
  {
    BufferedReader r = new BufferedReader(new InputStreamReader(System.in), 1);
    String s;
    String sl[];

    s = r.readLine();
    sl = s.split(" ");
    int n = Integer.parseInt(sl[0]);
    int k = Integer.parseInt(sl[1]);

    long a[] = new long[n];

    s = r.readLine();
    sl = s.split(" ");
    for(int i = 0; i < n; i++)
    {
      a[i] = Long.parseLong(sl[i]);
    }

    Arrays.sort(a);

    RemRing rr = new RemRing(1000000007L);

    long fact[] = new long[100001];
    fact[0] = 1;
    fact[1] = 1;

    for(int i = 2; i <= 100000; i++)
    {
      fact[i] = rr.prod(fact[i - 1], i);
    }

    long res = 0;

    for(int i = 0; i <= n - k; i++)
    {
      long c = rr.div(fact[n - i - 1], fact[k - 1]);
      c = rr.div(c, fact[(n - i - 1) - (k - 1)]);
      long v = a[n - 1 - i];
      v = rr.sub(v, a[i]);
      v = rr.prod(c, v);
      res = rr.sum(res, v);
    }

    System.out.println(res);
  }

}

class RemRing
{
  long module;

  public RemRing(long module)
  {
    this.module = module;
  }

  public long sum(long a, long b)
  {
    return (a + b + module) % module;
  }

  public long sub(long a, long b)
  {
    return (a - b + module) % module;
  }

  public long prod(long a, long b)
  {
    return (a * b) % module;
  }

  public long div(long a, long b)
  {
    return (a * inv(b)) % module;
  }

  public long inv(long a)
  {
    long b = this.module;
    long u = 1;
    long v = 0;
    while (b > 0)
    {
      long t = a / b;
      a -= t * b;
      u -= t * v;
      long z = a;
      a = b;
      b = z;
      z = u;
      u = v;
      v = z;
    }
    u %= this.module;
    if (u < 0)
      u += this.module;
    return u;
  }
}

Measured memory_bytes: 49600
#include <iostream>
using namespace std;
int main() {
  int n;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; ++i)
    cin >> a[i];
  cout << a[n-1];
  for (int i = n-2; i >= 0; --i)
    cout << " " << a[i];
  cout << "\n";
}



Measured memory_bytes: 3056
let split_string ?(pattern=" ") = Str.split @@ Str.regexp pattern

let n = Scanf.sscanf (read_line ()) "%d" @@ fun n -> n
let a = Array.of_list @@ List.map int_of_string @@ split_string @@ read_line ()

let () =
  Array.sort (fun a b -> a - b) a;
  let sum = ref a.(0) in
  let t = ref 0 in
  for i = 1 to n - 1 do
    if !sum * 2 < a.(i) then t := i;
    sum := !sum + a.(i)
  done;
  Printf.printf "%d\n" @@ n - !t


Measured memory_bytes: 16768
/* 
    AtCoder Beginner Contest 095
    A:Something on It
    AC
*/

#include <iostream>
using namespace std;

int main(void)
{
    int i;
    string s;
    int charge = 700;
    // int count = 0;
    cin >> s;
    for (i = 0; i < 3; i++)
    {
        if(s[i] == 'o')
            charge += 100;
        
        // count += s % 10;
        // s = s / 10;
    }
    cout << charge << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(int i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(int i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define uniq(x) (x).erase(unique((x).begin(), (x).end()), (x).end())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    string s;
    cin >> s;
    int wcnt = 0, bcnt = 0;
    int ans;
    rep(i, n) {
        if (s[i] == '.') wcnt++;
    }
    ans = wcnt;
    rep(i, n) {
        if (s[i] == '#') bcnt++;
        else wcnt--;
        ans = min(ans, (wcnt + bcnt));
    }
    ans = min(ans, bcnt);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 720
# AtCoder Beginner Contest 166
# 
# https://atcoder.jp/contests/abc166/tasks/abc166_b
(N, K) = gets.chomp.split.map(&:to_i)
d = []
a = []
(1..K).each do |i|
  d << gets.chomp.to_i
  a << gets.chomp.split.map(&:to_i)
end

puts N - a.flatten.uniq.length


Measured memory_bytes: 14500
#include<bits/stdc++.h>
using namespace std;
using Int = long long;

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

//INSERT ABOVE HERE
signed main(){
  Int n,w;
  cin>>n>>w;
  vector<Int> a(n),b(n);
  for(Int i=0;i<n;i++) cin>>a[i]>>b[i];
  const Int INF = 1e15;
  vector<Int> dp(w+1,-INF);
  dp[0]=0;
  for(Int i=0;i<n;i++){
    vector<Int> nx(w+1,-INF);
    for(Int j=0;j<=w;j++){
      chmax(nx[j],dp[j]);
      if(j+b[i]<=w)
	chmax(nx[j+b[i]],dp[j]+a[i]);
    }
    swap(dp,nx);
  }
  cout<<*max_element(dp.begin(),dp.end())<<endl;
  return 0;
}



Measured memory_bytes: 3232
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define PN cout << endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (n-1); i >= (int)(m); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v,c) sort(v.begin(), v.end(), greater<c>()) 
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - (a)) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - (a)) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

/*
ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
*/

/*
vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}
*/

/*
ll ncr[100][100];
ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

ll npr[100][100]={};
ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

ll nHr(int n,int r){ret nCr(n+r-1,r);}
*/

///////////////////////////////////////////////////////////////////////////



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

    rep(i,0,x+1){
	if(y == 2*i + 4*(x-i)){
	    Yes;
	    ret 0;
	}
    }
    No;
    return  0;
}


Measured memory_bytes: 3640
#include <iostream>
#include<vector>
using namespace std;
#define REP(i, j) for(int i = 0; i < j; i++)
const int N = 10000000;

bool isprime[N];

int makePrime(){
    REP(i, N) isprime[i] = true;
    isprime[0] = false;
    isprime[1] = false;

    for(int i = 2; (i * i) <= N; i++){
        if(!isprime[i]) continue;
        for(int j = i + i; j < N; j += i) isprime[j] = false;
    }
}

int main(){
    makePrime();

    int n;
    while(cin >>n && n){
        for(int i = n; i >= 8; i--){
            if(isprime[i] && isprime[i - 2] && isprime[i - 6] && isprime[i - 8]){
                cout <<i <<endl;
                break;
            }
        }
    }
    return 0;
}

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

int main(void)
{
	int a, b, c, d, e, k;
	cin >> a >> b >> c >> d >> e >> k;
	if (e - a <= k) { cout << "Yay!" << endl; }
	else { cout << ":(" << endl; }
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
  ll a;
  cin>>a;
  vector<ll>vec(a);
  for(ll i=0;i<a;i++){
    cin>>vec.at(i);
  }
  sort(vec.begin(),vec.end());
  for(ll i=1;i<a;i++){
    if(vec.at(i-1)==vec.at(i)){
      cout<<"NO"<<endl;
      return 0;
    }
  }
  cout<<"YES"<<endl;
}

Measured memory_bytes: 4644
#include<cstdio>
using namespace std;

int main(){
    int i = 1, x, y;
    char c;
    while(1){
        scanf("%d %c %d", &x, &c, &y);
        if(c=='?') break;
        else if(c=='+'){
            printf("%d\n", x+y);
        }
        else if(c=='-'){
            printf("%d\n", x-y);
        }
        else if(c=='*'){
            printf("%d\n", x*y);
        }
        else if(c=='/'){
            printf("%d\n", x/y);
        }
    }
    return 0;
}


Measured memory_bytes: 2708
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

bool ok(const string &s, const string &t, int i)
{
	for (int p = 0; p < t.length(); ++p) {
		if (s[i + p] != '?' && s[i + p] != t[p]) {
			return false;
		}
	}
	return true;
}

int main()
{
	string S, T;
	cin >> S >> T;

	string ans = "UNRESTORABLE";

	for (int i = 0; i + T.length() <= S.length(); ++i) {
		if (ok(S, T, i)) {
			string x = S;
			x.replace(i, T.length(), T);
			replace(x.begin(), x.end(), '?', 'a');
			if (ans == "UNRESTORABLE" || x < ans) {
				ans = x;
			}
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
import sys
from math import *
from collections import deque, Counter, defaultdict
from fractions import gcd
input = lambda: sys.stdin.readline().rstrip()

def eprint(s):
    sys.stderr.write('DEBUG: {}'.format(s))
    return

def main():
    n = int(input())
    Ss = [input() for i in range(n)]

    c = Counter(Ss)
    mc = c.most_common()
    mcn = mc[0][1]

    ans = list()

    for i in range(len(mc)):
        if mc[i][1] == mcn:
            ans.append(mc[i][0])
        else:
            break
    ans.sort()
    
    for i in range(len(ans)):
        print(ans[i])
    
    return

if __name__ == '__main__':
    main()

Measured memory_bytes: 121284
#include <bits/stdc++.h>
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v) sort(v.begin(), v.end(), greater<ll>())
#define ll long long
#define rep(i, s, g) for (ll i = (s); i < (g); i++)
#define MOD 1000000007
#define vfind(v, target) find(v.begin(), v.end(), target)
#define notFound(v, target) (vfind(v, target) == v.end())

using namespace std;

int main()
{
  ll N, score = 0, i = 1; cin >> N;
  vector<ll> Q;
  while(score <= N) {
    score += i;
  	Q.push_back(i);
    i++;
  }
  if (score > N) {
  	Q.erase(Q.begin() + (score - N - 1));
  }
  for(ll q : Q) {
  	cout << q << endl;
  }
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <string>
#include <map>

using namespace std;
typedef long long ll;

#define rep(i,n) for(int i=0;i<n;i++)

int main(){
  ll N,Q;
  cin >> N;
  vector<ll> A(N);
  rep(i,N) cin >> A[i];
  cin >> Q;
  vector<ll> B(Q), C(Q);  
  rep(i,Q) cin >> B[i] >> C[i];

  ll sum = 0;
  map<ll,ll> cnt;
  rep(i,N){
    cnt[A[i]]++;
    sum += A[i];
  }
  rep(i,Q){
    ll tmp = cnt[B[i]];
    cnt[B[i]] = 0;
    cnt[C[i]] += tmp;
    sum += C[i] * tmp - B[i] * tmp;
    cout << sum << endl;
  }
}

Measured memory_bytes: 11208
#include<bits/stdc++.h>
using namespace std;
#define LL long long

int jc[10]={1};
int a[10],b[10],n;
int cal(int a[],int n){
    int res=0;
    for(int i=1;i<=n;++i){
        int c=0;
        for(int j=i+1;j<=n;++j)c+=(a[j]<a[i]);
        res+=c*jc[n-i];
    }return res;
}
int main(){
    for(int i=1;i<=9;++i)jc[i]=i*jc[i-1];
    cin>>n;
    for(int i=1;i<=n;++i)cin>>a[i];
    for(int i=1;i<=n;++i)cin>>b[i];
    cout<<abs(cal(b,n)-cal(a,n))<<endl;
    return 0;
}



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

int main()
{
    string s1,s2;
    getline(cin,s1);
    getline(cin,s2);
    int sum = 0;
    for(int i = 0; i < 3; i++){
    	if(s1[i] == s2[i])
    		sum++;
	} 
	cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
using System;

class Program
{
    static void Main(string[] args)
    {

        //スペース区切りの整数の入力
        string[] input = Console.ReadLine().Split(' ');
        int n = int.Parse(input[0]);

        int[] a = new int[n];
        int[] b = new int[n];
        int[] c = new int[n];

        string[] a_str = Console.ReadLine().Split(' ');
        string[] b_str = Console.ReadLine().Split(' ');
        string[] c_str = Console.ReadLine().Split(' ');

        for (int i = 0; i < n; i++)
        {
            a[i] = int.Parse(a_str[i]);
            b[i] = int.Parse(b_str[i]);
            if (i != n - 1)
            {
                c[i] = int.Parse(c_str[i]);
            }
        }


        int result = 0;

        for (int i = 0; i < n; i++)
        {
            result += b[a[i]-1];
            if (i!=n-1 && (a[i] - a[i+1] == -1))
            {
                result += c[a[i]-1];
            }
        }

        Console.WriteLine(result);
        return;
    }

}


Measured memory_bytes: 13140
#include<iostream>
#include<cassert>
#include<stdexcept>
#include<utility>
#include<functional>
#include<numeric>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<array>
#include<stack>
#include<queue>
#include<deque>
#include<vector>
#include<complex>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<string>
#include<bitset>
using namespace std;
using ll=long long;

using Graph=vector<vector<int>>;


int main(){
    int n;
    cin>>n;
    Graph g(n);
    for(int i=0;i<n-1;i++){
        int a,b;
        cin>>a>>b;
        a--,b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    function<pair<int,int>(int,int)> dfs=[&](int v,int pre){
        pair<int,int> res={0,v};
        for(auto to:g[v]){
            if(to==pre) continue;
            auto tmp=dfs(to,v);
            tmp.first++;
            res=max(res,tmp);
        }
        return res;
    };
    auto calc=[&](){
        auto tmp=dfs(0,-1).second;
        return dfs(tmp,-1).first;
    };
    cout<<(calc()%3==1 ? "Second" : "First")<<endl;
    
    
    return 0;
}

Measured memory_bytes: 26752
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mod 1000000007
#define ff first
#define ss second
#define endl '\n'
using namespace std;
/*ll power(ll x,ll y)
{
    ll res=1;
    while(y>0)
    {
        if(y%2==1)
            res=((res%mod)*(x%mod))%mod;
        x=((x%mod)*(x%mod))%mod;
        y=y/2;
    }
    return res;
}*/
void dfs(vector<ll>v[],ll &c,ll n,ll node)
{
    queue<ll>q;
    q.push(node);
    ll vis[n+1]={0};
    vis[node]=1;
    ll dp[n+1]={0};
    dp[node]=1;
    c=max(c,dp[node]);
    while(!q.empty())
    {
        node=q.front();
        q.pop();
        for(auto u:v[node])
        {
            if(dp[u]==dp[node] && dp[node]!=0)
            {
                c=-1;
                return;
            }
            if(!vis[u])
            {
                dp[u]=dp[node]+1;
                q.push(u);
                vis[u]=1;
                c=max(c,dp[u]);
            }
        }
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
   ll n,i,j,c=0,m,k;
   cin>>n;
   ll arr[n+1][n+1],dp[n+1]={0};
   char ch;
   for(i=1;i<=n;i++)
   {
       for(j=1;j<=n;j++)
       {
           cin>>ch;
           arr[i][j]=ch-'0';
       }
   }
   vector<ll>v[n+1];
   for(i=1;i<=n;i++)
   {
       for(j=i+1;j<=n;j++)
       {
           if(arr[i][j]==1)
           {
               v[i].pb(j);
               v[j].pb(i);
           }
       }
   }
    for(i=1;i<=n;i++)
    {
     dfs(v,c,n,i);
     if(c==-1)
     {
         cout<<-1<<endl;
         return 0;
     }
    }
     cout<<c<<endl;
}


Measured memory_bytes: 1024
s=[[int(j) for j in input().split()] for i in range(4)]
a=s[0]
b=s[1]
c=s[2]
x=s[3]
a=a[0]
b=b[0]
c=c[0]
x=x[0]
count=0
ans=list()
for n in range(a+1):
    for m in range(b+1):
        for l in range(c+1):
            add=n*500+m*100+50*l
            if add==x:
                count+=1
                ans.append([n,m,l])
print(count)

Measured memory_bytes: 3064
"""
マスターオブ整数
公約数の問題
公約数とは最大公約数の約数であるという性質がある
"""
import fractions
A, B = map(int, input().split())

# まず公約数を列挙したくなる
# 最大公約数を求めてその約数を列挙する
# 最大公約数はユークリッドの互除法で求めることができる

ans = 1
gcd_value = fractions.gcd(A, B)
for i in range(2, int(gcd_value**0.5) + 1):
    if gcd_value % i == 0:
        ans += 1
        while gcd_value % i == 0:
            gcd_value //= i

# divisorリストの中からどの二つ互いに素となるようにいくつか選ぶ
# 素因数の数+1を答えれば良い
if gcd_value != 1:
    ans += 1

print(ans)

Measured memory_bytes: 5688
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;
typedef vector <int> VI;
typedef vector <double> VD;

int main( void )
{
	VD l(10); char c; double v1, v2;
	while ( cin.eof() == false )
	{
		for ( int i = 0; i < 10; i++ ) cin >> l[i] >> c;
		cin >> v1 >> c >> v2;

		if ( cin.eof() ) break;

		double length = accumulate( l.begin(), l.end(), 0.0 );
		double tc = length / ( v1 + v2 );
		double now = v1 * tc;

		int answer = -1;
		double sum = 0;
		for ( int i = 0; i < l.size(); i++ )
		{
			if ( sum <= now && now <= sum + l[i] )
			{
				answer = i+1;
				break;
			}
			sum += l[i];
		}

		cout << answer << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int * c;
int cost(int i,int n,int h[]){
	if(i==n){return 0;}
	int a=100000,b=100000;
	if(c[i+1]==-1&&i+1<=n)
		{
			c[i+1]=cost(i+1,n,h);
			a=abs(h[i+1]-h[i])+c[i+1];
		}	
	else if(i+1<=n)
		a=abs(h[i+1]-h[i])+c[i+1];
	if(c[i+2]==-1&&i+2<=n)
		{
			c[i+2]=cost(i+2,n,h);
			b=abs(h[i+2]-h[i])+c[i+2];
		}
	else if(i+2<=n)
		b=abs(h[i+2]-h[i])+c[i+2];
	
	return a<b?a:b;
}
int main(){
	int n;
	cin>>n;
	int h[n+1];
	c=new int[n+1];
	for(int i=0;i<=n;i++)c[i]=-1;
	for(int i=1;i<=n;i++)cin>>h[i];
	cout<<cost(1,n,h);
	return 0;
}

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

#define pb push_back
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define REP(i,n) for(int _n=n, i=0;i<_n;++i)
#define FOR(i,a,b) for(int i=(a),_b=(b);i<=_b;++i)
#define FORD(i,a,b) for(int i=(a),_b=(b);i>=_b;--i)
using ull = uint64_t;
using ll = int64_t;
using PII = pair<int, int>;
using VI = vector<int>;

string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string) s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B> string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; }
template <typename A> string to_string(A v) {
bool first = true; string res = "{";
for (const auto &x : v) { if (!first) { res += ", "; } first = false; res += to_string(x); }
res += "}"; return res; }
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H); debug_out(T...); }
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

const ll mod = 1000000007;
using ld = long double;

int main() {
    ios::sync_with_stdio(false), cin.tie(0);
    ld L;
    cin >> L;
    L /= 3.0;
    std::cout.precision(7);
    cout << std::fixed << L * L * L << endl;

}

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

using namespace std;

int main(void) {
	int num, i = 0, sum = 0;
	string s;
	cin >> num >> s;
	vector<int> d(s.size());
	for (; i < num; i++) {
		if (s[i] == 'W')
			sum++;
		d[i] = sum;
	}
	for (sum = 0, i = num - 1; i >= 0; i--) {
		if (s[i] == 'E')
			sum++;
		d[i] += sum;
	}
	for (sum = 1 << 29, i = 0; i < num; i++)
		sum = min(sum, d[i]);
	cout << sum - 1 << "\n";
	return 0;
}

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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define REPV(iter, v) for(auto (iter)=(v).begin(); (iter)!=(v).end();++(iter))
#define ALL(v) (v).begin(),(v).end()

#define MOD 1000000007

using namespace std;

typedef long long ll;

ll llPow(ll a, ll n)
{
    if (n == 0) return 1;
    if (n == 1) return a;
    return a * llPow(a, n - 1);
}

int main()
{
    ll N, M;
    cin >> N >> M;
    vector<ll> s(M), c(M);
    REP(i, M) cin >> s[i] >> c[i];

    ll ans = -1;
    ll start = llPow(10, N - 1);
    if (start == 1) start = 0;
    ll end = llPow(10, N) - 1;
    for (ll i = start; i <= end; ++i)
    {
        bool flag = true;
        vector<ll> digit(N);
        ll num = i;
        ll count = 0;
        while(num > 0)
        {
            digit[count] = num % 10;
            num /= 10;
            count++;
        }
        REP(i, M)
        {
            if (digit[N - s[i]] != c[i])
            {
                flag = false;
                break;
            }
        }
        if (flag)
        {
            ans = i;
            break;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <utility>
#include <algorithm>
#include <numeric>
#include <typeinfo>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <ctime>

using namespace std;

#define dump(n) cout<<"# "<<#n<<"="<<(n)<<endl
#define debug(n) cout<<__FILE__<<","<<__LINE__<<": #"<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
#define iter(c) __typeof((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();i++)
#define allof(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;

struct Edge{
	int src,dst,weight;
	Edge(){}
	Edge(int src,int dst,int weight):src(src),dst(dst),weight(weight){}
};

bool operator<(const Edge& lhs,const Edge& rhs)
{
	return lhs.weight<rhs.weight;
}

bool operator>(const Edge& lhs,const Edge& rhs)
{
	return lhs.weight>rhs.weight;
}

typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

int Prim(Graph& g,Edges& tree,int root=0)
{
	tree.clear();
	
	int size=g.size();
	vector<int> visited(size);
	
	priority_queue<Edge,vector<Edge>,greater<Edge> > pq;
	pq.push(Edge(-1,root,0));
	int res=0;
	while(!pq.empty()){
		Edge e=pq.top();
		pq.pop();
		if(visited[e.dst])
			continue;
		if(e.src!=-1)
			tree.push_back(e);
		visited[e.dst]=1;
		res+=e.weight;
		rep(i,g[e.dst].size()){
			Edge cand=g[e.dst][i];
			if(!visited[cand.dst])
				pq.push(cand);
		}
	}
	return res;
}

int main()
{
	for(int n,m;cin>>n>>m,n|m;){
		Graph g(n);
		rep(i,m){
			int a,b,cost; cin>>a>>b>>cost;
			g[a].push_back(Edge(a,b,cost));
			g[b].push_back(Edge(b,a,cost));
		}
		
		Edges t;
		int res=Prim(g,t);
		cout<<res<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;

class Main {
	public static void main(String[] $) {
		Scanner sc = new Scanner(System.in);
		String s=sc.next(),t;
		int countOdd=0,countEven=0;
		for(int i=0;i<s.length();i++) {
			if(i%2==0)t="0";
			else t="1";
			if(!s.substring(i, i+1).equals(t))countOdd++;
		}
		for(int i=0;i<s.length();i++) {
			if(i%2==0)t="1";
			else t="0";
			if(!s.substring(i, i+1).equals(t))countEven++;
		}
		System.out.println((int)Math.min(countOdd,countEven));
	}
}



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

int main(void){
    int a,b,c;
    cin>>a>>b>>c;
    int i=0;
    while(c>0){
        i++;
        c-=a;
        if(i%7==0){
            c-=b;
        }
    }
    cout<<i<<endl;
    return 0;
}


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

#[fastout]
fn main() {
    input!(n: usize, m: usize);

    let mut m_v = vec![0usize; m];

    for _i in 0..n {
        input!(k: usize, ka: [usize; k]);
        for v in &ka {
            m_v[*v - 1] += 1;
        }
    }
    println!("{}", m_v.iter().filter(|&x| *x == n).count());
}


Measured memory_bytes: 2192
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define MOD (1000000007)
#define vi vector<int>
#define vl vector<ll>
#define vvi vector<vi>
#define vvl vector<vl>
#define pii pair<int, int>
#define pb push_back

#define mp make_pair
#define all(a) (a).begin(),(a).end()

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

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

ll keta(ll n){
  string s = to_string(n);
  ll num = s.size();
  return num;
}

const ll INF = 1LL << 60;

const int dh[4] = {1,0,-1,0};
const int dw[4] = {0,1,0,-1};

const int VMAX = 1e5;
int main(){
  int n,W; cin >> n >> W;
  vl weight(n),value(n); rep(i,n) cin >> weight[i] >> value[i];
  vvl dp(n+1,vl(VMAX+1, INF));
  dp[0][0] = 0;

  rep(i,n) rep(v,VMAX+1) {
    dp[i+1][v] = dp[i][v];
    if(v >= value[i]) chmin(dp[i+1][v], dp[i][v - value[i]] + weight[i]);
  }

  ll ans = 0LL;
  rep(v,VMAX+1) if(dp[n][v] <= W) ans = v;

  cout << ans << endl;
}

Measured memory_bytes: 80256
N = int(input())
K = int(input())

min_m = 10 ** 10
for i in range(2 ** N):
    m = 1
    for n in range(N):
        if i & (1 << n):
            m *= 2
        else:
            m += K
    min_m = min(min_m, m)

print(min_m)


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

using namespace std;

#define READ() 	    freopen("in.txt","r",stdin)
#define WRITE()     freopen("out.txt","w",stdout)
#define sf(n) 	    scanf("%d",&n)
#define sl(x)       scanf("%I64d",&x)
#define lsf(n) 	    scanf("%lld", &n)
#define pb(n) 	    push_back(n)
#define mem(x,y)    memset(x,y,sizeof(x))
#define D(x)      	cout << #x << " = " << x << endl
#define CHKRTE		assert(false)
#define YOLO        cout << "YOLO" << endl
#define NL			printf("\n")
#define EPS 	    1e-10
#define INF         INT_MAX
#define MAX         INT_MAX
#define MOD         1000000007
#define LL          long long
#define endl        "\n"
#define pi          2.0*acos(0.0)
#define cnd         tree[idx]
#define lnd         tree[left]
#define rnd         tree[right]
#define callLeft    left,st,mid
#define callRight   right,mid+1,ed

string s;
int len;
int k;

int dp[301][301][301];

int rec(int i,int j,int k)
{
    if(i == j)return 1;
    if(i > j)return 0;

    if(dp[i][j][k] != -1)return dp[i][j][k];

    int ret = 0;

    if(s[i] == s[j])
    {
        ret = max(ret,(rec(i+1,j-1,k)+2));
    }
    else
    {
        ret = max(ret,(rec(i,j-1,k)));
        ret = max(ret,(rec(i+1,j,k)));

        if(k-1 >= 0)
        {
            ret = max(ret,(rec(i+1,j-1,k-1)+2));
        }
    }

    dp[i][j][k] = ret;
    return ret;
}

int main()
{
//	ios_base::sync_with_stdio(false);
//    cin.tie(0); /// use "\n" instead of endl

/**
#ifndef ONLINE_JUDGE
    READ();
    WRITE();
#endif
**/

#ifdef JAMILPC
//	READ();
//	WRITE();

//    int t;
//    cin >> t;
//    while(t--)
//    {
#endif

    cin >> s >> k;

    mem(dp,-1);
    cout << rec(0,s.size()-1,k) << endl;

#ifdef JAMILPC
//	}
#endif


    return 0;
}



Measured memory_bytes: 106752
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>

using namespace std;

long long cnt;
int l;
int A[1000000];
int n;
vector<int> G;

void trace(int A[],int N) {
  int i;
  for(i=0; i<N; i++) {
    if(i>0) printf(" ");
    printf("%d", A[i]);
  }
  printf("\n");
}

void insertionSort(int A[],int N,int g) {
    int i, j, v;
  for(i=g; i<N; i++) {
    v=A[i]; /* v に関して記述 */
    j=i-g; /* j に関して記述 */
    while(j>=0 && A[j]>v) {
      A[j+g]=A[j];
      j-=g;
    	cnt++;
    }
    A[j+g]=v;
    //trace(A,N);
  }
}

void shellSort(int A[], int n) {
  for(int h=1; ;) {
    if(h>n) break;
  	G.push_back(h);
    h=h*3+1;
  }
	//debug
	//puts("G!!");
	//for(int i=0;i<G.size();i++)printf("%d,",G[i]);
	//puts("");//
	
  for(int i=G.size()-1; i>=0; i--) {
    insertionSort(A, n, G[i]);
  }
}

int main(void) {
  cin >> n;
  for(int i=0; i<n; i++) scanf("%d",&A[i]);
	cnt=0;

  shellSort(A,n);

	cout<<G.size()<<endl;
	 for(int i=G.size()-1; i>=0; i--) {
	 	printf("%d",G[i]);
	 	if(i)printf(" ");
	 }
	printf("\n%d\n",cnt);
  for(int i=0;i<n;i++) printf("%d\n",A[i]);

  return 0;
}

Measured memory_bytes: 7112
#include <stdio.h>

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

    int dp[100050]={};
    dp[n-1]=0;
    for(int i=n-2;i>=0;i--)
    {
        if(h[i]>=h[i+1])
        {
            dp[i]=dp[i+1]+1;
        }
        else
        {
            dp[i]=0;
        }
    }
    int max=0;
    for(int i=0;i<n;i++)
    {
        if(max<dp[i]) max=dp[i];
    }
    printf("%d\n",max);
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (long long i = 0; i < (int)(n); i++)
#define printYes() cout << "Yes" << endl;
#define printNo() cout << "No" << endl;
#define printVector(v) rep(i, v.size()) cout << x << endl;

int main()
{
    long long H;
    cin >> H;
    int count = -1;
    while (H != 0)
    {
        H /= 2;
        count++;
    }
    long long ans = pow(2, count + 1) - 1;
    cout << ans << endl;
    return 0;
}

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

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    
    for (int i = 0; i < n - k; i++) {
        if (a[i] < a[k + i]) {
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }
    
    return 0;
}


Measured memory_bytes: 4048
S=input()
N=len(S)
ans = '-1 -1'
for i in range(N):
  if i+1<N:
    if S[i]==S[i+1]:
      ans = '{} {}'.format(i+1,i+2)
      break
  if i+3<=N:
    if S[i]==S[i+2]:
      ans = '{} {}'.format(i+1,i+3)
      break
print(ans)

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(ll i = 0; i < n; i++)
const ll INF = 1LL << 60;

int main(){
    ll a,b, x; cin >> a >> b >> x;
    if(a == 0) cout << b / x + 1 << endl;
    else cout << b / x -(a - 1) /x << endl;
}

Measured memory_bytes: 3616
N, C, K = map(int, input().split())
T = [int(input()) for i in range(N)]
T.sort()

ans = 1
bus = C
time = T[0] + K
for i in T:
    # バスの定員に空きがあり、かつ、乗車1人目の許容時間内の場合同じバスに乗る
    if (bus > 0) & (i <= time):
        bus -= 1
    # バスが定員、または、乗車1人目の許容時間外の場合新しいバスに乗る
    else:
        bus = C - 1
        time = i + K
        ans += 1

print(ans)


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

int main(){

  int n;
  int i;
  int cnt = 0;

  scanf("%d", &n);

  for(i = 1;i <= n;i++){
    if(1 <= i && i <= 9) cnt++;
    if(100 <= i && i <= 999) cnt++;
    if(10000 <= i && i <= 99999)cnt++;
  }

  printf("%d\n", cnt);

  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main()
  {int A, B, c{}; cin >> A >> B;
  for (int i{A}; i <= B; ++i)
    {auto s{to_string(i)}, t{s}; reverse(begin(t), end(t));
    c += s == t;}
  cout << c;}

Measured memory_bytes: 3640
#include <iostream>
#include <vector>
#include <algorithm>
#include <bitset>

using namespace std;

int main(int argc, char const *argv[]) {
  int n;
  cin >> n;
  vector<int> a(n);
  bitset<8> bs(0);
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i]<400) bs.set(0);
    else if (a[i]<800) bs.set(1);
    else if (a[i] < 1200) bs.set(2);
    else if (a[i] < 1600) bs.set(3);
    else if (a[i] < 2000) bs.set(4);
    else if (a[i] < 2400) bs.set(5);
    else if (a[i] < 2800) bs.set(6);
    else if (a[i] < 3200) bs.set(7);
    else cnt++;
  }
  int c = bs.count();
  int ansmin = max(c,1), ansmax = c+cnt;
  cout << ansmin << ' ' << ansmax << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w
using namespace std;

#define int long long 
//typedef    long long          ll;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;
 
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

int mod_inv(int X){
	int a = X, b = MOD, u = 1, v = 0;
	while(b) {
		int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	if(u < 0) u += MOD;
	return u;
}

vector<int> fact,factinv;

void nCr_init(int N){
	N = min(N,(int)MOD);
	fact.resize(N + 1);
	factinv.resize(N + 1);
	fact[0] = 1;
	for(int i = 1;i <= N;i++) fact[i] = fact[i - 1] * i % MOD;
	factinv[N] = mod_inv(fact[N]);
	for(int i = N;i >= 1;i--) factinv[i - 1] = factinv[i] * i % MOD;
}

int nCr(int ncr_n,int ncr_r){
	if(ncr_n >= MOD) return nCr(ncr_n % MOD, ncr_r % MOD) * nCr(ncr_n / MOD, ncr_r / MOD) % MOD;
	return ncr_r > ncr_n ? 0 : fact[ncr_n] * factinv[ncr_n - ncr_r] % MOD * factinv[ncr_r] % MOD;
}

class RMQ{
	int n,seg,init;
	vector<int> dat;
public:
	RMQ(int siz,int def) : n(siz),init(def),seg(1){
		while(seg < n) seg *= 2;
		dat.resize(seg * 2 - 1);
		for(int i = 0;i < seg * 2 - 1;i++) dat[i] = init;
	}
	void update(int i,int x){
		i += seg - 1;
		dat[i] = x;
		while(i){
			i = (i - 1) / 2;
			dat[i] = min(dat[i * 2 + 1],dat[i * 2 + 2]); //do
		}
	}
	int get(int a = 0,int b = -1,int k = 0,int l = 0,int r = -1){
		if(b == -1) b = seg;
		if(r == -1) r = seg;
		if(a == b) return INF;
		if(b <= l || r <= a) return init;
		if(a <= l && r <= b) return dat[k];
		return min(get(a,b,k * 2 + 1,l,(l + r) / 2),get(a,b,k * 2 + 2,(l + r) / 2,r)); //do
	}
};

signed main(){
	int n,x,y,c[200010],w[200010],mi[200010],cnt[200010] = {},sum = 0,ans = 1;
	cin >> n >> x >> y;
	nCr_init(200010);
	RMQ rmq(n,INF);
	for(int i = 0;i < n;i++) mi[i] = INF;
	for(int i = 0;i < n;i++){
		cin >> c[i] >> w[i]; c[i]--;
		mi[c[i]] = min(w[i],mi[c[i]]);
	}
	for(int i = 0;i < n;i++){
		rmq.update(i,mi[i]);
		if(mi[c[i]] + w[i] <= x) w[i] = mi[c[i]];
	}
	for(int i = 0;i < n;i++){
		int ami = min(rmq.get(0,c[i]),rmq.get(c[i] + 1,n));
		if(ami + w[i] <= y){
			sum++;
			cnt[c[i]]++;
		}
	}
	for(int i = 0;i < n;i++){
		(ans *= nCr(sum,cnt[i])) %= MOD;
		sum -= cnt[i];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 13696
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
using namespace std;



signed main(){
	int a, b, c;
	cin >> a >> b >> c;
	if (a + b >= c)cout << b + c << endl;
	else cout << a + b * 2 + 1 << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for(int (i)=0 ;i <(n); ++(i))
#define REP(i,m,n) for(int (i) = (m); (i) <= (n); ++(i))
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)? "YES":"NO")
typedef long long ll;
using namespace std;

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
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 2147483647 / 2;
const long long int llINF = 9223372036854775807 / 2;

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VV(T, a, b, c) vector<vector<T>>(a, vector<T>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define VVV(T, a, b, c, d)                                                     \
  vector<vector<vector<T>>>(a, vector<vector<T>>(b, vector<T>(c, d)))
#define SP(a) setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))
#define UNIQUE(vec)                                                            \
  do {                                                                         \
    sort(ALL((vec)));                                                          \
    (vec).erase(std::unique(ALL((vec))), (vec).end());                         \
  } while (0)

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp);
  } else {
    return (n * POW(n, m - 1));
  }
}

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll A, B, C;
  cin >> A >> B >> C;
  if (A * B * C % 2 == 0)
    cout << 0 << endl;
  else
    cout << min(A * B, min(A * C, B * C)) << endl;
  return 0;
}


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

int INF = 1e9;

int main(){
    int n;
    cin >> n;
    int m = INF;
    int cnt = 0;
    rep(i,n){
        int a;
        cin >> a;
        if(m > a) m = a;
        else cnt++;
    }
    int ans = n - cnt;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream& operator<<(ostream& os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
int main(){
    int k;
    string s;
    cin >> k >> s;
    if(s.size() <= k){
        cout << s << endl;
    }else{
        cout << s.substr(0,k) + "..." << endl;
    }
}


Measured memory_bytes: 3596
use proconio::{input, fastout};
use std::collections::{HashSet, HashMap};

#[fastout]
fn main() {
    input! {
        n: i32,
        m: i32,
        r: [(i32, i32); m],
    }
    let mut done: HashMap<i32, i32> = HashMap::new();

    let mut rooms: HashMap<i32, HashSet<i32>> = HashMap::new();
    for i in 1..(n + 1) {
        rooms.insert(i, HashSet::new());
    }
    for e in r {
        rooms.get_mut(&e.0).unwrap().insert(e.1);
        rooms.get_mut(&e.1).unwrap().insert(e.0);
    }

    let mut next: HashSet<i32> = HashSet::new();
    next.insert(1);

    while next.len() > 0 {
        let now = next;
        next = HashSet::new();
        for n in now {
            for e in rooms.get(&n).unwrap() {
                if *e != 1 && !done.contains_key(e) {
                    next.insert(*e);
                    done.insert(*e, n);
                }
            }
        }
    }
    let mut v: Vec<(i32, i32)> = Vec::new();
    for e in done {
        v.push(e);
    }
    v.sort_by(|(k1, _v1), (k2, _v2)| k1.cmp(k2));
    println!("Yes");
    for (_k, v) in v {
        println!("{}", v);
    }
}


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

using namespace std;
#define el '\n'
#define ll long long
typedef vector<int> vi;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n, s;
    cin >> n >> s;
    vector<pair<int, int>> items(n);
    int a, b;
    for (int i = 0; i < n; ++i) {
        cin >> a >> b;
        items[i].first = a;
        items[i].second = b;
    }
    ll dp[2][s + 1];
    memset(dp, 0, sizeof(dp));
    for (int indx = n - 1; indx >= 0; --indx) {
        for (int rem = 0; rem < s + 1; ++rem) {
            ll leave = dp[1][rem];
            ll take = 0;
            if ((rem - items[indx].first) < 0)
                take = 0;
            else
                take = items[indx].second + dp[1][rem - items[indx].first];
            dp[0][rem] = max(leave, take);
        }
        for (int r = 0; r < s + 1; ++r) {
            dp[1][r] = dp[0][r];
        }
    }
    cout << dp[1][s] << el;
    return 0;
}

Measured memory_bytes: 5204
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define debug(a) cout<<#a<<":"<<a<<endl;
const int INF=0x3f3f3f3f;
const int N=1e6+7;
const int mod=1e9+7;
int maxn,minn;
int T,n,m;
double dp[310][310][310];

double dfs(int a,int b,int c){
	double ans=(double)(n)/(a+b+c);
	if(a+b+c==0){
		return 0;
	}
	if(dp[a][b][c]!=0){
		return dp[a][b][c];
	}
	if(a!=0){
		ans=ans+((double)a/(a+b+c))*(dfs(a-1,b,c));
//		cout<<ans<<endl;
	}
	if(b!=0){
		ans=ans+((double)b/(a+b+c))*(dfs(a+1,b-1,c));
//		cout<<ans<<endl;
	}
	if(c!=0){
		ans=ans+((double)c/(a+b+c))*(dfs(a,b+1,c-1));
	}
	return dp[a][b][c]=ans;
}

int main(){
	int a,b,c;
	int a1,a2,a3;
	cin>>n;
	a1=0,a2=0,a3=0;
	for(int i=1;i<=n;i++){
		scanf("%d",&a);
		a1=a1+(a==1);
		a2=a2+(a==2);
		a3=a3+(a==3);
	}
	printf("%.9lf\n",dfs(a1,a2,a3));
//	printf("%lf\n",dp[0][1][0]);
//	printf("%lf\n",dp[1][0][0]);

	return 0;
}





Measured memory_bytes: 225536
function Main(input) {
	input = input.split(" ").map(a => parseInt(a));
	var N = input[0];
	var M = input[1];
	var ans = 0;
	if(N === 1 && M === 1) ans = 1;
	else if(N === 1 || M === 1) ans = N + M - 3;
	else ans = (N - 2) * (M - 2);
	
	if(ans > 9e15){
		ans = Math.floor((N - 2) / 10000) * (M - 2);
		tmp = (N - 2) % 10000 * (M - 2);
		ans += Math.floor(tmp / 10000);
		tmp = ("0000" + tmp % 10000).slice(-4);
		ans += tmp;
	}
	
	console.log(ans);
}

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

Measured memory_bytes: 21064