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

#define  __  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define  int  long long
#define  endl  '\n'
const double pi = acos(-1);
const int mod = 1e9 + 7;
//______________________



int32_t main()
{ 
  __

  
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  
  for(int i = 0; i < n; i++)
    cin >> a[i];

  int inv = 0, dinv = 0;

  for(int i = 0; i < n; i++)
  {
    for(int j = 0; j < n; j++)
    {
       if(a[i] > a[j])
       {
         if(j > i)
            inv++;
         dinv++;
       }
    }
  }

  if(k == 1)
   return cout << inv, 0;
  
  int ans = (k * inv) % mod;

  int exinv = ((k * (k - 1) / 2) % mod * dinv) % mod;

  cout << (ans + exinv) % mod;
 return 0;
}

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

using namespace std;
typedef long long ll;
#define out(ans) cout << ans << endl;
const long long mod = 1e9 + 7;

int main() {
  ll a, b, c, k;
  cin >> a >> b >> c >> k;
  if (abs(a - b) > 1e18) {
    cout << "Unfair" << endl;
    return 0;
  }
  if (k % 2 == 0) {
    cout << a - b << endl;
  } else {
    cout << b - a << endl;
  }

  return 0;
}


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------


int N,S;
int A[3030];
const ll mo=998244353;
ll dp[3030];
void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>S;
	dp[0]=0;
	ll ret=0;
	FOR(i,N) {
		cin>>x;
		for(j=S-x;j>=0;j--) {
			if(j==0) (dp[x]+=i+1)%=mo;
			else (dp[x+j]+=dp[j])%=mo;
		}
		ret+=dp[S];
	}
	cout<<ret%mo<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
using namespace std;
const int tINF = (int)INT_MAX;
const long long lINF = (long long)LLONG_MAX;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	#ifdef DEBUG
			assert(freopen("inp", "r", stdin));
			assert(freopen("out", "w",stdout));
	#else
			#define cerr if(false)cerr
	#endif
    int n;
    cin >> n;
    cout << ceil(n / 2.0) << '\n';
   cerr << "Time execute: " << (double)clock() / (double)CLOCKS_PER_SEC 
    << " sec" << endl;
}

Measured memory_bytes: 256
n, k = map(int, input().split())

l = 0
u = 0
du = n
dl = 0
ans = 0
for i in range(n+1):
    l += dl
    u += du
    if i+1 >= k:
        ans += u-l+1
        ans %= 1000000007
    du -= 1
    dl += 1
assert(l == u)
print(ans)


Measured memory_bytes: 64592
#include <iostream>
#include <iomanip>
#include <math.h>
#include <stdlib.h>
using namespace std;
int main()
{
	int n, i, 
		x[100] = {}, 
		y[100] = {};

	double d = 0.0,
		   diff[100] = {};

	cin >> n;
	for( i = 0; i < n; ++i ) cin >> x[i];
	for( i = 0; i < n; ++i ) cin >> y[i];
	for( i = 0; i < n; ++i ) diff[i] = (double)abs( x[i] - y[i] );
	for( i = 0; i < n; ++i ) d += diff[i];

	cout << fixed << setprecision(5) << d << "\n";

	d = 0;
	for( i = 0; i < n; ++i )
		d += diff[i] * diff[i];
	d = sqrt( d );

	cout << fixed << setprecision(5) << d << "\n";

	d = 0;
	for( i = 0; i < n; ++i )
		d += pow( diff[i], 3.0 );
	d = pow( d, 1.0/3.0);

	cout << fixed << setprecision(5) << d << "\n";

	d = 0;
	for( i = 0; i < n; ++i )
		d = max( d, diff[i] );

	cout << fixed << setprecision(5) << d << "\n";

	return 0;
}

Measured memory_bytes: 1304
#include <bits/stdc++.h>
using std::cerr;
using std::endl;

const int N = 75 * 10, P = 1e9 + 7;

inline int fpow(int x, int y) {
  int ret = 1;
  for ( ; y; y >>= 1, x = 1ll * x * x % P)
    if (y & 1) ret = 1ll * ret * x % P;
  return ret;
}

int n, m, fac[N], inv[N];
char str[N];
int size[N];

inline int binom(int x, int y) {
  if (x < y || x < 0 || y < 0) return 0;
  return 1ll * fac[x] * inv[y] % P * inv[x - y] % P;
}

int val[N], tot;
int ans = 1;
int last[N];
bool vis[N];

inline bool check() {
  for (int i = 1; i <= m; ++i)
    vis[i] = 0, last[i] = 0;
  for (int i = 1, j = 1; i <= tot; ++i) {
    while (j <= m && str[j] != 'r') ++j;
    if (j > m) return 0;
    last[i] = j, vis[j] = 1;
    ++j;
  }
  for (int i = 1, j = 1; i <= tot; ++i) {
    if (val[i] == 1) continue;
    if (j <= last[i]) j = last[i] + 1;
    while (j <= m && str[j] != 'b') ++j;
    if (j > m) return 0;
    last[i] = j, vis[j] = 1;
    ++j;
  }

  for (int i = 1, j = 1; i <= tot; ++i) {
    if (val[i] <= 2) continue;
    if (j <= last[i]) j = last[i] + 1;
    for (int k = val[i] - 2; k; --k) {
      while (j <= m && vis[j]) ++j;
      if (j > m) return 0;
      vis[j] = 1, ++j;
    }
  }
  return 1;
}

void dfs(int left, int high) {
  if (check()) {
    int sum = tot + 1;
    for (int i = 1; i <= tot; ++i) {
      sum += size[val[i]];
      if (val[i] > 1) sum += 2;
    }
    int way = 1ll * binom(sum + left - 1, left);
    way = 1ll * way * fac[tot] % P;
    for (int i = 1, j = 1; i <= tot; i = j) {
      while (j <= tot && val[i] == val[j])
        ++j;
      way = 1ll * way * inv[j - i] % P;
    }
    ans = (ans + way) % P;
  }
  for (int i = 1; i <= high; ++i) {
    if (size[i] + 1 > left) break;
    val[++tot] = i;
    dfs(left - size[i] - 1, i);
    --tot;
  }
}

