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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
	int a,b;
	cin>>a>>b;
	int flag=0;
	int ans=-1;
	for(int i=1;i<=1500;++i)
	{
	    double temp1=i*0.08;
	    double temp2=i*0.1;
	    if(floor(temp1)==a&&floor(temp2)==b)
	    {
	        flag=1;
	        ans=i;
	        break;
	    }
	}
	if(flag==1)
	{
	    cout<<ans<<endl;
	}
	else
	{
	    cout<<-1<<endl;
	}
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdio>

using namespace std;

typedef vector<int> vi;
typedef pair<int,int> pii;

#define dump(x)  cerr << #x << " = " << (x) << endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back

int main(){
    int n;
    int w;
    while(cin>>n>>w){
        if(n==0 && w==0)break;
        vi data(1000);
        
        rep(i,n){
            int v;
            cin>>v;
            data[(int)(v/w)]++;
        }
        
        int max_value=-1;
        int sum=0;
        rep(i,1000){
            if(data[i]!=0){
                sum=i;
                max_value=max(max_value,data[i]);
            }
        }
        sum++;
        
        double ans=0;
        rep(i,1000){
            ans+=(double)data[i]/max_value * (double)(sum-i-1)/(sum-1);
        }
        printf("%18.15lf\n",ans+0.01);
    }
    
    return 0;
}

Measured memory_bytes: 1228
import math

a, b, C = map(int, input().split())

h = b * math.sin(math.radians(C))
S = a * h * 0.5
L = a + b + math.sqrt(pow(a, 2) + pow(b, 2) - 2 * a * b *math.cos(math.radians(C)))

print(S)
print(L)
print(h)

Measured memory_bytes: 6868
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ii pair<int, int>
#define vi vector<int>
#define vii vector<ii>
#define vll vector<ll>
#define vvi vector<vector<int>>
#define vvii vector<vector<ii>>
#define vvll vector<vector<ll>>
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define uni(v) v.erase(unique(v.begin(), v.end()), v.end())
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) (ll) a / __gcd(a, b) * b
#define what_is(x) cerr << #x << " is " << x << endl;

using namespace std;

void write();
template <typename T, typename... Args>
void write(T x, Args... args);

void solve() {
    int x;
    cin >> x;
    write(1000 * (x / 500) + 5 * ((x % 500) / 5));
}
int main() {
    ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
    // freopen("in", "r", stdin);

    int t = 1;
    // cin >> t;
    while (t--) solve();

    return 0;
}
template <typename T, typename... Args>
void write(T x, Args... args) {
    cout << x;
    if (sizeof...(args)) {
        cout << ' ';
        write(args...);
    } else
        cout << '\n';
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
    char c[a+2][b+2];
    memset(c,0,sizeof(c));
    for(int i=1;i<=a;i++)
        for(int j=1;j<=b;j++)
        cin>>c[i][j];
    bool flag=0;
    for(int i=1;i<=a;i++)
        for(int j=1;j<=b;j++)
    {
        if(c[i][j]=='#')
            if(c[i+1][j]!='#'&&c[i-1][j]!='#'&&c[i][j-1]!='#'&&c[i][j+1]!='#')
                flag=1;
    }
    if(flag)
        cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define X first
#define Y second
#define mp make_pair
using namespace std;
typedef pair<int,int> PII;
typedef long long ll;
const int N = 100010;
int a[N],n;

int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",a+i);
	sort(a+1,a+n+1);
	ll sum = 0;
	int ans;
	for(int i=1;i<=n;i++) sum+=a[i];
	for(int i=n;i>0;i--){
		sum-=a[i];
		if(a[i]>2*sum){
			ans = n-i+1;
			break;
		}
	}	
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define rep(i,x,y) for (int i=(x); i<=(y); i++)
#define per(i,x,y) for (int i=(x); i>=(y); i--)
#define ll long long
#define ld long double
#define inf 1000000000
#define INF 1000000000000000000ll
#define pii pair<int,int>
#define F first
#define S second
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define sqr(x) ((x)*(x))
#define y1 y1_
#define cmin(x,y) (x)=(y)<(x)?(y):(x)
#define cmax(x,y) (x)=(y)>(x)?(y):(x)
#define mset(x,y) memset((x),(y),sizeof(x))
#define mcpy(x,y) memcpy((x),(y),sizeof(y))
using namespace std;
#define int ll
const ld pi=acos(-1);
const ld eps=1e-8;
//////////////////////// header files ////////////////////////
ll read(){
	char ch=getchar(); ll x=0; int op=1;
	for (; !isdigit(ch); ch=getchar()) if (ch=='-') op=-1;
	for (; isdigit(ch); ch=getchar()) x=(x<<1)+(x<<3)+ch-'0';
	return x*op;
}
void write(ll a){
	if (a<0) putchar('-'),a=-a;
	if (a>=10) write(a/10); putchar(a%10+'0');
}
////////////////////////// fast i/o //////////////////////////
#ifdef mod
ll ksm(ll x,ll p){
	ll ret=1;
	for (; p; p>>=1,x=x*x%mod) if (p&1) ret=ret*x%mod;
	return ret;
}
ll get_inv(ll x){
	return ksm(x,mod-2);
}
#else
ll ksm(ll x,ll p){
	ll ret=1;
	for (; p; p>>=1,x=x*x) if (p&1) ret=ret*x;
	return ret;
}
#endif
//////////////////////////// qpow ////////////////////////////
void solve(){
	ll a=read(),b=read(),c,ans;
	if (a>b) swap(a,b);
	if (a==1 && b==1){ cout<<0<<endl; return; }
	//if (a==2 && b==2){ cout<<1<<endl; return; }
	c=a*b-1; c=sqrt(c+0.5); if (c*c>=a*b) c--;
	ans=c*2; if (c*(c+1)>=a*b) ans--;
	if (c>=a) ans--;
	cout<<ans<<endl;
}
//#define local
signed main(){
#ifdef local
	freopen("test.in","r",stdin); freopen("test.out","w",stdout);
#endif
	int T=read(); while (T--) solve();
	return 0;
}
// sample data:
/*

*/

// rest:
/*

*/

Measured memory_bytes: 256
let read_n () = Scanf.scanf "%d " (fun i -> i)

let () =
  let n = read_n () in
  let a = Array.init n (fun _ -> read_n ()) in
  let rec doit v =
    Array.fast_sort (-) a;
    if a.(n-1) < n then v
    else if a.(0) >= n then begin
      let d = a.(0) - (n - 1) in
      for i = 0 to n - 1 do a.(i) <- a.(i) - d done;
      doit (v + d * n)
    end else begin
      let d = a.(n-1) / n in
      for i = 0 to n - 2 do a.(i) <- a.(i) + d done;
      a.(n-1) <- a.(n-1) mod n;
      doit (v + d)
    end in
  doit 0 |> Printf.printf "%d\n"

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

int main(){
	int ar[5], ans = 0, maxi = 0, cur;
	for(int i = 0; i < 5; i++){
		scanf("%d", &ar[i]);
		cur = ar[i]%10;
		ans += ar[i];
		if(cur > 0){
			ans += 10-cur;
			maxi = max(maxi, 10-cur);
		}
	}

	ans -= maxi;
	printf("%d\n", ans);
	
	return 0;
}

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

int lx = INT_MAX, rx = INT_MIN;
int ly = INT_MAX, ry = INT_MIN;


int main(){

  int n, H, W;

  cin >> n >> W >> H;

  int x, y, w;
  vector<pair<int,int> > vx, vy;
  for(int i = 0; i < n; i++){
    cin >> x >> y >> w;
    vx.push_back(make_pair(x-w,x+w));
    vy.push_back(make_pair(y-w,y+w));
  }

  sort(vx.begin(),vx.end());
  sort(vy.begin(),vy.end());
  lx = vx[0].first;
  rx = vx[0].second;
  ly = vy[0].first;
  ry = vy[0].second;
  
  for(int i = 1; i < n; i++){
    if(rx < vx[i].second){
      if(rx >= vx[i].first) rx = vx[i].second;
    }
    if(ry < vy[i].second){
      if(ry >= vy[i].first) ry = vy[i].second;
    }
    //    cout << lx << " " << rx << " " << ly << " " << ry << endl; 
  }
    //   


  if((lx <= 0 && rx >= W) || (ly <= 0 && ry >= H)) cout << "Yes" << endl;
  else cout << "No" << endl;


}

Measured memory_bytes: 2904
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int n;
int t[100001], x[100001], y[100001];
int i=0;

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

	for(;i<n;i++){
		scanf("%d %d %d", &t[i], &x[i], &y[i]);
		if(abs(x[i])+abs(y[i])>t[i] || (x[i]+y[i])%2 != t[i]%2){
			printf("No");
			break;
		}
	}
	if(i==n)	printf("Yes");
	
	return 0;
}

