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

using namespace std;
using ll = long long;

struct Tree {
  using T = ll; // For Node Type
  using Q = ll; // For Query Type
  using L = ll; // For Lazy Type
  T ID = 0; // set ID such that f(ID, x) = x;
  T f(T a, T b) { return a + b; }
  vector<T> tree;
  vector<L> lazy;
  int n;

  Tree() {}
  Tree(int _n) : n(_n) {
    int m = 1;
    while(m < n) m *= 2;
    tree.resize(2 * m, ID);
    lazy.resize(2 * m, 0);
  }

  void push(int x, int l, int r) {
    if(!lazy[x]) return;
    tree[x] += lazy[x];
    tree[x] = max(tree[x], 0LL);
    if(l != r) {
      lazy[2 * x] += lazy[x];
      lazy[2 * x + 1] += lazy[x];
    }
    lazy[x] = 0;
  }

  void update(int l, int r, L val) { upd(1, 0, n - 1, l, r, val); }
  void upd(int x, int l, int r, int ql, int qr, L val) {
    push(x, l, r);
    if(ql > r || qr < l) return;
    if(ql <= l && qr >= r) { lazy[x] += val; push(x, l, r); return; }
    upd(2 * x, l, (l + r) / 2, ql, qr, val);
    upd(2 * x + 1, (l + r) / 2 + 1, r, ql, qr, val);
    tree[x] = f(tree[2 * x], tree[2 * x + 1]);
  }

  Q query(int l, int r) { return qry(1, 0, n - 1, l, r); }
  Q qry(int x, int l, int r, int  ql, int qr) {
    push(x, l, r);
    if(qr < l || ql > r) return ID;
    if(ql <= l && qr >= r) {
      return tree[x];
    }
    return f(qry(2 * x, l, (l + r) / 2, ql, qr),
        qry(2 * x + 1, (l + r) / 2 + 1, r, ql, qr));
  }
};

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;ll d, a;
  cin >> n >> d >> a;
  map<ll, ll> mp;
  vector<pair<ll, ll>> ar(n);
  for(int i = 0; i < n; ++i) {
    cin >> ar[i].first >> ar[i].second;
    mp[ar[i].first];
  } 
  int cnt = 0;
  vector<ll> inv(n);
  for(auto &x: mp) {
    inv[cnt] = x.first;
    x.second = cnt++;
  }
  Tree T(cnt);
  for(auto &x: ar) {
    x.first = mp[x.first];
    T.update(x.first, x.first, x.second);
  }
  ll res = 0;
  sort(ar.begin(), ar.end());
  for(int i = 0; i < n; ++i) {
    auto x = ar[i];
    if(T.query(x.first, x.first) == 0) continue;
    ll p = 2LL * d + inv[x.first];
    auto it = mp.lower_bound(p);
    if(it == mp.end()) it--;
    while(it->first > p) it--;
    int last = it->second;
    ll rem = T.query(x.first, x.first);
    ll f = (rem * 1LL + a - 1) / a;
    T.update(i, last, -1LL * a * f);
    res += f;
  }
  cout << res << '\n';
  return 0;
}


Measured memory_bytes: 25600
import java.util.Arrays;
import java.util.Comparator;
import java.util.PriorityQueue;
import java.util.Scanner;

//Ninja Climbing
public class Main{

	static int[][] dist;
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true){
			int n = sc.nextInt();
			if(n==0)break;
			int[][] a = new int[n][2];
			for(int i=0;i<2;i++)for(int j=0;j<n;j++)a[j][i]=sc.nextInt();
			dist = new int[n][2];
			for(int i=0;i<n;i++)Arrays.fill(dist[i], Integer.MAX_VALUE);
			dist[0][0] = dist[0][1] = 0;
			PriorityQueue<int[]> q = new PriorityQueue<int[]>(n, new Comparator<int[]>() {
				public int compare(int[] o1, int[] o2) {
					return dist[o1[0]][o1[1]]-dist[o2[0]][o2[1]];
				}
			});
			q.add(new int[]{0,0});
			q.add(new int[]{0,1});
			int ans = -1;
			while(!q.isEmpty()){
				int[] v = q.poll();
				int h = v[0];
				int w = v[1];
//				System.out.println(h+" "+w+" "+dist[h][w]);
				if(h==n-1 && a[n-1][w]!=2){
					ans = dist[n-1][w];
					break;
				}
				if(a[h][w]==2){
					if(dist[h][w] < dist[h-1][w]){
						dist[h-1][w] = dist[h][w];
						q.add(new int[]{h-1,w});
					}
				}
				else if(a[h][w]==1){
					if(a[h+1][w]==1){
						if(dist[h][w] < dist[h+1][w]){
							dist[h+1][w] = dist[h][w];
							q.add(new int[]{h+1, w});
						}
					}
					else {
//						System.out.println("!!");
						int d = w==0?1:0;
						for(int k=0;k<3;k++){
							int nh = h + k;
							if(nh > n-1)break;
//							System.out.println("DIST:" + dist[h][w] + " OF:" + dist[nh][d]);
							if(dist[h][w]+1 < dist[nh][d]){
								dist[nh][d] = dist[h][w]+1;
								q.add(new int[]{nh,d});
							}
						}
					}
				}
				else{
					int d = w==0?1:0;
					for(int k=0;k<3;k++){
						int nh = h + k;
						if(nh > n-1)break;
						if(dist[h][w]+1 < dist[nh][d]){
							dist[nh][d] = dist[h][w]+1;
							q.add(new int[]{nh,d});
						}
					}
				}
			}
			System.out.println(ans==-1?"NA":ans);
		}
	}
}

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