int main() {
  for (int i = fac[0] = 1; i < N; ++i)
    fac[i] = 1ll * fac[i - 1] * i % P;
  inv[N - 1] = fpow(fac[N - 1], P - 2);
  for (int i = N - 1; i; --i)
    inv[i - 1] = 1ll * inv[i] * i % P;
  scanf("%d %d %s", &n, &m, str + 1);
  size[1] = size[2] = 1;
  for (int i = 3; i < N; ++i)
    size[i] = size[i - 1] + 2;
  for (int i = 1; ; ++i) {
    if (size[i] > n) break;
    val[tot = 1] = i;
    dfs(n - size[i], i);
  }
  std::cout << ans << std::endl;
  return 0;
}


Measured memory_bytes: 3824
package main

import "fmt"

func main () {
  var A,B int
  var S string
  fmt.Scan(&A,&B,&S)

  // if S[A+1:A+2] == "-"{
  //   for
  // }
  result := 1
  for i:=0; i<A+B+1; i++ {
    if i == A{
      if S[i:i+1] != "-"{
        result = 0
      }
    } else {
      if S[i:i+1] == "-"{
        result = 0
      }
    }
  }
  if result == 0{
    fmt.Println("No")
  }else{
    fmt.Println("Yes")
  }
  
}


Measured memory_bytes: 512
require 'prime'

n = gets.to_i

class Integer
    def divisor_list
        return [] if self <= 0
        return [1] if self == 1
  
        prime_division.map.with_index { |(base, k), i|
            s = i.zero? ? 0 : 1
            (s..k).map { |n| base ** n }
        }.inject { |res, e| res + res.flat_map { |t| e.map { |v| t * v } } }.sort
    end
end
  
ans = 0
list = n.divisor_list
list.each do |i|
    m = i - 1
    if m != 0
        if n / m == n % m
            ans += m
        end
    end
end

puts ans

Measured memory_bytes: 2428
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<int> a(n), b(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
        a[i]--;
    }
    int k = 0;
    int count = 0;
    do{
        k = a[k];
        b[k]++;
        if(b[k] == 2) k = 0;
        count++;
    }while(k != 0 && k != 1);
    if(k == 1) cout << count;
    else cout << -1;
}


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

const int INF = 1e+8;
int n, ans;
string a[10], b[10], start, goal;

void dfs(const string &s, int cnt){
	if( s == goal ){
		ans = min(ans, cnt);
		return ;
	}
	if( goal.size() <= s.size() || ans < cnt || 10 < cnt) return;
	
	for(int i=0 ; i < n ; i++ ){
		string t = s;
		int pos = 0;
		while( true ){
			pos = t.find(a[i], pos);
			if( pos == string::npos ){
				break;
			}else{
				t.replace(pos, a[i].size(), b[i]);
			}
			pos = pos + b[i].size();
		}
		if( t != s ){
			dfs(t, cnt+1);
		}
	}
}

int main(){
	while( cin >> n, n ){
		for(int i=0 ; i < n ; i++ ){
			cin >> a[i] >> b[i];
		}
		cin >> start >> goal;
		ans = INF;
		dfs(start, 0);
		if( ans == INF ) ans = -1;
		cout << ans << endl;
	}	
}

Measured memory_bytes: 1232
#include <iostream>
#include <algorithm>
#include <cstring>

#define REP(i, a, b) for ( int i = (a); i < (b); i++ )
#define REVREP(i, a, b) for ( int i = (a); i >= (b); i--)
#define DEBUG_INT(var) printf("the value of "#var" is %d\n", var)
#define PRINT_ARRAY(name, i) printf("the value of "#name"[%d] is %d\n", (i), name[(i)])
#define DEBUG_ARRAY(name, begin, end) REP(i, begin, end) PRINT_ARRAY(name, i)

#define YES puts("YES")
#define NO  puts("NO")
#define Yes puts("Yes")
#define No  puts("No")

using namespace std;

typedef long long ll;

int N;

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

  
    printf("%d\n", N*N*N);

	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 P = pair<int, int>;

int n, m, q;
vector<int> a, b, c, d;
int ans;

void dfs(vector<int> A) {
  if (A.size() == n + 1) {
    int now = 0;
    rep(i, q) if (A[b[i]] - A[a[i]] == c[i]) now += d[i];
    ans = max(ans, now);
    return;
  }

  A.push_back(A.back());
  while (A.back() <= m) {
    dfs(A);
    A.back()++;
  }
}

int main() {
  cin >> n >> m >> q;
  a = b = c = d = vector<int>(q);
  rep(i, q) cin >> a[i] >> b[i] >> c[i] >> d[i];
  dfs(vector<int>(1, 1));
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3580
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <math.h>
#include <cmath>
#include <set>   
//#include <boost/math/common_factor_rt.hpp>

#define ll long long

using namespace std;

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

	for (int i = 1; i <= k; i++)
	{
		if (i % 2 != 0) {
			if (a % 2 != 0) {
				a -= 1;
			}
			b += a / 2;
			a = a / 2;
		}
		else {
			if (b % 2 != 0) {
				b -= 1;
			}
			a += b / 2;
			b = b / 2;
		}
	}

	cout << a << " " << b << endl;
}

int dsum(ll a) {
	int ans = 0;
	while (a != 0) {
		ans += a % 10;
		a /= 10;
	}
	return ans;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
    ll x;
    cin>>x;
    return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
} 

ll modPow(ll a, ll x, ll p) {
    //calculates a^x mod p in logarithmic time.
    ll res = 1;
    while(x > 0) {
        if( x % 2 != 0) {
            res = (res * a) % p;
        }
        a = (a * a) % p;
        x /= 2;
    }
    return res;
}

ll modInverse(ll a, ll p) {
    //calculates the modular multiplicative of a mod m.
    //(assuming p is prime).
    return modPow(a, p-2, p);
}
ll modBinomial(ll n, ll k, ll p) {
// calculates C(n,k) mod p (assuming p is prime).

    ll numerator = 1; // n * (n-1) * ... * (n-k+1)
    for (int i=0; i<k; i++) {
        numerator = (numerator * (n-i) ) % p;
    }

    ll denominator = 1; // k!
    for (int i=1; i<=k; i++) {
        denominator = (denominator * i) % p;
    }

    // numerator / denominator mod p.
    return ( numerator* modInverse(denominator,p) ) % p;
}

