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

typedef long long i64;

i64 suma;
i64 a, b;

bool ok(i64 st, i64 dr, i64 l, i64 r)
{
    if (dr <= l)
        return dr * l <= suma;
    if (st >= r)
        return st * r <= suma;

    /// se suprapun
    double q = 1.0 * (st + r) / 2;
    i64 x = q;
    if (1.0 * x == q) {
        if (x * x > suma)
            return false;
    }
    else if (x * (x + 1) > suma)
        return false;
    return true;
}

bool split(int x, int y, int l, int r)
{
    if (y < x || r < l)
        return true;
    if (x <= a && a <= y) {/// impart
        int len = a - x;
        return split(x, x + len - 1, r - len + 1, r) &&
             split(x + len + 1, y + 1, l, r - len);
    }
    if (l <= b && b <= r) {
        int len = b - l;
        return split(y - len + 1, y, l, l + len - 1) &&
                split(x, y - len, l + len + 1, r + 1);
    }
    return ok(x, y, l, r);
}

bool cbin(int x)
{
    /// iau primii x
    return split(1, x, 1, x);
}


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

    while (t--) {
        cin >> a >> b;
        if (a > b)
            swap(a, b);
        suma = 1ll * a * b - 1;
        int p(0), q(1 << 30);
        while (q) {
            if (cbin(p + q))
                p += q;
            q /= 2;
        }
        cout << p << '\n';
    }
    return 0;
}


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

int main() {
  int n, k, min;

  cin>>n>>k;

  int h[n], custo[n];

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

  custo[n-1] = 0;

  for(int i = n-2; i >= 0; i--){
    min = 999999999;
    for(int l = 1; l <= k; l++){
      int c = h[i] - h[i+l];
      
      if(c < 0){
        c = c*(-1);
      }

      if(c + custo[i+l] < min){
        min = c + custo[i+l];
      }

      if(i+l == n-1){
        break;
      }
    }

    custo[i] = min;
  }

  cout<<custo[0]<<endl;
}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner( System.in );
		int n = sc.nextInt();
		int t = sc.nextInt();
		int ans = 10000;
		for(int i=0; i<n; i++){
			int c = sc.nextInt();
			int t2 = sc.nextInt();
			if(t2 <= t){
				ans = Math.min(ans, c);
			}
		}
		if(ans >= 10000){
			System.out.println("TLE");
		}else{
			System.out.println(ans);
		}
	}
}


Measured memory_bytes: 21844
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <random>

using namespace std;
 
#define mod 1000000007
#define FOR(x,to) for(int x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define long long long
inline int rei(){int x;cin>>x;return x;}
inline long rel(){long x;cin>>x;return x;}
inline string res(){string x;cin>>x;return x;}
//------------------------------------------------------- 
void Calc(){
	long A = rei();
	long B = rei();
	long C = (A+B)/2;
	if((A+B)%2 == 0){
		cout << C << endl;
	}
	else{
		cout << "IMPOSSIBLE" << endl;
	}
}
int main(int argc,char** argv){
	ios::sync_with_stdio(false), cin.tie(0);
	cout.tie(0); Calc(); return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;

public class Main {

    static Scanner sc = new Scanner(System.in);


    public static void main(String[] args) {
        int x = sc.nextInt();
        int y = sc.nextInt();
        int z = sc.nextInt();
        int k = sc.nextInt();
        Long[] A = new Long[x];
        Long[] B = new Long[y];
        Long[] C = new Long[z];
        for (int i = 0; i < x; i++) A[i] = sc.nextLong();
        for (int i = 0; i < y; i++) B[i] = sc.nextLong();
        for (int i = 0; i < z; i++) C[i] = sc.nextLong();
        List<Long> abc = new ArrayList<>();
        Arrays.sort(A, Collections.reverseOrder());
        Arrays.sort(B, Collections.reverseOrder());
        Arrays.sort(C, Collections.reverseOrder());
        for (int a = 0; a < x; a++) {
            for (int b = 0; b < y; b++) {
                if (a * b > k) break;
                for (int c = 0; c < z; c++) {
                    if (a * b * c > k) break;
                    abc.add(A[a] + B[b] + C[c]);
                }
            }
        }
        abc.sort(Comparator.reverseOrder());
        for (int i = 0; i < k; i++) {
            System.out.println(abc.get(i));
        }
    }
}


Measured memory_bytes: 147292
#include <stdio.h>

using namespace std;

int main(){
	int r,c,sum,total_sum = 0;
	scanf("%d %d",&r,&c);
	int table[r+1][c+1];

	for(int i = 0; i < r+1; i++){
		for(int j = 0; j < c+1; j++){
			table[i][j] = 0;//r+1,c+1までまっさらにする
		}
	}

	for(int i = 0; i < r; i++){
		sum = 0;
		for(int j = 0; j < c; j++){
			scanf("%d",&table[i][j]);
			sum += table[i][j];
			table[r][j] += table[i][j];
		}
		table[i][c] = sum;
		total_sum += sum;
	}
	table[r][c] = total_sum;

	for(int i = 0; i < r+1; i++){
		for(int j = 0; j < c; j++){
			printf("%d ",table[i][j]);
		}
		printf("%d\n",table[i][c]);
	}
}


Measured memory_bytes: 2724
using System.Linq;
using System;

public class Hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        var a = new int[n];
        for (int i = 0; i < n; i++) a[i] = int.Parse(Console.ReadLine().Trim());
        var asum = a.Sum();
        if (asum % 10 != 0) { Console.WriteLine(asum); goto end; }
        var b = a.Where(x => x % 10 != 0);
        if (b.Count() == 0) { Console.WriteLine(0); goto end; }
        var ret = b.OrderBy(x => x).First();
        Console.WriteLine(asum - ret);
        end:;
    }
}

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

typedef long long ll;

ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}

int main(){
	int n;
	cin>>n;
	vector<ll>a(n);
	for(int i=0;i<n;i++)cin>>a[i];
	ll ans=1;
	for(int i=0;i<n;i++){
		ans=ans/gcd(ans,a[i])*a[i];
	}
	cout<<ans<<endl;
}

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