Measured memory_bytes: 1280
import java.util.*;
import java.util.function.*;
import java.util.stream.*;

public class Main{
	Scanner s=new Scanner(System.in);

	void solve(){
		int a=s.nextInt();
		int b=s.nextInt();

		for(int i=0;i<=1000000;++i) {
			if((int)(i*0.08)==a&&(int)(i*0.1)==b) {
				System.out.println(i);
				return;
			}
		}
		System.out.println(-1);
	}

	public static void main(String[] A){
		new Main().solve();
	}

	int gInt(){
		return Integer.parseInt(s.next());
	}
	long gLong(){
		return Long.parseLong(s.next());
	}
	double gDouble(){
		return Double.parseDouble(s.next());
	}

	SupplyingIterator<Integer> ints(int n){
		return new SupplyingIterator<>(n,this::gInt);
	}
	SupplyingIterator<Long> longs(int n){
		return new SupplyingIterator<>(n,this::gLong);
	}
	SupplyingIterator<Double> doubles(int n){
		return new SupplyingIterator<>(n,this::gDouble);
	}
	SupplyingIterator<String> strs(int n){
		return new SupplyingIterator<>(n,s::next);
	}

	Range rep(int i){
		return Range.rep(i);
	}
	Range rep(int f,int t,int d){
		return Range.rep(f,t,d);
	}
	Range rep(int f,int t){
		return rep(f,t,1);
	}
	Range rrep(int f,int t){
		return rep(t,f,-1);
	}

	IntStream REP(int v){
		return IntStream.range(0,v);
	}
	IntStream REP(int l,int r){
		return IntStream.rangeClosed(l,r);
	}

	IntStream INTS(int n){
		return IntStream.generate(this::gInt).limit(n);
	}
	LongStream LONGS(int n){
		return LongStream.generate(this::gLong).limit(n);
	}
	Stream<String> STRS(int n){
		return Stream.generate(s::next).limit(n);
	}

}

class SupplyingIterator<T> implements Iterable<T>,Iterator<T>{
	int			t;
	Supplier<T>	supplier;

	SupplyingIterator(int t,Supplier<T> supplier){
		this.t=t;
		this.supplier=supplier;
	}

	@Override
	public Iterator<T> iterator(){
		return this;
	}

	@Override
	public boolean hasNext(){
		return t>0;
	}

	@Override
	public T next(){
		--t;
		return supplier.get();
	}

}

class Range implements Iterable<Integer>,PrimitiveIterator.OfInt{
	int to,cur,d;

	Range(int from,int to,int d){
		this.cur=from-d;
		this.to=to;
		this.d=d;
	}

	Range(int n){
		this(0,n-1,1);
	}

	@Override
	public Iterator<Integer> iterator(){
		return this;
	}

	@Override
	public boolean hasNext(){
		return cur+d==to||(cur!=to&&(cur<to==cur+d<to));
	}

	@Override
	public int nextInt(){
		return cur+=d;
	}
	static Range rep(int i){
		return new Range(i);
	}
	static Range rep(int f,int t,int d){
		return new Range(f,t,d);
	}
	static Range rep(int f,int t){
		return rep(f,t,1);
	}
	static Range rrep(int f,int t){
		return rep(f,t,-1);
	}
}


Measured memory_bytes: 23892
#include<stdio.h>
int main()