ll f[200001];
 
ll pow(ll a, ll b, ll MOD)
{
 ll x=1,y=a; 
 while(b > 0)
    {
        if(b%2 == 1)
    {
        x=(x*y);
        if(x>MOD) x%=MOD;
    }
    y = (y*y);
    if(y>MOD) y%=MOD; 
    b /= 2;
    }
 return x;
}
 
/* Modular Multiplicative Inverse
 Using Euler's Theorem
 a^(phi(m)) = 1 (mod m)
 a^(-1) = a^(m-2) (mod m) */
ll InverseEuler(ll n, ll MOD)
{
 return pow(n,MOD-2,MOD);
}
 
ll C(ll n, ll r, ll MOD)
{
 
 return (f[n]*((InverseEuler(f[r], MOD) * InverseEuler(f[n-r], MOD)) % MOD)) % MOD;
}
 


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n=nxt();
    vector <ll> v(n);
    generate(all(v),nxtl);
    sort(all(v));
    if(v[0]==0){
        cout<<"0\n";
        return 0;
    }
    ll test=1;
    ll mx=1e18;
    for(auto i:v){
        if(mx/test<i)
        {
            cout<<"-1\n";
            return 0;
        }
        test*=i;
    }
    cout<<test<<endl;


    return 0;   
}


 
 


Measured memory_bytes: 3956
S = gets.chomp
H = S.size

goal = [-1] * H
que = []

(H - 1).times do |i|
  next if S[i] != "R" || S[i + 1] != "L"
  goal[i] = i
  goal[i + 1] = i + 1
  que.push(i)
  que.push(i + 1)
end

until que.empty?
  n = que.pop
  if n >= 2 && S[n - 1] == "R" && S[n - 2] == "R" && goal[n - 2] == -1
    goal[n - 2] = goal[n]
    que.push(n - 2)
  end

  if n < H - 2 && S[n + 1] == "L" && S[n + 2] == "L" && goal[n + 2] == -1
    goal[n + 2] = goal[n]
    que.push(n + 2)
  end
end

ans = [0] * H
goal.each do |g|
  ans[g] += 1
end
puts ans.join(" ")





Measured memory_bytes: 4088
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<cstring>
#include<string>
#include<iomanip>
#include<map>
#include<fstream>
#include<queue>
#include<stack>

using namespace std;

int a[100010];


int main()
{
	int n, t, c;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> t;
		a[t]++;
	}
	sort(a, a +100001, greater<int>());

	t = 0;
	//2m+1を1にする
	for (int i = 0; i < n; i++) {
		if (a[i] >= 3 && a[i] % 2 == 1)
			a[i] = 1;
	}

	//4以上を2にする
	for (int i = 0; i < n; i++) {
		if (a[i] >= 4)
			a[i] = 2;
	}

	sort(a, a +100001, greater<int>());

	//2のうち1にできるものをさがす
	for (int i = 0; i < n; i++) {
		if (a[i] == 2 && a[i + 1] == 2) {
			a[i] = 1;
			a[i + 1] = 1;
		}
	}

	//2枚残っているものがないかさがす
	for (int i = 0; i < n; i++) {
		if (a[i] == 2) {
			a[i] = 0;
		}
	}

	//数える
	c = 0;
	for (int i = 0; i < n; i++) {
		if (a[i] >= 1)
			c++;
	}
	cout << c << endl;
}

Measured memory_bytes: 640
#include<stdio.h>

int main(void){
    int s;
    int h, m;
    scanf("%d", &s);
    h = s / 3600;
    s = s % 3600;
    m = s / 60;
    s = s % 60;
    printf("%d:%d:%d\n", h, m, s);
    return 0;
}


Measured memory_bytes: 2108
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;(i)--)
#define rrep1(i,n) for(int i=((int)(n));i>0;(i)--)
#define sz(c) ((int)(c).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> P;
typedef pair<int, pair<int, int> > PP;
const int MAX=1e5+10;
const int INF=1e9;

vector<int> G[3*MAX];
int N,M;
int S,T;
void input(){
	cin>>N>>M;
	rep(_,M){
		int u,v;
		cin>>u>>v;
		u--, v--;
		G[3*u].pb(3*v+1);
		G[3*u+1].pb(3*v+2);
		G[3*u+2].pb(3*v);
	}
	cin>>S>>T;
	S=(S-1)*3;
	T=(T-1)*3;
}

int d[3*MAX];

void solve(){
	rep(i,3*N)d[i]=INF;
	queue<P> q;
	q.push(mp(0,S));
	d[S]=0;
	while(!q.empty()){
		P p=q.front();
		q.pop();
		int dist=p.first;
		int v=p.second;
		rep(i,sz(G[v])){
			int u=G[v][i];
			if(d[u]!=INF)continue;
			d[u]=dist+1;
			q.push(mp(dist+1, u));
		}
	}
	if(d[T]==INF)cout<<-1<<endl;
	else cout<<d[T]/3<<endl;
}


int main(){
  input();
  solve();
}

Measured memory_bytes: 17792
N = int(input())
p = list(map(int, input().split()))

count = []
tmp_num = 0

for p_n in p:
    dif = p_n - tmp_num
    if dif < 0:
        count.append(abs(dif))
    tmp_num = p_n

if len(count) == 0:
    print("YES")
elif len(count) == 2:
    if count[0] == count[1]:
        print("YES")
    else:
        print("NO")
else:
    print("NO")

Measured memory_bytes: 3064
#include <stdio.h>

 

int main(void){
	int N;
	float a, b;
	do{
	scanf("%d", &N);
}while(N<=0 || N > 100);
	if(N % 2 == 0){
		b = N / 2;
	}
	if(N % 2 != 0){
		b = (N / 2) +1;
	}
	
	if (N == 1){
		printf("1");
	}
	a = b / N;
	if(N > 1){
		printf("%f", a);
	}
	return 0;
}


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


// type definitions
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< vi > vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
typedef complex<int> ci;
typedef complex<double> cd;
typedef complex<long double> cld;