int main(){
    ll n;
    cin>>n;
    if(n%2==0){
        cout<<(n/2)*(n/2)<<endl;
    }else{
        cout<<((n-1)/2)*((n+1)/2)<<endl;
    }
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Scanner;
import java.util.Set;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int K = sc.nextInt();

		Set<String> set = new HashSet<>();
		for (int i = 0; i < s.length(); i++) {
			for (int k = 1; k <= K; k++) {
				if(i + k > s.length()) break;
				set.add(s.substring(i, i + k));
			}
		}

		List<String> list = new ArrayList<>();
		list.addAll(set);
		Collections.sort(list);
		System.out.println(list.get(K - 1));
	}
}

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

signed main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    cout.tie(NULL);
    //cout<<"I must do it...Yeahhh";
    
    int t=1;
    //cin>>t;
    while(t--)
    {
        string s;
        cin>>s;
        if(s[2]==s[3] && s[4]==s[5])
            cout<<"Yes";
        else
            cout<<"No";
    }
    return 0;
}

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

int main(){
  int64_t A,B,N;
  cin>>A>>B>>N;
  int64_t m=0;
  if(N<B-1){
    m=N;
  }
  else{
    m=B-1;
  }
  cout<<(A*m)/B-(m/B)*A;
}

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

using namespace std;

#define endl '\n'
#define fi first
#define se second
#define MOD(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define FOR(i,n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<ii> vii;

const int MX = 200000;
int n, a[MX], b[MX];

int main () {
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		b[i] = a[i];
	}

	sort(b, b+n);

	int x = b[n/2-1], y = b[n/2];

	for (int i = 0; i < n; i++)
		if (a[i] <= x)
			cout << y << endl;
		else
			cout << x << endl;

	return 0;
}


Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second
#define all(f) (f).begin(),(f).end()
#define allr(f) (f).rbegin(),(f).rend()
const int mod = 1e9+7, A = 1e5+5;
int main()
{
	ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	int n, x, mn = 1e9, ans = 0;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> x;
		if (x <= mn)
			ans++, mn = x;
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 256
def main():
  import sys
  input = sys.stdin.readline
  from fractions import gcd
  def lcm(a, b):
      return a * b // gcd(a, b)
  
  N = int(input())
  A = tuple(sorted(list(map(int,input().split()))))
  MOD = 10**9+7
  
  L = 1
  for a in A:
    L = lcm(a,L)
  ans = 0
  for a in A:
    #ans += L//a
    ans += L*pow(a,MOD-2,MOD)
  print(ans%MOD)

if __name__ == '__main__':
  main()


Measured memory_bytes: 68568
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
	ll n; cin >> n;
  	ll ans = 0;
  	for (ll x = 1; x*(x+1) < n; x++) if (n%x==0)
    	ans += n/x-1;
  	cout << ans << endl;
} 

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

template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void POSS(T condition){ if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl; }
template<class T> inline void Poss(T condition){ if(condition) cout << "Possible" << endl; else cout << "Impossible" << endl; }
template<class T> inline void First(T condition){ if(condition) cout << "First" << endl; else cout << "Second" << endl; }
int character_count(string text, char character){ int ans = 0; for(int i = 0; i < text.size(); i++){ ans += (text[i] == character); } return ans; }
long power(long base, long exponent, long module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ long root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position move_pattern[4] = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++){ ans += to_string(*i) + " "; } ans.pop_back(); cout << ans << endl; }
template<class T> T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }} template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
#define mod long(1e9 + 7)
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl(long(n))

int main(){
    int N;
    cin >> N;
    int ans = 0;
    for(int i = 0; i < N; i++){
        int a;
        cin >> a;
        while(a % 2 == 0){
            a /= 2;
            ans++;
        }
    }
    cout << ans << endl;
}


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