int main(){
    int N,H;
    int s=0;
    int count =0;
    cin >> N;
    for(int i=0; i<N;++i){
        cin >> H;
        if(s<=H){
            s=H;
            ++count;
        }
    }
    cout << count <<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> //Andrei Alexandru a.k.a Sho10
#define ll long long
#define double long double
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define all(a) (a).begin(), (a).end()
#define sz size
#define f first
#define s second
#define pb push_back
#define er erase
#define in insert
#define mp make_pair
#define pi pair
#define rc(s) return cout<<s,0
#define endl '\n'
#define mod 1000000007
#define PI 3.14159265359
#define MAXN 100005
#define INF 1000000005
#define LINF 1000000000000000005
#define CODE_START  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
ll d,t,s;
int32_t main(){
CODE_START;
cin>>d>>t>>s;
ll x=(d+s-1)/s;
if(x<=t){
    cout<<"Yes"<<endl;
}else cout<<"No"<<endl;
}



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

int main(){
  int p,N,S=0,max=0;
  cin >> N;
  for(int i=0;i<N;i++){
    cin >> p;
    if(p>=max){max=p;}
    S+=p;
  }
  S-=(max/2);
  cout << S << endl;
  return 0;
}

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

struct lpl{
	long long xr, sm;
	inline bool operator < (const lpl &A)const{return (xr == A.xr) ? (sm < A.sm) : (xr < A.xr);}
};
map<lpl, int> mp;
long long n;

inline int dp(long long u, long long v){
	if(v < 0) return 0; if(!v) return 1;
	if(mp.count((lpl){u, v})) return mp[(lpl){u, v}];
	int ret = 0;
	ret += dp((u >> 1), (v >> 1)); ret = (ret >= mod) ? (ret - mod) : ret; 
	ret += dp(((u - 1) >> 1), ((v - 1) >> 1)); ret = (ret >= mod) ? (ret - mod) : ret; 
	if(v >= 2) ret += dp((u >> 1), ((v - 2) >> 1)); ret = (ret >= mod) ? (ret - mod) : ret; 
	mp[(lpl){u, v}] = ret; return ret;
}

int main()
{
	cin >> n;
	cout << dp(n, n);
	return 0;
} 

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

const ll INF = 1001001001;

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

ll f(ll x){
  if(x==0) return 0;
  else if(x==1) return 1;
  return x*f(x-1);
}

int zetai(int y,int z ){
  if(y>=z) return y-z;
  else return z-y;
}

//再起関数でとく

int main(){
  string s;
  cin>>s;
  if(s=="ABC"){
    cout<<"ARC"<<endl;
  }else{
    cout<<"ABC"<<endl;
  }
  
  return 0;
}



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

int main() {
    int64_t n;
	cin >> n;
	vector<int64_t> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	int64_t b;
	b = n * (n + 1) / 2;
	int64_t c = 0;
	for (int i = 0; i < n; i++) {
		c += a[i];
	}
	cout << c - b << endl;
		
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    vector<int> vec(n+1,0);
    for(int i=1;i<=n;i++)
    {
        for(int j=i;j<=n;j+=i)
        {
            vec[j]++;
        }
    }
    long long ans=0;
    for(int i=1;i<=n-1;i++)
    {
        ans+=vec[i];
    }
    cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 7096
#include<iostream>
#include<cstring>
#include<cstdio>
#include<string>
#include<algorithm>
#include<cmath>
#include<utility>
#include<stdio.h>
#include<cstdlib>
#include<iomanip> //cout<<setiosflags(ios::fixed)<<setprecision(2);
#include<ctime> //double a=(double)clock();   cout<<a<<endl;
#include<vector>
#include<queue>
using namespace std;
inline int read(){
    int x=0,ff=1;char ch=getchar();
    while(ch>'9'||ch<'0'){if(ch=='-')ff=-1;ch=getchar();}
    while(ch<='9'&&ch>='0'){x=x*10+ch-'0';ch=getchar();}
    return ff*x;
}

int main(){
	//freopen("in","r",stdin);
	int a=read(),b=read(),c=read();
	if(c<=a-b)
		puts("0");
	else
		printf("%d\n",c-(a-b));
	return 0;
}
 


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

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

    bool c = false;
    for(int i = 0; i < s.length(); i++){
        if(s[i] == 'C') c = true;

        if(c && s[i] == 'F'){
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;
    return 0;
}

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

template<class T> inline void chmax(T& a, const T& b) { if(b > a) a = b; }

#define MAX 16

int m, n;
double win[MAX][MAX];
double memo[MAX][(1 << MAX)];

inline double dfs(int room = 0, int rest = (1 << m) - 1) {
	if(memo[room][rest] >= 0.0)
		return memo[room][rest];

	double res = 0.0;
	for(int i = 0; i < m; ++i) {
		if(rest & (1 << i)) {
			const int next_rest = rest ^ (1 << i);
			double tmp = 0.0, p = 1.0;
			for(int j = room; j < n; ++j) {
				tmp += p * (1 - win[i][j]) * dfs(j, next_rest);
				p *= win[i][j];
			}

			chmax(res, tmp + p);
		}
	}

	return memo[room][rest] = res;
}

int main() {
	scanf("%d %d", &m, &n);

	for(int i = 0; i < m; ++i)
		for(int j = 0; j < n; ++j)
			scanf("%lf", &win[i][j]);

	memset(memo, -1, sizeof(memo));
	for(int i = 0; i < n; ++i)
		memo[i][0] = 0.0;

	printf("%.15lf\n", dfs());

	return EXIT_SUCCESS;
}

Measured memory_bytes: 9292
#include <bits/stdc++.h>
#define INF 1e9+7
#define pb push_back
#define mp make_pair
using namespace std;
typedef long long int lo;
string a,b,c;
lo x,y;

int main(){
    cin >> a >> b;
    cin >> x >> y;
    cin >> c;
    if(a == c) cout << x-1 << " " << y;
    else cout << x << " " << y-1; 
}

Measured memory_bytes: 256
def main():
    n=int(input())
    m=int((2*n)**0.5)
    if m*(m+1)==n*2:
        print("Yes")
        m+=1
        print(m)
    else:
        print("No")
        exit()
    
    ans=[[m-1] for i in range(m)]
    c=1
    for i in range(m):
        for j in range(i+1,m):
            ans[i].append(c)
            ans[j].append(c)
            c+=1
    for i in ans:
        print(*i)


if __name__ == '__main__':
    main()








Measured memory_bytes: 47196
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;

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

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

int extgcd(int a, int b, int& x, int&y) {
    int d = a;
    if(b != 0) {
        d = extgcd(b, a % b, y, x);
        y -= (a / b) * x;
    }else {
        x = 1;
        y = 0;
    }
    return d;
}

int inv(int a) {
    int x, y;
    extgcd(a, MOD, x, y);
    return (x + MOD) % MOD;
}

struct UniTree {
    int *par, *rank, *sz;

    UniTree(int n) {
        par = new int[n];
        rank = new int[n];
        sz = new int[n];
        for(int i = 0; i < n; i++) {
            par[i] = i;
            rank[i] = 0;
            sz[i] = 1;
        }
    }

    int root(int x) {
        if(par[x] == x) return x;
        else return par[x] = root(par[x]);
    }

    void merge(int x, int y) {
        x = root(x);
        y = root(y);
        if(x == y) return;
        if(rank[x] < rank[y]) {
            par[x] = y;
            sz[y] += sz[x];
        }else {
            par[y] = x;
            if(rank[x] == rank[y]) rank[x]++;
            sz[x] += sz[y];
        }
    }
    
    bool same(int x, int y) {
        return root(x) == root(y);
    }

    int siz(int x) {
        return sz[root(x)];
    }
};

bool check(double mid) {
    return true;
}

double bin(double left, double right) {
    while(right - left > 1e-4) {
        double mid = (left + right) / 2;
        if(check(mid)) left = mid;
        else right = mid;
    }
    return left;
}

int main() {
    int n, q;
    cin >> n >> q;
    ll* a = new ll[n];
    rep(i, n) cin >> a[i];
    
    rep(i, q) {
        ll x;
        cin >> x;
        ll sum = 0;
        ll ans = 0;
        int t = 0;
        rep(s, n) {
            while(t < n && sum + a[t] <= x) {
                sum += a[t++];
            }
            ans += t - s;
            sum -= a[s];
        }
        cout << ans << endl;
    }
}



Measured memory_bytes: 3872
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define all(obj) (obj).begin(),(obj).end() 
#define dump(x)  cout << #x << " = " << (x) << endl;
typedef long long lint;
using namespace std;
int main(){
	lint a,b,c;
	cin>>a>>b>>c;
	cout<<(4*a*b<(c-a-b)*(c-a-b)&&0<=c-a-b?"Yes":"No")<<endl;
}

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

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

lis = [0] * (p+1)

for i in range(p):

    if i == 0:
        lis[1] = 1
        lis[0] = 0

    else:
        
        nlis = [0] * (p+1)

        for j in range(p+1):
            nlis[j] += lis[j] * (-1 * i)
            if j != 0:
                nlis[j] += lis[j-1]
            nlis[j] %= p

        lis = nlis

#print (lis) = (x-0)*(x-1)*…*(x-p+1)の各項の係数
#ラグランジュ補完を実際に計算していく
#参考　https://mathtrain.jp/hokan

ans = [0] * p

for i in range(p):

    #fi(x)を計算 (x-i)でlisを割る
    if a[i] == 0:
        continue

    nlis = [0] * p

    for j in range(p-1,-1,-1):

        if j == p-1:
            nlis[j] = lis[j+1]
        else:
            nlis[j] = (lis[j+1] - nlis[j+1] * (-1 * i)) % p

    for j in range(p):
        ans[j] += nlis[j]

for i in range(p):
    ans[i] = (p - ans[i]) % p
print (" ".join(map(str,ans)))

Measured memory_bytes: 44764
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
using namespace std;
#define ll long long int 

int main(){
  int n,m,ans = 0;
  cin >> n >> m;
  vector<bool> eat(m + 5,true);
  for(int i = 0; i < n; ++i){
    int k;
    cin >> k;
    
    set<int> suki;
    for(int j = 0; j < k; ++j){
      int x;cin>>x;
      suki.insert(x);  
    }

    for(int l = 1; l <= m; ++l){
      bool ok = suki.count(l);
      if( ok == false)eat[l] = false;
    }
  }

  for(int i = 1; i <= m; ++i){
    if( eat[i] == true){
      ++ans;
      //cout << "i = " << i << endl;
    }
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 888
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
using namespace std;
typedef long long ll;
ll MOD = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)
int main() {
    string s;
    cin >> s;
    cout << s.substr(0, 4) << " " << s.substr(4, 8) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>  // clang-format off
using namespace std;
using Int = long long;
#define REP_(i, a_, b_, a, b, ...) for (int i = (a), lim_i = (b); i < lim_i; i++)
#define REP(i, ...) REP_((i), __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
struct SetupIO { SetupIO() { cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(13); } } setup_io;
#ifndef _MY_DEBUG
#define dump(...)
#endif  // clang-format on

/**
 *    author:  knshnb
 *    created: Sat Mar 14 21:00:01 JST 2020
 **/

#define double long double
signed main() {
    double a, b, c;
    cin >> a >> b >> c;
    bool ok = 2 * sqrt(a * b) < c - a - b;
    cout << (ok ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <complex>
#include <vector>
#include <limits>
#include <iomanip>
#include <cassert>

using namespace std;

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

#define debug(x) cout << #x << " = " << (x) << endl;
#define rep(i, n) for(int i = 0;i < n;i++)
#define repr(i, n) for(int i = n-1;i >= 0;i--)
#define pb push_back
#define mp make_pair
#define F first
#define S second

const long double pi = 3.141592653589793;
const int mod = 1e9 + 7;

vector<string> vs(1023);
int sx, sy, ex, ey, N, M;

template<typename T>
struct DijkstraGrid {
  int R, C;
  const T INF;
  vector<vector<T>> dij;
  vector<int> dx, dy;

  DijkstraGrid(int R, int C, T INF):
  R(R), C(C), INF(INF), dij(R, vector<T>(C, INF)) {}

  bool outside_grid(int x, int y) {
    return (x < 0 || y < 0 || x >= R || y >= C);
  }

  T edge_cost(int x, int y, int xn, int yn) {
    if(vs[xn][yn] == '#') return INF;
    if(abs(x-xn) + abs(y-yn) == 1) return 0;
    return 1;
  }

  void runDijkstra(int sx, int sy) {
    set<pair<T, pair<int, int>>> q;
    dij[sx][sy] = 0;
    q.insert({0, {sx, sy}});

    while (!q.empty()) {
      auto from = q.begin()->S;
			int x = from.F, y = from.S;
      q.erase(q.begin());

      for(int i = 0;i < dx.size();i++) {
        int xn = x + dx[i], yn = y + dy[i];
        if(outside_grid(xn, yn)) continue;

        T ecost = edge_cost(x, y, xn, yn);
        if(dij[x][y] + ecost < dij[xn][yn]) {
					q.erase({dij[xn][yn], {xn, yn}});
          dij[xn][yn] = dij[x][y] + ecost;
          q.insert({dij[xn][yn], {xn, yn}});
				}
      }
    }
  }

};


int main() {

 // freopen("input.in","r",stdin);
 // freopen("output.out","w",stdout);

 ios_base::sync_with_stdio(false);
 cin.tie(nullptr);

 cin>>N>>M>>sx>>sy>>ex>>ey;
 sx--;sy--;ex--;ey--;
 rep(i,N) cin>>vs[i];
 DijkstraGrid<int> dg(N,M,1e8);
 for(int i = -2;i <= 2;i++) {
   for(int j = -2;j <= 2;j++) {
     if(i==j && i==0) continue;
     dg.dx.push_back(i);
     dg.dy.push_back(j);
   }
 }
 dg.runDijkstra(sx, sy);

 if(dg.dij[ex][ey] == dg.INF) cout<<-1;
 else cout<<dg.dij[ex][ey];


 return 0;
}


Measured memory_bytes: 8788
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main(){
    int n,d,x;
    int cnt=0;
    cin >> n >> d >> x;
    vector<int> a(n);
    rep(i,n) cin >> a[i];

    rep(i,n){
        int nissu=1;
        
        while(nissu <= d){
            cnt++;
            nissu += a.at(i);
        }
    }
    cout << cnt+x << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;
 
int n,pos;
vector<int> pre,in,post;
 
void rec(int l,int r){
    if(l>=r)
        return;
    int root = pre[pos++];
    int m = distance(in.begin(),find(in.begin(),in.end(),root));
    rec(l,m);
    rec(m+1,r);
    post.push_back(root);
}
 
void solve(){
    pos = 0;
    rec(0,pre.size());
    for(int i=0;i<n;i++){
        if(i)
            cout<<" ";
        cout<<post[i];
    }
    cout<<endl;
}
 
int main(){
    int k;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>k;
        pre.push_back(k);
    }
 
    for(int i=0;i<n;i++){
        cin>>k;
        in.push_back(k);
    }
    solve();
}
 

 

Measured memory_bytes: 3160
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
int n,p,m=1e9,c;
int main(){
	scanf("%d", &n);
	rep(i,n){
		scanf("%d", &p);
		if(m > p){
			c++;
			m = p;
		}
	}
	printf("%d\n", c);
}

Measured memory_bytes: 256
a,b,c,d,e,f=map(int,input().split())
s=[]
for i in range(f):
    for j in range(f):
        y=i*c+j*d
        if y<=f:
            s.append(y)
w=[]
for i in range(0,f//100+1):
    for j in range(0,f//100+1):
        x=i*a*100+j*b*100
        if x<=f:
            w.append(x)
max_con=0
ans,ans_2=0,0
for x in w:
    for y in s:
        if x==0 and y==0:
            continue
        elif e*(x//100)<y:
            continue
        elif x+y>f:
            continue
        else:
            con=(100*y)/(x+y)
            if max_con<=con:
                max_con=con
                ans=x+y
                ans_2=y
print("{} {}".format(ans,ans_2))

Measured memory_bytes: 12440
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int[] h = new int[n];
        for (int i = 0; i < n; i++) {
            h[i] = in.nextInt();
        }

        boolean needsWatering = true;
        int numWaters = 0;
        while (needsWatering) {
            needsWatering = false;
            for (int i = 0; i < n; i++) {
                if (h[i] != 0) {
                    h[i]--;
                    needsWatering = true;
                    if (i == n - 1 || h[i + 1] == 0) {
                        numWaters++;
                    }
                }
            }
        }

        System.out.println(numWaters);

    }
}


Measured memory_bytes: 23764
#include <iostream>
#include <vector>
#include <set>

using namespace std;

int main(int argc, const char *argv[])
{
  int n;
  cin >> n;

  vector<int> v(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i];
  }
  
  // ボールを入れる箱番号
  set<int> boxes;
  for (int i = n - 1; i >= 0; i--) {
    int cnt = 0;
    if (!boxes.empty()) {
      for (int j = (i + 1) * 2; j <= *boxes.rbegin(); j += i + 1) {
        if (boxes.count(j) == 1) {
          cnt++;
        }
      }
    }

    if (v[i] != cnt % 2) {
      boxes.insert(i + 1);
    }
  }

  cout << boxes.size() << "\n";
  for (auto box : boxes) {
    cout << box << "\n";
  }
  
  return 0;
}

Measured memory_bytes: 7808
/*
  author: ruruvuvu
  GitHub account: colon-ku

  created at: 2020-01-07 11:06:23
*/

#include <bits/stdc++.h>
using namespace std;

#define all(x) (x).begin(),(x).end()
#define rep(x, y) for (int x = 0; x < y; x++)
#define MOD 1000000007

typedef long long LL;
typedef long double LD;

bool compare_by_b(pair<int, int> a, pair<int, int> b)
{
    if (a.second != b.second) {
        return a.second < b.second;
    } else {
        return a.first < b.first;
    }
}

ostringstream oss_global;
string s_global = oss_global.str();

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

    string ans = "No";
    for (int i = 0; i*4 <= n; i++) {
        int m = n - i*4;
        if (m % 7 == 0) ans = "Yes";
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <ext/rope>
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;

template<class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define ll long long
#define ull unsigned long long

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

    double out = 0;
    int n;
    double x;
    cin >> n;
    for(int i = 0 ; i < n ; i++) cin >> x , out += 1 / x;
    cout << fixed << setprecision(5) << 1 / out;

    return 0;
}


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

int h,w,grid[52][52],cnt=0;

void solve(int x, int y){
	if(grid[x-1][y]>grid[x][y]+1){
		grid[x-1][y]=grid[x][y]+1;
		solve(x-1,y);
	}
	if(grid[x][y-1]>grid[x][y]+1){
		grid[x][y-1]=grid[x][y]+1;
		solve(x,y-1);
	}
	if(grid[x+1][y]>grid[x][y]+1){
		grid[x+1][y]=grid[x][y]+1;
		solve(x+1,y);
	}
	if(grid[x][y+1]>grid[x][y]+1){
		grid[x][y+1]=grid[x][y]+1;
		solve(x,y+1);
	}
}


int main(){
	cin>>h>>w;
	grid[0][0]=0;
	grid[h+1][w+1]=0;
	for(int i=1;i<=h;i++){
		grid[i][0]=0;
		grid[i][w+1]=0;
		for(int j=1;j<=w;j++){
			if(i==1){
				grid[0][j]=0;
				grid[h+1][j]=0;
			}
			char tmp;
			cin>>tmp;
			if(tmp=='.'){
				grid[i][j]=3000;
				cnt++;
			}else{
				grid[i][j]=0;
			}
		}
	}
	grid[1][1]=1;
	solve(1,1);
	if(grid[h][w]==3000){
		cout<<-1<<endl;
	}else{
		cout<<cnt-grid[h][w]<<endl;
	}
	
}

Measured memory_bytes: 384
#include <iostream>
using namespace std;
int main(){
  int N, T, A; cin >> N >> T >> A;
  T = T*1000;
  A = A*1000;
  int temp, sa; sa = 100000000;
  int ans;
  int H[1000];
  for (int i=0; i<N; i++){
    cin >> H[i];
    H[i] = H[i]*1000;
  }
  
  for (int i=0; i<N; i++){  
    temp = T - 0.006*H[i];
    if (sa > abs(A - temp)){
      ans = i+1;
      sa = abs(A - temp);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
  int a[4], b, hit, blow, i, j;
  while (cin >> a[0]) {
    hit = 0, blow = 0;
    for (i = 1; i < 4; i++) {
      cin >> a[i];
    }
    for (i = 0; i < 4; i++) {
      cin >> b;
      for (j = 0; j < 4; j++) {
	if (a[j] == b) {
	  if (i == j) {
	    hit++;
	  }
	  else {
	    blow++;
	  }
	}
      }
    }
    cout << hit << ' ' << blow << endl;
  }
  return 0;
}

Measured memory_bytes: 0
import math

A, B, X = input().split()
a = int(A)
b = int(B)
x = int(X)
S = a * a * b
if x >= (S / 2):
    L = 2 * (S - x)/(a * a * a)
    print(math.degrees(math.atan(L)))
else:
    L = 2 * x / (a * b * b)
    print(90 - math.degrees(math.atan(L)))




Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define ALLR(v) v.rbegin(),v.rend()
typedef long long ll;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//isPrime
//modpow modinv
//getDigit
int main() {
  cout << fixed << setprecision(10);
  double n,k;
  cin >> n >> k;
  double ans = 0;
  for(int i = 1; i<=n; i++){
    if(i<k){
      int numcoin = ceil(log2(k/i));
      double p = 1/n;
      p = p*pow(0.5,numcoin);
      ans += p;
    }else{
      ans += 1/n;
    }

  }
  cout << ans << endl;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.nextLine();
        long k = sc.nextLong();
        int ans = 0;
        int n = 0;
        for (int i = 0; i < s.length(); i++) {
            n = s.charAt(i) - '0';
            k--;
            if (k == 0 || n > 1) break;
        }
        System.out.println(n);
        sc.close();
    }
}


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

using namespace std;

long long gcd(long long x, long long y){
    if(y == 0) return x;
    return gcd(y, x%y);
}

int main(){
    int x, y;
    cin >> x >> y;
    
    cout << gcd(x, y) << "\n";

    return 0;
}


Measured memory_bytes: 3084
#include<iostream>
#include<algorithm>

using namespace std;

static const int MAX = 200000;

int main() {
  int R[MAX], n;

  cin >> n;
  for (int i = 0; i < n; i++) cin >> R[i];

  int maxv = -2000000000; //十分小さい値を初期値に設定
  int minv = R[0];

  for (int i = 1; i < n; i++){ //ここで毎回R[i]を読み込めば配列は不要
    maxv = max(maxv, R[i] - minv); //最大値を更新
    minv = min(minv, R[i]);
  }

  cout << maxv << endl;

  return 0;
}


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

#define int long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define dbg(x) cerr << #x << ": " << x << endl;
#define dbg2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define dbg3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define dbgB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

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

template<typename T>
void print1(T begin, T end) {
  while (begin != end) {
    cerr << (*begin) << " ";
    *begin++;
  }
  cerr << endl;
}

template<typename T>
void print2(T Array, int height, int width) {
  for (int i = 0; i < height; i++) {
    for (int j = 0; j < width; j++) {
      cerr << " " << Array[i][j];
    }
    cerr << endl;
  }
}

void print() { std::cerr << endl; }
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  std::cerr << head << " ";
  print(std::forward<Tail>(tail)...);
}

template<class T>
void Add(T &a, const T &b, const T &mod=1000000007) {
  int val = ((a % mod) + (b % mod)) % mod;
  if (val < 0) { val += mod; }
  a = val;
}

template <typename X, typename T> auto vectors(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto vectors(X x, Y y, Z z, Zs... zs) { auto cont = vectors(y, z, zs...); return vector<decltype(cont)>(x, cont); }

// ------------------------------------------------------------------------------------------

signed main() {
  vec<int> a(3);
  rep (i, 3) {
    cin >> a[i];
  }
  sort(all(a));

  cout << a[2]*10 + a[1] + a[0] << endl;

  return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;

#define RN_MAX 1000010

typedef long long int lli;

int ptable[RN_MAX];

lli gcd(lli a, lli b)
{
	if (b > a){
		swap(a, b);
	}
	if (0 == b){
		return a;
	}
	return gcd(b, a%b);
}

bool prime(lli val)
{
	if (1 == val){
		return false;
	}
	for (int i = 2; i < RN_MAX; i++){
		if (0 == ptable[i]){
			continue;
		}
		if (0 == val%i){
			return false;
		}
	}
	return true;
}

void solv()
{
	fill(ptable, ptable + RN_MAX, -1);
	for (int i = 2; i < RN_MAX; i++){
		if (0 == ptable[i]){
			continue;
		}
		ptable[i] = 1;
		for (int j = i + i; j < RN_MAX; j += i){
			ptable[j] = 0;
		}
	}

	vector<pair<int, int> > v;

	lli A, B; scanf("%lld%lld", &A, &B);
	lli g = gcd(A, B);
	for (int i = 2; i < RN_MAX; i++){
		if (0 == ptable[i]){
			continue;
		}
		int cnt = 0;
		while (0 == g%i){
			g = g / i;
			cnt++;
		}
		if (0 != cnt){
			v.push_back(make_pair(i, cnt));
		}
	}
	if (prime(g)){
		v.push_back(make_pair(g, 1));
	}

	printf("%d", v.size() + 1);

	return;
}

int main()
{
	FILE *fin = NULL, *fout = NULL;
	//fin = freopen("input.txt", "r", stdin);
	//fout = freopen("output.txt", "w", stdout);

	solv();

	//finalize
	if (NULL != fin) fclose(fin);
	if (NULL != fout) fclose(fout);

	return 0;
}

Measured memory_bytes: 4224
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        
        int[] num = new int[5];
        for (int i=0; i<5; i++) {
            num[i] = sc.nextInt();
        }
        int k = sc.nextInt();

        String result = "Yay!";
        out: for (int i=0; i<5; i++) {
           for (int j=i+1; j<5; j++) {
              if (Math.abs(num[i] - num[j]) > k) {
                  result = ":(";
                  break out;
              }
           }
        }
        
        System.out.println(result);
    }
}


Measured memory_bytes: 35700
/**
 *    author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *    created : 2020-02-18 03:46:47
**/

#include <iostream>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
#include <bitset>
#include <cassert>
#include <cctype>
#include <iomanip>
#include <random>
#include <utility>
#include <chrono>

using namespace std;

using int64 = long long;

template<class T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) { os << '{'; size_t n = vec.size(); for (size_t i = 0; i < n; ++i) { os << vec[i]; if (i != n - 1) os << ','; } os << '}'; return os; }
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) { return os << '{' << p.first << " " << p.second << '}'; }
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) { os << '{'; for (auto it = mp.begin(); it != mp.end(); ++it) { os << '{' << it->first << ':' << it->second << '}'; if (it != --mp.end()) os << ','; } os << '}'; return os; }
template<class T> std::ostream& operator<<(std::ostream& os, const std::set<T>& st) { os << '{'; for (auto it = st.begin(); it != st.end(); ++it) { os << *it; if (it != --st.end()) os << ','; } os << '}'; return os; }
template<class T> std::istream& operator>>(std::istream& is, std::vector<T>& vec) { size_t n = vec.size(); for (size_t i = 0; i < n; ++i) is >> vec[i]; return is; }

#define all(_) begin(_), end(_)
#define rall(_) rbegin(_), rend(_)

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...) 1728
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}

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

  string s; cin >> s;
  int cntN = 0, cntW = 0, cntS = 0, cntE = 0;
  int n = s.size();

  for (int i = 0; i < n; ++i) {
    cntN += s[i] == 'N';
    cntW += s[i] == 'W';
    cntS += s[i] == 'S';
    cntE += s[i] == 'E';
  }

  if (cntN > 0 && cntS == 0 || cntN == 0 && cntS > 0) {
    cout << "No" << endl; return 0;
  }

  if (cntW > 0 && cntE == 0 || cntW == 0 && cntE > 0) {
    cout << "No" << endl; return 0;
  }

  cout << "Yes" << endl;

  return 0;
}

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

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    int foo, res = 0;
    for(int i = 0; i < n; i ++) {
        cin >> foo;
        while(!(foo & 1)) {
            res ++;
            foo >>= 1;
        }
    }
    cout << res;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	cin >> s;
	if(s.compare("Sunny")==0){
	   cout<<"Cloudy"<<endl;
	}else if(s.compare("Cloudy")==0){
	    cout<<"Rainy"<<endl;
	}else if(s.compare("Rainy")==0){
	    cout<<"Sunny"<<endl;
	}
}