// macros
#define rep(i, a, b) for(int i=a; i<b; i++)
#define TIME clock() * 1.0 / CLOCKS_PER_SEC
#define all(c) c.begin(), c.end()
#define tr(c, it) for(auto it=(c).begin(); it!=c.end(); it++)
#define pb push_back
#define bitcount __builtin_popcount
#define ispresent(c, x) ((c).find(x) != (c).end())
#define watch(x) cout<< (#x) << " is " << (x) <<"\n";
#define sz(x) ((int)((x).size()))
#define UNIQUE(c) (c).resize(unique(all(c)) - (c).begin())
#define pii2ll(p) ((ll)(p).first<<32 | (p).second)

// template functions
template <typename T>
inline void printV(vector<T>& a) { rep(i, 0, sz(a)) { cout<<a[i]<<" "; } cout<<"\n"; }
template <typename T>
inline void printV(vector<T>& a, int n) { rep(i, 0, n) { cout<<a[i]<<" "; } cout<<"\n"; }
template <typename T>
inline void printVV(vector<vector<T>>& a)
{
	rep(i, 0, sz(a)) {
		printV(a[i]);
	}
	cout<<"\n";
}

template <typename T>
inline void clearVV(vector<vector<T>>& a)
{
	for(auto& x:a) {
		x.clear();
	}
	a.clear();
}
template <typename T>
inline void assignVV(vector<vector<T>> &a, T val)
{
	for(int i=0; i<sz(a); i++) {
		for(int j=0; j<sz(a[i]); j++) {
			a[i][j]=val;
		}
	}
}


// constants
const long double eps = 1e-9;
const int inf = 5e8;
const int modn = 1e9+7;
const int MAX = 301;
typedef long double ld;

ld dp[MAX][MAX][MAX];
int n;

ld solve(int sum1, int sum2, int sum3)
{
	if(sum1<0 or sum2<0 or sum3<0) return (ld)0;
	if(sum1==0 and sum2==0 and sum3==0) return (ld)0;
	ld &memo=dp[sum1][sum2][sum3];
	if(fabs(dp[sum1][sum2][sum3]+1)>eps) return memo;
	memo=(ld)n/(sum1+sum2+sum3);
	ld tmp=1+solve(sum1-1, sum2, sum3)*sum1/n+solve(sum1+1, sum2-1, sum3)*sum2/n+solve(sum1, sum2+1, sum3-1)*sum3/n;
	memo*=tmp;
	return memo;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    // Your code here
    cout<<fixed<<setprecision(10);
    cin>>n;
    vector<int> a(n);
    
    for(int i=0; i<=n; i++) {
		for(int j=0; j<=n; j++) {
			for(int k=0; k<=n; k++) {
				dp[i][j][k]=-1;
			}
		}
    }
    int s1=0;
    int s2=0;
    int s3=0;
    for(int i=0; i<n; i++) {
		cin>>a[i];
		if(a[i]==1) {
			s1++;
		}
		if(a[i]==2) {
			s2++;
		}
		if(a[i]==3) {
			s3++;
		}
    }
    
    cout<<solve(s1, s2, s3)<<"\n";
    //~ watch(TIME);
    return 0;
}



Measured memory_bytes: 426496
#include<cstdio>
#include<cmath>
#include<string>
#include<vector>
#include<algorithm>

#define MOD 1000000007

using namespace std;

int main()
{
	int n;

	scanf("%d", &n);

	int cnt[3] = { 0, };

	long long sol = 1;

	for (int i = 0; i < n; i++)
	{
		int input;

		scanf("%d", &input);

		long long mult = 0;
		int ptr = -1;

		for (int j = 0; j < 3; j++)
		{
			if (cnt[j] == input)
			{
				mult++;

				ptr = j;
			}
		}

		if (ptr == -1)
		{
			printf("0\n");

			return 0;
		}

		sol = sol*mult%MOD;

		cnt[ptr]++;
	}

	printf("%lld\n", sol);

	return 0;
}

Measured memory_bytes: 128
// 2011/03/23 Tazoe

#include <iostream>
#include <string>
using namespace std;

int main()
{
	string trn[7][6] = {{"/", "/", "/", "/", "/", "/"},
	                    {"/", "a", "b", "c", "d", "e"},
	                    {"/", "f", "g", "h", "i", "j"},
	                    {"/", "k", "l", "m", "n", "o"},
	                    {"/", "p", "q", "r", "s", "t"},
	                    {"/", "u", "v", "w", "x", "y"},
	                    {"/", "z", ".", "?", "!", " "}};

	while(!cin.eof()){
		string str;
		cin >> str;
		if(str.empty())
			continue;

		string str2 = "";
		int i = 0;
		while(i<str.size()){
			if(str[i]<'1'||str[i]>'6'){
				str2 = "NA";
				break;
			}

			int j = str[i]-'0';

			i++;
			if(i>=str.size()){
				str2 = "NA";
				break;
			}

			if(str[i]<'1'||str[i]>'5'){
				str2 = "NA";
				break;
			}

			int k = str[i]-'0';
			str2 += trn[j][k];

			i++;
		}

		cout << str2 << endl;
	}

	return 0;
}

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

int main() {
	int n, l;
	cin >> n >> l;
	string s[n];
	for (int i = 0; i < n; i++) {
		cin >> s[i];
	}
	sort(s, s + n);
	for (int i = 0; i < n; i++) {
		cout << s[i];
	}
	cout << endl;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
  
int main() {
  int A,B; 
  cin>>A>>B;

  if(A==1){
    if(B==1){
      cout<<"Draw"<<endl;
    }
    else{
      cout<<"Alice"<<endl;
    }
  }
  if(B==1){
    if(A==1){
    }
    else{
      cout<<"Bob"<<endl;
    }
  }
  if(B!=1 && A!=1){
    if(A==B){
      cout<<"Draw"<<endl;
    }
    if(A<B){
       cout<<"Bob"<<endl;
    }
    if(B<A){
       cout<<"Alice"<<endl;
    }
  }
}

Measured memory_bytes: 256
def input():
    import sys
    return sys.stdin.readline().rstrip()


def main():
    import math
    import collections
    import itertools

    n, T = map(int, input().split())
    ts = list(map(int, input().split()))

    # last_time = ts[0]
    ans = T
    for i in range(1, n):
        ans += min(ts[i] - ts[i - 1], T)

    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 26084
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
int main(){
    int l;
    cin >> l;
    cout << fixed << setprecision(12) << pow(l/3.0,3);


    return 0;
}

Measured memory_bytes: 4184
import java.util.*;
public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String str1 = sc.nextLine();
        String str2 = sc.nextLine();
        int n1 = str1.length();
        int n2 = str2.length();
        int min_count = Integer.MAX_VALUE,count = 0;
        for(int i = 0;i<=n1-n2;i++){
            if(str1.substring(i,i+n2).equals(str2)){
                min_count = 0;
                break;
            }
            else{
                count = 0;
                for(int j = i;j<i+n2;j++){
                    if(str1.charAt(j) != str2.charAt(j-i))
                        count++;
                }    
            }
            min_count = Math.min(count,min_count);
            //System.out.print(min_count + " ");
        }
        //System.out.println();
        System.out.println(min_count);
    }
}