{
	int N;
	scanf("%d", &N);
	int A[N];
	int max=0;
	int r;
	
	for(r=0; r<N; r++)	scanf("%d", &A[r]);
	
	for(r=0; r<N; r++)
	{
		if (A[r] > max) max = A[r];
	}
	
	int min = max;
	
	for(r=0; r<N; r++)
	{
		if (A[r] < min) min = A[r];
	}
	
	printf("%d", max-min);
	
	return 0;
	
}

Measured memory_bytes: 128
n = int(input())
l_t = []
l_pos = []

l_pos.append([0, 0])
l_t.append(0)
# input
for i in range(n):
    a, b, c = (list)(map(int, input().split()))
    l_t.append(a)
    l_pos.append([b, c])


def manhattan(pos1, pos2):
    return abs(pos1[0]-pos2[0]) + abs(pos1[1]-pos2[1])


# check
ans = 'Yes'
for i in range(n):
    dis = manhattan(l_pos[i], l_pos[i+1])
    time = abs(l_t[i+1]-l_t[i])
    if dis > time:
        ans = 'No'
        break
    elif dis % 2 != time % 2:
        ans = 'No'
        break

print(ans)


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

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define in(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << std::endl;
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define out(...) write_to_cout(__VA_ARGS__);

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

using ll = long long;

using namespace std;

int main() {
  in(string, s);
  rep(i, s.size() - 1) {
    if (s[i] == s[i + 1]) {
      out("Bad");
      return 0;
    }
  }
  out("Good");
}


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

using namespace std;
#define X first
#define Y second
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

#define debug(x) cerr << #x << " = " << (x) << endl;
template<typename T>
ostream& operator<<(ostream& o, vector<T>& v) {
    for (auto& x : v) o << x << ' ';
    return o;
}

int n, k;
int arr[110];
int memo[100100];
int dp(int k) {
  int &res = memo[k];
  if (res != -1) return res;
  if (k == 0) return res = 0;
  for (int i = 0; i < n; i++) {
    if (arr[i] <= k) {
      if (dp(k - arr[i]) == 0) return res = 1;
    }
  }
  return res = 0;
}

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

    cin >> n >> k;
    for (int i = 0; i < n; i++) cin >> arr[i];
    memset(memo, -1, sizeof memo);
    if (dp(k)) cout << "First" << endl;
    else cout << "Second" << endl;
}


Measured memory_bytes: 3712
import java.util.Scanner;
 
public class Main {
 
	public static final MyScanner in = new MyScanner();

	public static void main(String[] args) {

		int A = in.nextInt();
		int B = in.nextInt();
		int C = in.nextInt();
		int D = in.nextInt();

		String answer="";
		boolean b = true;
		while(true) {
			if(b) {
				b = !b;
				C = C - B;
				if(C <= 0) {
					answer = "Yes";
					break;
				}
			} else {
				b = !b;
				A = A - D;
				if(A <= 0) {
					answer = "No";
					break;
				}
			}
		}

		System.out.println(answer);

	}



	public static class MyScanner {
		Scanner sc = new Scanner(System.in);
		String next() { return sc.next();}
		int nextInt() { return Integer.valueOf(sc.next());}
		long nextLong() { return Long.valueOf(sc.next()); }
	}
}

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

int main() {
    ll x,k,d;
    cin >> x >> k >> d;
    ll ans;
    if(x<0) x = -x;
    ll t = x/d;
    if(t>=k) ans = x - d * k;
    else if((k-t)%2==0) ans = x - d * t;
    else if((k-t)%2==1) ans = d - (x-d*t);
    cout << ans << endl;
}

Measured memory_bytes: 3624
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

public static class Program
{
    static long k;
    public static void Main()
    {
        k = long.Parse(ReadLine());
        if(k % 2 == 0 || k % 5 == 0)
        {
            WriteLine(-1);
            return;
        }
        long left = 0;
        long res = 1;
        for(int i = 1; ; ++i)
        {
            left = (left + res * 7) % k;
            if (left == 0)
            {
                WriteLine(i);
                return;
            }
            res *= 10;
            res %= k;
        }
    }
}

Measured memory_bytes: 27520
#include <stdio.h>
#include <iostream>

using namespace std;

int main() {
	int a,b;
	for (int i = 0; i < 4; i++) {
		cin >> a >> b;
		if (a == 1) {
			cout << b * 6000 << endl;
		} else if (a == 2) {
			cout << b * 4000 << endl;
		} else if (a == 3) {
			cout << b * 3000 << endl;
		} else {
			cout << b * 2000 << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 1160
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in)) {
            String S = sc.next();
            int N = S.length();
            System.out.println(isPalindrome(S) && isPalindrome(S.substring(0, (N - 1) / 2)) && isPalindrome(S.substring((N + 3) / 2 - 1, N)) ? "Yes" : "No");
        }
    }

    private static boolean isPalindrome(String s) {
        for (int l = 0, r = s.length() - 1; l < r; l++, r--) {
            if (s.charAt(l) != s.charAt(r)) {
                return false;
            }
        }
        return true;
    }
}


Measured memory_bytes: 26980
#include <iostream> 
#include <sstream> 
#include <fstream> 
#include <string> 
#include <vector> 
#include <deque> 
#include <queue> 
#include <stack> 
#include <set> 
#include <map> 
#include <algorithm> 
#include <functional> 
#include <utility> 
#include <bitset> 
#include <cmath> 
#include <cstdlib> 
#include <ctime> 
#include <cstdio> 
using namespace std;

int n,m;
vector<int> a[200005];
bool a_1[200005],a_n[200005];

int main(){
	cin>>n>>m;
	for(int i=1;i<=m;i++){
		int x,y;
		cin>>x>>y;
		if(x==1) a_1[y]=true;
		if(y==1) a_1[x]=true;
		if(x==n) a_n[y]=true;
		if(y==n) a_n[x]=true;
	}
	for(int i=2;i<n;i++){
		if(a_1[i]==true&&a_n[i]==true) cout<<"POSSIBLE"<<endl,exit(0);
	}
	cout<<"IMPOSSIBLE"<<endl;
return 0;
} 

