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

int main() {
  int n;
  std::cin >> n;
  std::vector<int> t(n), v(n);
  for (auto &i : t) {
    std::cin >> i;
  }

  for (auto &i : v) {
    std::cin >> i;
  }

  std::vector<int> t_b(n), t_e(n);
  t_b[0] = 0;
  for (int i = 1; i < n; i++) {
    t_b[i] = t_b[i - 1] + t[i - 1];
  }
  std::copy(std::next(t_b.cbegin()), t_b.cend(), t_e.begin());
  t_e.back() = t_b.back() + t.back();

  std::vector<int> v_max(t_e.back() + 1, 100);

  for (int i = 0; i < n; i++) {
    for (int j = t_b[i]; j <= t_e[i]; j++) {
      v_max[j] = std::min(v[i], v_max[j]);
    }
  }
  v_max.back() = 0;
  for (int i = n - 1; 0 <= i; i--) {
    auto j = t_e[i];
    auto val = v_max[j];
    while (0 < j && val + 1 < v_max[j - 1]) {
      v_max[j - 1] = val + 1;
      val++;
      j--;
    }
  }

  std::vector<int> v_ans(t_e.back() + 1);
  v_ans.front() = 0;

  for (int i = 1; i < v_ans.size(); i++) {
    v_ans[i] = std::min(v_max[i], v_ans[i - 1] + 1);
  }

  double l = 0;
  for (int i = 0; i < n; i++) {
    for (int j = t_b[i]; j < t_e[i]; j++) {
      if (v_ans[j] < v_ans[j + 1]) {
        l += v_ans[j] + 0.5;
      } else if (v_ans[j + 1] < v_ans[j]) {
        l += v_ans[j] - 0.5;
      } else if (v_ans[j] < v[i]) {
        l += v_ans[j] + 0.25;
      } else {
        l += v_ans[j];
      }
    }
  }

  std::cout << std::fixed << std::setprecision(2) << l << std::endl;
  return 0;
}


Measured memory_bytes: 384
/*
  Id: ak260901
  Task: a
  Lang: C++
*/

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <map>

using namespace std;

struct node {
  int p, q;
  node(): p(0), q(0) {}
  node(int _p, int _q): p(_p), q(_q) {}
  bool operator <(const node& o) const {
    return p == o.p ? q < o.q : p < o.p;
  }
  node operator -(const node& o) const {
    if(p < o.p)
      return node(o.p - p, o.q - q);
    return node(p - o.p, q - o.q);
  }
} a[100];
map<node, int> mp;
int n, inx, iny, ans;

int main() {
  scanf("%d", &n);
  for(int i = 1; i <= n; i++) {scanf("%d%d", &inx, &iny); a[i] = node(inx, iny);}
  sort(a + 1, a + n + 1);
  for(int i = 1; i <= n; i++) {
    for(int j = 1; j < i; j++) {
      node tmp = a[i] - a[j];
      mp[tmp]++;
      ans = max(ans, mp[tmp]);
    }
  } printf("%d\n", n - ans);
  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
 
int main() {
    ll n, k;
    cin >> n >> k;

    vl h(n);
    rep(i, n) {
        cin >> h[i];
    }
    sort(all(h));

    ll ans = INF;
    rep(i, n-k+1) {
        chmin(ans, h[i+k-1] - h[i]);
    }

    out(ans);
    re0;
}

Measured memory_bytes: 1024
alphabet = "abcdefghijklmnopqrstuvwxyz"


n = int(input())
res = dict()
for _ in range(n):
    s = str(input())
    freqency = [0 for _ in alphabet]
    for __ in s:
        freqency[alphabet.index(__)] += 1
    freq = "".join([str(___) for ___ in freqency])
    if freq not in res:
        res[freq] = 1
    else:
        res[freq] += 1

ans = 0
for value in res.values():
    ans += ((value-1)*value)/2
  
print(int(ans))

Measured memory_bytes: 19300
use std::io::stdin;
fn typecheck() -> i32 {42}

fn main() {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    let n: i32 = buf.trim().parse().unwrap();
    buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    let a: i32 = buf.trim().parse().unwrap();


    if a >= n%500 {
        println!("Yes");
    } else {
        println!("No");
    }

}


Measured memory_bytes: 4352
#include <iostream>
using namespace std;
int main(void){
  long long K;
  cin >> K;
  
  if(K % 2 == 0) cout << -1 << endl;
  else{
    long long ans = 1;
    long long mod = 7 % K;
    
    while(mod != 0){
      ans++;
      mod = (mod * 10 + 7) % K;
      if(ans > 1000000){
        cout << -1 << endl;
        return 0;
      }
    }
    
    cout << ans << endl;
  }
  
  return 0;
}


Measured memory_bytes: 3612
package main

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

var stdInScanner = bufio.NewScanner(os.Stdin)

func nextInt() int {
	stdInScanner.Scan()
	i, _ := strconv.Atoi(stdInScanner.Text())
	return i
}

func main() {
	stdInScanner.Split(bufio.ScanWords)

	N := nextInt()
	M := nextInt()
	s := make([]int, M)
	c := make([]int, M)
	for i := 0; i < M; i++ {
		s[i] = nextInt()
		c[i] = nextInt()
	}

	var start int
	if N == 1 {
		start = 0
	} else {
		start = int(math.Pow(10, float64(N-1)))
	}
	var no bool
	for i := start; i < int(math.Pow(10, float64(N))); i++ {
		no = false
		for j := 0; j < M; j++ {
			if s[j] == N {
				if c[j] == i%10 {
					continue
				} else {
					no = true
					break
				}
			} else {
				if c[j] == i/int(math.Pow(10, float64(N-s[j])))%10 {
					continue
				} else {
					no = true
					break
				}
			}
		}
		if !no {
			fmt.Println(i)
			return
		}
	}
	fmt.Println(-1)
}


Measured memory_bytes: 640
import math

n,h=map(int,input().split())
a=[]
b=[]
for i in range(n):
    a_sub,b_sub=map(int,input().split())
    a.append(a_sub)
    b.append(b_sub)
b.sort(reverse=True)

m=max(a)
j=n
for i in range(n):
    if b[i]<m:
        j=i
        break
x=0
for i in range(j):
    x+=b[i]
    if x>=h:
        print(i+1)
        break
else:
    print(j+math.ceil((h-x)/m))


Measured memory_bytes: 11264
#pragma GCC optimize("O3")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds; 

#define int long long
#define pb push_back
#define pf push_front
#define eb emplace_back
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define f first
#define s second
#define sz(x) (int)x.size()
#define endl "\n"
#define forn(i,n) for(int i=0;i<n;++i)
#define fore(i,l,r) for(int i=int(l);i<=int(r);++i)
#define rep(i,begin,end) for(__typeof(end) i=(begin);i!=(end);i++)
#define fill(a,value) memset(a,value,sizeof(a));
#define gcd(a,b) __gcd((a),(b))
#define watch1(x) cout<<(x)<<endl
#define watch2(x,y) cout<<(x)<<" "<<(y)<<endl
#define watch3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define fastio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long ll;
typedef long double ld; 
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> oset;

const int INF = 9e18;
const int mod = 1e9 + 7;
const int N = 1e5 + 5;

int i,n,a[N];

void solve()
{
    cin>>n;
    multiset<int> s;
    for(i=1;i<=n;++i)
    {
        cin>>a[i];
        auto it=s.lower_bound(a[i]);
        if(it==s.begin())
        {
            s.insert(a[i]);
        }
        else
        {
            it--;
            s.erase(it);
            s.insert(a[i]);
        }
    }
    cout<<sz(s);
}

signed main()
{
    fastio;
    int t;
    //cin>>t;
    t=1;
    while(t--)
    {
        solve();
    }
    return 0;
}

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

using namespace std;
using namespace __gnu_pbds;

using u128 = __uint128_t;

#define int long long
#define idxSet tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
#define atIdx find_by_order
#define idxOf order_of_key
#define MOD 1000000007
#define MAX 200005
#define endl '\n'

#define v(type) vector<type>
#define p(type1, type2) pair<type1 , type2>
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

int dp[MAX];

bool compare(const ii &x , const ii &y){
    return x.second > y.second;
}

void solve() {
    int n , m;
    cin>>n>>m;
    int a[n];
    for (int i = 0; i < n; ++i) {
        cin>>a[i];
    }
    sort(a , a + n);
    vii x(m);
    for (int j = 0; j < m; ++j) {
        cin>>x[j].first>>x[j].second;
    }
    sort(x.begin() , x.end() , compare);
    int l = 0;
    for(int i = 0 ; i< m; i++){
        while(l < n && x[i].first > 0 && x[i].second > a[l]){
            a[l] = x[i].second;
            l++;
            x[i].first--;
        }
    }
    int sum = 0;
    for(int i = 0 ; i <n ;i++){
        sum += a[i];
    }
    cout<<sum<<endl;

}

int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t = 1;
    //cin>>t;
    while (t--)
        solve();
    return 0;
}

