akhauriyash/Code-Regression huggingface dataset:
def main():
    N,M=map(int,input().split())
    like=[0]*M
    for _ in range(N):
        K,*A=map(int,input().split())
        for num in A:
            like[num-1]+=1
    print(like.count(N))

if __name__=='__main__':
    main()




     


Measured memory_bytes: 38256
#include<iostream>
using namespace std;
 
int main(){
  int n;
  cin>>n;
  int cards[9];
  char color;
  int num[3][9];
  for(int i=0;i<n;i++){
    for(int j=0;j<3;j++)
      for(int k=0;k<9;k++)num[j][k]=0;
    for(int j=0;j<9;j++) cin>>cards[j];
    for(int j=0;j<9;j++){
      cin>>color;
      if(color=='R'){
    num[0][cards[j]-1]++;
      }else if(color=='G'){
    num[1][cards[j]-1]++;
      }else{
    num[2][cards[j]-1]++;
      }
    }
    for(int k=0;k<3;k++){
      for(int j=0;j<7;j++){
    while(num[k][j]>=3)num[k][j]-=3;
    while(num[k][j]>0 && num[k][j+1]>0 && num[k][j+2]>0){
      num[k][j]--;num[k][j+1]--;num[k][j+2]--;
    }
      }
    }
    for(int k=0;k<3;k++){
      for(int j=0;j<9;j++){
    while(num[k][j]>=3)num[k][j]-=3;
      }
    }
    bool ans=true;
    for(int k=0;k<3;k++){
      for(int j=0;j<9;j++){
    //cout << num[k][j] << " " ;
    if(num[k][j]!=0){
      ans=false;
      break;
    }
      }
      //cout << endl;
    }
    if(ans==true) cout << 1 << endl;
    else cout << 0 << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#![allow(unused_imports)]
#![allow(dead_code)]

use proconio::input;
use proconio::marker::{Bytes, Chars};
use std::collections::*;

fn main() {
    input! {
        n:usize,
        m:usize,
        ab:[(usize,usize);m],
    }
    let ab = ab.iter().map(|&(a, b)| (a - 1, b - 1));

    let mut uf = UnionFind::new(n);
    for (a, b) in ab {
        uf.unite(a, b);
    }

    let ans = uf
        .data
        .iter()
        .filter_map(|&node| match node {
            UFdata::Child(_) => None,
            UFdata::Root(x) => Some(x),
        })
        .max()
        .unwrap();

    println!("{}", ans);
}

#[derive(Debug, Copy, Clone)]
enum UFdata {
    Child(usize),
    Root(usize),
}
struct UnionFind {
    data: Vec<UFdata>,
}
impl UnionFind {
    pub fn new(n: usize) -> Self {
        UnionFind {
            data: vec![UFdata::Root(1); n],
        }
    }
    fn root(&mut self, x: usize) -> usize {
        match self.data[x] {
            UFdata::Child(p) => {
                let res = self.root(p);
                self.data[x] = UFdata::Child(res);
                res
            }
            UFdata::Root(_) => x,
        }
    }
    pub fn size(&mut self, x: usize) -> usize {
        match self.data[x] {
            UFdata::Root(m) => m,
            UFdata::Child(_) => {
                let r = self.root(x);
                self.size(r)
            }
        }
    }
    pub fn unite(&mut self, x: usize, y: usize) -> bool {
        let (mut u, mut v) = (self.root(x), self.root(y));
        if u == v {
            false
        } else {
            if self.size(u) < self.size(v) {
                std::mem::swap(&mut u, &mut v);
            }
            self.data[u] = UFdata::Root(self.size(u) + self.size(v));
            self.data[v] = UFdata::Child(u);
            true
        }
    }
    pub fn is_same(&mut self, x: usize, y: usize) -> bool {
        self.root(x) == self.root(y)
    }
}

Measured memory_bytes: 10768
#include <stdio.h>
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <math.h>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <tuple>
#include <climits>
using namespace std;

int inf = INT_MAX;
//int inf = LLONG_MAX;

int a, b, c, res;

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

    res = b / a;

    if (res >= c)
    {
        res = c;
    }

    cout << res;

    return 0;
}


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

#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
#include <fstream>
#include <functional>
#include <iostream>
#include <iomanip>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

#define ll long long int
#define FOR(i, a, b) for(int i=(a);i<=(b);++i)
#define REP(i, n) for(int i=0;i<n;++i)
#define FOREACH(x, a) for(auto& (x) : (a))
#define ALL(a) (a).begin(),(a).end()
#define OUT(x) out << (x) << endl;
#define M0(x) memset(x,0,sizeof(x))
#define MINF(x) memset(x,0x3f,sizeof(x))
#define MMINUS(a) memset(a,0xff,sizeof(a))
#define ten(n) ((int)1e##n)

const int INF = 0x3f3f3f3f;
const int MOD = 1e9+7;
const ll LINF = 1e18;
const double EPS = 1.0/LINF;
const char ENDL = '\n'; // for JetBrains IDE only supports yen

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

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

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

using namespace std;

class CSwitches {
public:
    bool light[11];
    vector<int> sw[11];
    int p[11];
    int N, M;

    void solve(std::istream& in, std::ostream& out) {
        in >> N >> M;
        M0(light);
        FOR(i, 1, M) {
            int k; in >> k;
            FOR(j, 1, k) {
                int l; in >> l;
                sw[i].push_back(l);
            }
        }
        FOR(i, 1, M) {
            in >> p[i];
        }
        OUT(dfs(1));
    }

    int dfs(int now) {
        if (now == N+1) {
            FOR(i, 1, M) {
                int num = 0;
                FOREACH(s, sw[i]) {
                    if (light[s]) num++;
                }
                if (num % 2 != p[i]) return 0;
            }
            return 1;
        } else {
            int x = dfs(now+1);
            light[now] = !light[now];
            int y = dfs(now+1);
            return x + y;
        }
    }
};


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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000007;
 
int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  
  char A[3][3];
  for(int i=0;i<3;i++){
    for(int j=0;j<3;j++){
      cin >> A[i][j];
      if(i == j) cout << A[i][j];
    }
  }
  cout << endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int N;
	int i = 0;
	cin >> N;
	for (int c = 0; c <= 25; c++){
		for (int d = 0; d <= 14; d++){
			if (c * 4 + d * 7 == N){
				i++;
			}
		}
	}
	if (i == 0){
		cout << "No" << endl;
	}
	else{
		cout << "Yes" << endl;
	}
	return 0;
}

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