Measured memory_bytes: 36900
#include <float.h>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

// 内部定数
#define D_MAX_VAL		100000									// 最大値

// 内部変数
static FILE *szpFpI;											// 入力
static int siN, siK;											// N, K
static double sd1Rate[D_MAX_VAL];								// 確率

// 内部変数 - テスト用
#ifdef D_TEST
	static int siRes;
	static FILE *szpFpA;
	static int siTNo;
#endif

// 出力
int
fOut(
	char *pcpLine				// <I> １行
)
{
	char lc1Buf[1024];

#ifdef D_TEST
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, pcpLine)) {
		siRes = -1;
	}
#else
	printf("%s", pcpLine);
#endif

	return 0;
}

// 確率 - 取得
double
fGetRate(
	int piVal					// <I> 値
)
{
	// 範囲外
	if (piVal >= siK) {
		return 1.0;
	}

	// 取得済
	if (sd1Rate[piVal] > 0.0) {
		return sd1Rate[piVal];
	}

	// 確率 - セット
	if (piVal * 2 >= siK) {
		sd1Rate[piVal] = 0.5;
	}
	else {
		sd1Rate[piVal] = fGetRate(piVal * 2) * 0.5;
	}

	return sd1Rate[piVal];
}

// 実行メイン
double
fMain(
)
{
	int i;
	char lc1Buf[1024];

	// N, K - 取得
	fgets(lc1Buf, sizeof(lc1Buf), szpFpI);
	sscanf(lc1Buf, "%d%d", &siN, &siK);

	// 確率 - 取得
	double ldSum = 0.0;
	for (i = 1; i <= siN; i++) {
		ldSum += fGetRate(i);
	}
	ldSum /= (double)siN;

	return ldSum;
}

// １回実行
int
fOne(
)
{
	double ldRet;
	char lc1Buf[1024];

	// データ - 初期化
	memset(sd1Rate, 0, sizeof(sd1Rate));						// 確率

	// 入力 - セット
#ifdef D_TEST
	sprintf(lc1Buf, ".\\Test\\T%d.txt", siTNo);
	szpFpI = fopen(lc1Buf, "r");
	sprintf(lc1Buf, ".\\Test\\A%d.txt", siTNo);
	szpFpA = fopen(lc1Buf, "r");
	siRes = 0;
#else
	szpFpI = stdin;
#endif

	// 実行メイン
	ldRet = fMain();

	// 出力
	sprintf(lc1Buf, "%.10lf\n", ldRet);
	fOut(lc1Buf);

	// 残データ有無
#ifdef D_TEST
	lc1Buf[0] = '\0';
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, "")) {
		siRes = -1;
	}
#endif

	// テストファイルクローズ
#ifdef D_TEST
	fclose(szpFpI);
	fclose(szpFpA);
#endif

	// テスト結果
#ifdef D_TEST
	if (siRes == 0) {
		printf("OK %d\n", siTNo);
	}
	else {
		printf("NG %d\n", siTNo);
	}
#endif

	return 0;
}

// プログラム開始
int
main()
{

#ifdef D_TEST
	int i;
	for (i = D_TEST_SNO; i <= D_TEST_ENO; i++) {
		siTNo = i;
		fOne();
	}
#else
	fOne();
#endif

	return 0;
}



Measured memory_bytes: 896
#include <iostream>
#include <string>

using namespace std;

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

    int ans = 0, dir = 0;
    char pre;
    for (char c : S) {
        if (dir == 0) {
            pre = c;
        }

        (dir += (c == 'R' ? 1 : 3)) %= 4;

        if (dir == 0) {
            if (pre == 'R' && c == 'R') ++ans;
        }
    }
    cout << ans << endl;
    return 0;
}



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