Measured memory_bytes: 256
/*Remember: The Struggle is Important*/

//CF,CC,AtC,SPOJ: hp1999
//HE: hemant269
//HR: hemant2132

#include<bits/stdc++.h>
using namespace std;

#define     int          long long int
#define     ld           long double
#define     fast()       ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define     all(x)       x.begin(),x.end()
#define     mem(a,b)     memset(a,b,sizeof(a))
#define     gcd(a,b)     (__gcd((a),(b)))
#define     lcm(a,b)     (((a)*(b))/gcd((a),(b)))
#define     pb           push_back
#define     ins          insert
#define     pii          pair<int,int>
#define     F            first
#define     S            second
#define     makep        make_pair
#define     maket        make_tuple
#define     show(x)      for(auto c:x)cout<<c<<" ";cout<<"\n";
#define     show2(x)     for(auto c:x)cout<<c.F<<" "<<c.S<<"\n";

const int inf=1e18,M=1e9+7;
const int N=1;

void solve()
{
    string s;
    cin>>s;

    deque<char> dq;
    for(auto c:s)
        dq.pb(c);

    int q;
    cin>>q;

    int cnt=0;
    int t,f;
    char c;
    for(;q;--q)
    {
        cin>>t;

        if(t==1)
            cnt=1-cnt;
        else
        {
            cin>>f>>c;

            if(!cnt)
            {
                if(f==1)
                    dq.push_front(c);
                else
                    dq.pb(c);
            }
            else
            {
                if(f==2)
                    dq.push_front(c);
                else
                    dq.pb(c);
            }
        }
    }

    if(cnt)
        reverse(all(dq));

    for(auto c:dq)
        cout<<c;
}