Measured memory_bytes: 5376
#include <bits/stdc++.h>
using namespace std;
using ull = unsigned long long;
using i64 = int64_t;
using u64 = uint64_t;
using u32 = uint32_t;

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

constexpr int64_t MOD = 1000000007LL;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)    

template<class T>
std::tuple<T> input() {
    T x; std::cin >> x;
    return std::make_tuple(x);
}

template<class T, class U, class... Args>
std::tuple<T, U, Args...> input() {
    auto first = input<T>();
    auto rest = input<U, Args...>();
    return std::tuple_cat(first, rest);
}

template<class T>
std::vector<T> input_vec(std::size_t size) {
    std::vector<T> vec(size);
    for (std::size_t i=0; i<size; i++)
        cin >> vec[i];
    return vec;
}

template<class T>
std::vector<T> input_vec(std::size_t size, T fill_value) {
    std::vector<T> vec(size, fill_value);
    for (std::size_t i=0; i<size; i++)
        cin >> vec[i];
    return vec;
}

/******************************************************/

void solve()
{
    auto [N] = input<int>();
    vector<int> A(N);
    FOR(i, 0, N) {
        cin>>A[i];
    }
    ull money = 1000;
    FOR(i, 1, N) {
        if (A[i] > A[i-1]) {
            ull a = money / A[i-1];
            money += a * (A[i] - A[i-1]);
        }
    }
    cout<<money<<endl;
}

int main() {
    solve();
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef long double Double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

// chmax, chmin
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;
}

const string YES = "Yes";
const string NO = "No";

vector<pair<ll, ll>> g[100010];

int d[100010];
int X[100010];
bool v[100010];

void dfs(int root, ll d) {
    if (v[root]) return;
    v[root] = true;
    X[root] = d;
    for (auto e : g[root]) {
        dfs(e.first, d + e.second);
    }
}

void solve(long long N, long long M, std::vector<long long> L,
           std::vector<long long> R, std::vector<long long> D) {

    for (int i = 0; i < M; i++) {
        L[i]--;
        R[i]--;
        g[L[i]].push_back({R[i], D[i]});
        g[R[i]].push_back({L[i], -D[i]});
    }
    for (int i = 0; i < N; i++)
        dfs(i, 0);
    for(int i = 0 ; i < M ; i++){
        if( X[R[i]] - X[L[i]] != D[i]){
            cout << NO << endl;
            return;
        }
    }
    cout << YES << endl;


}

int main() {
    long long N;
    scanf("%lld", &N);
    long long M;
    scanf("%lld", &M);
    std::vector<long long> L(M);
    std::vector<long long> R(M);
    std::vector<long long> D(M);
    for (int i = 0; i < M; i++) {
        scanf("%lld", &L[i]);
        scanf("%lld", &R[i]);
        scanf("%lld", &D[i]);
    }
    solve(N, M, std::move(L), std::move(R), std::move(D));
    return 0;
}


Measured memory_bytes: 19968
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;


int main()
{
    vector<int> vector1{1, 3, 5, 7, 8, 10, 12};
    vector<int> vector2{4, 6, 9, 11};
    vector<int> vector3{2};
    int a, b;
    cin >> a >> b;
    if (count(ALL(vector1), a) > 0 && count(ALL(vector1), b) > 0) {
        cout << "Yes" << endl;
        return 0;
    } else if (count(ALL(vector2), a) > 0 && count(ALL(vector2), b) > 0) {
        cout << "Yes" << endl;
        return 0;
    } else if (count(ALL(vector3), a) > 0 && count(ALL(vector3), b) > 0) {
        cout << "Yes" << endl;
        return 0;
    } else {
        cout << "No" << endl;
        return 0;
    }
}

Measured memory_bytes: 256
def main():
    N = int(input())
    A = [int(i) for i in input().split()]

    money = 1000
    for i in range(1, N):
        if A[i-1] < A[i]:
            v = money//A[i-1]  # 株数
            money %= A[i-1]  # money -= v*A[i-1]
            money += v*A[i]
    print(money)


if __name__ == '__main__':
    main()


Measured memory_bytes: 61936
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int top,S[1000];

void push(int x)
{
    S[++top] = x;
}

int pop()
{
    top--;
    return S[top+1];
}

int main()
{
    int a,b;
    top = 0;
    char s[100];
    while (scanf("%s",s)!=EOF)
    {
        if(s[0]=='+')
        {
            a = pop();
            b = pop();
            push(a+b);
        }
        else if(s[0]=='-')
        {
            
            b = pop();
            a = pop();
            push(a-b);
        }
        else if(s[0]=='*')
        {
            a = pop();
            b = pop();
            push(a*b);
        }
        else push(atoi(s));
    }

    printf("%d\n",pop());

    return 0;
}