Measured memory_bytes: 2560
#include <cstdio>
using namespace std;

const int N = 1e5 + 100;
int n, m, flag, a[N], b[N];

inline void swap(int &a, int &b) {int t = a; a = b, b = t;}
template <class T> inline void in(T &x) {
	x = 0; int f = 1; char ch = getchar();
	for (; ch<'0' || ch>'9';) {if (ch=='-') f=-1; ch = getchar();}
	for (; ch>='0' && ch<='9';) x = x*10 + ch-'0', ch = getchar();
	x *= f;
}

int main() {
	int od1 = 0, od2 = 0; in(n), in(m);
	for (int i = 1; i <= m; ++i) in(a[i]);
	for (int i = 1; i <= m; ++i)
		if (a[i] & 1) {
			if (!od1) od1 = i;
			else if (!od2) od2 = i;
			else {puts("Impossible"); return 0;}
		}
	if (od1) swap(a[1], a[od1]);
	if (od2) swap(a[m], a[od2]);
	if (m == 1) {
		if (a[1] == 1) {printf("1\n1\n1"); return 0;}
		printf("%d\n2\n1 %d", a[1], a[1] - 1); return 0;
	}
	for (int i = 1; i <= m; ++i) printf("%d ", a[i]); puts("");
	printf("%d\n%d", a[m] == 1 ? m - 1 : m, a[1] + 1);
	for (int i = 2; i <= m - 1; ++i) printf(" %d", a[i]);
	if (a[m] > 1) printf(" %d\n", a[m] - 1);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <utility>
#include <string>

using namespace std;

struct RollingHash {
    static const int base1 = 1007, base2 = 2009;
    static const int mod1 = 1000000007, mod2 = 1000000009;
    vector<long long> hash1, hash2, power1, power2;

    // construct
    RollingHash(const string &S) {
        int n = (int)S.size();
        hash1.assign(n+1, 0);
        hash2.assign(n+1, 0);
        power1.assign(n+1, 1);
        power2.assign(n+1, 1);
        for (int i = 0; i < n; ++i) {
            hash1[i+1] = (hash1[i] * base1 + S[i]) % mod1;
            hash2[i+1] = (hash2[i] * base2 + S[i]) % mod2;
            power1[i+1] = (power1[i] * base1) % mod1;
            power2[i+1] = (power2[i] * base2) % mod2;
        }
    }

    // get hash of S[left:right]
    inline pair<long long, long long> get(int l, int r) const {
        long long res1 = hash1[r] - hash1[l] * power1[r-l] % mod1;
        if (res1 < 0) res1 += mod1;
        long long res2 = hash2[r] - hash2[l] * power2[r-l] % mod2;
        if (res2 < 0) res2 += mod2;
        return {res1, res2};
    }
};


int main() {
    int n;
    string s;
    cin >> n >> s;
    RollingHash rh(s);
    auto check = [&](int d) -> bool {
        map<pair<long long, long long>, int> ma;
        for (int i = 0; i + d <= n; ++i) {
            auto p = rh.get(i, i+d);
            if (ma.count(p)) {
                if (i - ma[p] >= d) return true;
            }
            else ma[p] = i;
        }
        return false;
    };

    for (int length = (n >> 1); length > 0; --length) {
        if (check(length)) {
            cout << length << endl;
            return 0;
        }
    }
    cout << 0 << endl;
}


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

ll n, x, m;
ll ans;
ll cnt[100005];

int main() {
    ios::sync_with_stdio(0), cin.tie(0);
    cin >> n >> x >> m;
    ll k = 1;
    ll last = -1;
    ll curr = x;
    while (!cnt[curr]) {
        cnt[curr] = k++;
        last = curr;
        curr = curr * curr % m;
    }

    ll head = cnt[curr];
    ll tail = cnt[last];
    ll len_front = head - 1;
    ll len_cycle = (tail - head + 1);

    ll sum_front = 0;
    ll y = x;
    while (y != curr) {
        sum_front += y;
        y = (y * y) % m;
    }

    ll sum_cycle = 0;
    y = curr;
    do {
        sum_cycle += y;
        y = (y * y) % m;
    } while (y != curr);

    if (n < len_front) {
        for (ll i = 0; i < n; i++) {
            ans += x;
            x = (x * x) % m;
        }
    } else {
        ans += sum_front;
        ans += sum_cycle * ((n - len_front) / len_cycle);
        ll lim = (n - len_front) % len_cycle;
        x = curr;
        for (ll i = 0; i < lim; i++) {
            ans += x;
            x = (x * x) % m;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 4320
import sys
 
ma = {}
def _sum(n):
    if not n in ma:
        ma[n] = sum(range(1,n+1))
    return ma[n]

def ev(v):
    return _sum(v) * 1.0/v
 
N, K = [int(x) for x in sys.stdin.readline().strip().split(" ")]
p = [ev(int(x)) for x in sys.stdin.readline().strip().split(" ")]
 

cur = sum([p[i] for i in range(K)])
_max = cur

i = K-1
j = 0

while i < N - 1:
    cur -= p[j]
    i += 1
    j += 1
    cur += p[i]
    if _max < cur:
        _max = cur

print(_max)

Measured memory_bytes: 20072
### SNIPPET
  # n = gets.split.map(&:to_i)
  # array = n.times.map { gets.split.map(&:to_i) }
  # [].all?(&:even?)
  # a = [*1..m].repeated_combination(n).to_a
  # [1,2,3,4,5].select { |num| num.even? }  # => [2, 4]
  # ["a","a","b"].group_by(&:itself).map{|k,v| [k, v.count]}.to_h #=> {"a"=>2, "b"=>1}
  # 切り捨て: .floor(2).to_f ,切り上げ： .ceil(2).to_f,四捨五入: round(2)
  # 3.upto(6) do |i|, 6.downto(3) do |i|
  # 公約数125.gcd(100)、公倍数125.lcm(100)
  # PI = Math::PI
  # 高さ = a * Math.sin(w / 180.0 * Math::PI), 底辺 = a * Math.cos(w / 180.0 * Math::PI)
  # def chmax(a, b) a > b ? a : b end
  # INF = Float::INFINITY
  # def chmin(a, b) a < b ? a : b end

t = gets.split

a = t[0].to_i
b = t[1].to_f
puts (a.rationalize*b.rationalize).floor

Measured memory_bytes: 14428
import math

n, d = map(int, input().split())
p=[]
for i in range(n):
    p.append(list(map(int, input().split())))
#print(p)
count=0
for i in range(n):
    if math.sqrt(((p[i][0])**2 + (p[i][1])**2)) <= d:
        count+=1
print(count)

Measured memory_bytes: 45352
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <vector>
using namespace std;

constexpr double EPS = 1e-9;

struct point {
	double x, y;
	point(double x_ = 0.0, double y_ = 0.0):x(x_), y(y_) {}

	point operator-(const point &p) const {
		return point(x - p.x, y - p.y);
	}
};

double angle(const point &p) {
	return atan2(p.y, p.x);
}

double norm(const point &p) {
	return p.x * p.x + p.y * p.y;
}

double normalize(double theta) {
	return theta < 0 ? theta + 2 * M_PI : theta;
}

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout.precision(1);
	cout.setf(ios::fixed);
	constexpr double INF = 1e9;

	for(int n; cin >> n && n;) {
		vector<point> flags;
		flags.reserve(n);

		for(int i = 0; i < n; ++i) {
			double x, y;
			cin >> x >> y;
			flags.emplace_back(x, y);
		}

		double ans = 0.0;
		point pos(0, 0);
		double dir = M_PI / 2;
		bitset<400> visited;

		for(int i = 0; i < n; ++i) {
			pair<double, double> best(INF, INF);
			int next = -1;
			double next_dir;

			for(int v = 0; v < n; ++v) {
				if(visited[v]) continue;

				const double dist2 = norm(flags[v] - pos);
				const double theta = normalize(dir - angle(flags[v] - pos));

				const pair<double, double> tmp(theta, dist2);

				if(tmp < best) {
					best = tmp;
					next = v;
					next_dir = angle(flags[v] - pos);
				}
			}

			ans += sqrt(best.second);
			pos = flags[next];
			dir = next_dir;
			visited.set(next);
		}

		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 1396
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    long[] h = new long[n];
    long[] p = new long[n];
    long[][] s = new long[n][2];
    for(int i = 0; i < n; i++) {
      h[i] = sc.nextLong(); 
      p[i] = sc.nextLong();
      s[i][0] = i;
      s[i][1] = h[i] + p[i]; 
    }
    Arrays.sort(s, new Comparator<long[]>() {
	public int compare(long[] s1, long[] s2) {
		return (int)(s1[1] - s2[1]);
	}
    });
    long[] dp = new long[n + 1];
    dp[1] = p[(int)s[0][0]];
    long[] t = new long[n + 1];
    t[1] = p[(int)s[0][0]];
    for(int i = 2; i < n + 1; i++) {
      dp[i] = (long)Math.pow(10, 16);
      t[i] = (long)Math.pow(10, 16);
    }
    for(int i = 1; i < n; i++) {
      int index = (int)s[i][0];
      for(int j = 1; j < n + 1; j++) {
        if(t[j - 1] > h[index]) {
        } else {
          dp[j] = Math.min(dp[j], t[j - 1] + p[index]);
        }
      }
      for(int j = 1; j < n + 1; j++) {
        t[j] = dp[j];
      }
    }
    int ans = 1;
    for(int j = n; j >= 0; j--) {
      if(dp[j] < (long)Math.pow(10, 16)) {
        ans = j;
        break;
      } 
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 37872
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};


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

    int n,k;
    cin >> n >> k;
    vector<double> p(n,0);
    vector<double> s(n+1,0);
    rep(i,n){
        cin >> p[i];
        p[i] = (1+p[i])/2;

        s[i+1] = s[i] + p[i];
    }

    //for(auto it:p) cout << it << endl;
    //for(auto it:s) cout << it << endl;
    double mx = 0;
    rep(i,n-k+1){
        mx = max(mx,s[i+k]-s[i]);
        //cout << mx << endl;
    }

    cout << fixed << setprecision(15) << mx << endl;
    return 0;

}


Measured memory_bytes: 3456
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		int Y = sc.nextInt();
		if(Y % 2 == 0 && X * 2 <= Y && X * 4 >= Y)
			System.out.println("Yes");
		else
			System.out.println("No");
	}

}

Measured memory_bytes: 35736
#include<iostream>
#include<vector>
#include<map>
#include<numeric>
#define ll long long
#define MOD = 1e9+7
 
using namespace std;
 
int main() {
  int S,W;
  cin >> S >> W;
  if(S<=W){
    cout << "unsafe" << endl;
  }else{
    cout << "safe" << endl;
  }
}


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

#define gap " "
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define ok cout<<"ok"<<endl
#define dbg(x) cout<<(#x)<<" is "<<x<<endl
#define fastio {ios_base::sync_with_stdio(false);cin.tie(NULL);}


typedef long long ll;

ll dp[102][100005];
ll wt[102],val[102];

ll knapsack(int n,int w)
{

   for(int i=0; i<=n; i++){
      for(int j=0; j<=w; j++){
         if(i==0 || j==0) dp[i][j]=0;
         else if(wt[i]<=j){
            dp[i][j]=max(dp[i-1][j],val[i]+dp[i-1][j-wt[i]]);
         }
         else dp[i][j]=dp[i-1][j];
      }
     
   }
   return dp[n][w];
}
int main()
{
   ll n,w,i;
   scanf("%lld %lld",&n,&w);
   for(int i=1; i<=n; i++){
      scanf("%lld %lld",&wt[i],&val[i]);
   }
   ll ans=knapsack(n,w);
   printf("%lld\n",ans);
   return 0;
}

Measured memory_bytes: 82532
#include<bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define repk(i,k,n) for (ll i = k; i < (ll)(n); ++i)
#define INF 5000000000
#define MOD 1000000007
typedef long long  ll;

using namespace std;

int ans;

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

	int N,D;
	cin >> N >> D;

	vector<vector<int>> X(N,vector<int>(D));
	rep(i,N){
		rep(j,D){
			cin >> X[i][j];
		}
	}
	
	rep(i,N){
		repk(j,i+1,N){
			double d = 0;
			rep(k,D){
				d += pow(X[i][k] - X[j][k],2);
			}
			d = sqrt(d);
			if(d == floor(d)){
				//cout << i << " " << j << endl;
				ans++;
			}
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

def abc077_c():
    N = int(readline())
    A = list(map(int, readline().split()))
    B = list(map(int, readline().split()))
    C = list(map(int, readline().split()))
    A.sort()
    B.sort()
    C.sort()
    ans = 0

    from bisect import bisect_left

    # Bjに対するCの使える個数は、前処理で求めておく
    B2C = [0] * N
    # 真に大きいが条件なので Ai + 1 が入るポイントを探す
    for j in range(N):
        B2C[j] = N - bisect_left(C, B[j]+1)
    # 累積和
    accum = [0]
    for j in range(N):
        accum.append(accum[-1] + B2C[j])

    # Ai -> B は二分探索
    for i in range(N):
        jst = bisect_left(B, A[i]+1)
        if jst == N: continue
        # 前処理済みなので、Bj以降を使ったときにCが何個使えるかはすぐわかる
        ans += accum[N] - accum[jst]
    print(ans)

abc077_c()

Measured memory_bytes: 24932
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
long long a,b,c,k;
void solve(){
    if(a>=k) {
        cout<<k<<endl;
    }else if((a+b)>=k) {
        cout<<a<<endl;
    }else{
        cout<<a-(k-a-b)<<endl;
    }
}

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

    solve();
    return 0;
}


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

using namespace std;

static long long gcd(long long a,long long b){
	int amari = a % b;
	int c = b;
	if(amari == 0){
		return b;
	}else{
		return gcd(b,amari);
	}
}
static long long lcm(long long a,long long b){
	return a*b/gcd(a,b);
}
int main() {
	long long a,b,c,d;
	cin >> a >> b >> c >> d;
	long long kosu = b - a + 1;
	long long cc,dd,cd;
	cc = (a-1) / c;
	dd = (a-1) / d;
	cd = (a-1) / lcm(c,d);
	long long ans = kosu - b /c - b /d + b / lcm(c,d) + cc + dd - cd;
	cout << ans;
}



Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<set>

#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 FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

using namespace std;

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


template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
	for (auto& e : t) fill_v(e, v);
}


#define ARRAY_MAX 100005
const int INF = 1e9 + 7;
const ll MOD = 1e9 + 7;

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




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



//素数判定
bool is_prime(ll n) {
	for (ll i = 2; i*i <= n; i++) {
		if (n % i == 0) {
			return false;
		}
	}
	return n != 1;//1の場合は除外
}



//約数の列挙
template<typename T>
vector<T> divisor(T n) {
	vector<T> res;
	for (T i = 1; i * i <= n; i++) {
		if (n % i == 0) {
			res.push_back(i);
			if (i != n / i) {
				res.push_back(n / i);
			}
		}
	}
	return res;
}




//ユークリッド互除法
template<typename T>
T gcd(T x, T y) {

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



//繋げる方向を一方向にする
typedef struct union_find {

	vector<ll> pa;//親
	vector<ll> ra;//木の深さ
	vector<ll> siz;
	//n要素で初期化
	void init(ll n) {
		pa.resize(n);
		ra.resize(n);
		siz.resize(n);
		for (ll i = 0; i < n; i++) {
			pa[i] = i;/*各ノードに番号を振る,この時par[x]=xとなる時は木の根となる*/
			ra[i] = 0LL;/*各ノード自体の高さは0*/
			siz[i] = 1LL;
		}
	}
	//木の根を求める
	ll find(ll x) {
		if (pa[x] == x) {
			return x;/*根ならそのノードの番号を返す*/
		}
		else {
			return pa[x] = find(pa[x]);/*根でないならさらにノードの根を探す*/
		}
	}

	//xとyの属する集合を併合する
	void unite(ll x, ll y) {
		x = find(x);//xの根の番号を探す
		y = find(y);//yの根の番号を探す
		if (x == y) {//一致すればつながっている
			return;
		}
		pa[y] = x;
		siz[x] += siz[y];
	}

	//xとyが同じ集合に属するか判定
	bool same(ll x, ll y) {
		return find(x) == find(y);//同じ集合なら1、違うなら0が返る
	}
}UF;




int main() {

	int n, x;
	cin >> n >> x;
	vector<int> a(n);

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

	ll ans = 0;

	for (int i = 0; i < n; i++)
	{
		if (a[i] > x) {
			ans += a[i] - x;
			a[i] = x;
		}

		if (i > 0) {
			if (a[i] + a[i - 1] > x) {
				ans += a[i] + a[i - 1] - x;
				a[i] -= (a[i] + a[i - 1] - x);
			}
		}
	}

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

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using V = vector<int>;
using VV = vector<vector<int>>;
using VVV = vector<vector<vector<int>>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VVVL = vector<vector<vector<ll>>>;
using pq = priority_queue<int>;
template<class T>
using P = pair<T, T>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,k,n) for(int i=(k);i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define output(x,y) cout << fixed << setprecision(y) << x << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int under = (1 << 31);
int upper = under - 1;
ll UNDER = (1LL << 63);
ll UPPER = UNDER - 1;
const int MOD = 1e9 + 7;
const long double pi = 3.141592653589793;
int main() {
	string s;
	cin >> s;
	int n = s.size();
	V mod(n + 1, 0);
	int mul = 1;
	map<int, int> mp;
	mp[0]++;
	for (int i = n - 1; i >= 0; i--) {
		int num = (s[i] - '0') * mul % 2019;
		mod[i] = (mod[i + 1] + num) % 2019;
		mp[mod[i]]++;
		mul = mul * 10 % 2019;
	}
	ll ans = 0;
	for (auto c : mp) {
		ans += c.second * (c.second - 1) / 2;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4344
#include <bits/stdc++.h>
#include <string.h>
#include <stdlib.h>
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define abs(a) ((a)>(0)?(a):-(a))
#define rep(i,l,r) for((i)=(l);(i)<(r);(i)++)
int cmp(const void *a,const void *b){
return *(char *)a-*(char *)b;
}
int cmps(const void *a,const void *b){
return strcmp((char *)a,(char *)b);
}
using namespace std;
int main(){
    int n,i;
    long long ans=0,buf=0;
    cin>>n;
    char s[n][11];
    rep(i,0,n){
        cin>>s[i];
        qsort(s[i],10,sizeof(char),cmp);
    }    
   qsort(s,n,sizeof(s[0]),cmps);
    for(i=0;i<n;i++){
        if(strcmp(s[i],s[i+1])==0){
            if(buf==0)buf+=2;
            else buf++;
        }
        else{
            ans+=(buf*(buf-1))/2;
            if(buf==1)ans++;
            buf=0;
        }
    }
    cout<<ans<<endl;
    
}

Measured memory_bytes: 2428
import java.util.*;
public class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int m = sc.nextInt();
    int a[] = new int[m];
    int total = 0;
    for(int i=0 ; i<m ; i++){
      a[i] = sc.nextInt();
    }
    for(int i=0 ; i<m ; i++){
      total = total + a[i];
    }
    if(total <=n){
      System.out.println(n-total);
    }else{
      System.out.println(-1);
    }
  }
}


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

#define FOR(i, a, b) for (int i = (a); i < (b); i++)

typedef long long ll;

class Human {
 public:
  vector<pair<int, bool> > answers;
};

int GetBinFromDec(int dec, const int& digit) {
  // example
  // dec: 5
  // bin: B101
  // when digit is 0, return 1
  // when digit is 1, return 0
  // when digit is 2, return 1
  // when digit is 3, return -1

  if (digit < 0) return -1;
  for (int i = 0; i < digit; i++) {
    dec /= 2;
  }
  return dec % 2;
}

int main() {
  int n;
  cin >> n;
  vector<Human> people(n);
  FOR(i, 0, n) {
    int a;
    cin >> a;
    FOR(j, 0, a) {
      int x, y;
      cin >> x >> y;
      people[i].answers.push_back(pair<int, bool>(x - 1, y));
    }
  }
  int case_max = pow(2, n);
  int ans = 0;
  FOR(i, 0, case_max) {
    bool is_able = true;
    FOR(j, 0, n) {
      int bin = GetBinFromDec(i, j);
      if (bin == -1) {
        cout << "error" << endl;
        return 0;
      }
      if (bin == 0) continue;
      for (auto answer : people[j].answers) {
        int check_id = answer.first;
        int target_flag = GetBinFromDec(i, check_id);
        if (target_flag != answer.second) {
          is_able = false;
          break;
        }
      }
      if (!is_able) break;
    }
    if (!is_able) continue;
    int test_ans = 0;
    FOR(j, 0, n) {
      if (GetBinFromDec(i, j) == 1) test_ans++;
    }
    ans = max(test_ans, ans);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#3
N,A,B = map(int,input().split())
S = input()
cou = 0
coub = 0

for i in range(N):
    if S[i] == "a":
        if  cou < (A+B):
            print("Yes")
            cou += 1
        else:
            print("No")
    elif S[i] == "b":
        coub += 1
        if cou < (A+B) and coub <= B:
            print("Yes")
            cou += 1
        else:
            print("No")
    else:
        print("No")


Measured memory_bytes: 9232
s = [i for i in input()]
flg=0
ki = ['R', 'U', 'D']
gu = ['L', 'U', 'D']

for i in range(len(s)):
    if i%2==0:
        if s[i] not in ki:
            flg=1
            break
    elif i%2==1:
        if s[i] not in gu:
            flg=1
            break
        
print('Yes' if flg==0 else 'No')

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

#define ll long long
int main()
{
	ll N,A=0,m=9999999999999,t=0;
	cin>>N;
	for(int i=(int)sqrt(N);i>=2;i--)
	{
		if(N%i==0)
		{
			A=i+N/i;
			cout<<A-2<<endl;		 
			return 0;
		}
	}
	//t!=1?cout<<N-1:cout<<m-2;
	cout<<N-1;

}

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


using namespace std;
typedef long long ll;

const ll MAXN=1e5+10;

int main() {
	int n,k,x,ans=0;
	cin>>n>>k;
	for(int i=1;i<=n;i++){
		cin>>x;
		ans+=min(fabs(0-x),fabs(x-k));
	}
	cout<<2*ans;
	return 0;
}


Measured memory_bytes: 256
/* {{{ Shinobu kawaii */
/*
  ______   __        _                  __                 
.' ____ \ [  |      (_)                [  |                
| (___ \_| | |--.   __   _ .--.   .--.  | |.--.   __   _   
 _.____`.  | .-. | [  | [ `.-. |/ .'`\ \| '/'`\ \[  | | |  
| \____) | | | | |  | |  | | | || \__. ||  \__/ | | \_/ |, 
 \______.'[___]|__][___][___||__]'.__.'[__;.__.'  '.__.'_/ 

*/
// clang-format off
/* }}} */

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

// #define int long long
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

/* cpp template {{{ */

/* short */
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) (v).begin(), (v).end()
#define X real()
#define Y imag()

/* REPmacro */
#define REPS(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (int i = (a); i >= n; --i)
#define DEP(i, n) DEPS(i, n, 0)

/* debug */
#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

/* alias */
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using D = double;
using P = complex<D>;
template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;
const D EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
inline int in() {int x; cin >> x; return x;}
template <typename T> inline void print(const T& x) {cout << x << '\n';}
template <typename T, typename S> inline void print(const pair<T, S>& p) {cout << p.first << " " << p.second << '\n';}
template <typename T, typename S> inline void print(const vector<pair<T, S>>& v) {
  REP(i, v.size()) print(v[i]);
}
template <typename T> inline void print(const vector<T>& v, string s = " ") {
  REP(i, v.size()) {
    if (i != 0) cout << s;
    cout << v[i];
  }
  cout << '\n';
}
// clang-format on
/* }}} */

signed main() {
  string s, t;
  int N = in();
  cin >> s >> t;
  int ans = -1;
  REP(i, N) {
    int cnt = 0;
    REP(j, i + 1) {
      if (s[N - 1 - i + j] == t[j]) ++cnt;
      //print(mp(s[N - 1 - i + j], t[j]));
    }
    ans = max(ans, cnt);
    //print("========");
  }
  print(N * 2 - ans);

  return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<bitset>
#include<vector>
#include<deque>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<iomanip>
#include <functional>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const int INF = 1 << 28;
const double EPS = 1e-10;
//cout << fixed << std::setprecision(9)
//memset(a, 0, sizeof(a));
//--------------------------

int a[26];

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

	if (s == "zyxwvutsrqponmlkjihgfedcba") {
		cout << -1 << endl;
		return 0;
	}

	for (int i = 0;i < s.size();i++) {
		int k = (int)s[i] - 'a';
		a[k]++;
	}

	if (s.size() < 26) {
		int t = 30;
		for (int i = 0;i < 26;i++) {
			if (!a[i]) {
				t = min(t, i);
			}
		}
		s += (t + 'a');
	}
	else {
		for (int i = s.size() - 1;i >= 0;i--) {
			s[i]++;
			while (s[i] <= 'z') {
				int flag = 1;
				memset(a, 0, sizeof(a));

				for (int j = 0;j <= i;j++) {
					int tmp = s[j] - 'a';
					if (a[tmp]) flag = 0;
					else a[tmp]++;
				}

				if (flag) {
					for (int h = 0;h <= i;h++) cout << s[h];
					cout << endl;
					return 0;
				}

				s[i]++;
			}
		}
	}

	cout << s << endl;

	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse2")

#include<bits/stdc++.h>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;


#define ll          long long
#define pb          push_back
#define pii         pair<int ,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define FF           first
#define SS           second
#define sz(x)       (int)x.size()
#define endl        '\n'
//#define hell          1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define REP(i,n) for (int i = 1; i <= n; i++)

// mp::cpp_int



int solve( ){
    
int n;
vi a;
a.pb(0);
cin>>n;
rep(i,0,n)
{
  int x;
  cin>>x;
  a.pb(x);
}
a.pb(0);

int count=0;
int k=0;
for(int j=0;j<100;j++)
for(int i=0;i<=n+1;i++)
{
   if(a[i]==0){count+=k;k=0;}
   else {a[i]-=1;k=1;}  
}
cout<<count;





return 0;
}
 

int main()
{  int t=1;
 ios::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);
  
   
  
  clock_t time_req;

    // Without using pow function
    time_req = clock();
    
//cin>>t;
   while(t--)
     {solve();
     }

         time_req = clock() - time_req;
    //cout << "Processor time taken is "
      //<< (double)time_req/CLOCKS_PER_SEC << " seconds" << endl;


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    vector<int>a(n),b(n),c(n);
    for(int i=0;i<n;i++)cin>>a.at(i);
    for(int i=0;i<n;i++)cin>>b.at(i);
    for(int i=0;i<n;i++)cin>>c.at(i);
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    sort(c.begin(),c.end());
    ll i=0,j=0,k=0,ans=0;
    while(1){
        if(j==b.size())break;
        while(i+1<a.size()&&a.at(i+1)<b.at(j))i++;
        while(k+1<c.size()&&c.at(k)<=b.at(j))k++;
       if(a.at(i)<b.at(j)&&b.at(j)<c.at(k)) ans+=(i+1)*(c.size()-k);
        j++;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 1408
#include <stdio.h>

int main(void) {
	int A,B;
	scanf("%d",&A);
	scanf("%d",&B);
	if (A%3 == 0 || B%3 == 0 ||(A+B)%3 == 0){
		printf("Possible\n");
	}else {
		printf("Impossible\n");
	}
}

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

#define infi            1e9
#define infl            5e18
#define MX              100005
#define pi              2*acos(0.0)
#define ll              long long int
#define rr              read()
#define ff              first
#define ss              second
#define pb              push_back
#define pii             pair<int,int>
#define ms(a,b)         memset(a, b, sizeof(a))
#define loop(i,n)       for(register int i=0;i<n;i++)
#define pool(i,n)       for(register int i=n-1;i>=0;i--)
#define loop1(i,n)      for(register int i=1;i<=n;i++)
#define pool1(i,n)      for(register int i=n;i>0;i--)

using namespace std;

inline ll read(){char c=getchar();ll num,sign=1;for(;c<'0'||c>'9';c=getchar())if(c=='-')sign=-1;for(num=0;c>='0'&&c<='9';){c-='0';num=num*10+c;c=getchar();}return num*sign;}
//inline ll pw(ll b, ll p){ll ans=1;while(p>0){if(p&1)ans*=b;p>>=1;b*=b;}return ans;}
// inline bool isPrime(ll n){if(n==1)return false;if(n==2)return true;if(!(n%2))return false;for(ll i=3;i<=sqrt(n);i+=2)if(!(n%i))return false;return true;}
inline ll gcd(ll a, ll b){if(a==0)return b;return gcd(b%a,a);}

// //*************************************  Bitmask Opereations  **********************************//
// int Set(int N,int pos){return N=N | (1<<pos);}
// int reset(int N,int pos){return N= N & ~(1<<pos);}
// bool check(int N,int pos){return (bool)(N & (1<<pos));}
// //********************************************************************************************//

int A[45],B[45],C[45];
int dp[45][405][405];
int aa,bb,n;

int solve(int ind, int Ma, int Mb){
    if(ind==n){
        int g=gcd(Ma,Mb);
        if(g!=0 && Ma/g==aa && Mb/g==bb)return 0;
        else return infi;
    }
    if(dp[ind][Ma][Mb]!=-1)return dp[ind][Ma][Mb];

    return dp[ind][Ma][Mb]=min(solve(ind+1,Ma+A[ind],Mb+B[ind])+C[ind], solve(ind+1,Ma,Mb));
}

int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    //#ifdef rid.dle
    //freopen("in.txt", "r", stdin);//#endif
    
    n=rr;aa=rr;bb=rr;

    loop(i,n){
        A[i]=rr;
        B[i]=rr;
        C[i]=rr;
    }
    ms(dp, -1);

    int ans=solve(0,0,0);

    cout << (ans==infi?-1:ans) << endl;

    return 0;
}

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

int n,m,tot,c[1007],a[33],b[33],ans=1007,is[33];
void dfs(int v){
    if(n<v){
        int cnt=0,mm=m;
        tot=0;
        for(int i=1;i<=n;i++){
            if(is[i])cnt+=a[i],mm-=(a[i]*i*100+b[i]);
            else for(int j=1;j<a[i];j++)c[++tot]=i*100;
        }
        /*printf("solve");
        for(int i=1;i<=n;i++)printf(" %d",is[i]);
        printf("\n");
        printf("%d %d\n",cnt,mm);
        for(int i=1;i<=tot;i++)printf("%d\n",c[i]);*/
        if(mm<=0){ans=min(ans,cnt);return;}
        for(int i=tot;i;i--){
            mm-=c[i],++cnt;
            if(mm<=0){ans=min(ans,cnt);return;}
        }
        return;
    }
    is[v]=0,dfs(v+1);
    is[v]=1,dfs(v+1);
}
int main(){
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++)scanf("%d%d",&a[i],&b[i]);
    dfs(1);
    printf("%d",ans);
    return 0;
}

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

#define fio() cin.tie(0); ios::sync_with_stdio(false);
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl;

//str.substr(pos,number) str.insert(str.begin()+5,'3')
//set.insert(num) set.count(i)!=0
const int MAXN = 2e5 + 5;
const int INF = 1e9;
typedef pair<int,int> P;
int n;
int main(){
    fio();
	long  double a,b;
	cin>>a>>b;
	long long int c = a*b;
	cout<<c<<endl;

}














Measured memory_bytes: 3796
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			int tmp = 0;

			for (int i = 0; i < n; i++) {
				int h = sc.nextInt();
				if (h < tmp && h - 1 < tmp) {
					System.out.println("No");
					return;
				}
				if (tmp <= h - 1) {
					tmp = h - 1;
				} else {
					tmp = h;
				}
			}

			System.out.println("Yes");
		}
	}
}


Measured memory_bytes: 46372
A = int(input())
if 1 <= A <= 9:
  print(A)
elif 10 <= A <= 99:
  print(9)
elif 100 <= A <= 999:
  print(A-90)
elif 1000 <= A <= 9999:
  print(909)
elif 10000 <= A <= 99999:
  print(A-9090)
else:
  print(90909)

Measured memory_bytes: 3060
"use strict";
function I(s,f){this._s=s.split("\n");this._c=0;this._l=0;this._f=f||Number}I.prototype.a=function(){var l=this._s[this._l];if(!l)return;var t=l.trim().split(" ");var a=t[this._c];this._c++;if(t.length===this._c){this._c=0;this._l++}return this._f(a)};I.prototype.l=function(){var l=this._s[this._l];if(!l)return;this._c=0;this._l++;return l.split(" ").map(this._f)};module.exports=I;

function main(input) {
  const o = new I(input);

  const N = o.a();
  const M = o.a();

  const divisors = [];
  for (let i = 1; i<= Math.sqrt(M); i++) {
    if (M % i === 0) {
      divisors.push(i);
    }
  }

  for (let i=divisors.length - 1; i >= 0; i--) {
    const j = M / divisors[i];
    if ( j > divisors[divisors.length - 1]) {
      divisors.push(j);
    }
  }

  let max = 1;
  for ( let i =0; i< divisors.length; i++) {
    if ( M / divisors[i] >= N) {
      max = divisors[i];
    }
  }
  console.log(max);
}


main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 9548
fun main(args: Array<String>){
    val s = readLine()!!.toCharArray().map { it.toString() }.map { it.toInt() }.toIntArray()
    val k = readLine()!!.toLong()
    var f = 0L
    for (i in s.indices){
        if(s[i] == 1){
            f++
            if(f == k){
                println(1)
                return
            }
        }else{
            println(s[i])
            return
        }
    }
}

Measured memory_bytes: 36256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		int m = stdIn.nextInt();
		int n = stdIn.nextInt();
		int max = 0;
		for(int i=0;i<m;i++){
			int tmp = 0;
			for(int j=0;j<n;j++){
				tmp += stdIn.nextInt();
			}
			if(tmp>max){
				max = tmp;
			}
		}
		System.out.println(max);
	}
}