int32_t main()
{
    fast();

    int t=1;
    //cin>>t;
    while(t--)
    {
        solve();
        //cout<<"\n";
    }

    return 0;
}




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



#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)

using namespace std;

template <class T>
using vec = std::vector<T>;
typedef long long ll;
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; }

const long long INF = 1LL<<60;

int lcm(int a,int b){
    //最小公倍数
    return a/__gcd(a,b) * b;
}

struct edge{int from, to,cost;};

// int型の2次元配列(3×4要素の)の宣言
// vector<vector<int>> data(3, vector<int>(4));

static const  double pi = 3.14159265358979323846;
double sp_l=2*pi/12; //longの1時間の速度
double sp_l_min=sp_l/60; //longのminuteの速度
double sp_s=2*pi; // shortの1時間の速度
double sp_s_min=sp_s/60; // shortのminuteの速度
double a,b;
int h,m;

int main()
{
    cin>>a>>b>>h>>m;
    double l_pos,s_pos;
    l_pos=h*sp_l+m*sp_l_min;
    s_pos=m*sp_s_min;
    
    double x,y;
    x=max(l_pos,s_pos);
    y=min(l_pos,s_pos);
    double rad;
    if(x-y>pi) rad=2*pi-(x-y);
    else if (x-y<pi) rad=x-y;
    else {
        cout<<a+b<<endl;
        return 0;
    }
    // cout<<rad<<endl;


    double c,c2;
    c2=a*a+b*b-2*a*b*cos(rad);
    c=sqrt(c2);
    cout<< std::fixed << std::setprecision(20)<<c<<endl;

    return 0;

}