Measured memory_bytes: 2104
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pqueue priority_queue
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  string S;
  cin>>S;
  vector<ll> arr;
  ll num = 1;
  bool up;
  if(S[0]=='<') up = true;
  else up = false;

  for(int i=1;i<S.size();++i) {
    if(S[i]=='<') {
      if(up) {
        num++;
      }
      else {
        arr.push_back(num);
        num = 1;
        up = true;
      }
    }
    else {
      if(up) {
        arr.push_back(num);
        num = 1;
        up = false;
      }
      else {
        num++;
      }
    }
  }
  arr.push_back(num);
  ll ans = 0;
  for(int i=0;i<arr.size();++i) ans += arr[i]*(arr[i]-1)/2;
  if(S[0]=='<') {
    for(int i=0;i<arr.size();++i) {
      if(i%2==0) {
        if(i==arr.size()-1) {
          ans += arr[i];
        }
        else {
          ans += max(arr[i], arr[i+1]);
        }
      }
    }
  }
  else {
    ans += arr[0];
    for(int i=0;i<arr.size();++i) {
      if(i%2==1) {
        if(i==arr.size()-1) ans += arr[i];
        else ans += max(arr[i], arr[i+1]);
      }
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 6032
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <fstream>
#include <string>
#include <math.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P> T;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define revrep(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define f first
#define s second
#define pb push_back

const ll mod = 1000000007;
const ll INF = 100000010000;

ll kai[100010];
ll bit[700010];

void pres(double A, ll x = 20) { printf("%.20f\n", x); }

/*ll sum(ll i)
{
	ll s = 0;
	while (i > 0)
	{
		s += bit[i];
		i -= i & -i;
	}
	return s;
}

void add(ll i, ll x)
{
	while (i <= 700005)
	{
		bit[i] += x;
		i += i & -i;
	}
}*/

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

ll pow_mod(ll x, ll y) {
	if (y == 0) return 1;
	if (y % 2 == 1) {
		return x * pow_mod(x, y - 1) % mod;
	}
	else {
		ll half = pow_mod(x, y / 2);
		return half * half % mod;
	}
}

ll div_mod(ll x) {
	return pow_mod(x, mod - 2);
}

ll com(ll x, ll y) {
	return kai[x] * div_mod(kai[y] * kai[x - y] % mod) % mod;
}

ll H, N, ans;
ll A[1010], B[1010];
ll dp[10010];
vector<P> vec;
map<ll, ll> mp;

void solve() {
	cin >> H >> N;
	rep(i, N) {
		cin >> A[i] >> B[i];
		vec.push_back(P(B[i], A[i]));
		mp[B[i]] = max(mp[B[i]], A[i]);
	}
	for (int i = 0; i <= H; i++) {
		dp[i] = INF;
	}
	dp[0] = 0;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j <= H; j++) {
			dp[min(H, j + A[i])] = min(dp[min(H, j + A[i])], dp[j] + B[i]);
		}
	}
	cout << dp[H] << endl;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	solve();
	ll N;
	cin >> N;
}

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

int main(){
    string s1,s2;
    cin>>s1>>s2;
    cout<<(s1[0]==s2[2] && s1[1]==s2[1] && s1[2]==s2[0]?"YES":"NO")<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    int N = scanner.nextInt();
    int Q = scanner.nextInt();

    long[] a = new long[N];
    for (int i = 0; i < N; i++) a[i] = scanner.nextInt();

    long[] mx = new long[(N - 1) / 2];
    for (int i = 1; i <= (N - 1) / 2; i++) {
      mx[i - 1] = (a[N - i - 1] + a[N - 2 * i - 1]) / 2 + 1;
    }
    reverse(mx);
    long[] sum = new long[N];
    sum[0] = a[0];
    for (int i = 1; i < N; i++) {
      sum[i] = sum[i - 1] + a[i];
    }
    long[] sum2 = new long[N];
    sum2[0] = N % 2 == 1 ? a[0] : 0;
    for (int i = 1; i < N; i++) {
      if ((N - i) % 2 == 1) {
        sum2[i] = sum2[i - 1] + a[i];
      } else {
        sum2[i] = sum2[i - 1];
      }
    }

    for (int i = 0; i < Q; i++) {
      int x = scanner.nextInt();
      int j = upperBound(mx, x);
      if (j < 0) System.out.println(sum[N - 1] - sum[N / 2 - 1]);
      else if (j == mx.length) System.out.println(sum2[N - 1]);
      else System.out.println(sum[N - 1] - sum[N / 2 + j] + sum2[(j + 1) * 2 - 1]);
    }
  }

  public static int upperBound(long[] a, long k) {
    int left = -1;
    int right = a.length;
    while (right - left > 1) {
      int mid = (left + right) / 2;
      if (a[mid] <= k) {
        left = mid;
      } else {
        right = mid;
      }
    }
    return left;
  }

  private static void reverse(long[] a) {
    int i = 0;
    int j = a.length - 1;
        while (i < j) {
          long tmp = a[i];
          a[i] = a[j];
          a[j] = tmp;
          i++;
          j--;
        }
  }
}


Measured memory_bytes: 114200
N,X = map(int,input().split())
list = list(map(int,input().split()))
diff = [abs(x - X) for x in list]
diff.sort()

def gcd(a,b):
    while b:
        a,b = b,a%b
    return a

#差の最大公約数を取得
gcd_val = diff[0]
for i in diff[1:]:
    gcd_val = gcd(i,gcd_val)

print(gcd_val)


Measured memory_bytes: 14252
package main

import (
        "fmt"
        "sort"
)

func main() {
        var N int
        var ls []int

        fmt.Scanf("%d", &N)
        for i := 0; i < N; i++ {
                var l int
                fmt.Scanf("%d", &l)
                ls = append(ls, l)
        }

        sort.Ints(ls)
        max := ls[len(ls)-1]
        other := ls[:len(ls)-1]
        var sum int
        for _, l := range other {
                sum = sum + l
        }
        if sum > max {
                fmt.Println("Yes")
        } else {
                fmt.Println("No")
        }
}


Measured memory_bytes: 512
#include <iostream>
#define int long long
#define REP(i,n) for(int i = 0; i < (n); ++i)
#define FOR(i,a,b)  for(int i = (a); i < (b); ++i)

using namespace std;
//const int MOD = 10e9+7;
const int INF = 1LL << 60;
template <class T> inline bool chmin(T& a, T b){if(a > b){ a = b; return 1;} return 0;}  
template <class T> inline bool chmax(T& a, T b){if(a < b){ a = b; return 1;} return 0;}  

int dp[110][100100];

signed main (){
    int N , W; 
    cin >> N >> W;
    int v[N],w[N];
    REP(i,N) cin >> w[i] >> v[i];
    REP(i,N) REP(j,W) dp[i][j] = 0;
    REP(i,N)REP(m,W+1){
        if(m >= w[i]) dp[i+1][m] = max(dp[i][m-w[i]] + v[i] ,dp[i][m]);
        else dp[i+1][m] = dp[i][m];
    }
    int ans{0};
    REP(j,W+1) chmax(ans,dp[N][j]);
    cout << ans << endl;
}