Measured memory_bytes: 12000
#include <stdio.h>

/** Application main entry point. */
int main (
  int     argc,
  char  * argv[ ]
  )
{
  int a, b, n;
  int i;

  while ( scanf ( "%d%d%d", &a, &b, &n ) == 3 )
  {
    int res = 0;

    a %= b;
    for ( i = 0; i < n; ++i )
    {
      a *= 10;
      res += a / b;
      a %= b;
    }

    printf ( "%d\n", res );
  }

  return ( 0 );
}

Measured memory_bytes: 0
S = input()
T = input()

import math


def calculate(s, t):
    lenS = len(s)
    lenT = len(t)

    count = math.inf

    for i in range(lenS - lenT + 1):
        value = s[i:i + lenT]

        tmp = 0
        isOk = True
        for j in range(len(value)):
            if value[j] != t[j]:
               tmp += 1
               if tmp > count:
                   isOk = False
                   break

        if isOk:
            count = min(count, tmp)

    print(count)
calculate(S, T)


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

int main()
{
   long long num1, num2, i, gcd, lcm;


   cin >> num1 >> num2;

   //calculation of gcd
   for(i=1; i <= num1 && i <= num2; ++i)
   {
      if(num1 % i == 0 && num2 % i == 0)
      gcd = i;
   }
   //calculation of lcm using gcd
   lcm = (num1 * num2) / gcd;
   cout <<lcm << endl;

   return 0;
} //end main