Measured memory_bytes: 4188
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;


public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		Scanner scan=new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		int x=scan.nextInt();
		int s=x%60;
		x=x/60;
		int m=x%60;
		int h=x/60;

		System.out.println(h+":"+m+":"+s);

	}

}

Measured memory_bytes: 17344
n=int(input())
l=list(map(int,input().split()))

if n<=2:
  print(1)
  exit()
  
cnt=0

if l[0]>l[1]:
  ans="low"
elif l[0]<l[1]:
  ans="high"
else:
  ans="even"
  
for i in range(2,n):
  if l[i-1]>l[i] and (ans=="low" or ans=="even"):
    ans="low"
  elif l[i-1]<l[i] and (ans=="high" or ans=="even"):
    ans="high"
  elif l[i-1]==l[i]:
    continue
  else:
    cnt+=1
    ans="even"
    
print(cnt+1)


Measured memory_bytes: 20164
#include<stdio.h>
int main(){
	int a,b,c,d,e,f;
	scanf("%d%d%d%d%d",&a,&b,&c,&d,&e);
	a=a*e;
	if(c<e)
	{
		f=b+(e-c)*d;
	}
	if(c>e)
	{
		f=b;
	}
	if(a>f)
	{
		printf("%d\n",f);
	}
	if(f>a)
	{
		printf("%d\n",a);
	}
	
return 0;
}