Measured memory_bytes: 80128
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;
using ll = long long;
int main() {
    int A, B, C, X, Y;
    cin >> A >> B >> C >> X >> Y;
    if (A + B < 2*C) {
        cout << A * X + B * Y << endl;
    }
    else {
        if (X < Y) {
            int ans1 = 2 * Y*C;
            int ans2 = 2 * X*C + (Y - X)*B;
            if (ans1 < ans2)
                cout << ans1 << endl;
            else
                cout << ans2 << endl;
        }
        else {
            int ans3 = 2 * X*C;
            int ans4 = 2 * Y*C + (X - Y)*A;
            if (ans3 < ans4)
                cout << ans3 << endl;
            else
                cout << ans4 << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll;
const int inf = 1000000000; //10^9
const ll inff = 1000000000000000000; //10^18

int main(){
    int n, m, p[12];
    vector<int> x[12];

    cin >> n >> m;
    rep(i, m) {
        int k, a;
        cin >> k;
        rep(j, k) {
            cin >> a;
            a--;
            x[i].push_back(a);
        }
    }
    rep(i, m) cin >> p[i];

    int cou = 0;
    for(int i = 0; i < (1 << n); i++) {
        int bit[12]; 
        for(int j = 0; j < n; j++) bit[j] = (i / (1 << j)) % 2;
        int ans = 0;
        for(int j = 0; j < m; j++)  {
            int ret = 0;
            for(int v : x[j]) ret ^= bit[v];
            if(ret != p[j]) ans++;
        }
        if (ans == 0) cou++;
    }

    cout << cou << endl;

    return 0;
}

Measured memory_bytes: 3596
import math
N=int(input())

if N==2:
    print(N)
    exit()
while True:
    maxi=int(math.sqrt(N))+1
    test=[i for i in range(maxi)]
    for i in range(2,maxi):
        if test[i]!=-1:
            if N%test[i]!=0:
                j=i
                while j<maxi:
                    test[j]=-1
                    j+=i
            else:
                break
        if i==maxi-1:
            print(N)
            exit()
    N+=1

Measured memory_bytes: 9140
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define SORTD(a) sort(a.rbegin(), a.rend());
#define UNIQUE(a) unique(a.begin(), a.end())
#define ll long long
#define INF 1000000000000000000
#define INT_MAX 2147483647

#include <iostream>
#include <vector>
#include <cmath>
#include <cctype>
#include <numeric>
#include <algorithm>
#include <queue>
#include <set>
#include <utility>
#include <ios>
#include <iomanip>

using namespace std;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;

vector<vector<pair<int, ll>>> t(100001);
ll depth[100001];

void dfs(int v,int p, ll d) {
	depth[v] = d;
	
	for (int i = 0; i < t[v].size(); i++) {
		if (t[v][i].first != p) {
			dfs(t[v][i].first, v, d + t[v][i].second);
		}
	}
}

int main() {
	int n;
	cin >> n;
	REP(i, n - 1) {
		int a, b, c;
		cin >> a >> b >> c;
		a--; b--;
		t[a].push_back(pair<int, ll>(b, c));
		t[b].push_back(pair<int, ll>(a, c));
	}
	
	int q, k;
	cin >> q >> k;
	k--;
	dfs(k, -1, 0);

	REP(i, q) {
		int x, y;
		cin >> x >> y;
		x--; y--;
		cout << depth[x] + depth[y] << endl;
	}
	return 0;
}


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

using namespace std;

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

ll occurrences[200'001], numbers[200'001], N;
ll answer[200'001], total;

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

    cin >> N;

    for (int i = 0; i < N; i++) {
        cin >> numbers[i];
        occurrences[numbers[i]]++;

        ll answerOld = answer[numbers[i]];
        total -= answerOld;

        ll answerNew = occurrences[numbers[i]] * (occurrences[numbers[i]] - 1) / ll(2);
        answer[numbers[i]] = answerNew;
        total += answerNew;
    }

    for (int i = 0; i < N; i++) {
        cout << total - answer[numbers[i]] + (occurrences[numbers[i]] - 1) * (occurrences[numbers[i]] - 2) / ll(2)
             << "\n";
    }

    // --------------------
    return 0;
}

Measured memory_bytes: 6272
use petgraph::algo::dijkstra;
use petgraph::graph::{NodeIndex, UnGraph};
use proconio::input;

fn main() {
    input! {
        n: usize,
        edges: [(usize, usize, usize); n-1],
        q: usize,
        k: usize,
        pairs: [(usize, usize); q],
    }

    let g = UnGraph::<usize, usize, usize>::from_edges(&edges);
    let res = dijkstra(&g, k.into(), None, |e| *e.weight());

    /*
    for (key, value) in &res {
        println!("key {:?} value {}", key, value);
    }
    */

    for (start, end) in &pairs {
        let distance =
            res.get(&NodeIndex::new(*start)).unwrap() + res.get(&NodeIndex::new(*end)).unwrap();
        println!("{}", distance);
    }
}

Measured memory_bytes: 19296
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#define Mod 1000000007
#define INF 1e14
typedef long long int ll;

ll fast(ll n,ll a,ll m)
{
    if(n==0)
        return 1;
    if(n==1)
        return a;
    else
    {
        ll res=fast(n/2,a,m);
        if(n%2==0)
            return (((res%m)*(res%m))%m);
        else
        {
            return (((((res%m)*a)%m)*res)%m);
        }
    }
}
int main()
{
  ll n,m;
  cin>>n>>m;
  ll i,a[n];
  priority_queue<ll> pq;
  for(i=0;i<n;i++)
  {
      cin>>a[i];
      pq.push(a[i]);
  }
  for(i=0;i<m;i++)
  {
      ll p=pq.top();
      if(p==0)
      {
          break;
      }
      else
      {
          pq.pop();
          pq.push(p/2);
      }
  }
  ll ans=0;
  while(pq.size())
  {
      ll t=pq.top();
      ans+=t;
      pq.pop();
  }
  cout<<ans;

}


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

int main()
{
  int h, w;
  cin >> h >> w;
  if (h == 1 || w == 1)
  {
    cout << 1 << endl;
    return 0;
  }
  ll a = (w + 1) / 2;
  ll b = w / 2;
  ll ans = a * ((h + 1) / 2) + b * (h / 2);
  cout << ans << endl;
}

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

int main() {
	long long n, i, ans = 1;
	cin >> n;
	for (i = 1; i * i <= n-1;i++){
		if((n-1)%i==0){
			if(i>1)
				ans++;
			if(i*i<n-1&&n-1>1)
				ans++;
		}
	}
	for (i = 2; i * i <= n;i++){
		if(n%i==0){
			long long cn = n;
			while(cn%i==0)
				cn /= i;
			if(cn%i==1)
				ans++;
			if(i*i<n){
				cn = n;
				while (cn % (n/i) == 0)
					cn /= (n/i);
				if (cn % (n/i) == 1)
					ans++;
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
class UnionFind{
   public:
      vector<int> parent;
      
      UnionFind(int N)
      {
         parent = vector<int>(N, -1);
      }
      int root(int A)
      {
         if(parent[A] < 0) return A;
         return parent[A] = root(parent[A]);
      }
      int size(int A)
      {
         return -parent[root(A)];
      }
      bool connect(int A, int B)
      {
         A = root(A);
         B = root(B);
         if(A == B)
         {
            return  false;
         }
         if(size(A) < size(B))
            swap(A, B);
         parent[A] += parent[B];
         parent[B] = A;
         return true;
      }
};
int main()
{
   int N, M;
   cin >> N >> M;
   vector<int> A(M), B(M);
   for(int i = 0; i < M; i++)
   {
      cin >> A[i] >> B[i];
      A[i]--;
      B[i]--;
   }
   vector<long long> ans(M);
   ans[M-1] = (long long) N*(N-1)/2;
   UnionFind Uni(N);
   for(int i = M - 1; i >= 1; i--)
   {
      if(Uni.root(A[i]) != Uni.root(B[i]))
      {
         ans[i-1] = ans[i] - (long long)Uni.size(A[i])*Uni.size(B[i]);
         Uni.connect(A[i], B[i]);
      }
      else
      {
         ans[i-1] = ans[i];
      }
   }
   for(int i = 0; i < M; i++)
   {
      cout << ans[i] << endl;
   }
   return 0;
}



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

#define EPS (1e-10)
#define equals(a, b) (fabs((a) - (b)) < EPS)
#define pb push_back
#define rep(i, n) for(int i = 0; i < (n); i++)
#define INF (1 << 29)

using namespace std;

int main(){
	int k, a, b;
	bool flag = false;
	cin >> k;
	cin >> a >> b;

	for(int i = a; i <= b; i++){
		if(i % k == 0){
			flag = true;
			break;
		}
	}

	if(flag) cout << "OK" << endl;
	else cout << "NG" << endl;

	return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
int main() {
  int64_t a, b, x;
  cin >> a >> b >> x;
  if(a!=0){
    a = (a - 1) / x;
    b = b / x;
    cout << b - a << endl;
  }
  else{
    cout << b / x + 1 << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF (1<<29)
#define LINF (1LL<<60)
#define EPS (1e-10)
#define PI 3.1415926535897932384626433832795028
#define all(a) (a).begin(),(a).end()
#define sz(x) (int)x.size()
#define max_heap priority_queue<int>
#define min_heap priority_queue<int,vector<int>,greater<int>>
using ll = long long;
#define int long long
#define endl "\n"
#define vi vector<int>
#define pb push_back
#define inp_arr(a,n) for(ll i=0;i<n;i++)cin>>a[i];
#define out_arr(a) for(ll i=0;i<a.size();i++)cout<<a[i]<<" ";
#define deb(n) cerr << #n << " = " << n << "\n";
int gcd(int a, int b) { if (a == 0) return b; return gcd(b % a, a);}
ll mypower(ll x,ll n,ll c){
    if(n == 0)
        return 1;
    ll temp = mypower(x,n/2,c)%c;
    if(n%2)
        return (n<0)? (1/x)*temp*temp%c: ((x*temp)%c)*temp%c;
    else
        return temp*temp%c;
}
bool codejam = 0;

int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif

	vector<int> a(2);
	vector<int> b(2);
	cin>>a[0]>>a[1]>>b[0]>>b[1];
	int ans = a[0]*b[0];
	for(int i=0;i<2;i++){
		for(int j=0;j<2;j++)
			ans = max(ans,a[i]*b[j]);
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long int ll;
int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int n; cin >> n;
	vector<int> p(n),a(n),b(n);
	for(int i=0;i<n;i++){
		cin >> p[i];
	}
	for(int i=0;i<n;i++){
		a[i]=20020*(i+1);
		b[i]=20020*(n-i-1)+1;
	}
	for(int i=0;i<n;i++){
		a[p[i]-1]+=i;
	}
	for(int i=0;i<n;i++){
		cout << a[i] << " ";
	}
	cout << endl;
	for(int i=0;i<n;i++){
		cout << b[i] << " ";
	}
	cout << endl;
}

Measured memory_bytes: 896
/*
СТРОИМ СТЕНУ РАБОТЯГИ!
█▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀█
█═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═█
█═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═█
█═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═█
█═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═█
█═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═█
█═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═█
█═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═█
█═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═█
█▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄█
*/
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
const ll MOD = 1000 * 1000 * 1000 + 7;
const int MAXN = 1007;
ll cnk[MAXN][MAXN];
ll dp[MAXN][MAXN];
ll binaryPow(ll x, ll y, ll MOD)
{
	if (y == 0) return 1;
	if (y % 2 == 0)
	{
		ll tmp = binaryPow(x, y / 2, MOD);
		return (tmp * tmp) % MOD;
	}
	else
	{
		return binaryPow(x, y - 1, MOD) * x % MOD;
	}
}
ll moduloInverse(ll x, ll MOD)
{
	return binaryPow(x, MOD - 2, MOD);
}
ll facts[1007];
ll rfacts[1007];
int main()
{
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
#endif
	int n;
	scanf("%d", &n);
	cnk[0][0] = 1;
	facts[0] = 1;
	for (int i = 1; i <= n; i++)
	{
		facts[i] = (facts[i - 1] * i) % MOD;
		cnk[i][0] = 1;
		for (int j = 1; j <= i; j++)
		{
			cnk[i][j] = (cnk[i - 1][j] + cnk[i - 1][j - 1]) % MOD;
		}
	}
	rfacts[n] = moduloInverse(facts[n], MOD);
	for (int i = n - 1; i >= 0; i--)
	{
		rfacts[i] = (rfacts[i + 1] * (i + 1)) % MOD;
	}
	int a, b, c, d;
	scanf("%d %d %d %d", &a, &b, &c, &d);
	for (int i = a - 1; i <= b; i++)
	{
		dp[0][i] = 1;
	}
	for (int i = 1; i <= n; i++)
	{
		for (int j = a; j <= b; j++)
		{
			dp[i][j] = dp[i][j - 1];
			ll ways = 1;
			if (i == 3 && j == 3)
			{
				int x = 228;
			}
			for (int take = 1; take <= d && j * take <= i; take++)
			{
				ways = (ways * cnk[i - j * (take - 1)][j]) % MOD;
				if (take >= c)
				{
					dp[i][j] = (dp[i][j] + dp[i - j * take][j - 1] * ways % MOD * rfacts[take]) % MOD;
				}
			}
		}
	}
	printf("%lld\n", dp[n][b]);
}



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

int main(){
	int a,b;
	cin >> a >> b;
	if (a > b){
		cout << "a > b" << endl;
	}else if (a == b){
		cout << "a == b" << endl;
	}else{
		cout << "a < b" << endl;
	}

}


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

typedef long long ll;

#define F first 
#define S second 
#define PB push_back
#define MP make_pair 
#define rep(i,a,b) for (ll i=a;i<b;i++)
const ll INF = 1LL << 60;

typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<ll> vl;
typedef pair<ll,ll> pl;


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

    vector<string> a(n);
    rep(i,0,n) cin>>a[i];

    map<string,int> m;
    int max =0;
    rep(i,0,n) {

        m[a[i]]++;
        if(m[a[i]]>max) max = m[a[i]];
    }
    for(auto x:m) {
        if(x.second==max) cout<<x.first<<endl;
    }
    return 0; 
}



Measured memory_bytes: 26752
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
  private static class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
      reader = new BufferedReader(new InputStreamReader(in));
      tokenizer = null;
    }

    public String next() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          tokenizer = new StringTokenizer(reader.readLine());
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }
      return tokenizer.nextToken();
    }

    public String nextLine() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          return reader.readLine();
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }

      return tokenizer.nextToken("\n");
    }

    public long nextLong() {
      return Long.parseLong(next());
    }

    public int nextInt() {
      return Integer.parseInt(next());
    }

    public double nextDouble() {
      return Double.parseDouble(next());
    }

    public int[] nextIntArray(int n) {
      int[] a = new int[n];
      for (int i = 0; i < n; i++)
        a[i] = nextInt();
      return a;
    }

    public long[] nextLongArray(int n) {
      long[] a = new long[n];
      for (int i = 0; i < n; i++)
        a[i] = nextLong();
      return a;
    }
  }

  public static void main(String[] args) {
    FastScanner sc = new FastScanner(System.in);
    int n = sc.nextInt();
    int[] p = sc.nextIntArray(n);
    int min = n + 1;
    int count = 0;
    for (int i = 0; i < n; i++) {
      if (p[i] <= min) count++;
      min = Math.min(min, p[i]);
    }
    System.out.println(count);
  }
}

Measured memory_bytes: 45908
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//clock_t start=clock();clock_t end=clock();cout<<(double)(end-start)/CLOCKS_PER_SEC<<endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
typedef pair<double,double> pdd;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll mod5=1000000009;
ll inf=1LL<<60;
double pi=3.141592653589793238462643383279L;
double eps=1e-9;
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
#define srep(itr,st) for(auto itr=st.begin();itr!=st.end();itr++)
#define Max(a,b) a=max(a,b)
#define Min(a,b) a=min(a,b)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll beki(ll n,ll k,ll md){
  ll ret=1;
  ll now=n;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=md;
    }
    now*=now;
    now%=md;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n,ll md){
  return beki(n,md-2,md);
}
ll popcount(ll n){
    ll ret=0;
    ll u=n;
    while(u>0){
        ret+=u%2;
        u/=2;
        
    }
    return ret;
}
int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    ll n;cin>>n;
    ll a,b;cin>>a>>b;
    ll c=a+b;
    ll d=n/c;
    ll e=n%c;
    ll ans=d*a;
    ans+=min(a,e);
    cout<<ans<<endl;
}








Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <vector>

