akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <list>
#include <unordered_set>
#include <tuple>
#include <cmath>
#include <limits>
#include <type_traits>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <set>
#include <bitset>
#include <regex>
#include <random>
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
#define rep(i,n)for(ll i=0;i<n;++i)
#define exout(x) printf("%.10f\n", x)
const double pi = acos(-1.0);
const ll MOD = 1000000007;
const ll INF = 1e18;
const ll MAX_N = 201010;

// 組み合わせの余りを求める
ll fac[MAX_N], finv[MAX_N], inv[MAX_N];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX_N; i++) {
		fac[i] = fac[i - 1] * i;
	}
}

// 二項係数計算
long long COM(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] / (fac[k] * fac[n - k]);
}


ll dx[4] = { 0,0,-1,1 };
ll dy[4] = { -1,1,0,0 };
char c[310][310];
ll dp[101];

//long longしか使わない
//素数は1より大きい
//lower_boundは指定したkey以上の要素の一番左のイテレータをかえす
//upper_boundは指定したkeyより大きい要素の一番左のイテレータをかえす
int main() {
	ll n, k;
	cin >> n >> k;
	ll res = 0;
	ll amari = 0;
	for (ll i = 1;i <= n;++i) {
		if (i % k == 0)res++;
		if (k%2==0) {
			if (i % k == k / 2)amari++;
		}
	}
	ll ans = 0;
	ans += res * res * res;
	if (k % 2 == 0) {
		ans += amari * amari * amari;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
#include "cmath"
#define ll long long int
#define ull unsigned long long 
#define mod 1000000007;
using namespace std;
int main()
{
     ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll a,b,h,m;
    cin>>a>>b>>h>>m;
    double hour=30*h+(m/(60.0))*30;
    double ang=abs(6*m-hour);
    double temp=2*a*b*cos(ang*1.0*(M_PI/(180.0)));
    double ans=a*a+b*b-temp;
    printf("%.20lf\n",sqrt(ans));
    //cout<<" ";
    //cout<<a*a+b*b-a*b;

    

    return 0;
}

Measured memory_bytes: 4176
#include<stdio.h>
int main(){
    
    int i=0,count=0,m,n,j;
    scanf("%d",&m);
    int S[m];
    for(i=0;i<m;i++) scanf("%d",&S[i]);
    scanf("%d",&n);
    int T[n];
    for(i=0;i<n;i++) scanf("%d",&T[i]);
    
    for(j=0;j<n;j++){
        i=0;
    while (S[i] != T[j]){
        i++;
        if(i == m) break;
    }
    if (S[i] == T[j]) count++;
    }
    printf("%d\n",count);
    return 0;
}



Measured memory_bytes: 2108
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()
// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return;std::cout << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class X> void DEBUG(X d, T e){if(DEBUG_OUT == false)return;std::cout <<d<<" ";DEBUG(e);};
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

//CODE

void solve(void)
{
  int A,B,C,D;
  cin>>A>>B>>C>>D;
  cout<<max(0LL,min(B,D) - max(A,C))<<endl;
  return;
}


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

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();
  

 
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <array>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <tuple>
#include <cmath>
#include <algorithm>
#include <functional>
#include <numeric>
#include <cfloat>
#include <climits>
#include <cassert>
#include <random>
#include <bitset>
#include <memory>

int main() {
	long long int n; std::cin >> n;
	std::cout << n * (n - 1) / 2 << std::endl;
}


Measured memory_bytes: 256
cost,m,=map(int,input().split())
c=list(map(int,input().split()))
DP=[[10**10 for i in range(60001)] for j in range(21)]
for i in range(m):
    DP[i][c[i]]=1
    for j in range(60001):
        if c[i]>j:
            if i==0:
                DP[i][j]=0
            else:DP[i][j]=DP[i-1][j]
        elif j+c[i]<=60000:
            DP[i][j]=min(DP[i][j-c[i]]+1,DP[i-1][j])
print(DP[m-1][cost])


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

int main () {
  int N;
  cin >> N;
  vector<int> dif(N);
  for (int i = 0; i < N; i++) cin >> dif.at(i);
  sort (dif.begin(), dif.end());
  
  cout << dif.at(N/2) - dif.at(N/2-1) << endl;
}

Measured memory_bytes: 640
N,M = list(map(int, input().split()))
n = [0]*(N+1)
for _ in range(M):
    a,b = list(map(int, input().split()))
    n[a] += 1
    n[b] += 1


flag = True
for j in range(len(n)):
    if n[j]%2 != 0:
        flag = False

if flag:
    print('YES')
else:
    print('NO')





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

typedef unsigned long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;

#define mem0(x) memset(x, 0, sizeof(x))
#define asort(x) sort(x.begin(), x.end());
#define dsort(x, t) sort(x.begin(), a.end(), greater<t>());
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define MINS(m, s) m.insert(mp(s, 1));
#define MFIN(m, s) m.find(s) != m.end()
#define mp make_pair
#define pb push_back
#define INF (1 << 29)
const int mod = 1000000007;

int main() {
    ll N, A, B, ans;
    ans = 0;
    cin >> N >> A >> B;
    ans = N / (A + B) * A + min(N % (A + B), A);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long ll;
ll X;
bool check(ll t) {
	return t * (t+1) / 2 >= X;
}
int main() {
	cin >> X;
	ll L = 0;
	ll R = X;
	while (L + 1 < R) {
		ll M = (L + R) >> 1;
		if (check(M)) R = M;
		else L = M;
	}
	cout << R << endl;
	return 0;
}


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

using namespace std;

int main()
{
	int coins[4] = {10, 50, 100, 500};
	int price;
	bool flag = true;

	while (true){
		scanf("%d", &price);

		if (price == 0){
			break;
		}

		int have_coins[4];
		int sum = 0;

		for (int i = 0; i < 4; i++){
			scanf("%d", &have_coins[i]);

			sum += coins[i] * have_coins[i];
		}

		int exceed = sum - price;

		for (int i = 3; i >= 0; i--){
			have_coins[i] -= exceed / coins[i];
			exceed %= coins[i];
		}

		if (flag){
			flag = false;
		}
		else {
			puts("");
		}

		for (int i = 0; i < 4; i++){
			if (have_coins[i] > 0){
				printf("%d %d\n", coins[i], have_coins[i]);
			}
		}
	}

	return (0);
}

Measured memory_bytes: 1196
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<stdbool.h>
#include<math.h>
#include<limits.h>
#define MAX 200002
typedef long long ll;
int main(){
    ll N,D;
    scanf("%lld %lld",&N,&D);
    ll X[MAX],Y[MAX];
    ll dist;
    ll ans=0;
    for(int i=0;i<N;i++){
        scanf("%lld %lld",X+i,Y+i);
        dist = X[i]*X[i] + Y[i]*Y[i];
        if(dist <= D*D)
            ans++;
    }
    printf("%lld",ans);
}


Measured memory_bytes: 4856
#include <stdio.h>
#define rep(i,n)for(int(i)=0;(i)<(n);(i)++)
int c[10][10];
int H,W,A,res;
int main()
{
scanf("%d%d",&H,&W);
rep(i,10)rep(j,10)scanf("%d",&c[i][j]);
rep(k,10)rep(i,10)rep(j,10)
if(c[i][j]>c[i][k]+c[k][j])c[i][j]=c[i][k]+c[k][j];
rep(i,H)rep(j,W)
{
scanf("%d",&A);
if(A>=0)res+=c[A][1];
}
printf("%d\n",res);
}


Measured memory_bytes: 128
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;
using static AtCoderTemplate.MyLibrary;

namespace AtCoderTemplate
{
    class Program
    {
        static void Main (string[] args)
        {
            string[] str;
            str = Console.ReadLine ().Split (' ');

            int H = int.Parse (str[0]);
            int W = int.Parse (str[1]);
            int K = int.Parse (str[2]);

            char[, ] P = new char[H, W];

            int B = 0;

            for (int i = 0; i < H; i++)
            {
                string str2 = Console.ReadLine ();
                for (int j = 0; j < W; j++)
                {
                    P[i, j] = (char) str2[j];
                    if (P[i, j] == '#') B += 1;
                }
            }

            int ans = 0;

            for (int hbit = 0; hbit < (1 << H); hbit++)
            {
                for (int wbit = 0; wbit < (1 << W); wbit++)
                {
                    int count = 0;

                    for (int i = 0; i < H; i++)
                    {
                        if (((1 << i) & hbit) != 0) continue;

                        for (int j = 0; j < W; j++)
                        {
                            if (((1 << j) & wbit) != 0) continue;

                            if (P[i, j] == '#') count += 1;
                        }
                    }

                    if (count == K) ans += 1;

                }

            }

            Console.Write (ans);

        }
    }

    class MyLibrary
    {
        public static int GCD (int a, int b)
        {
            if (a % b == 0) return b;
            return GCD (b, a % b);
        }
    }
}

Measured memory_bytes: 27540
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define si short int
#define speed ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define pill pair<ll,ll>
#define f first
#define s second
#define pilc pair<ll,char>
#define all(a) (a).begin(),(a).end()
#define rep(s,e,step) for(int i = (s); i < (e) ; i += step)
#define vrep(s,e,step) for(int j = (s); j < (e) ; j += step)
#define ex exit(0)
#define sz(a) (a).size()


using namespace std;

const ll N = 1e5 + 120;
const ll big = 1e18;
const ll M = 2020;
const ll mod = 998244353;

ll n, m;

vector<ll> g[N];

ll cnt[N];

bool red[N];

int main() {
    speed;
	cin >> n >> m;
	red[1] = 1;
	for(int i = 1; i <= n; i++)
		cnt[i]++;
	while(m--) {
		ll a, b;
		cin >> a >> b;
		if(red[a]) {
			red[b] = 1;
			cnt[b]++;
			cnt[a]--;
			if(!cnt[a])
				red[a] = 0;
		}
		else
			cnt[b]++, cnt[a]--;
	}
	ll ans = 0;
	for(int i = 1; i <= n; i++)
		ans += red[i];
	cout << ans;
}

/*
*/



Measured memory_bytes: 3456
#include<bits/stdc++.h>
using namespace std;
const int maxn=400100;
const long long md=1e9+7;
const long long INF=1e17;
struct edge{
	int s,t,v;
}E[maxn];
struct node{
	int p;
	long long d;
};
bool operator < (const node &A,const node &B){
	return A.d>B.d;
}
int S,T;
int n,m;
long long dp1[maxn],dp2[maxn];
long long dis1[maxn],dis2[maxn];
int beg[maxn],tto[maxn],nex[maxn],w[maxn],e;
void putin(int s,int t,int v){
	tto[++e]=t;
	nex[e]=beg[s];
	beg[s]=e;
	w[e]=v;
}
void dij(int s,long long *dis,long long *dp){
	static priority_queue<node> q;
	static bool vis[maxn];
	while(!q.empty()) q.pop();
	for(int i=1;i<=n;i++){
		dis[i]=INF;
		vis[i]=0;
	}
	dis[s]=0,dp[s]=1;
	q.push((node){s,0});
	node st;
	int u;
	while(!q.empty()){
		st=q.top();
		q.pop();
		if(vis[st.p]) continue;
		u=st.p,vis[u]=1;
		for(int i=beg[u];i;i=nex[i]){
			if(dis[tto[i]]>dis[u]+w[i]){
				dis[tto[i]]=dis[u]+w[i];
				dp[tto[i]]=dp[u];
				q.push((node){tto[i],dis[tto[i]]});
			}
			else if(dis[tto[i]]==dis[u]+w[i])
				(dp[tto[i]]+=dp[u])%=md;
		}
	}
}
int main(){
//	freopen("A.in","r",stdin);
	int s,t,v;
	scanf("%d%d",&n,&m);
	scanf("%d%d",&S,&T);
	for(int i=1;i<=m;i++){
		scanf("%d%d%d",&s,&t,&v);
		E[i<<1]=(edge){s,t,v};
		E[i<<1|1]=(edge){t,s,v};
		putin(s,t,v);
		putin(t,s,v);
	}
	dij(S,dis1,dp1);
	dij(T,dis2,dp2);
	long long sum=dp1[T],ans=0;
	for(int i=1;i<=n;i++){
		if(dis1[i]+dis2[i]==dis1[T]&&dis1[i]==dis2[i]){
			ans=(ans+dp1[i]*dp2[i]%md*(dp1[T]-dp1[i]*dp2[i]%md+md)%md)%md;
			sum=(sum-dp1[i]*dp2[i]%md+md)%md;
		}
	}
//	printf("%lld\n",sum);
	for(int i=2;i<=(m<<1|1);i++){
		if(dis1[E[i].s]+E[i].v+dis2[E[i].t]!=dis1[T]) continue;
		if((dis1[E[i].s]+E[i].v)*2>dis1[T]&&(dis2[E[i].t]+E[i].v)*2>dis1[T])
			ans=(ans+dp1[E[i].s]*dp2[E[i].t]%md*(dp1[T]-dp1[E[i].s]*dp2[E[i].t]%md+md))%md;
	}
	printf("%lld\n",ans);
	return 0;
}


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

int main() {
	string S;
	cin >> S;
	int a = 0, b = 0, c = 0;
	for (char& i : S) {
		if (i == 'a') a++;
		else if (i == 'b') b++;
		else c++;
	}
	if (max({ a, b, c }) - min({ a, b, c }) <= 1) cout << "YES";
	else cout << "NO";
}

Measured memory_bytes: 512
k = int(input())
gdc_table = [[-1 for _ in range(k+1)] for _ in range(k+1)]

def gdc(a, b):
	if a < b:
		a, b = b, a

	if b == 0:
		gdc_table[a][b] = a
	else:
		if gdc_table[a][b] == -1:
			gdc_table[a][b] = gdc(b, a%b)
	return gdc_table[a][b]

for i in range(0, k+1):
	for j in range(0, i+1):
		gdc_table[i][j] = gdc(i, j)
		gdc_table[j][i] = gdc_table[i][j]

# def gdc(a, b):
# 	if a < b:
# 		a, b = b, a
# 	init_a, init_b = a, b
# 	if gdc_table[init_a][init_b] == -1:
# 		while b:
# 			a, b = b, a % b
# 	# return a	
# 		gdc_table[init_a][init_b] = a
# 	return gdc_table[init_a][init_b]

# def triple_gdc(a, b, c):
# 	return gdc(gdc(a, b), c)

ans= 0
for first in range(1, k+1):
	for second in range(1, k+1):
		gdc1 = gdc_table[first][second]
		for third in range(1, k+1):
			# if gdc_table[gdc1][third] == -1:
			# 	print("Alert!")
			# 	print("gdc1", gdc1)
			# 	print("third", third)
			# 	break
			ans += gdc_table[gdc1][third]

print(ans)
# print("gdc_table[198]", gdc_table[198])


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

using namespace std; 

int main(){ 
  int n;
  cin>>n;
  int a[n];
  for (int i=0;i<n;i++){
     cin>>a[i];
  }
  int ans=1;
  int r=1;
  while(ans<n+1){
    r=a[r-1];
    if(r==2){
      cout<<ans;
      break;
    }
    ans+=1;
  }
  if(ans>n) cout<<-1;
}

Measured memory_bytes: 640
h,w = map(int,input().split())
pixcels = []

for i in range(h):
    pixcels.append(input())
    
output=[]

for i in range(h):
    output.append(pixcels[i])
    output.append(pixcels[i])

for i in range(2*h):
    print(output[i])

Measured memory_bytes: 3060
#include <string>
#include <vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<functional>
#include<list>
#include<deque>
#include<bitset>
#include<set>
#include<map>
#include<cstring>
#include<sstream>
#include<complex>
#include<iomanip>
#include<numeric>
#define X first
#define Y second
#define pb push_back
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y-1);(X) >=0;--(X))
#define repe(X,Y) for ((X) = 0;(X) < (Y);++(X))
#define peat(X,Y) for (;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"{"; rep(i,t.size()) {os<<t[i]<<",";} os<<"}"<<endl; return os;}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}

int main(){
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(0);
  int i,j,k,T;
  cin>>T;
  while(T--){
    double x[2],y[2],r[2],d,dx,dy;
    rep(i,2)
      cin>>x[i]>>y[i]>>r[i];
    dx=x[1]-x[0]; dy=y[1]-y[0];
    d=sqrt(dx*dx+dy*dy);
    if(d+r[0]<r[1]){
      cout<<-2<<endl;
    }else if(d+r[1]<r[0]){
      cout<<2<<endl;
    }else if(d>r[1]+r[0]){
      cout<<0<<endl;
    }else{
      cout<<1<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1236
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define ll int64_t
#define _GLIBCXX_DEBUG
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main(){
  int a,b,h,m;
  cin >> a>>b>>h>>m;
  double kaku=max(30*h-5.5*m,5.5*m-30*h)*3.1415926535897932386426/180;
  cout << fixed << setprecision(13);
  cout << sqrt(a*a+b*b-2*a*b*cos(kaku)) << endl; 
  
}

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

int solvegcd(int m,int n)
{
	if(n==0){return m;}
	if(m%n==0){return n;}
	else{solvegcd(n,m%n);}
}
int solvelcm(int m,int n)
{
	int mm,nn;
	mm = m/solvegcd(m,n);
	nn = n/solvegcd(m,n);
	return mm*nn*solvegcd(m,n);
}

int main()
{
	int a,b;
	while(cin >> a && cin >> b){
		if(a != max(a,b)){
			int tmp = b;
			b = a;
			a = tmp;
		}
		cout << solvegcd(a,b) << " " << solvelcm(a,b) << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include<stdio.h>
long long int max(long long int a, long long int b)
{
	if (a > b)
		return a;
	else
		return b;
}
long long int min(long long int a, long long int b)
{
	if (a < b)
		return a;
	else
		return b;
}
int main()
{
	int n, k;
	scanf("%d %d", &n, &k);
	int i;
	long long int x[55], y[55];
	for (i = 0; i < n; i++)
		scanf("%lld %lld", &x[i], &y[i]);
	int a, b, c, d;
	long long int minx, miny, maxx, maxy;
	int count;
	long long int ans = 1e18 * 4 + 1e9;
	for (a = 0; a < n; a++)
	{
		for (b = 0; b < n; b++)
		{
			for (c = 0; c < n; c++)
			{
				for (d = 0; d < n; d++)
				{
					minx = min(min(x[a], x[b]), min(x[c], x[d]));
					miny = min(min(y[a], y[b]), min(y[c], y[d]));
					maxx = max(max(x[a], x[b]), max(x[c], x[d]));
					maxy = max(max(y[a], y[b]), max(y[c], y[d]));
					count = 0;
					for (i = 0; i < n; i++)
						if (minx <= x[i] && x[i] <= maxx && miny <= y[i] && y[i] <= maxy)
							count++;
					if (count >= k)
						ans = min(ans, (maxx - minx) * (maxy - miny));
				}
			}
		}
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 128
M, D = map(int, input().split())
ans = 0
for m in range(1, M+1):
    for d in range(1, D+1):
        d_1 = d % 10
        d_10 = d // 10
        if d_1 >= 2 and d_10 >= 2 and d_1*d_10 == m:
            ans += 1
print(ans)

Measured memory_bytes: 3060
x, n = map(int, input().split())
p = list(map(int, input().split()))
min_n = 1000
ans = 1000

for i in range(-200, 200):
    if i in p:
        continue
    if min_n > abs(x-i):
        min_n = abs(x-i)
        ans = i

print(ans)

Measured memory_bytes: 9184
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

using ll = long long;

const int nax = 305;
double p[nax][nax][nax], ev[nax][nax][nax];
// ev[a][b][c] - the expected number of operations so far to get to state (a,b,c)
// easier: p-bility of getting to this state at all

int main() {
    int n;
    scanf("%d", &n);
    vector<int> cnt(4);
    for(int i = 0; i < n; ++i) {
        int x;
        scanf("%d", &x);
        ++cnt[x];
    }
    p[cnt[1]][cnt[2]][cnt[3]] = 1;
    for(int c = n; c >= 0; --c) {
        for(int b = n; b >= 0; --b) {
            for(int a = n; a >= 0; --a) {
                if(a == 0 && b == 0 && c == 0) {
                    continue;
                }
                if(a + b + c > n) {
                    continue;
                }
                // dp[a][b][c]
                
                double p_waste = (double) (n - (a + b + c)) / n;
                // p_waste + p_waste^2 + ... = S
                // 1 + S = S / p_waste
                double ev_waste = p_waste / (1 - p_waste) + 1;
                debug() << imie(a) imie(b) imie(c) imie(ev_waste);
                ev[a][b][c] += ev_waste * p[a][b][c];
                
                // remove 1 -> dp[a-1][b][c]
                // we will eventually choose one of a+b+c
                if(a != 0) {
                    double p_go = (double) a / (a + b + c);
                    p[a-1][b][c] += p[a][b][c] * p_go;
                    ev[a-1][b][c] += ev[a][b][c] * p_go;
                }
                
                // remove 2 -> dp[a+1][b-1][c]
                if(b != 0) {
                    double p_go = (double) b / (a + b + c);
                    p[a+1][b-1][c] += p[a][b][c] * p_go;
                    ev[a+1][b-1][c] += ev[a][b][c] * p_go;
                }
                
                // remove 3
                if(c != 0) {
                    double p_go = (double) c / (a + b + c);
                    p[a][b+1][c-1] += p[a][b][c] * p_go;
                    ev[a][b+1][c-1] += ev[a][b][c] * p_go;
                }
            }
        }
    }
    printf("%.10lf\n", ev[0][0][0]); // + cnt[1] + 2 * cnt[2] + 3 * cnt[3]);
}

Measured memory_bytes: 221376
#include <bits/stdc++.h>
#define REP(i, a, n) for (ll i = ((ll) a); i < ((ll) n); i++)
using namespace std;
typedef long long ll;

int main(void) {
  ll N, A, B;
  cin >> N >> A >> B;
  vector<ll> P(N);
  REP(i, 0, N) cin >> P[i];

  ll cnt0 = 0, cnt1 = 0, cnt2 = 0;
  REP(i, 0, N) {
    if (P[i] <= A) {
      cnt0++;
    } else if (P[i] <= B) {
      cnt1++;
    } else {
      cnt2++;
    }
  }

  cout << min({ cnt0, cnt1, cnt2 }) << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

const int weight[ ]
  = { 0, 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335 };
const char *day[ ]
  = { "Wednesday", "Thursday", "Friday", "Saturday", "Sunday",
    "Monday", "Tuesday" };

/** Application main entry point. */
int main (
  int argc,
  char *argv[ ]
  )
{
  int m, d;

  scanf ( "%d %d", &m, &d );
  while ( m )
  {
    puts ( day[ ( weight[ m ] + d ) % 7 ] );

    scanf ( " %d %d", &m, &d );
  }

  return ( 0 );
}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String S = in.next();
		int l=S.length();
		int a[]=new int[l-2];
		int min = 10000;
		for (int i = 0; i < l-2; i++) {
			String b=S.substring(i,i+1)+S.substring(i+1,i+2)+S.substring(i+2,i+3);
			a[i]=Integer.parseInt(b);
			int c = Math.abs(a[i]-753);
			if(c<=min) {
				min=c;
			}
		}
		System.out.println(min);
	}
}

Measured memory_bytes: 21716
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <queue>
#include <list>
#include <unordered_map>
#include <algorithm>
#include <functional>
#include <iomanip> // std::std::setprecision(X)
#include <limits>  //std::numeric_limits<int>::max(), min()

int main (void) {

  int T, X; std::cin >> T >> X;
  std::cout << std::fixed;
  std::cout << std::setprecision(8) << (double) T / X << std::endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <array>
#include <cstdint>
#include <functional>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string>
#include <utility>
#include <vector>

#define INF 1000000000
#define MOD 1000000007
#define ll long long
#define rep(i,a,b) for(int32 i = (a); i < (b); ++i)
#define rrep(i,a,b) for(int32 i = (b) - 1; i >= (a); --i)
#define bitget(a,b) (((a) >> (b)) & 1)
#define vint vector<int>
#define ALL(x) (x).begin(),(x).end()
#define C(x) cout << #x << " : " << x << endl
#define scanf scanf_s

using int32 = int_fast32_t;
using int64 = int_fast64_t;
using uint32 = uint_fast32_t;
using uint64 = uint_fast64_t;

using namespace std;


inline uint32 popcount(uint32 c) {
	c = (c & 0x55555555) + ((c >> 1) & 0x55555555);
	c = (c & 0x33333333) + ((c >> 2) & 0x33333333);
	c = (c & 0x0f0f0f0f) + ((c >> 4) & 0x0f0f0f0f);
	c = (c & 0x00ff00ff) + ((c >> 8) & 0x00ff00ff);
	return c;
}
int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	uint32 n;
	cin >> n;
	uint32 f[100] = {};
	int32 p[100][10] = {};
	int32 a;
	rep(i, 0, n) {
		rep(j, 0, 10) {
			cin >> a;
			if (a) f[i] |= 1 << j;
		}
	}
	rep(i, 0, n) {
		rep(j, 0, 11)
			cin >> p[i][j];
	}
	int32 ans = -INF;
	rep(i, 1, 1024) {
		a = 0;
		rep(j, 0, n) {
			a += p[j][popcount(i&f[j])];
		}
		ans = max(ans, a);
	}
	printf("%d", ans);
	return 0;
}

Measured memory_bytes: 256
X,N = map(int, input().split())
array = list(map(int, input().split()))
ans_l = [X]


x  = (N % 2)
if x == 0:
    n = N // 2
else:
    n = N // 2 + 1
i = 1

while i <= n:
    ans_l.append(X - i)
    ans_l.append(X + i)
    i += 1
l = len(array)

for j in range(l):
    try:
        ans_l.remove(array[j])
    except ValueError:
        pass
print(ans_l[0])

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

const long long MOD = 998244353;

template <long long MOD_ = (long long)1e9 + 7>
class ModMath {
public:
    ModMath(int N = 0)
        : N_(N)
    {
    }

    template <class... Ts>
    constexpr long long mul(long long head, Ts&&... tail)
    {
        auto res = head;
        using swallow = std::initializer_list<int>;
        (void)swallow { (void(res = (res * tail) % MOD_), 0)... };
        return res;
    }

    template <class... Ts>
    constexpr long long add(long long head, Ts&&... tail)
    {
        auto res = head;
        using swallow = std::initializer_list<int>;
        (void)swallow { (void(res = (res + tail) % MOD_), 0)... };
        return res;
    }

    constexpr long long pow(long long x, long long y)
    {
        ll ans = 1;
        while (y > 0) {
            if (y & 0x1) {
                ans = mul(ans, x);
            }
            x = mul(x, x);
            y >>= 1;
        }
        return ans;
    }

    long long combination(long long n, long long k)
    {
        if (k < 0 || k > n) {
            return 0;
        }
        if (fact_.empty()) {
            build_fact();
        }
        return mul(fact_[n], fact_inv_[k], fact_inv_[n - k]);
    }

private:
    void build_fact()
    {
        if (!fact_.empty()) {
            return;
        }
        fact_.resize(N_ + 1);
        fact_[0] = 1;
        for (ll i = 1; i <= N_; i++) {
            fact_[i] = mul(fact_[i - 1], i);
        }
        fact_inv_.resize(N_ + 1);
        fact_inv_[N_] = pow(fact_[N_], MOD_ - 2);
        for (ll i = N_ - 1; i >= 0; i--) {
            fact_inv_[i] = mul(fact_inv_[i + 1], (i + 1));
        }
    }

    int N_;
    vector<long long> fact_;
    vector<long long> fact_inv_;
};

void solve(long long N, long long M, long long K)
{
    ModMath<MOD> m(N);
    ll ans = 0;
    for (ll i = 0; i <= K; i++) {
        auto val = m.mul(M, m.pow(M - 1, N - i - 1), m.combination(N - 1, i));
        ans = m.add(ans, val);
    }
    cout << ans << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    long long N;
    scanf("%lld", &N);
    long long M;
    scanf("%lld", &M);
    long long K;
    scanf("%lld", &K);
    solve(N, M, K);
    return 0;
}


Measured memory_bytes: 6424
n,m=map(int,input().split())

bottom=0
top=10**5
for i in range(m):
  a,b=map(int,input().split())
  bottom=max(bottom,a)
  top=min(top,b)
  
if top<bottom:
  print(0)
else:
  print(top-bottom+1)
  

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

using ll    = long long;
using ull   = unsigned long long;
using veci  = vector<int>;
using vecll = vector<ll>;
#define EPS (1e-7)
#define INF (1e9)
#define PI  (acos(-1))
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define REP(i,n) for(int i= 0;i<(int)(n);++i)
#define pb push_back

veci enum_div(int n){
	veci ret;
	ret.pb(1);
	for(int i=1;i*i<n;i++){
		if(n%i==0){
			ret.pb(i);
			if(i != n/i){ret.pb(n/i);}
		}
	}
	ret.pb(n);
	return ret;
}
int gcb(int a,int b){return ((b == 0)? a : gcb(b,a%b));}
int gcd(int a,int b){return (a*b) / gcb(a,b);}

int main(){
    string s;
    cin >> s;
    s[3] = '8';
    cout << s << endl;
    return 0;
}



Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		String T = sc.next();
		sc.close();
		
		boolean flag = true;
		Map<Character, Character> map = new HashMap<>();
		Map<Character, Integer> sMap = new HashMap<>();
		Map<Character, Integer> tMap = new HashMap<>();
		for(int i = 0;i < S.length();++i) {
			if(map.containsKey(S.charAt(i))) {
				if(map.get(S.charAt(i)) != T.charAt(i)) {
					flag = false;
					break;
				}
			} else {
				map.put(S.charAt(i), T.charAt(i));
			}
			if(sMap.containsKey(S.charAt(i)))
				sMap.put(S.charAt(i), sMap.get(S.charAt(i)) + 1);
			else
				sMap.put(S.charAt(i), 1);
			if(tMap.containsKey(T.charAt(i)))
				tMap.put(T.charAt(i), tMap.get(T.charAt(i)) + 1);
			else
				tMap.put(T.charAt(i), 1);
		}
		if(flag) {
			List<Entry<Character, Integer>> sList = new ArrayList<>(sMap.entrySet());
			List<Entry<Character, Integer>> tList = new ArrayList<>(tMap.entrySet());
			sList.sort(Entry.comparingByValue());
			tList.sort(Entry.comparingByValue());
			for(int i = 0;i < sList.size();++i) {
				if(sList.get(i).getValue().intValue() != tList.get(i).getValue().intValue()) {
					flag = false;
					break;
				}
			}
		}
		
		if(flag)
			System.out.println("Yes");
		else
			System.out.println("No");
	}
}


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

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

	int d[n][2];
	for (int i = 0;i < n;i++) {
		for (int j = 0;j < 2;j++) {
			cin >> d[i][j];
		}
	}

	int flag = 0;
	for (int i = 0;i < n;i++) {
		if (d[i][0] == d[i][1]) flag++;
		else flag = 0;

		if (flag == 3) {
			break;
		}
	}

	if (flag == 3) cout << "Yes";
	else cout << "No";

	return 0;
}

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

xs = list(map(int, input().split()))

flag = False
for x in xs:
    if x % 2 == 0:
        if x % 3 == 0 or x % 5 == 0:
            pass
        else:
            flag = True
            break

if flag:
    print('DENIED')
else:
    print('APPROVED')



Measured memory_bytes: 2940
#include<stdio.h>
int main(){
	
	int A,B,i,j,k,count=0;
	scanf("%d%d",&A,&B);
	
	for(i=1;i<10;i++){
		for(j=0;j<10;j++){
			for(k=0;k<10;k++){
				
				if(A<=10000*i+1000*j+100*k+10*j+i&&10000*i+1000*j+100*k+10*j+i<=B){
					count++;
				}
				
				
			}
			
		}
		
	}
	
	printf("\n%d\n\n",count);
	
	return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<pll> vpl;
typedef vector<vll> vvll;

#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#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 FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define yes cout<<"Yes"<<endl
#define YES cout<<"YES"<<endl
#define no cout<<"No"<<endl
#define NO cout<<"NO"<<endl
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

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

  ll a;
  cin>>a;

  ll ans=a+a*a+a*a*a;
  cout<<ans<<endl;

}



Measured memory_bytes: 3688
#include<bits/stdc++.h>
using namespace std;
typedef long long  ll;
ll cnt[100001],a[100001];
int main ()
{
    ll n,sum=0;
    cin>>n;
    for(ll i=0;i<n;i++)
    {
        cin>>a[i];
        cnt[a[i]]++;
        sum+=a[i];
    }
    ll q;
    cin>>q;
    for(ll i=0;i<q;i++)
    {
        ll b,c;
        cin>>b>>c;
        ll t=cnt[b];
        cnt[c]+=t;
        cnt[b]=0;
        sum-=b*t;
        sum+=c*t;
        cout<<sum<<endl;
    }
}

Measured memory_bytes: 5144
#include <stdio.h>

int main(void){
    int i,num,ans=0;
    scanf("%d", &num);
    unsigned int a[num];
    for(i=0; i<num; i++) scanf("%d", &a[i]);
    while(1){
        i=0;
        while(i<num){
            if(a[i] & 0x1)break;
            a[i] = a[i] >> 1;
            i++;
        }
        if(i!=num)break;
        ans++;
    }
    printf("%d", ans);
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define INF 10000000000000

int main(){
    ll n;cin>>n;
    
    ll MIN=INF;
    bool prime=true;
    for(ll i=2;i*i<=n;i++){
        if(n%i==0){MIN=min(MIN,i+n/i);prime=false;}
    }

    if(prime){MIN=n+1;}

    cout<<MIN-2<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <cmath>
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<set>
#include<tuple>
#include<bitset>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll inf = 1000000007;
int p[10];
int q[10];
int x[10];
int main(void) {
	int n;
	cin >> n;

	for (int i = 0; i < n; i++) {
		cin >> p[i];
		x[i] = p[i];
	}
	sort(x, x + n);
	for (int i = 0; i < n; i++) {
		cin >> q[i];
	}
	int a;
	int b;
	int count = 0;
	do {
		count++;
		bool pok = true;
		bool qok = true;
		for (int i = 0; i < n; i++) {
			if (x[i] != p[i]) {
				pok = false;
			}
			if (x[i] != q[i]) {
				qok = false;
			}
		}
		if (pok) {
			a = count;
		}
		if (qok) {
			b = count;
		}

	} while (next_permutation(x, x + n));
	cout << abs(a - b) << endl;
	return 0;

}

Measured memory_bytes: 3628
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <iomanip>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
// const int dy[] = {1, 1, 0, -1, -1, -1, 0, 1},
//           dx[] = {0, -1, -1, -1, 0, 1, 1, 1};

struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    cerr << fixed << setprecision(10);
  }
} iosetup;
/*-------------------------------------------------*/
int main() {
  int n; cin >> n;
  vector<long long> a(n); REP(i, n) cin >> a[i];
  long long sum = accumulate(ALL(a), 0LL), mae = 0, ans = LINF;
  REP(i, n - 1) {
    sum -= a[i];
    mae += a[i];
    ans = min(ans, abs(sum - mae));
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

ll v[150001];
int par[150001];
vi adj[150001];

vector<ii> S[150001];

bool cmp2(const ii &a, const ii &b)
{
	if(a.se!=b.se) return a.se<b.se;
	return a.fi<b.fi;
}

void calc(ll mid, int u)
{
	for(int i=0;i<adj[u].size();i++)
	{
		calc(mid,adj[u][i]);
	}
	if(adj[u].empty())
	{
		S[u].pb(mp(0,0)); return ;
	}
	int u1=adj[u][0]; int u2=adj[u][1];
	if(S[u1].size()>S[u2].size()) swap(u1,u2);
	sort(S[u1].begin(),S[u1].end(),cmp2); sort(S[u2].begin(),S[u2].end());
	int ptr2=0;
	ll mind=ll(1e18);
	for(int i = int(S[u1].size()) - 1; i >= 0; i--)
	{
		ll a=S[u1][i].fi; ll b=S[u1][i].se; ll cap=mid-v[u1]-v[u2]-b;
		while(ptr2<S[u2].size()&&S[u2][ptr2].fi<=cap)
		{
			mind=min(mind,S[u2][ptr2].se);
			ptr2++;
		}
		if(mind<ll(1e18))
		{
			S[u].pb(mp(a+v[u1],mind+v[u2]));
		}
	}
	sort(S[u1].begin(),S[u1].end()); sort(S[u2].begin(),S[u2].end(),cmp2);
	ptr2=0;
	mind=ll(1e18);
	for(int i = int(S[u1].size()) - 1; i >= 0; i--)
	{
		ll a=S[u1][i].fi; ll b=S[u1][i].se; ll cap=mid-v[u1]-v[u2]-a;
		while(ptr2<S[u2].size()&&S[u2][ptr2].se<=cap)
		{
			mind=min(mind,S[u2][ptr2].fi);
			ptr2++;
		}
		if(mind<ll(1e18))
		{
			S[u].pb(mp(mind+v[u2],b+v[u1]));
		}
	}
}

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n; cin>>n;
	for(int i=1;i<n;i++)
	{
		cin>>par[i]>>v[i];
		par[i]--;
		adj[par[i]].pb(i);
	}
	ll lo=0; ll hi=ll(1e11);
	ll ans=0;
	while(lo<=hi)
	{
		ll mid=(lo+hi)>>1;
		calc(mid,0);
		if(S[0].empty())
		{
			lo=mid+1;
		}
		else
		{
			hi=mid-1;
			ans=mid;
		}
		for(int i=0;i<=n;i++) S[i].clear();
	}
	cout<<ans<<'\n';
}


Measured memory_bytes: 30968
#include <bits/stdc++.h>
	  #define endl "\n"
	  #define ll long long int
	  #define mod 1000000007
	  #define inf 1000000000000000001;
	  using namespace std;
	  int main()
	  {
	    // #ifndef ONLINE_JUDGE
	     // for getting input from input.txt
	    // freopen("input.txt", "r", stdin);
	     // for writing output to output.txt
	    // freopen("output.txt", "w", stdout);
	   // #endif
	    std::ios::sync_with_stdio(false);
	    cin.tie(NULL);
	    ll n,v[5],m=inf;
	    cin>>n;
	    for (int i = 0; i < 5; ++i)
	    {
	    	cin>>v[i];
	    	m = min(v[i],m);
	    }
	    // cout<<n<<m;
	    cout<<(n-1)/m+5;
	    return 0;
	  }


Measured memory_bytes: 3616
import java.util.*;
 
public class Main{
  public static void main(String[]args){
    Scanner sc =  new Scanner(System.in);
    String s = sc.nextLine();
    String t = sc.nextLine();
    int S = s.length();
    int T = t.length();
    int[][] dp = new int[S+1][T+1];
    
    for(int i = 0; i <= S; i++){
      for(int j = 0; j <= T; j++){
        if(i == 0 || j == 0){
          dp[i][j] = 0;
        }else if(s.charAt(i-1) == t.charAt(j-1)){
          dp[i][j] = Math.max(dp[i][j], dp[i-1][j-1]+1);
        }else{
          dp[i][j] = Math.max(dp[i][j], dp[i-1][j]);
          dp[i][j] = Math.max(dp[i][j], dp[i][j-1]);
        }
      }
    }
    int i = S;
    int j = T;
    String ans = "";
    while(i > 0 && j > 0){
      if(dp[i][j] == dp[i-1][j]){
        i--;
      }else if(dp[i][j] == dp[i][j-1]){
        j--;
      }else{
        ans = String.valueOf(s.charAt(i-1)) + ans;
        i--;
        j--;
      }
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 87232
#pragma target("avx")
#include<bits/stdc++.h>
using ll = int_fast64_t;
using P = std::pair<ll,ll>;
using V = std::vector<ll>;
template<typename T> using pq = std::priority_queue<T>;
template<typename T> using rpq = std::priority_queue<T, std::vector<T>, std::greater<T>>;

#define rep(i,b,e) for(ll i=b; i<e; i++)
#define be(vec) vec.begin(),vec.end()
#define print(vec) printf("[ ");for(auto &i:vec)printf("%ld ",i);puts("]");
#define scan(vec) for(auto &i:vec)scanf("%ld",&i)
#define fi first
#define se second

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

int main(){
	int n;
	scanf("%d", &n);
	char s[n+1];
	scanf("%s", s);
	int w[n+1], e[n+1];
	w[0] = e[0] = 0;
	rep(i, 0, n){
		w[i+1] = w[i] + (s[i]=='W');
		e[i+1] = e[i] + (s[i]=='E');
	}
	int ans = n;
	rep(i, 1, n+1){
		ans = std::min(ans, w[i-1]+e[n]-e[i]);
	}
	printf("%d\n", ans);
	return 0;
}


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

using namespace std;

int main() {
  long long N, M;
  cin >> N >> M;
  if (N > M) swap(N, M);
  long long ans;
  if (N == 1) {
    if (M == 1) {
      ans = 1;
    } else {
      ans = M - 2;
    }
  } else {
    ans = (N - 2) * (M - 2);
  }
  cout << ans << endl;

  return 0;
}
/* vim:set fdm=marker: */


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

namespace IO
{
    const int S=(1<<20)+5;
    char buf[S],*H,*T;
    inline char Get()
    {
        if(H==T) T=(H=buf)+fread(buf,1,S,stdin);
        if(H==T) return -1;return *H++;
    }
    inline int read()
    {
        int x=0;char c=Get();
        while(!isdigit(c)) c=Get();
        while(isdigit(c)) x=x*10+c-'0',c=Get();
        return x;
    }
    char obuf[S],*oS=obuf,*oT=oS+S-1,qu[55];int qr;
    inline void flush(){fwrite(obuf,1,oS-obuf,stdout);oS=obuf;}
    inline void putc(char x){*oS++ =x;if(oS==oT) flush();}
    template <class I>inline void print(I x)
    {
        if(!x) putc('0');
        while(x) qu[++qr]=x%10+'0',x/=10;
        while(qr) putc(qu[qr--]);
    }
    inline void prints(const char *s)
    {
        int len=strlen(s);
        for(int i=0;i<len;i++) putc(s[i]);
        putc('\n');
    }
}

using namespace IO;
const int N=510;
int a[N*N],X[N],n;
int c[N],cnt[N];
int pos[N][N],num[N];

bool cmp(const int &x,const int &y){return X[x]<X[y];}

bool check()
{
    for(int i=1;i<=n*n;i++)
        pos[a[i]][++num[a[i]]]=i;
    for(int i=1;i<=n;i++)
        if(pos[i][i]!=X[i]) return 0;
    return 1;
}

int main()
{
    n=read();
    for(int i=1;i<=n;i++) X[i]=read();
    for(int i=1;i<=n;i++) c[i]=i,a[X[i]]=i;
    sort(c+1,c+1+n,cmp);
    for(int i=1;i<=n;i++) cnt[i]=i-1;
    for(int i=1;i<=n*n;i++)
    {
        if(a[i]) continue;
        for(int j=1;j<=n;j++)
            if(cnt[c[j]]){a[i]=c[j];cnt[c[j]]--;break;}
    }
    for(int i=1;i<=n;i++) cnt[i]=n-i;
    for(int i=n*n;i>=1;i--)
    {
        if(a[i]) continue;
        for(int j=n;j>=1;j--)
            if(cnt[c[j]]){a[i]=c[j];cnt[c[j]]--;break;}
    }
    if(check())
    {
        prints("Yes");
        for(int i=1;i<=n*n;i++)
            print(a[i]),putc(' ');
    }
    else prints("No");
    flush();
    return 0;
}

Measured memory_bytes: 5248
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,n,s) for(int i = s; i < (n); ++i)
#define rsrep(i,n,s) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<x<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define out_ary(...) { for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef vector<int> vint;
typedef vector<float> vfloat;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vstr> vvstr;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;

ll GCD(ll a, ll b) {
    if (a < b) swap(a, b);
    ll r = a % b;
    while (r > 0) {
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}

ll calc(ll a, ll b) {
    return a / b;
}

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

    ll ans = b - a + 1;
    ll lcm = c * d / GCD(c, d);
    ans -= calc(b, c) - calc(a-1, c);
    ans -= (calc(b, d) - calc(a-1, d));
    ans += (calc(b, lcm) - calc(a-1, lcm));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
N, W = map(int, input().split())
INF = 10**10
dp = [[-INF]*(W+1) for i in range(N+1)]
dp[0][0] = 0

for i in range(N):
    w,v = map(int, input().split())
    dp[i+1][:] = dp[i][:]
    for j in range(W):
        if dp[i][j] == -INF:continue 
        if j + w > W: continue
        dp[i+1][j+w] = max(dp[i][j+w], dp[i][j] + v)

print(max(dp[N]))

Measured memory_bytes: 120980
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define INF 2147483647
#define LINF 9223372036854775807
#define MOD 1000000007
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define repb(i,n) for(int i=n-1;i>=0;i--)
#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef pair<int,int> P;
//typedef long long int ll;

int ans;

signed main(){

    int n,k;
    string s;
    cin>>n>>k>>s;
    s[k-1]-='A'-'a';
    cout<<s<<endl;
    
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<ctype.h>
#include<string>
using namespace std;
int main(){
	int x, a, b;
	cin >> x >> a >> b;
	int A = x - a, B = x - b;
	if(A <= 0){
		A *= -1;
	}
	if(B <= 0){
		B *= -1;
	}
	if(A < B){
		cout << "A" << endl;
	}
	else{
		cout << "B" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#define INF 1<<30
#define FinishFunction return 0
#define MAX 1000000
using namespace std;
      
struct edge {
  int from,to,cost,k;
};
    
edge es[MAX];
    
int main(){
  int n,u,k,E,c,v;
  E = 0;
  scanf("%d",&n);
    
  for(int i=0;i<n;i++){
    scanf("%d %d",&u,&k);
       
    for(int j=0;j<k;j++){
      scanf("%d %d",&v,&c);
      es[E].from = u;
      es[E].to = v;
      es[E++].cost = c;
    }
  }
    
  // Ika berumanfo-do 
  int d[MAX];
  for(int i=0;i<n;i++)d[i] = INF;
  d[0] = 0;
  while(true){
    bool update = false;
    for(int i=0;i<E;i++){
      edge e = es[i];
      if(d[e.from] != INF && d[e.to] > d[e.from] + e.cost){
    d[e.to] = d[e.from] + e.cost;
    update = true;
      }
    }
    if(!update)break;
  }
  for(int i=0;i<n;i++)cout << i << " " << d[i] << endl;
  FinishFunction;// return 0
}

Measured memory_bytes: 8644