Measured memory_bytes: 1916
(N, M), As = readlines.map{|l| l.split.map(&:to_i)}

if As.map{|a| a.to_s(2).reverse.index('1')}.uniq.size != 1
  puts 0
else
  l = As.map{|a| a/2}.inject(&:lcm)
  puts (M/l + 1)/2
end

Measured memory_bytes: 16644
// #include <boost/multiprecision/cpp_int.hpp>
// using boost::multiprecision::cpp_int;
#include <bits/stdc++.h>
using namespace std;
// ¯\_(ツ)_/¯
#define f first
#define s second
#define p push
#define mp make_pair
#define pb push_back
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define debug(x) cout << '>' << #x << ':' << x << endl;
#define all(v) v.begin(), v.end()
#define sz(x) ((int)(x).size())
#define endl " \n"
#define newl cout<<"\n"
#define MAXN 100005
#define MOD 1000000007LL
#define EPS 1e-13
#define INFI 1000000000             // 10^9
#define INFLL 1000000000000000000ll //10^18
// ¯\_(ツ)_/¯
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define vll vector<long long>
#define vvll vector<vll>
//vector<vector<int>> v(10, vector<int>(20,500)); 2d vector initialization. of 10 rows and 20 columns, with value 500.
#define pll pair<long long, long long>