int main()
{
    int N;
    int t[110000],x[110000], y[110000];
    t[0] = 0;
    x[0] = 0;
    y[0] = 0;
    cin >> N;
    for (int i = 1; i <= N; ++i){
        cin >> t[i] >> x[i] >> y[i];
    }

    bool can = true;
    for (int i = 0; i < N; ++i){
        int dt = t[i+1]-t[i];
        int dist = abs(x[i+1] - x[i]) + abs(y[i+1]-y[i]);
        if (dt < dist){
            can = false;
        }
        if (dist % 2 != dt % 2){
            can = false;
        }
    }

    if (can){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 1408
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  int a, b, k;
  cin >> a >> b >> k;
  for (int i = 110; i >= 1; i--) {
    if (a % i == 0 && b % i == 0) k--;
    if (k == 0) {
      cout << i << endl;
      return 0;
    }
  }
  return 0;	  
}

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

map<int,int>col,row;
char m[105][105];

signed main(){
    
    int r,c;
    cin >> r >> c;

    for(int i = 0;i<r;i++){
        int cr = 0;
        for(int j = 0;j<c;j++){
            cin >> m[i][j];
            if(m[i][j]=='.')cr++;
        }
        if(cr==c)row[i]=1;
    }

    for(int j = 0;j<c;j++){
        int cc = 0;
        for(int i = 0;i<r;i++){
            if(m[i][j]=='.')cc++;
        }
        if(cc==r)col[j]=1;
    }

    for(int i = 0;i<r;i++){
        for(int j = 0;j<c;j++){
            if(!row[i] && !col[j])cout << m[i][j];
        }
        if(!row[i])cout << endl;
    }
    return 0;
}


Measured memory_bytes: 256
x,y,z,K=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
a.sort(reverse=1)
b.sort(reverse=1)
c.sort(reverse=1)
m=[]
for i in range(x):
  for j in range(y):
    for k in range(z):
      if (i+1)*(j+1)*(k+1)>K:
        break
      m.append(a[i]+b[j]+c[k])
m.sort(reverse=1)
for i in m[:K]:
  print(i)


Measured memory_bytes: 8708
// Copyright (C) 2017 Sayutin Dmitry.
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
// published by the Free Software Foundation; version 3

// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program; If not, see <http://www.gnu.org/licenses/>.

#include <iostream>
#include <vector>
#include <stdint.h>
#include <algorithm>
#include <set>
#include <map>
#include <array>
#include <queue>
#include <stack>
#include <functional>
#include <utility>
#include <string>
#include <assert.h>
#include <iterator>
#include <cstdint>
#include <cinttypes>
#include <string.h>
#include <random>
#include <numeric>
#include <tuple>


using std::cin;
using std::cout;
using std::cerr;

using std::vector;
using std::map;
using std::array;
using std::set;
using std::string;

using std::pair;
using std::make_pair;

using std::min;
using std::abs;
using std::max;

using std::unique;
using std::sort;
using std::generate;
using std::reverse;
using std::min_element;
using std::max_element;

#ifdef LOCAL
#define LASSERT(X) assert(X)
#else
#define LASSERT(X) {}
#endif

template <typename T>
T input() {
    T res;
    cin >> res;
    LASSERT(cin);
    return res;
}

template <typename IT>
void input_seq(IT b, IT e) {
    std::generate(b, e, input<typename std::remove_reference<decltype(*b)>::type>);
}

#define SZ(vec)         int((vec).size())
#define ALL(data)       data.begin(),data.end()
#define RALL(data)      data.rbegin(),data.rend()
#define TYPEMAX(type)   std::numeric_limits<type>::max()
#define TYPEMIN(type)   std::numeric_limits<type>::min()

#define pb push_back
#define eb emplace_back

bool dfs(const vector<vector<int>>& graph, vector<char>& type, int v) {
    for (int u: graph[v])
        if (type[u] == 0) {
            type[u] = 3 - type[v];
            if (not dfs(graph, type, u))
                return false;
        } else if (type[u] == type[v]) {
            return false;
        }
    
    return true;
}

int main() {
    std::iostream::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    
    // code here.
    int n = input<int>();
    int m = input<int>();

    vector<vector<int>> graph(n);
    for (int i = 0; i != m; ++i) {
        int v = input<int>() - 1;
        int u = input<int>() - 1;

        graph[v].pb(u);
        graph[u].pb(v);
    }

    vector<char> type(n, 0);
    type[0] = 1;
    bool bip = dfs(graph, type, 0);

    if (bip) {
        int num[2] = {0, 0};
        for (int i = 0; i != n; ++i)
            num[type[i] - 1] += 1;

        cout << num[0] * int64_t(num[1]) - m << "\n";
    } else {
        cout << n * int64_t(n - 1) / 2 - m << "\n";
    }
    
    return 0;
}


Measured memory_bytes: 6400
#include <stdio.h>

int main() {
  int H, W;
  scanf("%d %d", &H, &W);
  
  int flagH[100] = {}, flagW[100] = {};
  int data[10000] = {};
  getchar();
  for (int h = 0; h < H; h++) {
    int h100 = h * 100;
    for (int w = 0; w < W; w++) {
      char c = getchar();
      if (c & 1) {
        flagH[h] += 1;
        flagW[w] += 1;
        data[h100 + w] = 1;
      }
    }
    getchar();
  }
  
  for (int h = 0; h < H; h++) {
    if (!flagH[h]) continue;
    int h100 = h * 100;
    for (int w = 0; w < W; w++) {
      if (!flagW[w]) continue;
      char c = data[h100 + w] ? '#' : '.';
      putchar(c);
    }
    putchar('\n');
  }
  return 0;
}


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

int main()
{
    string N;

    cin >> N;

    ll sum = 0;

    ll size = N.size();

    for(ll i = 0; i < size; i++){
        char c = N[i];
        ll n = c - '0';

        sum += n % 10;
    }

    if(sum % 9 == 0){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

const double EPS = 1e-9;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007;

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

int main(void){
    ll X; cin >> X;
    ll n = 0;
    while((n+1)*(n+2)/2 <= X) n++;
    ll ans = 0;
    if(n*(n+1)/2 == X) ans = n;
    else ans = n + 1;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int a;
    int b;
    int c;
    
    scanf("%d %d %d", &a, &b, &c);
    if(0 <= a && a <= 100 && 0 <= b && b <= 100 && 0 <= c && c <= 100)
    {
        if(a < b && b < c)
        {
            printf("Yes\n");
        }
        else
        {
            printf("No\n");
        }
    }
    return(0);
}


Measured memory_bytes: 2088
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
using namespace std;
typedef long long ll;
typedef struct pair<int,int> P;
typedef struct pair<int,P> P2;

ll d[1001]={};
int a[100001]={};
int main() {
	char a[50][50];
	char b[50][50];
	int n,m;
	cin>>n>>m;
	char chr;
	for(int i=0;i<n;++i){
		for(int j=0;j<n;++j){
			cin>>chr;
			a[i][j]=chr;
		}
	}
	for(int i=0;i<m;++i){
		for(int j=0;j<m;++j){
			cin>>chr;
			b[i][j]=chr;
		}
	}

	bool res=false;
	for(int i=0;i<n-m+1;++i){
		for(int j=0;j<n-m+1;++j){
			bool flg=true;
			for(int o=0;o<m;++o){
				for(int p=0;p<m;++p){
					if(a[i+o][j+p]!=b[o][p])flg=false;
				}
			}
			if(flg)res=true;
		}
	}
	if(res){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;

	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using  namespace std;
 
#define endl '\n'
#define ll long long
#define int long long
#define re register
#define pb(x) push_back(x)
#define ce(x) cout << x << '\n';
 
#define db  long double;
#define pll pair < ll, ll >;
#define scan(a, n) 		for(int i = 0; i < n; i++)cin >> a[i];
 
#define rep(i,x,n,inc) for(i=x ; i<n ; i+=inc)
#define repr(i,x,n,inc) for( i=x ; i>n ; i+=inc)
#define all(a)      (a).begin(),(a).end()
#define unique_sort(x) sort(all(x)), x.resize(distance(x.begin(), unique(all(x))))
 
#define mp(a,b) make_pair(a,b)
#define ff first
#define ss second
#define hell 1000000007
#define infl LLONG_MAX
 
#define Foxen(i,s) for (i=s.begin(); i!=s.end(); i++)
#define Fill(s,v) memset(s,v,sizeof(s))
#define cout_p(x, p) cout << fixed << setprecision((p)) << x << endl     //print with precision
 
#define tc(tt) \
    ll tt;    \
    cin >> tt; \
    for (ll _tt = 0; _tt < tt; _tt++) // testcase 
 
int32_t main() {
	ios::sync_with_stdio(0); 		cin.tie(0); cout.tie(0);
 
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
 
	ll t, i, x, j, y, 	z, k, n;
	cin >> n;
	cout_p((44 * n) / 7.0, 6);
}

Measured memory_bytes: 3780
#include <stdio.h>
#include <vector>
#include <algorithm>
using namespace std;
int n,i;
vector<int> a;
int cc[100010];
int main(){
  scanf("%d\n",&n);
  for (i=0;i<n;i++){
    int tmp;
    scanf("%d\n",&tmp);
    a.push_back(tmp);
  }
  sort(a.begin(),a.end());
  int tmp=a[0],c=0,j=0;
  for (i=1;i<n;i++){
    if (tmp!=a[i]){
      cc[j++]=i-c;
      tmp=a[i];
      c=i;
    }
    if (i==n-1){cc[j++]=n-c;}
  }
  tmp=0;
  for (i=0;i<j;i++){
    if (cc[i]%2==0){tmp++;}
  //  printf("%d\n",cc[i] );
  }
  printf("%d\n",j-tmp%2 );
}


Measured memory_bytes: 1144
import           Control.Monad
import           Control.Monad.ST
import qualified Data.Array                    as A
import qualified Data.Array.Unboxed            as AU
import qualified Data.Array.ST                 as ST
import qualified Data.ByteString.Char8         as BS
import           Data.Char
import           Data.Int
import qualified Data.IntMap                   as IM
import           Data.List
import qualified Data.Map                      as M
import           Data.Maybe
import           Data.Ord
import qualified Data.Set                      as S
import           Data.Time
import qualified Data.Vector                   as V
import qualified Data.Vector.Mutable           as VM
import qualified Data.Vector.Unboxed           as VU
import qualified Data.Vector.Unboxed.Mutable   as VUM

readInt = map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine
readInts n = replicateM n readInt
readString = map BS.unpack . BS.words <$> BS.getLine
readStrings n = replicateM n $ BS.unpack <$> BS.getLine
toPair [x, y] = (x, y)

main = do
  [n, a, b] <- readInt
  print $ solve n a b

solve n a b = a * d + min a m
 where
  loop   = a + b
  (d, m) = n `divMod` (a + b)





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

/*If you are going to try,keep going until the end ,or don't even try to start*/

/* Remember, Hope is a good thing... May be the best of things... And No Good thing ever Dies !!!*/

using namespace std;

#define ll long long
#define nada "\n"
#define st string
#define S  second
#define F  first
#define pb push_back
#define MP make_pair
#define isnttriangle(a,b,c)  (a+b<c||a+c<b||b+c<a)
#define todegree(rad) rad*(180.0/pi)
#define rrp(i, a, b)  for(ll i = a; i >= b; i--)
#define repp(i,a,b)   for (int i = int(a); i <=int(b); i++)
#define rep(i, n)     for (int i = 0; i <n; i++)
#define rep1(i,n)     for (int i = 1; i <=n; i++)
#define allr(v)       ((v).rbegin()), ((v).rend())
#define all(v)        ((v).begin()),((v).end())
#define fx(n)         cout<<fixed<<setprecision(n);
#define sz(v)         ((int)(v).size())
#define Test          ll t;cin>>t;while(t--)
#define mod           1000000009LL


const double ME = 2.71828;
const int    N  = 3e5 + 20;
const int   inf = 0x3f3f3f3f;
const double pi = 3.141592653;




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

void file()
{
    freopen("records.in", "r", stdin);
    //freopen("text.out", "w", stdout);
}

ll gcd(ll a, ll b)
{
    //Eculidean Algorthim
    return (!b) ? a : gcd(b, a % b);
    //complixty=log(ab);
}

ll lcm(ll a,ll b)
{
    return a / gcd(a, b) * b;
}

ll Fib_recur(ll n)
{
    vector<ll>v(n+5,0);
    //BaseCase
    v[1]=0;
    v[2]=1;
    repp(i,3,n)v[i]=v[i-1]+v[i-2];
    return v[n];
}

bool isprime(ll n)
{
    for(ll i = 2; i <= sqrt(n); i++)
    {
        if(n%i == 0)
            return false;
    }
    return true;
}



void Solve()
{
    vector<int>ans(10050,0);
    int n,v=0;
    cin>>n;
    rep1(i,105)
    {
        rep1(j,105)
        {
            rep1(k,105)
            {
                if(v = i*i+j*j+k*k+i*j+j*k+k*i)
                    if(v<10050)ans[v]+=1;
            }
        }
    }
    rep1(i,n)
    {
        cout<<ans[i]<<nada;
    }
}




//"I AM A LOSER ";

int main()
{
    // fx(7)
    //file();
    LOSER();
    //Test

    Solve();

}


Measured memory_bytes: 3616
n,m = map(int, input().split())
x = []
y = []
for _ in range(m):
  l,r = map(int, input().split())
  x.append(l)
  y.append(r)
x = max(x)
y = min(y)

if y-x >= 0: print(y-x+1)
else: print(0)

Measured memory_bytes: 16892
#include <bits/stdc++.h>
using namespace std;
#define endl    "\n"
#define int		long long
#define mp		make_pair
#define pb		push_back
#define fi		first
#define se 		second
#define sz(x)	((int)(x).size())
#define dbg(x) cerr<<#x<<" :: "<<x<<endl;
#define dbg2(x,y) cerr<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
const int INF = 1e9;
const int MOD = 1e9 + 7; 
const double pi = acos(-1);

void solve (){
    int n; cin>>n;
    unordered_map<int,int> m;

    int sum = 0;
    for(int i = 1; i <= n; i++){
        int temp; cin>>temp;
        sum = sum + temp;
        m[temp]++;
    }

    int q; cin>>q;
    for(int i = 1; i <= q; i++){
        int b, c; cin>>b>>c;
        int change = m[b] * (c - b);
        sum = sum + change;
        m[c] = m[c] + m[b];
        m[b] = 0;
        cout<<sum<<endl;
    }
}

int32_t main(){
    ios::sync_with_stdio(false); cin.tie(0);
    solve();
    return 0;
}
//g++ -std=c++17 -Wshadow -Wall -o "%e" "%f" -g -D_GLIBCXX_DEBUG

Measured memory_bytes: 7116
[N,M] = list(map(int,input().split()))
X = list(map(int,input().split()))
X = sorted(X)
#print('X',X)

if N>=M:
    out=0
else:
    aida=[0]*(M-1)
    for i in range(M-1):
        aida[i] = X[i+1] - X[i]
    #print(aida)
    aida = sorted(aida, reverse=True)

    out = X[-1] - X[0]
    for j in range(N-1):
        out-=aida[j]

print(out)

Measured memory_bytes: 54056
#include <stdio.h>

int main(void) {

  int h,w,n;
  scanf("%d %d %d", &h, &w, &n);
  int a[n];
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  int grid[h][w];
  int height = 0;
  int width = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < a[i]; j++) {
      grid[height][width] = i+1;
      if (height%2 == 0) {
        if (width != w-1) {
          width++;
        } else {
          height++;
        }
      } else {
        if (width != 0) {
          width--;
        } else {
          height++;
        }
      }
    }
  }
  for (int i = 0; i < h; i++) {
    printf("%d", grid[i][0]);
    for (int j = 1; j < w; j++) {
      printf(" %d", grid[i][j]);
    }
    printf("\n");
  }

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=100005,INF=1<<30;

int main(){
    
    string S;cin>>S;
    if(S[0]=='S') cout<<"Cloudy"<<endl;
    else if(S[0]=='C') cout<<"Rainy"<<endl;
    else if(S[0]=='R') cout<<"Sunny"<<endl;
}



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

typedef long long ll;
typedef long double ld;

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

    string A, B;
    cin >> A >> B;

    if(A.length() > B.length()) {
        cout << "GREATER" << endl;
        return 0;
    }
    if(A.length() < B.length()) {
        cout << "LESS" << endl;
        return 0;
    }

    for(int i = 0; i < A.length(); i++) {
        if(A[i] > B[i]) {
            cout << "GREATER" << endl;
            return 0;
        }
        if(A[i] < B[i]) {
            cout << "LESS" << endl;
            return 0;
        }
    }

    cout << "EQUAL" << endl;
}

Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<cmath>
#include<queue>
#include<stack>
#include<list>

#define endl "\n"
using namespace std;
using ll = long long;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define REP(i, n) for(int i = 0; i < n; i++)
using Graph = vector<vector<int>>;

int main(){
    int x,n;
    cin>>x>>n;
    int p[n];
    vector<bool> used(101,false);
    for(int i=0;i<n;i++){
        cin>>p[i];
        used[p[i]] = true;
    }
    int ans,tmp = 110;
    for(int i=0;i<=101;i++){
        if(used[i]) continue;
        if(tmp > abs(x - i)){
            ans = i;
            tmp = abs(x-i);
        }
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 3596
from math import sqrt
X=int(input())
sqrt_X=int(sqrt(X))
ans=1
##最後は含まないので＋１する必要がある
for b in range(1,sqrt_X + 1):
    ##pは2から始めまる
    for p in range(2,sqrt_X+1):
        now_num = b**p
        if now_num <= X and ans <= now_num:
            ans =now_num
print(ans)

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {
    public static void main( String[] args) {
        Scanner s = new Scanner(System.in);
            int a = s.nextInt();
            int b = s.nextInt();
            if ((a*b) % 2 ==0) {
                System.out.println("Even");
            } else {
                System.out.println("Odd");
            }
    }
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> pii;
typedef vector<pii> vii;
typedef vector<ll> vi;
typedef queue<ll> qi;
typedef queue<char> qc;
typedef queue<string> qs;
typedef vector<char> vc;
typedef vector<string> vs;
typedef map<char,ll> mpci;
typedef map<ll,ll> mpii;
typedef map<string,ll> mpsi;
typedef set<ll> sei;
typedef set<char> sec;
typedef set<string> ses;
typedef stack<ll> si;
typedef stack<char> sc;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
typedef vector<pll> vpll;
typedef vector<pdd> vdd;
typedef unsigned int uint;
typedef long double ld;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<vii> vvii;
/*=====================================================================*/
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define sz(a) (int)(a.size())
#define len(a) (int)(a.length())
#define all(s) (s).begin(),(s).end()
#define fi first
#define se second
#define be begin
#define en end
#define repd(i,n) for(int i=n-1;i>=0;i--)
#define forn(i,p,n) for(int i=p;i<n;i++)
#define ford(i,p,n) for(int i=n-1;i>=p;i--)
#define foreach(i,c) for(__typeof(c.begin())i=(c.begin());i!=(c).end();++i)
#define zero(a) memset(a,0,sizeof(a))
#define number(a,num) memeset(a,num,sizeof(a))

/*=====================================================================*/

inline void read(int &x)
{
	short negative=1;
    x=0;
    char c=getchar();
    while(c<'0' || c>'9')
    {
		if(c=='-')
			negative=-1;
		c=getchar();
	}
    while(c>='0' && c<='9')
        x=(x<<3)+(x<<1)+(c^48),c=getchar();
    x*=negative;
}
inline void write(long long x) {
  static long long sta[35];
  long long top = 0;
  do {
    sta[top++] = x % 10, x /= 10;
  } while (x);
  while (top) putchar(sta[--top] + 48);
  puts("");
}
/*======================================================================*/
bool prime(int n)
{
	if(n==0||n==1)
	  return false;
	for(int i=2;i*i<=n;i++)
	  if(n%i==0)
	    return false;
	return true;
}
/*======================================================================*/
const int dx[]={-1,0,1,0};
const int dy[]={0,-1,0,1};
/*======================================================================*/
int main()
{
  /*
	ios_base::sync_with_stdio(0);
	cin(tie);
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
  */
  /*====================================================================*/
  int n;
  cin>>n;
  int l=(n+1)/2;
  float f=l*1.0/n;
  cout<<f<<endl;
  return 0;
}


Measured memory_bytes: 256
function Main(input) {
  var list = input.split("");
  if((list[0] == list[1] && list[1] == list[2]) ||
    (list[1] == list[2] && list[2] == list[3]) ||
     (list[0] == list[1] && list[1] == list[2] && list[2] == list[3])
    ){
     console.log("Yes");
     }else{
       console.log("No");
     }
}

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


Measured memory_bytes: 7372
#include<bits/stdc++.h>
using namespace std;
#define ll long long                                    // long long省略
#define pb push_back                                    // push_back省略
#define mp make_pair                                    // make_pair省略
#define fi first                                        // first省略
#define se second                                       // second省略
#define itn int                                         // int誤字保険
#define count cout                                      // cout誤字保険
#define vecotr vector                                   // vector誤字保険
#define ednl endl                                       // endl誤字保険
#define opt() cin.tie(0); ios::sync_with_stdio(false)   // 入出力速度改善

#define rep(i,l,r) for(ll i=(l);i<(r);i++)               // 範囲[l, r)で刻み1のfor文(順方向)
#define repp(i,l,r,k) for(ll i=(l);i<(r);i+=(k))         // 範囲[l, r)で刻みkのfor文(順方向)
#define rrep(i,l,r) for(ll i=(r-1);i>=(l);i--)           // 範囲[l, r)で刻み1のfor文(逆方向)
#define rrepp(i,l,r,k) for(ll i=(r-1);i>=(l);i-=(k))     // 範囲[l, r)で刻みkのfor文(逆方向)
#define all(x) (x).begin(), (x).end()                   // vectorのポインタ位置指定用
#define max(p,q)((p)>(q)?(p):(q))                       // max拡張
#define min(p,q)((p)<(q)?(p):(q))                       // min拡張
#define bit(n,m)(((n)>>(m))&1)                          // 変数nのm番目のbitを取り出す

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

int dy[]={0, 1, 0, -1};                                 // 4方向近傍
int dx[]={1, 0, -1, 0};                                 // 4方向近傍

int main(){
    ll a,b,c,d;cin>>a>>b>>c>>d;
    cout << (a<=999 ? "ABC" : "ABD") << ednl;
}

Measured memory_bytes: 256
n,k=map(int,input().split())
a=[int(i) for i in input().split()]
b=[0]*n
b[n-2]=abs(a[n-1]-a[n-2])
for i in range(n-3,-1,-1):
    for j in range(i+1,min(n,i+k+1)):
        x=abs(a[j]-a[i])+b[j]
        if j==i+1:
            mini=x
        mini=min(mini,x)
    b[i]=mini
print(b[0])

Measured memory_bytes: 52448
#include<stdio.h>
int main(){
    int n,w[100],i,j,q,r=999999999;
    scanf("%d",&n);
    for(i=0;i<n;i++)scanf("%d",&w[i]);
    for(i=n;i--;){
        q=0;
        for(j=n;j--;)q+=j>i?w[j]:-w[j];
        q=abs(q);
        r=r>q?q:r;
    }
    printf("%d",r);
    return 0;
}

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

int main(){
    int N;
    cin >> N;
    for(int i=0;i<10;i++){
        for(int j=0;j<10;j++){
            if(i*j==N ){
                puts("Yes");
                return 0;
            }
        }
        
    }
  puts("No");
}

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

#define loop(i,first,end) for(int i=(first);i<(end);i++)
#define uint unsigned int
#define ull unsigned long long
#define ll long long
#define vint vector<int>
#define vuint vector<unsigned int>
#define vull vector<ull>
#define vll vector<ll>

const ull mod = 1000000007ULL;
const ull INF = (ull)(-1LL);

int main(void){
	int a, b;
	cin >> a >> b;
	int c = a + b;
	if (c % 2)cout << "IMPOSSIBLE" << endl;
	else cout << c / 2 << endl;
	return 0;
}

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

signed main() {
    int N, M;
    cin >> N >> M;
    vector<int> A(N);
    for (int& x : A) cin >> x;

    vector<pair<int, int>> vp(M);
    int cMax = 0;
    for (auto& p : vp) {
        cin >> p.first >> p.second;
        cMax = max(cMax, p.second);
    }

    sort(A.begin(), A.end());
    int iMax = -1;
    for (int i = 0; i < N; i++) {
        if (A[i] <= cMax) iMax = i;
    }

    sort(vp.begin(), vp.end(), [](auto a, auto b){return a.second > b.second;});
    auto itr = vp.begin();
    for (int i = 0; i <= iMax; i++) {
        A[i] = max(A[i], itr->second);
        itr->first -= 1;
        if (itr->first == 0) {
            itr++;
            if (itr == vp.end()) break;
        }
    }

    cout << accumulate(A.begin(), A.end(), 0LL) << endl;
}


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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
using ll = long long;
using ld = long double;
const int MOD = 1e9+7;
const ll INF = 1LL << 60;


int main() {
    string s; cin >> s;
    int n = s.size();

    V<int> a(n + 1);
    for(int i = 0; i < n; i++){
        if(s[i] == '<') a[i + 1] = max(a[i + 1], a[i] + 1);
    }
    for(int i = n - 1; i >= 0; i--){
        if(s[i] == '>') a[i] = max(a[i], a[i + 1] + 1);
    }
    ll ans = 0;
    for(int i = 0; i <= n; i++){
        ans += a[i];
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 5868
#include<stdio.h>

int main(){
    int a, b, n;
    scanf("%d", &n);
    if(n==1){
        printf("Hello World\n");
    }
    else{
        scanf("%d", &a);
        scanf("%d", &b);
        printf("%d\n", a+b);
    }
    return 0;
}

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

#include "bits/stdc++.h"
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define inv(i, a, b) for (int i = (int)(a); i >= (int)(b); i--)
#define ALL(obj) begin(obj), end(obj)
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define LOWER_BOUND(A, key) distance(A.begin(), lower_bound(ALL(A), key))
#define UPPER_BOUND(A, key) distance(A.begin(), upper_bound(ALL(A), key))

using namespace std;
const int MOD = (int)(1e9 + 7);
const int INF = (int)(1e13 + 7);

int CEIL(int a, int b) { return (a >= 0 ? (a + (b - 1)) / b : (a - (b - 1)) / b); }
int mod(int a, int b) { return a >= 0 ? a % b : a - (b * CEIL(a, b)); }
int bpm(int x, unsigned int y) {
  if (x == 0) return 0;
  if (y == 0) return 1;
  int ans   = 1;
  int digit = (int)((log((double)y) / log((double)2) / 1 + 1));
  x %= MOD;
  for (int i = 0; i < digit; i++) {
    if (((y >> i) & 1u) == 1) ans = ans * x % MOD;
    x = x * x % MOD;
  }
  return ans;
}
template <class T>
void cumulative_sum(T &container) {
  for (int i = 0; i < container.size() - 1; i++) container[i + 1] += container[i];
}

class CGridRepainting2 {
public:
  static void solve(std::istream &cin, std::ostream &cout) {
    int H, W;
    cin >> H >> W;
    vector<string> S;
    S.emplace_back( string(W + 2, '.'));
    rep(i, H){
      string temp;
      string temp2;
      cin>>temp;
      temp2 = ".";
      temp2 += temp;
      temp2 += ".";
      S.emplace_back(temp2);
    }
    S.emplace_back( string(W + 2, '.'));
    FOR(i, 1, H+1){
      FOR(j, 1, W+1){
        if (S[i][j] == '#' and S[i-1][j] == '.' and S[i+1][j] == '.' and S[i][j+1] == '.' and S[i][j-1] == '.'){
          cout<<"No"<<endl;
          return;
        }
      }
    }
    cout<<"Yes"<<endl;
  }
};


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


Measured memory_bytes: 256
# -*- coding: utf-8 -*-

def get_input() -> tuple:
    """
    標準入力を取得する.

    Returns:\n
        tuple: 標準入力
    """
    N = int(input())
    A = list(map(int, input().split()))

    return N, A

def main(N: int, A: list) -> None:
    """
    メイン処理.

    Args:\n
        N (int): 日数（2 <= N <= 80）
        A (list): i日目の株価（100 <= A_i <= 200）
    """
    # 求解処理
    pos = 1000
    for i in range(N - 1):
        stock = 0
        if A[i] < A[i + 1]:
            stock = pos // A[i]
        pos += (A[i + 1] - A[i]) * stock

    # 結果出力
    print(pos)

if __name__ == "__main__":
    # 標準入力を取得
    N, A = get_input()

    # メイン処理
    main(N, A)


Measured memory_bytes: 9108
#include <cstdio>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <iterator>
#define loop(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define debug(x)  cout << #x << " = " << (x) << endl;

using namespace std;
using LL = long long;
using ULL = unsigned long long;

vector<pair<int64_t,int64_t>>
make_divisors(int64_t n) {
    vector<pair<int64_t, int64_t>> ret;

    for (int64_t i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back({i, n / i});
        }
    }
    return ret;
}
int
count_digit(int64_t n) {
    return floor(log10(n) + 1);
}
int
main() {
    int64_t n; cin >> n;

    auto div_pairs = make_divisors(n);
    int ans = 1e9;
    for (auto p: div_pairs) {
        auto x = p.first;
        auto y = p.second;

        ans = min(ans, max(count_digit(x),count_digit(y)));
    }
    cout << ans << endl;
}


Measured memory_bytes: 888
import math
N = int(input())
b=[]
a = list(map(int,input().split()))
#print('@',a)

x = (min(a)+max(a))//2

#if (min(a)+max(a))%2 == 0:
for i in range(N):
    b.append(abs(x-a[i]))
print("{:.0f}".format(max(b)))

#else:
    


Measured memory_bytes: 5696
#include <stdio.h>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;

int main(void) {
  ll i, j, k, n, ans = 0, v;
  scanf("%lld%lld", &n, &v);
  ll a[4][n];
  vector<ll> v1, v2;
  vector<ll>::iterator it;
  for(i = 0; i < 4; ++i) for(j = 0; j < n; ++j) scanf("%lld", &a[i][j]);
  for(i = 0; i < n; ++i) for(j = 0; j < n; ++j) v1.push_back(a[0][i] + a[1][j]);
  for(i = 0; i < n; ++i) for(j = 0; j < n; ++j) v2.push_back(a[2][i] + a[3][j]);
  sort(v1.begin(), v1.end());
  sort(v2.begin(), v2.end());
  for(it = v1.begin(); it != v1.end(); ++it) {
    ans += upper_bound(v2.begin(), v2.end(), v - (*it)) - lower_bound(v2.begin(), v2.end(), v - (*it));
  }
  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 22564
#include <stdio.h>
#include <string.h>

int main(void)
{
	char s[11], t[11], u[11];
	int sNum, tNum;

	scanf("%s%s", s, t);
	scanf("%d%d", &sNum, &tNum);
	scanf("%s", u);

	/* s = uのとき */
	if (strcmp(s, u) == 0)
	{
		sNum--;
	}
	else /* s = uでなければ自動的にt = uである */
	{
		tNum--;
	}

	printf("%d %d\n", sNum, tNum);

	return 0;
}

Measured memory_bytes: 128
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace C
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var nx = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
            var xi = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
            var x = nx[1];
            Array.Sort(xi);
            var answer = Math.Min(Math.Abs(xi[0] - x), Math.Abs(xi[xi.Length - 1] - x));
            for (var i = 1; i < xi.Length; i++)
            {
                answer = GCD(answer, xi[i] - xi[i - 1]);
            }
            Console.WriteLine(answer);
        }
        static int GCD(int a, int b) => b == 0 ? a : GCD(b, a % b);
    }
}


Measured memory_bytes: 19680
A, B, C, D, E, F = gets.split.map(&:to_i)

ws = []
ss = []

0.upto(F / A) do |i|
  0.upto(F / B) do |j|
    next if i == 0 && j == 0
    wv = 100 * i * A + 100 * j * B
    if wv <= F
      ws << wv
    end
  end
end

0.upto(F / C) do |i|
  0.upto(F / D) do |j|
    next if i == 0 && j == 0
    sv = i * C + j * D
    if sv <= F
      ss << sv
    end
  end
end

maxRate = 0
w = 0
s = 0

ws.each do |i|
  ss.each do |j|
    if i + j <= F
      rate = j.to_f / (i + j)
      if rate > maxRate && j * 100 <= E * i
        maxRate = rate
        w = i + j
        s = j
      end
    end
  end
end
w = A * 100 if w == 0
puts "#{w} #{s}"

Measured memory_bytes: 3836
import java.util.*;
import java.io.*;
public class Main{
  
    public static void main(String [] args){
        Scanner sc=new Scanner(System.in);
        long n=sc.nextLong();
        long a=sc.nextLong();
        long b=sc.nextLong();
    
            long div=n/(a+b);
            long rem=n%(a+b);
            
            long sum=div*a;
            sum+=Math.min(rem,a);
            System.out.println(sum);


    }
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ll  long long
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
int main()
{
    FASTINOUT;
    int x;
    cin>>x;
    double m=x/1.08;
    ll first=m,second=m+1;
    ll f=first*1.08;
    ll s=second*1.08;
    if (f==x)
        cout<<first;
    else if (s==x)
        cout<<second;
    else
        cout<<":(";
    return 0;
}


Measured memory_bytes: 256
Scanf.scanf "%d" (fun t ->
    let module M = Map.Make (struct type t = int let compare = compare end) in
    for i = 1 to t do
        Scanf.scanf " %d %d %d %d %d" (fun n a b c d ->
            let rec calc =
                let map = ref (M.add 0 0 (M.singleton 1 d)) in
                fun k ->
                if M.mem k !map then M.find k !map else (
                    let ans = if k < max_int / d then k * d else max_int in
                    let ans = List.fold_left (fun acc i ->
                        if (k + i) mod 2 <> 0 then acc else
                            min acc (calc ((k + i) / 2) + a + d * abs i)
                        ) ans [ -1; 0; 1 ]
                    in
                    let ans = List.fold_left (fun acc i ->
                        if (k + i) mod 3 <> 0 then acc else
                            min acc (calc ((k + i) / 3) + b + d * abs i)
                            ) ans [ -1; 0; 1 ]
                    in
                    let ans = List.fold_left (fun acc i ->
                        if (k + i) mod 5 <> 0 then acc else
                            min acc (calc ((k + i) / 5) + c + d * abs i)
                            ) ans [ -2; -1; 0; 1; 2 ]
                    in
                    map := M.add k ans !map;
                    ans
                  )
            in
            Printf.printf "%d\n" @@ calc n
        )
    done
)

Measured memory_bytes: 7796
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=1LL<<60;
const double EPS = 1e-10;
const ll mod=1000000007;
//const ll mod=998244353;

int main(void){
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    ll ans=max({b*d,a*c,a*d,b*c});
    cout<<ans<<endl;
}

Measured memory_bytes: 3600
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int n;
double a[54],cur;
int main() {
	scanf("%d",&n);
	for (int i=1;i<=n;++i)
		scanf("%lf",&a[i]);
	sort(a+1,a+n+1);
	cur=a[1];
	for (int i=2;i<=n;++i) {
		cur+=a[i];
		cur/=2;
	}
	printf("%.6lf\n",cur);
	return 0;
}

Measured memory_bytes: 256
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

n,m=map(int,input().split())
uf = UnionFind(n)

for i in range(m):
    a,b=map(int,input().split())
    uf.union(a-1,b-1)

ans=0
for i in range(n):
    ans=max(ans, uf.size(i))
print(ans)



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

int main(){
    string S;
    cin >> S;
    int len = S.length();
    int min = 1000;
    for(int i = 0; i < len-2; i++){
        string sub = S.substr(i,3);
        int num = atoi(sub.c_str());
        int tmp = abs(753-num);
        if(tmp < min) min = tmp;
    }
    cout << min << endl;
    
    return 0;
}

Measured memory_bytes: 256
use std::*;

fn read<T: str::FromStr>() -> T {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).ok();
    buf.trim().parse().ok().unwrap()
}

fn read_vec<T: str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|a| a.parse().ok().unwrap())
        .collect()
}

fn read_vec2d<T: str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

fn digit(n: u32) -> u32 {
    if n < 10 {
        1
    } else {
        digit(n / 10) + 1
    }
}

fn main() {
    let n: u32 = read();
    let ans: u32 = (1..n + 1).map(|n| digit(n) % 2).sum();
    println!("{}", ans);
}


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

int main() {
	int n;
	cin >> n;
	vector<pair<int,int>> p;
	for (int i = 0; i < n; i++) {
		int a, b;
		cin >> a >> b;
		p.push_back(make_pair(a, b));
	}

	vector<pair<int, int>> sub;
	int ans = INT_MAX;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			if (i == j) break;
			pair<int, int> s = make_pair(p[i].first - p[j].first, p[i].second - p[j].second);
			sub.push_back(s);
		}
	}

	for (auto s : sub) {
		int count = 0;
		for (auto e : p) {
			pair<int, int> x = make_pair(e.first + s.first, e.second + s.second);
			if (find(p.begin(), p.end(), x) != p.end()) {
				count++;
			}
			x = make_pair(e.first - s.first, e.second - s.second);
			if (find(p.begin(), p.end(), x) != p.end()) {
				count++;
			}
		}
		count /= 2;
		if (n - count < ans) ans = n - count;
	}

	if (n == 1) ans = 1;

	cout << ans << endl;

	return 0;
}

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


#define ll long long
#define int long long
#define pb push_back

#define loop(i, a, b) for(int i = (a); i < (b); i++)
#define loopb(i, a, b) for(int i = (a); i > (b); --i)

typedef pair <int,int> ii;
typedef vector <int> vi;
typedef vector <ii> vii;
typedef vector <ll> vl;

const int mod = 998244353;
const ll inf = 2e18+5;




signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
   
    int n,m;
    cin>>n>>m;
    int ans=0;
    ans+=n*(n-1)/2;
  ans+=m*(m-1)/2;
  cout<<ans<<endl;
    return 0;
}   

Measured memory_bytes: 256