Measured memory_bytes: 256
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
long long n;
int m, i, j, k, l, r, z, a[405], len;
int po[80];
int main()
{
	cin >> n;
	if (n == 1) {cout << "2\n 1 1"; return 0;}
	n ++;
	l = 200; r = 199;
	while (n != 1)
	{
		++len;
		if (n & 1) po[len] = 1;
		n >>= 1;
	}
	//cout << len << endl;
	for(i = len; i >= 1; i --)
	{
		a[++r] = ++z;
		if (po[i]) a[--l] = ++z;
	}
	cout << (r - l + 1) * 2 << endl;
	for(i = l; i <= r; i ++)
		cout << a[i] << " ";
	for(i = 1; i <= r - l + 1; i ++)
		cout << i << " ";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ull unsigned long long
#define MOD (int)(1e9+7)
#define ceil(x, y) (x%y==0? (x/y) : (x/y+1))
#define FOR(i, N) for(int i = 0; i < N; ++i)
#define FOR1(i, N) for(int i = 1; i <= N; ++i)
#define vi vector <int>
#define pii pair <int, int>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mset(a, v) memset(a, v, sizeof(a))
#define all(v) (v).begin(), (v).end()
#define INF 2e9
#define EPS 1e-9
#define int long long
using namespace std; 
void primeFactorise(int X, map<int, int>& pows){
		while(X % 2 == 0){
			pows[2] += 1;
			X /= 2;
		}
		for(int i = 3; i*i <= X; i+=2){
			while(X % i == 0){
				pows[i] += 1;
				X /= i;
			}
		}
		if(X > 2){
			pows[X] += 1;
		}
}
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifndef ONLINE_JUDGE
    	freopen("in.txt", "r", stdin);
    	freopen("out.txt", "w", stdout);
    #endif

	int T=1;
	//cin >> T;
	FOR1(tp, T)
	{
		//cout << "Case #" << i << ": ";
		
		int n; cin >> n;
		map<int, int> pows;
		primeFactorise(n, pows);
		int ans = 0;
		for(pii p : pows){
			int e = p.ss;
			int sum = 0;
			for(int k = 1; sum + k <= e; k++){
				sum += k;
				ans++;
			}

		}
		cout << ans;
		cout<<'\n';
	}
	return 0;
}


Measured memory_bytes: 3656
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        if(a < b){
            System.out.println("a < b");   
        }else if(a > b){
            System.out.println("a > b");   
        }else{
            System.out.println("a == b");   
        }
    }
}


Measured memory_bytes: 26132