#define fast_io()                   \
  ios_base::sync_with_stdio(false); \
  cin.tie(NULL);                    \
  cout.tie(NULL);

ll tc, n, m, k;

int main()
{
    fast_io();
#ifndef ONLINE_JUDGE
    //freopen("../input.txt", "r", stdin);
    //freopen("../output.txt", "w", stdout);
#endif

    cin>>n>>k;
    vll arr(n, 0);
    rep(i, 0, n) cin>>arr[i];
    vvll dp(n+1, vll(k+1, 0));

    rep(i, 0, n+1) dp[i][0] = 1;

    rep(i, 1, n+1) {
        rep(j, 1, k+1) {
            // two things happening here, querying prefix sum, making prefix array.
            if(j-arr[i-1]-1 >= 0)
                // dp[i][j-1] is making prefix arr
                //dp[i-1][j-arr[i-1]-1] is querying prefix : candies can go from 1 - arr[i-1];
                dp[i][j]  = dp[i][j-1]  + dp[i-1][j] - dp[i-1][j-arr[i-1]-1] + MOD;
            else
                dp[i][j] = dp[i][j-1] + dp[i-1][j];
            dp[i][j] %= MOD;
        }
    }

    cout<<(dp[n][k]);

    return 0;
}

/*
2
4
0 1 0 1
5
0 0 1 0 0
*/