int main() {
    string s;
    cin >> s;
    int16_t l = s.length();

    int64_t answer = 0;
    int64_t acc;
    for (int16_t b = 0; b < 1 << (l - 1); b++) {
        acc = s[0] - '0';
        for (int16_t i = 1; i <= l - 1; i++) {
            if (b & (1 << (l - i - 1))) {
                answer += acc;
                acc = s[i] - '0';
            } else {
                acc = acc * 10 + (s[i] - '0');
            }
        }
        answer += acc;
    }
    cout << answer << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for((i)=0;(i)<(int)(n);(i)++)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;

const int Maxn = 100010;

P cost[Maxn];
ll sum[Maxn];

int main(){
    int h, w, d;
    cin >> h >> w >> d;
    for (int i = 0; i < h; i++){
        for (int j = 0; j < w; j++){
            int x;
            cin >> x;
            cost[x].first = i;
            cost[x].second = j;
        }
    }

    for (int i = h * w - d; i >= 1; i--){
        sum[i] = sum[i + d] + abs(cost[i].first - cost[i + d].first) + abs(cost[i].second - cost[i + d].second);
    }

    int q;
    cin >> q;
    for (int i = 0; i < q; i++){
        int l, r;
        cin >> l >> r;
        cout << sum[l] - sum[r] << endl;
    }
    
    return 0;
}

Measured memory_bytes: 3200
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SZ(x) ((int)x.size())
#define FOR(i,a,b) for (int i=a;i<=b;++i)
#define FORD(i,a,b) for (int i=a;i>=b;--i)
using namespace std;
typedef long long LL;
typedef pair<int,int> pa;
typedef vector<int> vec;
void getint(int &v){
    char ch,fu=0;
    for(ch='*'; (ch<'0'||ch>'9')&&ch!='-'; ch=getchar());
    if(ch=='-') fu=1, ch=getchar();
    for(v=0; ch>='0'&&ch<='9'; ch=getchar()) v=v*10+ch-'0';
    if(fu) v=-v;
}
bool e[500010],ee,ok[500010];
int n,las[500010],nxt[500010],s[500010],a[500010],ans,bit[500010],k,top,stk[500010];
int lowbit(int x){
	return x&-x;
}
void add(int x){
	for (;x<=n;x+=lowbit(x)) ++bit[x];
}
int que(int x){
	int t=0;
	for (;x;x-=lowbit(x)) t+=bit[x];
	return t;
}
int main(){
	cin>>n>>k;
	FOR(i,1,n) getint(a[i]),++a[i];
	top=0;
	stk[0]=0;
	FOR(i,1,n){
		while (top>0 && a[stk[top]]<a[i]) --top;
		las[i]=stk[top];
		stk[++top]=i;
	}
	stk[0]=n+1;
	FORD(i,n,1){
		while (top>0 && a[stk[top]]>a[i]) --top;
		nxt[i]=stk[top];
		stk[++top]=i;
	}
	FOR(i,2,n) if (a[i]>a[i-1]) ok[i]=1;
	s[0]=1;
	FOR(i,1,n) s[i]=s[i-1]+ok[i];
	FOR(i,1,n-k+1) e[i]=(s[i+k-1]-s[i]==k-1);
	ans=1;
	if (e[1]) ee=1;
	FOR(i,2,n-k+1){
		if (e[i-1] && e[i]) continue;
		if (e[i-1] && !e[i]){++ans;ee=1;continue;}
		if (!e[i-1] && e[i]){if (ee) continue;++ans;ee=1;continue;}
		if (nxt[i-1]>=i+k-1 && las[i+k-1]<i) continue;
		++ans;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 10624
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <cctype>
#define rep(i, m, n) for(int i = m;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define ll long long
#define ull unsigned long long
#define push(a) push_back(a)
#define pop(a) pop_back(a)
#define debug(x) cout<<#x<<": "<<x<<endl
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

int main(){
  int n, x, x_max=0;
  string s;
  cin >> n >> s;
  rep(i,0,n){
    if(s[i] == 'I'){
      x++;
    }else if(s[i] == 'D'){
      x--;
    }
    x_max = max(x_max, x);
  }
  cout << x_max << endl;
}


Measured memory_bytes: 256
import sys
import numpy as np
import numba
from numba import njit
i8 = numba.int64

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

@njit((i8[:], ), cache=True)
def main(S):
    N = len(S)
    L = np.empty(N, np.int64)
    R = np.empty(N, np.int64)

    x = y = 0
    n = 0
    for s in S:
        if s == 0:
            y += 1
        elif s == 1:
            if y:
                y -= 1
            else:
                x += 1
        else:
            L[n], R[n] = x, y
            n += 1
            x = y = 0

    L, R = L[:n], R[:n]
    L1, R1 = L[L > R], R[L > R]
    L2, R2 = L[L <= R], R[L <= R]

    ind = R1.argsort()
    L1, R1 = L1[ind], R1[ind]

    ind = L2.argsort()[::-1]
    L2, R2 = L2[ind], R2[ind]

    L = np.concatenate((L1, L2))
    R = np.concatenate((R1, R2))

    n = 0
    for i in range(len(L)):
        if n < R[i]:
            return False
        n += L[i] - R[i]
    return n == 0

N = int(readline())
S = np.array(list(read()), np.int64) - ord('(')

print('Yes' if main(S) else 'No')

Measured memory_bytes: 167740
#include<stdio.h>
#include<stdlib.h>

int main()
{
	int a,b;
	scanf("%d %d",&a,&b);
	
	if(a>b){
		printf("a > b\n");
	}
	
	if(a<b){
		printf("a < b\n");
	}
	
	if(a==b){
		printf("a == b\n");
	}
	
	return 0;
}


Measured memory_bytes: 2000
#define _CRT_SECURE_NO_WARNINGS
#pragma GCC optimize("O3") 
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx") 
#define __USE_MINGW_ANSI_STDIO 0
#define _USE_MATH_DEFINES
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include<stdio.h>
#include<iomanip>
#include<set>
#include<string>
#include<map>
#include <math.h>
#include<queue>
#include<complex>
#include<ctime>
#include<list>
#include<stack>
#define ll  long long
#define lll __int128
#define fi first
#define ld long double
#define se second
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vi vector<int>
#define vll vector<ll>
#define vii vector<vector<int>>
using namespace std;
ll a,b;
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
    cin >> a >> b;
    cout << a*b;
  return  0;    
}

Measured memory_bytes: 3196
#include <bits/stdc++.h>
#define int long long
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define rep(i,a,n) for(int i=a;i<n;i++)
#define repr(i,a,n) for(int i=a;i>n;i--)
#define leng(n) (int)(log10(n)+1)
#define INF 9000000000000000000
using namespace std;

int gcd(int a,int b){return b?gcd(b,a%b):a;}  //  最大公約数gcd
int lcm(int a,int b){return a/gcd(a,b)*b;}  //  最小公倍数lcm

signed main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,0,n) cin >> a[i];
  sort(ALL(a));
  cout << a[n-1] - a[0] << endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	 public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		String t = sc.next();
		
		int sL = s.length()+1;
		int tL = t.length()+1;
				
		//dp i j - lcs for s from 1 to i and t from 1 to j
		int[][] dp = new int[sL][tL];
		
		for(int i = 1; i < sL; i++) {
			for(int j = 1; j < tL; j++) {
				if(s.charAt(i-1) == t.charAt(j-1)) {
					dp[i][j] = dp[i-1][j-1] + 1;
				}else {
					dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
				}
			}
		}
		
		int lcsLen = dp[sL-1][tL-1];
		char[] res1 = new char[lcsLen+1];
		
		int i = sL-1;
		int j = tL-1;
		int index = lcsLen;
		while(i > 0 && j > 0) {
			if(s.charAt(i-1) == t.charAt(j-1)) {
				res1[index] = s.charAt(i-1);
				i--;
				j--;
				index--;
			}else if(dp[i-1][j] > dp[i][j-1]) {
				i--;
			}else {
				j--;
			}
		}
		String lcs = "";
		for(int k = 1; k < res1.length; k++) {
			lcs += res1[k];
		}
		
		System.out.println(lcs);
		
		
	}
	 
	static int max(int a, int b) {
		return a > b ? a : b;
	}
	 
	 

}

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

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string n;
  cin >> n;
  string ans;
  ans = "ABC" + n;
  cout << ans << endl;
  return 0;
}


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