int main(){
    int N; cin>>N;
    for(int i=N;i>0;i--){
        for(int j=0;pow(2,j)<=100;j++){
            if(i==pow(2,j)){
                cout<<i;
                return 0;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))

vector< string > ans;
int N;
int K;
string cand = "abcdefghij";

void dfs(int k, string s)
{
    if (s.size() == N)
    {
        ans.push_back(s);
        return;
    }

    rep (i, k)
    {
        dfs(k, s + cand[i]);
    }
    dfs(k + 1, s + cand[k]);
    return;
}

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

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

    cin >> N;
    dfs(1, "a");

    rep (i, ans.size())
    {
        cout << ans[i] << "\n";
    }
    return 0;
}



Measured memory_bytes: 7796
// Create by JJL
#define IOS ios_base::sync_with_stdio(0); cin.tie(0);
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <unordered_map>
#include <set>
#include <queue>
#define fi first
#define se second
using namespace std;
typedef long long LL;
typedef pair<int,int> PII;

const int N=5010,Mod=1e9+7;
int a[N],p[N],len[N];
bool st[N];
LL sum[N][N],tsum[N][N];
int main(){
    IOS;
    /* START CODE */
    int n,k;
    cin>>n>>k;
    for(int i=1;i<=n;++i) cin>>p[i];
    for(int i=1;i<=n;++i) cin>>a[i];
    for(int i=1;i<=n;++i){
       memset(st,0,sizeof st);
       int pos=i,idx=0;
       LL res=0;
       while(st[pos]==0){
            sum[i][++idx]=res+a[pos];
            res+=a[pos];
            st[pos]=1;
            pos=p[pos];
       }
       len[i]=idx;
    }
    LL ans=-1e18;
    memset(tsum,-0x3f,sizeof tsum);
    for(int i=i;i<=n;++i){
        for(int j=1;j<=len[i];++j){
            tsum[i][j]=max(tsum[i][j-1],sum[i][j]);
        }
    }
    for(int i=1;i<=n;++i){
        LL res=k/len[i]*sum[i][len[i]]+tsum[i][k%len[i]];//走最多圈
        if(k>=len[i]){
            res=max(tsum[i][len[i]],res);
            res=max((k/len[i]-1)*sum[i][len[i]]+tsum[i][len[i]],res);
        }
        ans=max(ans,res);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 394984
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
#include <random>
#include <string.h>
using namespace std;
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define int long long
#define P pair<int,int>
#define all(vec) vec.begin(),vec.end()

int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}

int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}

int k, a, b;

signed main() {
	cin >> k >> a >> b;
	for (int i = k;; i += k) {
		if (a <= i && i <= b) {
			cout << "OK" << endl;
			return 0;
		}
		if (b < i)break;
	}
	cout << "NG" << endl;
}

Measured memory_bytes: 3620
import math

N = int(input())
base = math.ceil(math.sqrt(N))

ans = [0] * (N + 1)

for x in range(1,base+1):
    for y in range(1,base+1):
        for z in range(1,base+1):
            P = x ** 2 + y ** 2 + z ** 2 + x*y + y*z + z*x
            if P <= N:
                ans[P] += 1

for i in range(1,N+1):
    print(ans[i])

Measured memory_bytes: 69420
#include <stdio.h>
int main (void){
  int N,Y,x,y,z,i,j,a,b,c;
  scanf("%d %d",&N,&Y);
  a = -1;
  b = -1;
  c = -1;
  for (i = 0; i <= N; i++){
    x = i;
    for (j = 0; j <= N - i; j++){
      y = j;
      z = N - (i + j);
      if (10000 * x + 5000 * y + 1000 * z == Y && x + y + z == N){
	a = x;
	b = y;
        c = z;
      }
    }
  }
  printf("%d %d %d\n",a,b,c);
  return (0);
}
       


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define reset(X) memset(X, 0, sizeof(X))
#define int long long
typedef long long ll;
#define pb push_back
#define se second
#define fi first
#define endl '\n'
#define all(X) X.begin(),X.end()

const int INF=1e18;
const int mod=1e9+7;
const int mod2=998244353;



#define REDN(a) int a;cin>>a;
#define REDL(a,n) int a[n];for(int i=0;i<n;i++) cin>>a[i];
#define REDA(a,n,m) int a[n][m];for(int i=0;i<n;i++)for(int j=0;j<m;j++) cin>>a[i][j];





int pow(int a, int b)
{
    int prod=1;
    int mult=a;
    while(b!=0)
    {
        if(b%2)
        {
            prod*=mult;
            prod%=mod2;
        }
        mult*=mult;
        mult%=mod2;
        b/=2;
    }
    return prod;
}
int mod_inv(int q, int mod)
{
    return pow(q, mod-2);
}




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

const int MAXN=4e5+10;




char win(char mech)

{
    map<char, char> winning;
    winning['r']='p';
    winning['s']='r';
    winning['p']='s';
    return winning[mech];
}
vector<char> non_win(char mech)
{
    map<char, vector<char> > non_winning;
    non_winning['r']={'r', 's'};
    non_winning['s']={'p', 's'};
    non_winning['p']={'p', 'r'};
    return non_winning[mech];
}

signed main()
{
    
    
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    #ifndef ONLINE_JUDGE
    if (fopen("INPUT.txt", "r")) {
        freopen ("INPUT.txt" , "r" , stdin);
        // freopen ("OUTPUT.txt" , "w" , stdout);
    }
    #endif
//---------------------------------------------------------------------------------------------------
    
    int n,k;

    cin>>n>>k;
    int r, s, p;
    cin>>r>>s>>p;
    string t;
    cin>>t;
    map<char, int> winning;
    winning['r']=r;
    winning['s']=s;
    winning['p']=p;
    vector<char> pos[n];
    char ans[n];
    reset(ans);
    int total=0;
    for(int i=0;i<min(n,k);i++)

    {
        ans[i]=win(t[i]); 
        total+=winning[ans[i]];
    }
    for(int i=min(n,k);i<n;i++)

    {
        char out=win(t[i]);
        if(out==ans[i-k])
        {
            //leave it empty
            pos[i]=non_win(t[i]);
        } 
        else
        {
            ans[i]=out;
            total+=winning[ans[i]];

        }

    }
    cout<<total<<endl;
}

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

// clang-format off
#define  range(i, l, r) for (int i = (int)(l); i < (int)(r); ++(i))
#define rrange(i, l, r) for (int i = (int)(r) - 1; i >= (int)(l); --(i))

#define  whole(f, x, ...) ([&](decltype((x)) container) { return (f)(  begin(container),  end(container), ## __VA_ARGS__); })(x)
#define rwhole(f, x, ...) ([&](decltype((x)) container) { return (f)( rbegin(container), rend(container), ## __VA_ARGS__); })(x)

#define endl '\n'
#define debug(x) cerr << "(" << __LINE__ << ")" << #x << ": " << (x) << endl

using i32 = int;
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;

// constexpr i32 mod   = 998244353;
constexpr i32 mod   = 1e9 + 7;
constexpr i32 inf   = 1001001001;
constexpr i64 infll = 1001001001001001001ll;

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

struct IoSetup { IoSetup(int x = 15){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(x); cerr << fixed << setprecision(x); } } iosetup;

template <typename T = i64> T input() { T x; cin >> x; return x; }

template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { range(i, 0, v.size()) { os << v[i] << (i + 1 != v.size() ? " " : ""); } return os; } 
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }

template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }

template <typename T> vector<T> make_vector(size_t a, T b) { return vector<T>(a, b); }
template <typename... Ts> auto make_vector(size_t a, Ts... ts) { return vector<decltype(make_vector(ts...))>(a, make_vector(ts...)); }

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); }
// clang-format on

void solver() {
    int X = input();
    
    int ans = 1000 * (X / 500);
    X %= 500;
    ans += 5 * (X / 5);
    
    cout << ans << endl;
}

signed main(int argc, char *argv[]) {
    solver();
}


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

using namespace std;

#define ll long long int
#define get(a) ll a; cin >> a;
#define show(a) cout << a << endl;
#define full(p) p.begin(), p.end()
#define sz(a) (ll)(a.size())
#define pb push_back

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.precision(10);
	cout<<fixed;
	////////////////////////////////
	get(H);
	get(W);
	get(h);
	get(w);

	cout << H*W - H*w - W*h+ h*w << endl;	

	return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rp(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////
 int gcd(int x,int y){
    if(y==0) return x;
    return gcd(y,x%y);
 }
int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    int n,X;
    cin >> n >> X;
    if(n==1){
        int t;
        cin >> t;
        print(abs(X-t));
        return 0;
    }
    int ans;
    vi x(n);
    rp(i,n) cin >> x.at(i);
    ans=gcd(abs(X-x[0]),abs(X-x[1]));
    repi(i,2,n){
        ans=gcd(ans,abs(X-x[i]));
    }
    print(ans);
    return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<climits>
#include<set>
#include<utility>
using namespace std;
typedef long long int ll;
const ll MOD=1e9+7;

int main(){

	string s;
	cin >> s;

	int i=s.size()-1;
	while(0<i){
		if(s[i]=='m' && s[i-1]=='a' && s[i-2]=='e' && s[i-3]=='r' && s[i-4]=='d'){
			i-=5;
		} else if(s[i]=='r' && s[i-1]=='e' && s[i-2]=='m' && s[i-3]=='a' && s[i-4]=='e' 
		&& s[i-5]=='r' && s[i-6]=='d'){
			i-=7;
		} else if(s[i]=='e' && s[i-1]=='s' && s[i-2]=='a' && s[i-3]=='r' && s[i-4]=='e'){
			i-=5;
		} else if(s[i]=='r' && s[i-1]=='e' && s[i-2]=='s' && s[i-3]=='a' && s[i-4]=='r' 
		&& s[i-5]=='e'){
			i-=6;
		} else {
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;

	return 0;
}


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

int main()
{
    int n;
    cin >> n;
    long long ans = 1;
    long long p = 1000000000000000000;
    vector<long long> a(n);
    for (int i = 0; i < n; i++)
    {
        cin >> a.at(i);
        if (a.at(i) == 0)
        {
            ans = 0;
            break;
        }
    }

    for (int i = 0; i < n; i++)
    {
        if (ans == 0)
        {
            break;
        }
        else if (ans <= p / a.at(i))
        {
            ans *= a.at(i);
        }
        else
        {
            ans = -1;
            break;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4044
#include<bits/stdc++.h>
using namespace std;
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define pa pair<int,int>
#define mod 998244353
#define ll long long
#define mk make_pair
#define pb push_back
#define fi first
#define se second
#define cl(x) memset(x,0,sizeof x)
#ifdef Devil_Gary
#define bug(x) cout<<(#x)<<" "<<(x)<<endl
#define debug(...) fprintf(stderr, __VA_ARGS__)
#else
#define bug(x)
#define debug(...)
#endif

const int INF = 0x7fffffff;
const int N=3e5+5;
/*
char *TT,*mo,but[(1<<15)+2];
#define getchar() ((TT==mo&&(mo=(TT=but)+fread(but,1,1<<15,stdin),TT==mo))?-1:*TT++)//*/
inline int read(){
    int x=0,rev=0,ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')rev=1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+ch-'0';ch=getchar();}
    return rev?-x:x;
}/*
struct Edge{
	int nxt,v;
//	int w;
//	int id;
}e[N<<1];
void add(int u,int v){
	e[++tot].v=v,e[tot].nxt=head[u],head[u]=tot;
	e[++tot].v=u,e[tot].nxt=head[v],head[v]=tot;
}*/
map<pa,int>mp;
int n,m,Q;
pa R[N],H[N]; 
int main(){
#ifdef Devil_Gary
    freopen("in.txt","r",stdin);
//  freopen("out.txt","w",stdout);
#endif
	n=read(),m=read(),Q=read();
	for(int i=1;i<=Q;i++){
		int x=read(),y=read();
		R[x].fi++,H[y].fi++;
		mp[mk(x,y)]=1; 
	}
	for(int i=1;i<=n;i++){
		R[i].se=i;
	}
	for(int i=1;i<=m;i++){
		H[i].se=i;
	}
	sort(R+1,R+n+1);
	sort(H+1,H+m+1);
	for(int i=n;i;i--){
//		bug(R[n]);
		if(R[i].fi!=R[n].fi) break;
		for(int j=m;j;j--){
			if(H[j].fi!=H[m].fi) break;
			if(!mp.count(mk(R[i].se,H[j].se))){
//				cerr<<R[i].se<<" "<<H[j].se<<endl;-
				return cout<<R[n].fi+H[m].fi<<endl,0;
			}
		}
	}
	return cout<<R[n].fi+H[m].fi-1<<endl,0;
}


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

int main(){
    int N,M;
    int A[1000];
    int vote_sum=0,cnt=0;
    cin >>N>>M;
    for(int i=0;i<N;i++){
        cin>> A[i];
        vote_sum+=A[i];
    }
    for(int i=0;i<N;i++){
        if(A[i]>=(double)vote_sum/(4*(double)M)){
            cnt++;
        }
    }
    if(cnt>=M){
        cout <<"Yes"<<endl;
        return 0;
    }
    cout<<"No"<<endl;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=2;i<=n;i++)
#define rep2(i,n) for(int i=2;i<=n;i++)
#define repr(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define double long double
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
#define MAX 1000000
int MOD=1e9+7;

int fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<MAX;i++){
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }  
}

// 二項係数計算
int COM(int n, int k){
    if(n<k) return 0;
    if(n<0||k<0) return 0;
    return fac[n]*(finv[k]*finv[n - k]%MOD)%MOD;
}
signed main(){
int a,b;
  cin>>a>>b;
 if((a+b)%3==0&&2*a>=b&&2*b>=a){
  int c=(a+b)/3;
  int d=abs(a-c);
  COMinit();
    cout<<COM(c,d)<<endl;
  
 }
   else
     cout<<0;
}


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

int t[200];
double v[200];
double maxv[20000*2 + 1];

int main() {

    int n;

    cin >> n;

    t[0] = 0;

    for(int i=1; i<=n; i++){
        cin >> t[i];
        t[i] *= 2;
    }

    for(int i=1; i<=n; i++){
        t[i] += t[i-1];
    }

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

    int end = t[n];

    for(int i=0; i<n; i++){
        for(int j=t[i]+1; j<=(t[i+1]); j++){
            maxv[j] = v[i];
        }
    }

    for(int i=0; i<n-1 ;i++){
        maxv[t[i+1]] = min(v[i],v[i+1]);
    }

    maxv[0] = 0;
    maxv[end] = 0;


    for(int i=1; i<=end; i++){
        maxv[i] = min(maxv[i],maxv[i-1] + 0.5);
    }

    for(int i=end-1; i>=0; i--){
        maxv[i] = min(maxv[i],maxv[i+1] + 0.5);
    }

    double ans = 0.0;

    for(int i=1; i<=end; i++){
        ans += (maxv[i] + maxv[i-1]) * 0.5 / 2.0;
    }

    cout << fixed << setprecision(3) << ans << endl;

    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define all(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main(){
    string S;
    cin>>S;
    int ans=0;
    rep(i,S.size()-1){
        if(S.at(i)!=S.at(i+1)){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include <bits/stdc++.h>
#include<string>
#include<algorithm>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)





int main(){
    int A,B,C;
    cin >> A >> B >> C;

    if(A==B || A == C || B ==C){
        if (A == B && B== C){
            cout << "No" << endl;
            return 0;
        }
        else{
            cout << "Yes"<< endl;
        }
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}

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

#define boost                         \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define ll long long int
// #define int ll
#define vi vector<ll>
#define vvi vector<vi>
#define pii pair<int, int>
#define vii vector<pii>
#define pb push_back
#define B begin()
#define E end()
#define sz(A) (ll)(A).size()
#define F first
#define S second
#define loop(z, v) for (auto &z : v)
#define sp << ' ' <<
#define sps << ' '
#define nl "\n"
// #define nl endl
#define fat 1000000007
// #define fat 998244353
#define PI_2 1.57079632679489661923

ll pref_sum(vi &f, int r){ // range query [0..r]
    ll ret = 0;
    for(; r >= 0; r = (r&(r + 1)) - 1){
        ret += f[r];
    }

    return ret;
}

ll get_sum(vi &f, int l, int r){ // arbitary range query [l..r]
	return pref_sum(f, r) - pref_sum(f, l - 1);
}

void update(vi &f, int idx, ll val){ // point update
    for(; idx < sz(f); idx |= (idx + 1)){
        f[idx] += val;
    }
}

int main() {
    ll tt = 1, n, m, l, r, c, i, j, k, w, x, y;
    boost;

    // cin >> tt;
    ll ans = 0;
    ll x1, y1, z1, x2, y2, z2;
    for(int _ = 1; _ <= tt; _++) {
        cin >> n;
        ans = 0;
        ll mx = -1;

        for(i = 0; i < n; i++){
            cin >> l;
            mx = max(mx, l);
            if(mx > l){
                ans += (mx - l);
            }
        }
        cout << ans << nl;
    }
}

Measured memory_bytes: 3600
open Batteries
let () =
  let s = Scanf.scanf "%s " (fun a -> a) in
  let s_l = String.to_list s in

  let difference xs ys =
    List.fold_left (fun a b -> if List.mem b ys then a else (b::a)) [] xs
  in

  let all = List.init 26 (fun i -> char_of_int (i+97)) in

  Printf.printf "%s\n" @@
  match (difference all s_l) with
    [] -> "None"
  | l -> List.sort compare l |> List.hd |> String.of_char


Measured memory_bytes: 6784
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

const int MAX_V = 1e4;
const int MAX_E = 1e4;

struct Edge {
    ll from, to, w;
};

vector<Edge> w(MAX_E);
ll d[MAX_V];
int V, E;

bool bellman_ford(int s) {
    REP(i, V) d[i] = INF;
    d[s] = 0;

    REP(i, 2 * V) {
        REP(j, E) {
            Edge e = w[j];
            if (d[e.from] != INF && d[e.to] > d[e.from] + e.w) {
                d[e.to] = d[e.from] + e.w;

                if (i >= V - 1 && e.to == V - 1) {
                    return true; // detect negative loop.
                }
            }
        }
    }

    return false; // no negative loops.
}

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    cin >> V >> E;

    REP(i, E) {
        ll a, b, c;
        cin >> a >> b >> c;
        --a; --b;

        w[i] = {a, b, -c};
    }

    if (bellman_ford(0)) {
        cout << "inf" << endl;
    } else {
        cout << -d[V-1] << endl;
    }
    
}


Measured memory_bytes: 512
N, A, B = map(int, raw_input().split())
v = map(int, raw_input().split())

v.sort()
print "%.8f"%(float(sum(v[-A:]))/A)

x = v[-A]
ans = 0
for b in range(A, B+1):
  if v[-b]!=x:
    break
  if b!=A and v[-1]!=x:
    break
  n1 = v.count(x)
  n2 = v[-b:].count(x)
  a = 1
  for i in range(n2):
    a *= n1-i
  for i in range(n2):
    a /= i+1
  ans += a
print ans


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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

#define mod (ll)((1e6)+3)

ll v[mod], v_inv[mod];

ll pmod(ll n, ll p){
	ll m=n%mod;
	if(p==0) return 1;
	ll rtn=pmod((m*m)%mod, p/2)%mod;
	if(p%2==1) rtn=rtn*m%mod;
	return rtn;
}

void factorial(ll n){
	v[0]=1;
	for(ll i=1; i<=n; i++){
		v[i]=v[i-1]*i%mod;
	}
	return;
}
void factorial_inv(ll n){
	for(ll i=0; i<=n; i++){
		v_inv[i]=pmod(v[i],mod-2);
	}
}

int main(){
	factorial(mod);
	factorial_inv(mod);

	int q;
	cin >> q;
	ll x, d, n;
	for(int i=0; i<q; i++){
		cin >> x >> d >> n;
		if(d==0) cout << pmod(x, n) << endl;
		else{
			ll r=x*pmod(d, mod-2)%mod;
			if(n>=mod || r%mod==0 || (r+n-1)%mod==0 || (r%mod>(r+n-1)%mod)) cout << 0 << endl;
			else cout << (v[r+n-1]*v_inv[r-1]%mod)*pmod(d, n)%mod << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 16512
use proconio::{input, fastout};
use proconio::marker::{Chars};
use std::collections::*;
#[fastout]
fn main() {
    input!{
        mut s: Chars,
        q: usize,
    }
    let mut ans: VecDeque<char> = VecDeque::new();
    for i in 0..s.len() {
        ans.push_back(s[i]);
    }
    let mut cnt = 0;
    for i in 0..q {
        input!{
            t: usize,
        }
        if t==1 {
            cnt += 1;
        } else {
            input!{
                f: usize,
                c: char,
            }
            if (f==1 && cnt%2==0) || (f==2 && cnt%2==1){
                ans.push_front(c);
            } else {
                ans.push_back(c);
            }
        }
    }
    let mut ans1: Vec<char> = Vec::new();
    let mut ans2: String = String::new();
    if cnt%2==1 {
        for i in (0..ans.len()).rev() {
            ans1.push(ans[i]);
        }
        ans2 = ans1.into_iter().collect();
        println!("{}", ans2);
        return;
    }

    ans2 = ans.into_iter().collect();
    println!("{}", ans2);
}


Measured memory_bytes: 6560
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	C
# CreatedDate:  2020-05-17 21:46:48 +0900
# LastModified: 2020-05-17 21:49:23 +0900
#


import os
import sys
import math
#import numpy as np
#import pandas as pd


def main():
    a,b,h,m = map(int,input().split())
    angle = math.radians(30*h+0.5*m-6*m)
    cos_angle = math.cos(angle)
    x_2 = a**2+b**2-2*a*b*cos_angle
    print(math.sqrt(x_2))
    return 

if __name__ == "__main__":
    main()


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

int main()
{
  string s;
  while(1){
    getline(cin,s);
    if(s == ".")
      break;
    stack<char> b;
    bool flag = true;
    for(int i = 0; i < s.size(); i++){
      if(s[i] == '('){
        b.push('(');
      }else if(s[i] == '['){
        b.push('[');
      }else if(s[i] == ')'){
        if(b.empty() || b.top() != '('){
          cout << "no" << endl;
          flag = false;
          break;
        }
        b.pop();
      }else if(s[i] == ']'){
        if(b.empty() || b.top() != '['){
          cout << "no" << endl;
          flag = false;
          break;
        }
        b.pop();
      }
    }
    if(b.empty() && flag)
      cout << "yes" << endl;
    else if(!b.empty() && (b.top() == '(' || b.top() == '[') && flag)
      cout << "no" << endl;
  }
}

Measured memory_bytes: 1176
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
struct E{ll to,co,ti;};
struct P{ll ti,id,re;};
bool operator <(const P &a,const P &b){return a.ti>b.ti;}
ll dp[50][5001],c[50],d[50],ans[50],n,m,s;
vector<E> edge[50];
priority_queue<P> que;

signed main(){
  cin>>n>>m>>s;
  while(m--){
    ll u,v,a,b;cin>>u>>v>>a>>b;u--;v--;
    edge[u].push_back({v,a,b});
    edge[v].push_back({u,a,b});
  }
  for(ll i=0;i<n;i++)cin>>c[i]>>d[i];
  que.push({1,0,min(5000LL,s)});
  while(que.size()){
    P p=que.top();que.pop();
    if(dp[p.id][p.re])continue;
    dp[p.id][p.re]=p.ti;
    if(!ans[p.id])ans[p.id]=p.ti;
    for(E q:edge[p.id])
      if(p.re>=q.co&&!dp[q.to][p.re-q.co])
        que.push({p.ti+q.ti,q.to,p.re-q.co});
    if(p.re+c[p.id]<=5000)que.push({p.ti+d[p.id],p.id,p.re+c[p.id]});
  }
  for(ll i=1;i<n;i++)cout<<--ans[i]<<endl;
}


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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using WGraph = vector<vector<pair<int, ll>>>;

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

constexpr int dx[4] = {-1, 0, 0, 1}, dy[4] = {0, -1, 1, 0};
constexpr int INF = 1e9;
constexpr int MOD = 1e9 + 7;
constexpr long long LINF = 1e18;
constexpr double EPS = 1e-10;
constexpr double PI = M_PI;

void solve() {
    int H, W, h, w;
    cin >> H >> W >> h >> w;

    if (H % h == 0 && W % w == 0) {
        cout << "No" << '\n';
    } else if (H%h == 0) {
        cout << "Yes" << '\n';
        vector<int> s(W+1), a(W);
        for (int i=0; i<w; ++i) {
            int c = i;
            if (c == 0) s[c] = 0;
            else s[c] = 1000;
            c += w;
            while (c < W + 1) {
                s[c] = s[c-w] - 1;
                c += w;
            }
        }
        for (int i=0; i<W; ++i) a[i] = s[i+1] - s[i];
        for (int i=0; i<H; ++i) {
            for (int j=0; j<W; ++j) {
                cout << a[j];
                if (j == W-1) cout << '\n';
                else cout << ' ';
            }
        }
    } else {
        cout << "Yes" << '\n';
        vector<int> s(H+1), a(H);
        for (int i=0; i<h; ++i) {
            int c = i;
            if (c == 0) s[c] = 0;
            else s[c] = 1000;
            c += h;
            while (c < H + 1) {
                s[c] = s[c-h] - 1;
                c += h;
            }
        }
        for (int i=0; i<H; ++i) a[i] = s[i+1] - s[i];
        for (int i=0; i<H; ++i) {
            for (int j=0; j<W; ++j) {
                cout << a[i];
                if (j == W-1) cout << '\n';
                else cout << ' ';
            }
        }
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}


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

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

const ll MOD = 1e9 + 7;
const ll inf = 1LL<<60;
const int int_inf = 100000000;
const double eps = 1e-9;

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
 
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n, m, sum = 0;
    cin >> n >> m;
    vector <int> x(n);
    for (int i = 0; i < n; i++) {
        cin >> x[i];
        sum += x[i];
    }

    int ans = 0;

    for (int i = 0; i < n; i++) {
        if (x[i] * 4 * m >= sum) ans++;
    }

    if (ans >= m) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<utility>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

#define MOD 1000000007;

int main(){
	long long n, a, b, c, d, e;
	cin >> n >> a >> b >> c >> d >> e;
	long long neck=min(min(min(min(a,b),c),d),e);
	cout << (n+neck-1)/neck+4 << endl;
	return 0;
}

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

using namespace std;

long long inf=1000000007;

int main(){
	long long h,n;
	cin>>h>>n;
	vector<pair<long long,long long>> magic(n);

	for(long long i=0;i<n;i++){
			cin>>magic.at(i).first>>magic.at(i).second;
	}

	vector<long long> dp(h+20000,inf);
	dp.at(0)=0;
	long long ans=inf;

	for(long long i=0;i<h;i++){
		for(long long j=0;j<n;j++){
			dp[i+magic.at(j).first]=min(dp[i+magic.at(j).first],dp[i]+magic.at(j).second);
			if(i+magic.at(j).first>=h) ans=min(ans,dp[i+magic.at(j).first]);
		}
	}

	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 3624
n = int(input())
s = str(input())
s_rev = s[::-1]

ans = 1000

can = [i for i in range(0,1000)]
can_str = []

for c in can:
    can_s = str(c)
    if len(can_s) == 1:
        can_s = '00' + can_s
    elif len(can_s) == 2:
        can_s = '0' + can_s
    can_str.append(can_s)

for c in can_str:
    try:
        i = s.index(c[0])
        k = s_rev.index(c[2])
        ind = n - k -1
        if i >= ind:
            raise ValueError
        if s[i+1:ind].count(c[1]) == 0:
            raise ValueError
    except:
        ans -= 1

print(ans)

Measured memory_bytes: 3188
#include <iostream>

using namespace std;

int main(){
	int n,a,b;
	while(cin>>n){
		if(n==0)break;
		int sa=0,sb=0;
		for(;n>0;n--){
			cin>>a>>b;
			if(a>b)sa+=a+b;
			else if(b>a)sb+=a+b;
			else{sa+=a;sb+=b;}
		}
		cout<<sa<<" "<<sb<<endl;
	}
}


Measured memory_bytes: 3008
using System;

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

            string[] buf = Console.ReadLine().Split(' ');
            int a = int.Parse(buf[0]);
            int b = int.Parse(buf[1]);

            if (a < b)
            {
                Console.WriteLine("a < b");
            }
            else if(a>b)
            {
                Console.WriteLine("a > b");
            }
            else
            {
                Console.WriteLine("a == b");
            }
        }
    }
}

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

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

 for (int i = 0; i < 2; i++) {
 if (a > b) {
  swap (a, b);
 }
 if (b > c) {
  swap (b, c);
 }
}

 cout << a << " " << b << " " << c << endl;
  
  return 0;

}


Measured memory_bytes: 3072
# ABC 066: B – ss
s = input()
is_even_string = False

s = s[:-1]
while not is_even_string:
    if len(s) % 2 == 0:
        if s[:len(s) // 2] == s[len(s) // 2:]:
            is_even_string = True
    s = s[:-1]

print(len(s) + 1)

Measured memory_bytes: 3060
import java.util.*;

public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
    	int a=sc.nextInt();
      	int b=sc.nextInt();
      	if(1<=a && a<=100 && 1<=b && b<=100){
        	System.out.println(a*b);
        }
    }
}

Measured memory_bytes: 35656
#include<bits/stdc++.h>
using namespace std;
namespace FAST_IO
{
	template<typename T> void read(T &a)
	{
		a=0;
		int f=1;
		char c=getchar();
		while(!isdigit(c))
		{
			if(c=='-')
			{
				f=-1;
			}
			c=getchar();
		}
		while(isdigit(c))
		{
			a=a*10+c-'0';
			c=getchar();
		}
		a=a*f;
	}
	template <typename T> void write(T a)
	{
		if(a<0)
		{
			a=-a;
			putchar('-');
		}
		if(a>9)
		{
			write(a/10);
		}
		putchar(a%10+'0');
	}
	template <typename T> void writeln(T a)
	{
		write(a);
		puts("");
	}
}
char z[20]= {'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F','G','H','I','J'};
void zhuan(int n,int m)
{
	if(!n)
	{
		return;
	}
	else
	{
		if(n>0||n%m==0)
		{
			zhuan(n/m,m);
			cout<<z[n%m];
			return;
		}
		else
		{
			zhuan(n/m+1,m);
			cout<<z[(n%m)-m];
			return;
		}
	}
}
int n,m=-2;
int main()
{	
	cin>>n;
	zhuan(n,m);
	if(n==0)
	{
		cout<<0;
	}
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<cstdio>
using namespace std;
using ll = long long;
int main(){
    ll n,k;
    cin >> n >> k;
    vector<ll> a(max(n,k)+1);
    for(ll j=k-1;j>=1;j/=2)
        for(ll i=1;i<=j;i++) a[i]++;
    double sum=0;
    for(ll i=1;i<=n;i++){
        if(i<k) sum+=1/pow(2,a[i]);
        else sum+=1;
    }
    printf("%.15lf",sum/n);
}

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

int main(){
  string c;
  cin >> c;
  char s = c[0];
  if(s =='a' ||s == 'e' ||s == 'i' || s=='o' || s== 'u' ){
    cout << "vowel\n";
  }else cout << "consonant\n";
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

const ll INF = 1LL << 60;
ll n, s;

ll digitSum(ll x, ll b) {
  ll res = 0;
  while (x) {
    res += x % b;
    x /= b;
  }
  return res;
}

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> n >> s;
  if (n == s) {
    cout << s+1 << endl;
    return 0;
  }
  for (ll b = 2; b*b <= n; b++) {
    if (digitSum(n, b) == s) {
      cout << b << endl;
      return 0;
    }
  }
  ll ans = INF;
  for (ll i = 1; i*i < n; i++) {
    ll tmp = n - s + i;
    if (tmp < 0) continue;
    if (tmp % i != 0) continue;
    ll b = tmp / i;
    if (b < 2) continue;
    if (digitSum(n, b) == s) {
      ans = min(ans, b);
    }
  }
  cout << (ans == INF ? -1 : ans) << endl;

  return 0;
}

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

#define ll long long

using namespace std;

const int N = 100100;

vector<bool> isp(N + 1, true);

void sieve() {
  isp[0] = false;
  isp[1] = false;
  for (int i = 2; i * i <= N; i++) {
    if (isp[i])
      for (int j = 2; i * j <= N; j++)
        isp[i * j] = false;
  }
}

int main() {
  ll X;
  cin >> X;
  sieve();
  for (int i = X;; i++) {
    if (isp[i]) {
      cout << i << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 256
#include<stdio.h>

	int main(){
		
		int i;
		char str[20]={};
		scanf("%s",str);
		
		for(i=19;i>=0;i--){
			if(str[i]!=0){
				printf("%c",str[i]);
			}
			if(i==0){
				printf("\n");
			}
		}
	
	
	return 0l;
}

Measured memory_bytes: 524
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<vl> vvl;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<vb> vvb;
#define fi first
#define se second
const ll INFLL=LLONG_MAX;
const int INF=INT_MAX;
const ll MAXLL=0x3f3f3f3f3f3f3f3f;
const int MAX=0x3f3f3f3f;
#define eb emplace_back
#define emp emplace
#define mp(a,b) make_pair(a,b)
template<class T> using min_heap=priority_queue<T,vector<T>,greater<T> >;
template<class T>
void sort(vector<T>& v){
	sort(v.begin(),v.end());
}
template <class T, class U>
void sort(vector<T>& v,U func){
	sort(v.begin(),v.end(),func);
}
template <class T>
int lb_index(vector<T>& v,T k){
	return lower_bound(v.begin(),v.end(),k)-v.begin();
}
template <class T>
int ub_index(vector<T>& v,T k){
	return upper_bound(v.begin(),v.end(),k)-v.begin();
}

void solve(){
	int n;
	cin>>n;
	vi v(n);
	int x=0;
	for(int i=0;i<n;i++){
		cin>>v[i];
		x^=v[i];
	}
	for(int i=0;i<n;i++){
		cout<<(x^v[i])<<' ';
	}	
}

int main(){
	ios::sync_with_stdio(0);
	int numberofsubtestcases=1;
//	cin>>numberofsubtestcases;
	while(numberofsubtestcases--){
		solve();
	}
}



Measured memory_bytes: 3932
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Collectors;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		List<Integer> monster = new ArrayList<>();
		for(int i = 0; i < N; i++) {
			monster.add(sc.nextInt());
		}
		while(!(monster.size() == 1)) {
			Collections.sort(monster);
			int tmp = monster.get(0);
			monster = monster.stream().map(num -> num % tmp).collect(Collectors.toList());
			List<Integer> delete = new ArrayList<>();
			delete.add(0);
			monster.removeAll(delete);
			monster.add(tmp);
		}
		System.out.println(monster.get(0));
	}
}


Measured memory_bytes: 61812