Measured memory_bytes: 80256
def kaijo(x):
    if(x <= 2):
        return x
    else:
        return x*kaijo(x-1)

n = int(input())
p = list(map(int, input().split()))
q = list(map(int, input().split()))

count_p = 0
count_q = 0
for i in range(n):
    count_p = count_p + (p[i]-1) * kaijo(n-i-1)
    for j in range(i+1,n):
        if(p[i] < p[j]):
            p[j] = p[j] - 1
    count_q = count_q + (q[i]-1) * kaijo(n-i-1)
    for j in range(i+1,n):
        if(q[i] < q[j]):
            q[j] = q[j] - 1

print(abs(count_p - count_q))

Measured memory_bytes: 3064
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)
	n := readInt()
	sum := 0.0
	for i := 1; i <= n; i++ {
		sum = sum + (1 / float64(readInt()))
	}
	fmt.Println(1 / sum)
}

func read() string {
	sc.Scan()
	return sc.Text()
}

func readInt() int {
	i, e := strconv.Atoi(read())
	if e != nil {
		panic(e)
	}
	return i
}


Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include<complex>
#include <cassert>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repd(i, n) for (int i = n; i > 0; i--)
#define mod 1000000007
#define MOD 998244353
#define inf 1e20
typedef long long int ll;
typedef pair<ll, ll> pr;
typedef complex<double> com;


int main(){
	int n;
	cin >> n;
	if (n < 1200) {
		cout << "ABC";
	}
	else {
		cout << "ARC";
	}
	return 0;
}
//Ctrl+Aを使わない

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
using u64 = unsigned long long;
#define REP(i, n) for (int i = 0; (i64)(i) < (i64)(n); ++i)

#ifdef ENABLE_DEBUG
template <typename T>
void debug(T value) {
  cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  cerr << value << ", ";
  debug(args...);
}
#define DEBUG(...)                              \
  do {                                          \
    cerr << " \033[33m (L" << __LINE__ << ") "; \
    cerr << #__VA_ARGS__ << ":\033[0m ";        \
    debug(__VA_ARGS__);                         \
    cerr << endl;                               \
  } while (0)
#else
#define debug(...)
#define DEBUG(...)
#endif

const i64 INF = 1LL << 40;

using VP = vector<tuple<i64, i64>>;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N;
  cin >> N;
  VP pu, pr, pd, pl;
  REP(i, N) {
    i64 x, y;
    char u;
    cin >> x >> y >> u;
    if (u == 'R') {
      pr.emplace_back(x, y);
    } else if (u == 'L') {
      pl.emplace_back(x, y);
    } else if (u == 'U') {
      pu.emplace_back(x, y);
    } else {
      assert(u == 'D');
      pd.emplace_back(x, y);
    }
  }
  i64 ans = INF;

  // Rotates points by k*90 degrees.
  auto rotate = [&](const VP& p, int k) -> VP {
    VP res(p.size());
    REP(i, p.size()) {
      auto [x, y] = p[i];
      REP(j, k) {
        i64 tmp = x;
        x = -y;
        y = tmp;
      }
      res[i] = {x, y};
    }
    return res;
  };

  auto check_du = [&](const VP& pd, const VP& pu) {
    map<i64, set<i64>> t;
    for (auto [x, y] : pd) {
      t[x].insert(y);
    }
    for (auto [x, y] : pu) {
      auto& s = t[x];
      auto it = s.lower_bound(y);
      if (it == s.end()) continue;
      ans = min(ans, (*it - y) * 5);
    }
  };

  auto check_dr = [&](const VP& pd, const VP& pr) {
    map<i64, set<i64>> t;
    for (auto [x, y] : pd) {
      t[y - x].insert(x);
    }
    for (auto [x, y] : pr) {
      auto& s = t[y - x];
      auto it = s.lower_bound(x);
      if (it == s.end()) continue;
      ans = min(ans, (*it - x) * 10);
    }
  };

  check_du(pd, pu);
  check_du(rotate(pl, 1), rotate(pr, 1));
  check_dr(pd, pr);
  check_dr(rotate(pl, 1), rotate(pd, 1));
  check_dr(rotate(pu, 2), rotate(pl, 2));
  check_dr(rotate(pr, 3), rotate(pu, 3));

  if (ans == INF) {
    cout << "SAFE" << endl;
  } else {
    cout << ans << endl;
  }
}


Measured memory_bytes: 33968
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
char buf[80];
int getheight(void) {
  memset(&buf, 0, 80);
  int c;
  char* p = buf;
  while('\n' != (c = fgetc(stdin))) {
	if(c == EOF)
		return -1;
	*p++ = c;
  }
  return atoi(buf);
}
int limit = 80;
int pos = 0;
void add(int** a, int v) {
  if(pos < limit) {
	*(*a +pos++) = v;
  } else {
    limit *= 2;
    int* na = malloc(limit*sizeof(int));
    memcpy(na, *a, pos*sizeof(int));
    na[pos++] = v;
    *a = na;
  }
}
void sort(int* a) {
int i;
  for(i = 1; i < pos; i++) {
    int v = a[i];
    int j = i - 1;
    while(j >= 0 && a[j] < v) {
       a[j+1] = a[j];
       j--;
    }
    a[j+1] = v;
  }
}
int main(void) {
int v;
int* a = malloc(limit*sizeof(int));
  while(0 < (v = getheight())) {
  	add(&a, v);
  }
  sort(a);
int i;
  for(i = 0; i< 3; i++) {
	printf("%d\n", *a++);
  }
  return 0;
}

Measured memory_bytes: 0