typedef unsigned long long	ull;
const size_t			MaxN = 5005;
const int			Mod = 1000000007;

int fexp(int base, int exp)
{
	int	res = 1;
	for(; exp; exp >>= 1, base = (ull) base * base % Mod)
		if(exp & 1)
			res = (ull) res * base % Mod;
	return res;
}

int	N, D[MaxN];
int	Fac[MaxN], Inv[MaxN], F[MaxN][2];

bool all2()
{
	for(int i = 1; i <= N; ++i)
		if(D[i] != 2)
			return false;
	return true;
}

int main()
{
	scanf("%d", &N);
	for(int i = 1; i <= N; ++i)
		scanf("%d", D + i);

	Fac[0] = 1;
	for(int i = 1; i <= N; ++i)
		Fac[i] = (ull) Fac[i - 1] * i % Mod;
	Inv[N] = fexp(Fac[N], Mod - 2);
	for(int j = N - 1; ~j; --j)
		Inv[j] = (ull) Inv[j + 1] * (j + 1) % Mod;
	int	inv2 = Inv[2];

	if(all2())
		printf("%llu\n", (ull) Fac[N - 1] * inv2 % Mod);
	else {
		F[0][0] = 1;
		for(int i = 1; i <= N; ++i) {
			for(int j = i - 1; ~j; --j) {
				if(F[j][0]) {
					if(D[i] >= 2)
						F[j + 1][0] = (F[j + 1][0] + (ull) F[j][0] * Inv[D[i] - 2]) % Mod;
					if(D[i] >= 3)
						F[j + 1][1] = (F[j + 1][1] + (ull) F[j][0] * Inv[D[i] - 3]) % Mod;
					F[j][0] = (ull) F[j][0] * Inv[D[i] - 1] % Mod;
				}
				if(F[j][1]) {
					if(D[i] >= 2)
						F[j + 1][1] = (F[j + 1][1] + (ull) F[j][1] * Inv[D[i] - 2]) % Mod;
					F[j][1] = (ull) F[j][1] * Inv[D[i] - 1] % Mod;
				}
			}
		}
		int	ans = 0;
		for(int i = 3; i <= N; ++i)
			ans = (ans + (ull) F[i][1] * Fac[N - i - 1] % Mod * Fac[i - 1] % Mod * inv2) % Mod;
		printf("%d\n", ans);
	}

	return 0;
}


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

typedef long long int ll;

ll cnt=0;

void prime(ll x)
{
	ll ans=0;
	while(x%2==0)
	{
		ans++;
		x=x/2;
	}

	cnt+=(-1+sqrt(1+8*ans))/2;

	for(ll i=3;i*i<=x;i+=2)
	{
		ans=0;
		while(x%i==0)
		{
			ans++;
		x=x/i;
		}
		cnt+=(-1+sqrt(1+8*ans))/2;
	}

	if(x>2)
	{
		cnt++;
	}
}

int main()
{
	ll n;
	scanf("%lld",&n);
	prime(n);
	printf("%lld\n",cnt);
}




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

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> H(N), A(M), B(M);
    for(int i=0; i<N; i++) cin >> H[i];
    for(int i=0; i<M; i++) cin >> A[i] >> B[i];
    set<int> st;
    for(int i=1; i<=N; i++) st.insert(i);


    for(int i=0; i<M; i++) {
        int na = H[A[i]-1];
        int nb = H[B[i]-1];
        if(na < nb) st.erase(A[i]);
        if(na > nb) st.erase(B[i]);
        if(na == nb) {
            st.erase(A[i]);
            st.erase(B[i]);
        }
    }
    cout << st.size() << endl;
}

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

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  rep(i, 0, N) {
    cin >> A[i];
  }

  int ans = A[0];
  rep(i, 0, N) {
    ans = __gcd(ans, A[i]);
  }
  cout << ans << endl;
};


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

int main() {
  int64_t N, A[5], minN = 1000000000000000, minM = 5;
  cin >> N;
  for(int i=0;i<5;i++) {
    cin >> A[i];
    if(A[i] < minN) {
      minN = A[i];
      minM = i;
    }
  }
  int64_t ans = 10000000000000000;
  if(N % minN !=0){
    ans = 5 + N / minN;
    cout << ans << endl;
  }
  else {
    ans = 4 + N/ minN;
    cout << ans << endl;
  }
}
    
    

Measured memory_bytes: 256
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
MOD = 10**9 + 7

a,b = map(int,input().split())
if a + b>=24:
    print(a+b-24)
else:
    print(a + b)

Measured memory_bytes: 3316
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

A = INT()
B = INT()
C = INT()
D = INT()

print(min(A, B)+min(C, D))


Measured memory_bytes: 3896
#include <iostream>
#include <sstream>
#include <stack>
#include <iomanip>
#include <numeric>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >
#define endl '\n'

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

template<class U, class V>
istream& operator >>(istream& in, pair<U, V>& pr) {
    return in >> pr.first >> pr.second;
}

template<class U, class V>
ostream& operator <<(ostream& out, pair<U, V>& p) {
    return out << p.first << " " << p.second;
}

template<class T>
ostream& operator <<(ostream& out, vector<T> vec) {
    for (T& e : vec)
        out << e << " ";
    return out << endl;
}

// ---- BEGIN LIBRARY CODE ----
// ---- END LIBRARY CODE ----
void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    int K, X;
    cin >> K >> X;
    cout << (500 * K >= X ? "Yes" : "No" ) << endl;
    return 0;
};

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

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