using namespace std;
typedef long long ll;

struct Edge{
	int node0;
	int node1;
	int isValid;
};

// https://pyteyon.hatenablog.com/entry/2019/03/11/200000 より
// union by size + path having
class UnionFind {
public:
    vector <ll> par; // 各元の親を表す配列
    vector <ll> siz; // 素集合のサイズを表す配列(1 で初期化)

    // Constructor
    UnionFind(ll sz_): par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);  // resize だとなぜか初期化されなかった
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }

    // Member Function
    // Find
    ll root(ll x) { // 根の検索
        while (par[x] != x) {
            x = par[x] = par[par[x]]; // x の親の親を x の親とする
        }
        return x;
    }

    // Union(Unite, Merge)
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        // merge technique（データ構造をマージするテク．小を大にくっつける）
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) { // 連結判定
        return root(x) == root(y);
    }

    ll size(ll x) { // 素集合のサイズ
        return siz[root(x)];
    }
};

int main()
{
	int N, M;
	Edge Edges[2500];
	
	scanf("%d %d", &N, &M);
	for(int i = 0; i < M; i++){
		int a, b;
		scanf("%d %d", &a, &b);
		Edges[i].node0 = a;
		Edges[i].node1 = b;
		Edges[i].isValid = true;
	}
	
	int count = 0;
	for(int i = 0; i < M; i++){
		Edges[i].isValid = false;
		
		UnionFind uf(N);
		for(int j = 0; j < M; j++){
			if(Edges[j].isValid){
				uf.merge(Edges[j].node0 - 1, Edges[j].node1 - 1);
			}
		}
		
		if(uf.size(0) < N){
			count++;
		}
		
		Edges[i].isValid = true;
	}
	
	printf("%d\n", count);
	
	return 0;
}

Measured memory_bytes: 256