using namespace std;
typedef long long ll;

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

    int N;
    cin >> N;

    vector<ll> A(N);
    rep(i, N) cin >> A[i];

    sort(A.begin(), A.end());

    if (A[0] == 0)
    {
        cout << 0 << endl;
        return 0;
    }

    double d = 1.0;
    for (auto a : A)
    {
        d *= a;
        if (d > 2000000000000000000)
        {
            cout << -1 << endl;
            return 0;
        }
    }

    ll res = 1;
    for (auto a : A)
    {
        res *= a;
        if (res > 1000000000000000000)
        {
            cout << -1 << endl;
            return 0;
        }
    }

    cout << res << endl;

    return 0;
}


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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll N;
    cin >> N;
    vector<ll> A(N), B(N), C(N - 1);
    rep(i, N) cin >> A[i], A[i]--;
    rep(i, N) cin >> B[i];
    rep(i, N - 1) cin >> C[i];
    ll prev = -2;
    ll ans = 0;
    iter(i, A) {
        if(prev + 1 == i) ans += C[prev];
        ans += B[i];
        prev = i;
    }
    cout << ans << endl;
    return 0;
}


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

int main (){
	int H,W;cin>>H>>W;
	vector<vector<char>> A(H,vector<char>(W));
	for(int i=0;i<H;i++)
	{
		for(int j=0;j<W;j++)
		{
			cin>>A.at(i).at(j);
		}
	}
	
	for(int i=0;i<H-1;i++)
	{
		for(int j=0;j<W-1;j++)
		{
			if(A[i][j]=='#'&&A[i][j+1]=='#'&&A[i+1][j]=='#')
			{
				cout<<"Impossible"<<endl;
				return 0;
			}
			
			
			if(A[i+1][j+1]=='#'&&A[i+1][j]=='#'&&A[i][j+1]=='#')
			{
				cout<<"Impossible"<<endl;
				return 0;
			}
			
		}
	}
	
	cout<<"Possible"<<endl;
   return 0;
}

Measured memory_bytes: 256
import math
import collections
import bisect
from collections import deque
from copy import copy, deepcopy


def main():
    L, R, d = map(int, input().split())

    ans = 0
    for i in range(L, R + 1):
        if i % d == 0:
            ans += 1

    print(ans)


if __name__ == '__main__':
    main()


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

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

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

/* 
 * * stuff you should look for
 * * int overflow, array bounds
 * * special cases (n=1?), set tle
 * */

int main(){
    fcin;

    int n;
    cin >> n;

    set<int> s;
    for(int i = 0; i < n; i++){
        int x;  
        cin >> x;
        s.insert(x);
    }

    if(s.size() == n) cout << "YES";
    else cout << "NO";
    return 0;
}



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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;

const ll LongINF=1e13+7;
const int INF=1e9+7;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template <class T, class Y>T GCD(T a, Y b){if(a<b){int c=a;a=b;b=c;}if (a % b == 0){return b;}return GCD(b, a % b);}
template<class T,class Y>T LCM(T a,Y b){return (a*b)/GCD(a,b);}
void clear(queue<pair<int, int>> &q){queue<pair<int, int>> empty;swap(q, empty);} //queueの中身の型は適時変更を忘れない

using vi=vector<int>;
using vii=vector<vi>;

#define REP(i,a,b) for(ll i=(a);i<(b);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define rv reverse
#define ALL(a) (a).begin(),(a).end()
#define decimal(x) fixed<<setprecision(x)


int main(){
    int K;
    string S;
    cin>>K>>S;
    if(S.length()>K){
        cout<<S.substr(0,K)<<"..."<<endl;
    }else{
        cout<<S<<endl;
    }
    return 0;
}

//a=97,z=122

Measured memory_bytes: 3628
#うまい人のを見て説いた。
require "prime"
n = gets.chomp.to_i
a = n.prime_division
aa = a.size
ans = 0
(0...aa).each do |i|
    s = a[i][1]
    x = 1
    s -= x
    while s >= 0 
        ans += 1
        x += 1
        s -= x
    end
end
puts ans

Measured memory_bytes: 14496
#include <iostream>
using namespace std;
int main()
{
	int n, s, r[20000], i, j, res;
	while (cin >> n >> s, n && s)
	{
		for (i = 0; i < n; i++)
			cin >> r[i];
		for (i = res = 0; i < n-1; i++)
		{
			for (j = i+1; j < n; j++)
			{
				if (r[i]+r[j] > s)
					res++;
			}
		}
		cout << res << endl;
	}
}

Measured memory_bytes: 912
n,k= map(int, input().split())
t= [list(map(int, input().split())) for i in range(n)]
q=[]
ans=0
r=[0]*(n+1)

t.sort(key=lambda x:x[1],reverse=True)

for i in range(k):
    ans += t[i][1]
    if r[t[i][0]]==0:
        r[t[i][0]]=1
    else:
        q.append(t[i][1])
v=sum(r)
ans+=v**2
cnt=ans


for i in range(k,n):
    if r[t[i][0]]==0 and len(q)!=0:
        r[t[i][0]]=1
        x=q.pop()
        cnt+=t[i][1]+2*v+1-x
        v+=1
        ans=max(cnt,ans)
print(ans)

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

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

  vector<int> A(N);
  vector<int> B(N);
  for(int i  = 0; i < N; i++){
    cin >> A[i];
    B[i] = A[i];
  }

  sort(B.begin(), B.end());
  int max = B[N-1];
  int second = B[N-2];

  for(int i = 0; i < N; i++){
    if(A[i] == max){
      cout << second << endl;
    }else{
      cout << max << endl;
    }
  }
 
  return 0;
}

Measured memory_bytes: 3200
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#include <set>
#include <map>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;

int main(){
  ll n, x;
  cin >> n >> x;
  ll ans = 0;
  ans += x+(n-x)*2*(x/(n-x));
  ll a = n-x, b = x%(n-x);
  while(b!=0){
    //cout << ans << endl;
    ans += a+b*(2*(a/b)-1);
    ll c = a;
    a = b;
    b = c%b;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256