akhauriyash/Code-Regression huggingface dataset:
#pragma region Header
#ifdef DEBUG
#include "debug.hpp"
#else
#define debug(...)
#define IFD(...)
#ifndef NDEBUG
#define NDEBUG
#endif
#endif
#include <utility>
#include <cstdint>
#include <cmath>
#include <cassert>
#include <vector>
#include <array>
#include <deque>
#include <queue>
#include <stack>
#include <tuple>
#include <set>
#include <map>
#include <unordered_map>
#include <bitset>
#include <string>
#include <functional>
#include <algorithm>
#include <numeric>
#include <stdexcept>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <boost/hana/functional/fix.hpp>
using boost::hana::fix;
using namespace std;
using i32 = int32_t;
using i64 = int64_t;
using u32 = uint32_t;
using u64 = uint64_t;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repd(i, n) for (int i = (n)-1; i >= 0; --i)
#define FOR(i, a, b) for (int i = (a); i <= (b); ++i)
#define FORD(i, b, a) for (int i = (b); i >= (a); --i)
template <typename T>
int SZ(T const &x)
{
    return static_cast<int>(x.size());
}
template <class T>
bool chmax(T &a, T const &b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
bool chmin(T &a, T const &b)
{
    if (b < a)
    {
        a = b;
        return true;
    }
    return false;
}
#pragma endregion

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

    int n;
    cin >> n;
    vector a_s(n, vector<i64>(n));
    rep(i, n)
    {
        rep(j, n) { cin >> a_s[i][j]; }
    }

    vector<i64> score(1 << n, 0);
    rep(s, 1 << n)
    {
        rep(i, n)
        {
            if (not((s >> i) & 1))
            {
                continue;
            }
            FOR(j, i + 1, n - 1)
            {
                if (not((s >> j) & 1))
                {
                    continue;
                }
                score[s] += a_s[i][j];
            }
        }
    }

    vector<i64> dp(1 << n, 0);
    // sは確定した集合
    for (u32 s = 0; s < (1 << n); ++s)
    {
        // disjointな集合tを列挙
        for (u32 t = (1 << n) - 1; t = t & (~s), t >= 1; --t)
        {
            chmax(dp[s | t], dp[s] + score[t]);
        }
    }

    cout << dp[(1 << n) - 1] << '\n';

    return 0;
}


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


int main(){
  int n, c;
  cin >> n >> c;
  vector<pair<int, pair<int, int>>> v(n);
  for(int i=0;i<n;i++){
    int s, t, c;
    cin >> s >> t >> c;
    v[i].first = s, v[i].second.first = t, v[i].second.second = c;
  }
  sort(v.begin(), v.end());
  vector<pair<int, int>> m;
  m.push_back(pair<int, int>(v[0].second.first, v[0].second.second));
  for(int i=1;i<n;i++){
    int flag=0;
    for(int j=0;j<m.size();j++){
      if (m[j].first <= v[i].first && m[j].second == v[i].second.second){
        m[j].first = v[i].second.first;
        flag=1;
        break;
      }else if(m[j].first < v[i].first){
        m[j].first = v[i].second.first;
        m[j].second = v[i].second.second;
        flag = 1;
        break;
      }
    }
    if (flag==0){
      m.push_back(pair<int, int>(v[i].second.first, v[i].second.second));
    }
  }
  cout << m.size() << endl;
  return 0;
}

Measured memory_bytes: 1408
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007;
constexpr lint LINF = 1111111111;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "" : " ");
	return os;
}

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

template <class T1, class T2>
ostream &operator<<(ostream &os, const map<T1, T2> &mp) {
	for (const auto &e : mp) os << "[" << e << "] ";
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

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

int main() {

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

	lint H, W;
	cin >> H >> W;

	lint ans = LINF;
	if (H % 3 == 0 || W % 3 == 0) ans = 0;
	else {
		
		for (int i = 1; i < H; i++) {
			auto mM = minmax({ W * i, ((W + 1) / 2) * (H - i), (W / 2) * (H - i) });
			chmin(ans, mM.second - mM.first);
		}
		for (int i = 1; i < W; i++) {
			auto mM = minmax({ H * i, ((H + 1) / 2) * (W - i), (H / 2) * (W - i) });
			chmin(ans, mM.second - mM.first);
		}

		chmin(ans, min(H, W));

	}

	cout << ans << "\n";

	return 0;
}

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

#define l long
#define ll long long
#define pb push_back
#define vb vector<bool>
#define vi vector<int>
#define vll vector<ll>
#define MOD 998244353
#define nl "\n"
#define sp " "
#define gcd __gcd
#define pf printf
#define sf scanf

int main()
{
    int k,a,b;
    cin>>k;
    cin>>a>>b;
    if(k == 1){
        cout<<"OK"<<nl;
    }
    else{
        // cout<<(k*(ceil((float)a/(float)k)))<<nl;
        if(k*(ceil((float)a/(float)k)) <= b){
            cout<<"OK"<<nl;
        }
        else{
            cout<<"NG"<<nl;
        }
    }

}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,n1,n2) for(ll i=n1;i<n2;i++)
#define bFOR(i,n1,n2) for(ll i=n1;i>=n2;i--)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef long long int ll;
typedef pair<ll,ll> Pi;
typedef tuple<ll,ll,ll> Tu;
const int INF=(ll)(1LL<<30)-1;
const double INFd=100000000000.0;
const double PI=3.14151926535;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
const ll tMOD=(ll)998244353;
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 dx[4]={0,-1,0,1},dy[4]={-1,0,1,0};
int mdx[8]={0,1,0,-1,1,1,-1,-1},mdy[8]={-1,0,1,0,1,-1,1,-1};


template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int n,k;
double p[200100];
double ans=0;
double realans=0;
int main(){
	cin>>n>>k;
	REP(i,n){
		int pp;
		cin>>pp;
		p[i]=(double)(pp+1)/2;
	}
	REP(i,k)ans+=p[i];
	realans=ans;
	FOR(i,k,n){
		ans=ans+p[i]-p[i-k];
		realans=max(realans,ans);
	}
	printf("%.10f\n",realans);
	return 0;
}

Measured memory_bytes: 1792
import java.util.*;
public class Main{
	//A - Traveling Budget
	public static void main(String[] args) {
		
		Scanner scanner = new Scanner(System.in);

		    int A = scanner.nextInt(), B = scanner.nextInt();
		    int S = 0;
		    if(A <= B){
		      S += A; 
		    }
		    else{
		      S += B;
		    }
		    int C = scanner.nextInt(), D = scanner.nextInt();
		    if(C <= D){
		      S += C; 
		    }
		    else{
		      S += D;
		    }
		    System.out.println(S);
		
		
	}

}


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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)

using namespace std;

/////////////////////////////////////////////////////
#define pll pair<ll,ll>
#define mkp make_pair

ll N;
vector<ll> av;
ll ct[90];

ll i, j,k;
int main(){
    scanf("%lld",&N);
    fornum(i,0,N){
        ll a;
        scanf("%lld", &a);
        av.push_back(a);
    }
    sort(av.begin(), av.end());
    k = 0;
    fornum(i,0,N){
        if((av[i]-k)%2){   
        for (j = 0; (1l << j)<=(N-i);j++){
            if((N-i)&(1l<<j)){
                ct[j]++;
            }
        }
        }
        k = av[i];
    }
    fornum(i,0,80){
        if(ct[i]%2){
            printf("first");
            return 0;
        }
    }
    printf("second");
    return 0;
}

Measured memory_bytes: 1400
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array;


void main() {
    int a, b, c;
    auto line = readln.split.to!(int[]).sort();
    a = line[2], b = line[1], c = line[0];

    int ans;

    if (b % 2 == c % 2) {
        if (a % 2 == b % 2) {
            ans = (a - b) / 2 + (a - c) / 2;
        }
        else {
            ans = (a - b) / 2 + (a - c) / 2 + 1;
        }
    }
    else {
        ans = (a - b) / 2 + (a - c) / 2 + 2;
    }

    writeln(ans);
}


void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
#define dbg(x) cout << #x << '=' << x << '\n';
#define ll long long
#define pi pair<int,int>
#define pl pair<long long,long long>
#define lg length()
#define pb push_back
#define MAXN 100005
#define INF 1000000005
#define LINF 1000000000000000005

long long n,a[100005],b[100005],c[100005],dp[100005][4];

int32_t main(){
    ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();
    cin >> n;
    for(int i=1;i<=n;i++) cin >> a[i];
    for(int i=1;i<=n;i++) cin >> b[i];
    for(int i=1;i<=n;i++) cin >> c[i];
    sort(a+1,a+n+1);
    sort(b+1,b+n+1);
    sort(c+1,c+n+1);
    for(int i=1;i<=n;i++) dp[i][1]=i;
    int j=0;
    for(int i=1;i<=n;i++){
        while(j<n && a[j+1]<b[i]) j++;
        dp[i][2]=dp[i-1][2]+dp[j][1];
    }
    j=0;
    for(int i=1;i<=n;i++){
        while(j<n && b[j+1]<c[i]) j++;
        dp[i][3]=dp[i-1][3]+dp[j][2];
    }
    cout << dp[n][3];
}


Measured memory_bytes: 5760
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        long X = sc.nextLong();
        if(X==0){
            System.out.println(0);
            return;
        }

        long sum = 0;

        long A = X % 500;
        long B = X / 500;

        long C = A % 5;
        long D = A / 5;

        sum += 1000 * B + 5 * D;
        System.out.println(sum);
    }
}

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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;

#define INF INT_MAX/3

#define MAX_N 1000


//// gcd
ll gcd(ll a,ll b){
	return b?gcd(b,a%b):a;
}

int main(){
	cin.sync_with_stdio(false);
	ll a,b;
	cin>>a>>b;
	cout<<gcd(a,b)<<endl;
	return 0;
}

Measured memory_bytes: 3200
n, m = map(int, input().split())
if(n == 1 and m == 1):
    print(1)
elif(n == 1):
    print(m - 2)
elif(m == 1):
    print(n - 2)
else:
    print(m * n - 2 * n - 2 * m + 4)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define LB(a,x) lb(all(a),x)-a.begin()
#define UB(a,x) ub(all(a),x)-a.begin()
#define mod 1000000007
#define FS fixed<<setprecision(15)
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<n;i++)
const double pi=3.141592653589793;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

const ll INF=1e18;

class UnionFind{
public:
    vector<ll> par,num;

    int find(ll v){
        return (par[v]==v)? v: (par[v]=find(par[v]));
    }
    explicit UnionFind(ll N):par(N),num(N,1){
        iota(par.begin(),par.end(),0);
    }
    void unite(ll u,ll v){
        u=find(u),v=find(v);
        if(u==v)return ;
        if(num[u]<num[v])swap(u,v);
        num[u] += num[v];
        par[v] = u;
    }
    bool same(ll u,ll v){
        return find(u) == find(v);
    }
    bool ispar(ll v){
        return v=find(v);
    }
    ll size(ll v){
        return num[find(v)];
    }
};

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    ll h,w;
    cin>>h>>w;
    char s[h][w];
    rep(i,h){
        rep(j,w)cin>>s[i][j];
    }
    ll ans=0;
    UnionFind G(h*w);
    rep(i,h){
        rep(j,w){
            for(ll x=-1;x<=1;x++){
                for(ll y=-1;y<=1;y++){
                    if(abs(x+y)==1&&0<=i+x&&i+x<h&&0<=j+y&&j+y<w){
                        if(s[i][j]!=s[i+x][j+y]){
                            G.unite(i*w+j,(i+x)*w+j+y);
                        }
                    }
                }
            }
        }
    }
    V<ll> cnt(h*w,0);
    rep(i,h){
        rep(j,w){
            if(s[i][j]=='#'){
                cnt[G.find(i*w+j)]++;
            }
        }
    }
    rep(i,h){
        rep(j,w){
            if(s[i][j]=='#'){
                ll cur=i*w+j;
                ans+=G.size(cur)-cnt[G.find(cur)];
            }
        }
    }
    cout<<ans<<endl;
}
//ペナルティ出しても焦らない　ACできると信じろ！！！
//どうしてもわからないときはサンプルで実験　何か見えてくるかも
//頭で考えてダメなら紙におこせ！！
/*
V,P(大文字)使用不可
乗算などの際にオーバーフローに注意せよ！
(適切にmodをとれ　にぶたんで途中で切り上げろ)
制約をよく読め！
{
    ・全探索できるなら全探索しろ
    ・異常な制約ならそこに注目
}
stringの計算量(扱い)注意
コーナー注意！(特に数値が小さいものについては要検証)
N行出力のときは'¥n'
グリッド上では行先が範囲内におさまるかif文で確認(RE注意)
if文ではちゃんと比較演算子==を使え('='でもエラー出ない)
配列(vector)の大きさが0か1以上かで場合分けせよ(RE注意)
(vector<int> a(m)でm==0というものはできない)
modはなるべく最後に取れ！
doubleを扱うときには(abs)ではなく'fabs'!!!
*/

Measured memory_bytes: 7164
#include<iostream>
#include<algorithm>
#include<queue>

static const int MAX = 10000;
static const int INFTY = (1 << 20);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

void dijkstra(int n, std::vector<std::pair<int, int> > adj[MAX]) {
	std::priority_queue<std::pair<int, int> > PQ;
	int color[MAX];
	int d[MAX];
	for (int i = 0; i < n; i++) {
		d[i] = INFTY;
		color[i] = WHITE;
	}

	d[0] = 0;
	PQ.push(std::make_pair(0, 0));
	color[0] = GRAY;

	while (!PQ.empty()){
		std::pair<int, int> f = PQ.top(); PQ.pop();
		int u = f.second;
		color[u] = BLACK;

		//????°???????????????????????????????????????§???????????°??????
		if (d[u] < f.first * (-1))continue;
		
		for (size_t i = 0; i < adj[u].size(); i++) {
			int v = adj[u][i].first;
			if (color[v] == BLACK) continue;
			if (d[v] > d[u] + adj[u][i].second) {
				d[v] = d[u] + adj[u][i].second;
				//priority_queue????????????????????§??§??????????????????????????????-1????????????
				PQ.push(std::make_pair(d[v] * -1, v));
				color[v] = GRAY;
			}
		}
	}

	for (int i = 0; i < n; i++) {
		std::cout << i << " " << (d[i] == INFTY ? -1 : d[i]) << std::endl;
	}
}

int main() {
	std::vector<std::pair<int, int> > adj[MAX];
	int n;

	std::cin >> n;
	for (int i = 0; i < n; i++) {
		int u, k;
		std::cin >> u >> k;
		for (int j = 0; j < k; j++) {
			int v, c;
			std::cin >> v >> c;
			adj[u].push_back(std::make_pair(v, c));
		}
	}

	dijkstra(n, adj);
	
	return 0;
}

Measured memory_bytes: 6304
using System;
using System.Collections.Generic;
using System.Linq;

namespace PaizaTest
{
    class Program
    {
        static void Main(string[] args)
        {
            var A = new int[3][];
            var bingoA = new bool[3][];
            for (int i = 0; i < 3; i++)
            {
                A[i] = System.Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
                bingoA[i] = new bool[3];
            }

            var N = int.Parse(Console.ReadLine());
            var b = new int[N];
            for (int i = 0; i < N; i++)
            {
                b[i] = int.Parse(Console.ReadLine());
            }

            for (int i = 0; i < b.Length; i++)
            {
                for (int j = 0; j < A.Length; j++)
                {
                    for (int k = 0; k < A[j].Length; k++)
                    {
                        if (A[j][k] == b[i]) bingoA[j][k] = true;
                    }
                }
            }

            var result = false;
            for (int i = 0; i < 3; i++)
            {
                // 横
                if (bingoA[i].All(x => x))
                {
                    result = true;
                    goto End;
                }
                else if (bingoA[0][i] && bingoA[1][i] && bingoA[2][i])
                {
                    result = true;
                    goto End;
                }
            }
            if (bingoA[0][0] && bingoA[1][1] && bingoA[2][2])
            {
                result = true;
                goto End;
            }
            else if(bingoA[0][2] && bingoA[1][1] && bingoA[2][0])
            {
                result = true;
                goto End;
            }

        End:;
            Console.WriteLine(result ? "Yes" : "No");

        }
    }
}


Measured memory_bytes: 13524
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

int main(){
    int n,m;
    cin>>n>>m;
    priority_queue<pair<int, int>> pq;
    for(int i = 0; i < n; i++){
        int a;
        cin>>a;
        pq.push(make_pair(a, 1));
    }
    for(int i = 0; i < m; i++){
        int b,c;
        cin>>b>>c;
        pq.push(make_pair(c,b));
    }
    ll ans = 0LL;
    while(n--){
        pair<int,int> p = pq.top();
        pq.pop();
        ans += p.first;
        if(p.second>1){
            p.second--;
            pq.push(p);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 2548
import java.util.Arrays;
import java.util.Scanner;

public class Main {

  Scanner sc;

  Main() {
    sc = new Scanner(System.in);
  }

  int ni() {
    return sc.nextInt();
  }

  public static void main(String[] args) {
    new Main().run();
  }

  void run() {
    for (; ; ) {
      int n = ni();
      if (n == 0) {
        break;
      }
      int w = ni();
      int h = ni();
      boolean[][] f = new boolean[h][w];
      for (int i = 0; i < n; ++i) {
        int x = ni() - 1;
        int y = ni() - 1;
        f[y][x] |= true;
      }
      int s = ni();
      int t = ni();
      int ans = 0;
      for (int i = 0; i <= h - t; ++i) {
        for (int j = 0; j <= w - s; ++j) {
          int cnt = 0;
          for (int k = 0; k < t; ++k) {
            for (int l = 0; l < s; ++l) {
              if (f[k + i][l + j]) {
                ++cnt;
              }
            }
          }
          ans = Math.max(ans, cnt);
        }
      }
      System.out.println(ans);
    }
  }

  void debug(Object... os) {
    System.err.println(Arrays.deepToString(os));
  }
}

Measured memory_bytes: 43752
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) debug(x) debug(y);
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	ll n;
	cin >> n;
	vector<ll> a(n), b(n);
	ll tot = 0, prevTot = 0;
	rep(i, n){
		cin >> a[i] >> b[i];
		if(!i) tot = a[i] + b[i];
		if(i){
			if(a[i] >= a[i - 1] && b[i] >= b[i - 1]){
				//we are good, because some guys just added here and there
				tot = max(prevTot, a[i] + b[i]);
			}
			else{
				//we need to do some multiplication?
				ll m1 = (a[i - 1] + a[i] - 1) / a[i];
				ll m2 = (b[i - 1] + b[i] - 1) / b[i];
				a[i] *= max(m1, m2), b[i] *= max(m1, m2);
				tot = a[i] + b[i];
			}
		}
		prevTot = tot;
	}
	cout << tot << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 256
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;
 
int main() {
    int m, f, b; cin >> m >> f >> b;
    if(m + f < b) cout << "NA" << endl;
    else cout << max(0, b - m) << endl;
    return 0;
}



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

using namespace std;
typedef long long ll;

#define rep(i, N) for (int i = 0; i < (int)N; i++)
const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;


int main() {
  int N; cin >> N;
  ll T[N]; rep(i,N) cin >> T[i];
  ll A[N]; rep(i,N) cin >> A[i];
  int pt; pt = lower_bound(T,T+N,T[N-1]) - T;
  int pa; pa = upper_bound(A,A+N,A[0],greater<ll>()) - (A+1);

  if (pt>pa||T[N-1]!=A[0]) { cout << 0 << endl; return 0; }
  ll result = 1;
  rep(i,max(0,pa-pt-1)) { result *= A[0]; result %= MOD; }
  for (int i=1; i<=pt; i++) {
    if (T[i]==T[i-1]) { 
      result *= T[i];
      result %= MOD;
    }
  }
  for (int i=N-1; i>=pa; i--) {
    if (A[i]==A[i+1]) { 
      result *= A[i];
      result %= MOD;
    }
  }  
  // cout << pt << " " << pa << endl;
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 1792
#include <algorithm>
#include <vector>
#include <map>
#include <iostream>
#include <string>

typedef long long ll;

using namespace std;
vector< int > ans(100100);
vector< int > memo(100100);
int main()
{
	//8 3
	//	ACACTACG
	//	3 7
	//	2 3
	//	1 8
	int N, Q;
	int l, r;

	string s;
	

	cin >> N >> Q;
	cin >> s;

	int count = 0;

	for (int i = 0; i < s.size(); i++)
	{
		if ( i > 0 && s[i] == 'C' && s[i - 1] == 'A')
		{
			count++;
		}

		memo[i] = count;
	}


	for (int i = 0; i < Q; i++)
	{
		cin >> l >> r;

		int  x = memo[r-1] - memo[l-1];

		ans[i] = x;
	}

	for (int i = 0; i < Q; i++)
	{
		std::cout << ans[i] << endl;
	}
	
	return 0;
}


Measured memory_bytes: 1792
/**
SXR0aXAkI0JwbXptI3FhI3Z3I293bCNqY2IjUG0jMCNicG0jVHFkcXZvLyNCcG0jQW10bjBhY2phcWFicXZvLyNNYm16dml0MSNWdyNhdGN1am16I2tpdiNhbXF9bSNQcXUjVnd6I0F0bW14MSNQcWEjaXptI2l0dCNicHF2b2EjUXYjYnBtI3BtaWRtdmEjaXZsI3d2I21pemJwMSNFcHcjcWEjYnBtem0ja2l2I3F2Ym16a21sbSNRdiNQcWEjeHptYW12a20jbXtrbXhiI0lhI3BtI3htenVxYmJtYnBHI1BtI3N2d2VtYnAjRXBpYiMraXh4bWl6bWJwI2J3I1BxYSNrem1pYmN6bWEjSWEsI0ptbnd6bSN3eiNJbmJteiN3eiNKbXBxdmwjYnBtdTEjVnd6I2FwaXR0I2JwbXwja3d1eGlhYSNJY29wYiN3biNwcWEjc3Z3ZXRtbG9tI017a214YiNpYSNQbSNlcXR0bWJwMSNQcWEjYnB6d3ZtI2x3YnAjbXtibXZsI1dkbXojYnBtI3BtaWRtdmEjSXZsI3d2I21pemJwLyNpdmwjUG0jbm1tdG1icCNWdyNuaWJxb2NtI3F2I29jaXpscXZvI0l2bCN4em1hbXpkcXZvI2JwbXUvI053eiNQbSNxYSNicG0jVXdhYiNQcW9wMSNCcG0jQWN4em11bSMrcXYjb3R3enwsMQ==
*/
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cassert>

#define F first
#define S second
#define endl '\n'
#define deb(x) cout<<#x<<' '<<x<<endl;
#define pb push_back

/*
#ifdef IZI_KATKA
#define int __int64_t
#else
#define int __int64
#endif
*/

const long long MOD = 998244353;
const long long MAXN = 1e6 + 1;
using namespace std;

typedef long long ll;

long long readInt() {
    bool minus1 = false;
    long long result = 0;
    char ch;
    ch = getchar();
    while (true) {
        if (ch == '-') break;
        if (ch >= '0' && ch <= '9') break;
        ch = getchar();
    }
    if (ch == '-') minus1 = true; else result = ch-'0';
    while (true) {
        ch = getchar();
        if (ch < '0' || ch > '9') break;
        result = result*10 + (ch - '0');
    }
    if (minus1)
        return -result;
    else
        return result;
}

ll fact[MAXN];


ll binpow (ll a, ll n) {
	if (n == 0)
		return 1;
	if (n % 2 == 1)
		return (binpow (a, n-1) * a) % MOD;
	else {
		ll b = binpow (a, n/2) % MOD;
		return (b * b) % MOD;
	}
}


ll C(ll n, ll k) {
	ll res1 = fact[n];
	ll res2 = (fact[k] * fact[n - k]) % MOD;
	return (res1 * binpow(res2, MOD - 2)) % MOD;
}

int main() {
	#ifdef IZI_KATKA
	assert(freopen("input", "r", stdin));
    assert(freopen("output", "w", stdout));
    #endif
    ll N = readInt(), A = readInt(), B = readInt(), K = readInt();
    fact[0] = 1;
    for (int i = 1; i <= N; i++) {
    	fact[i] = fact[i - 1] * i;
    	fact[i] %= MOD;
    }
    ll ans = 0;
    for (int cnt1 = 0; cnt1 <= N; cnt1 ++) {
		ll res = cnt1 * A;
		if (K - res < 0) continue;
		if ((K - res) % B == 0) {
			ll cnt2 = (K - res) / B;
			if (cnt2 <= N)
			ans += C(N, cnt1) * C(N, cnt2);
			ans %= MOD;
		}  
    }
    cout << ans;
    return 0;
}

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

#define rep(i,l,r) for(int i=l;i<=r;++i)

int main()
{
	//freopen("1.in","r",stdin);
	string s;
	cin>>s;
	char c[]="NWSE";bool have[4];
	rep(i,0,3)have[i]=s.find(c[i])!=string::npos;
	rep(i,0,1)
	if(have[i]^have[i+2])
	{
		puts("No");
		exit(0);
	}
	puts("Yes");
}

Measured memory_bytes: 256
// atcoder/abc141/A/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  string s;
  while (cin >> s) {
    map<string, string> m;
    m["Sunny"] = "Cloudy";
    m["Cloudy"] = "Rainy";
    m["Rainy"] = "Sunny";
    cout << m[s] << endl;
  }

  return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        String input = stdIn.nextLine();
        int n = Integer.parseInt(input.split(" ")[0]);
        int k = Integer.parseInt(input.split(" ")[1]);

        String P = stdIn.nextLine();
        int[] p = new int[n];
        for(int i = 0 ; i < n ; i++){
            p[i] = Integer.parseInt(P.split(" ")[i]);
        }
        Arrays.sort(p);
        int ans = 0;
        for(int i = 0 ; i < k ; i++){
            ans += p[i];
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 56996
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T> void assign(V<T>& v, int n, const T& a = T()) { v.assign(n, a); }
template<class T, class... Args> void assign(V<T>& v, int n, const Args&... args) { v.resize(n); for (auto&& e : v) assign(e, args...); }


constexpr lint mod = 1e9 + 7;
inline lint emod(lint a, lint p = mod) { return (a % p + p) % p; }

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  lint n, k; cin >> n >> k;
  if (n < k) return cout << 0 << '\n', 0;
  VV<> mem; assign(mem, n + 1, k + 1, -1);
  fill(begin(mem[0]), end(mem[0]), 1);
  for (int i = 1; i < n + 1; ++i) mem[i][0] = 0;
  auto rec = [&](auto rec, lint n, lint k) -> lint {
    if (n < 0 or k < 0) return 0;
    if (mem[n][k] != -1) return mem[n][k];
    return mem[n][k] = (rec(rec, n, k - 1) + rec(rec, n - k, k)) % mod;
  };
  cout << emod(rec(rec, n - k, k)) << '\n';
}


Measured memory_bytes: 6800
import java.util.Scanner;

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

        int res = 0;
        char chars[] = s.toCharArray();
        for(int i=1; i<s.length(); i++){
            String former = s.substring(0, i);
            String latter = s.substring(i);
            int tmp = 0;
            for (int k=0; k<former.length(); k++){
                int c = former.charAt(k);
                if (former.indexOf(c)==k && latter.indexOf(c)!=-1){
                    tmp++;
                }
            }
            res = Math.max(res, tmp);
        }
        System.out.println(res);
    }

}

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

#define stirng string
#define vvi vector<vector<int>>
#define vi vector<int>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

const int inf = 1e9 + 7;

int main() {
  int a, b, x;
  cin >> a >> b >> x;
  if (x <= a + b && a <= x) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        char[] s = sc.next().toCharArray();
        sc.close();
        int len = s.length;
        boolean ans = true;
        int count = 0;
        for (int i = 0; i < len; i++){
            if(i == 0 ){
                if(s[i] !='A'){
                    ans = false;
                    break;
                }
            }else if(i > 1 && i < len -1 && s[i] == 'C'){
                count += 1;
            }else{
                if(Character.isUpperCase(s[i])){
                    ans = false;
                    break;
                }
            }
        }
        if(count != 1)ans = false;
        if(ans){
            System.out.println("AC");
        }else{
            System.out.println("WA");
        }

    }

}


Measured memory_bytes: 22996
N=input()
N=int(N)

ini=input().split()
W=[int(i) for i in ini]

Wa=0
S=0
for i in range(N):
    Wa+=W[i]

#print(Wa)
for i in range(N):
    S+=W[i]
    if S>Wa/2:
        S1=S
        S2=Wa-S1
        S11=S-W[i]
        S22=Wa-S11
        break

ans1=abs(S1-S2)
ans2=abs(S11-S22)

#print(ans1,ans2,S1,S2,S11,S22)

if ans1>=ans2:
    print(ans2)
else:
    print(ans1)

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

int main(){
    int n, m;
    cin >> n >> m;
    priority_queue<int> pq;
    rep(i,n){
        int a;
        cin >> a;
        pq.push(a);
    }

    rep(i,m){
        int p = pq.top();
        pq.pop();
        p /= 2;
        pq.push(p);
    }

    ll total = 0;
    while(pq.size()){
        total += pq.top();
        pq.pop();
    }
    cout << total << endl;

    return 0;
}

Measured memory_bytes: 892
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
template <class T> void chmin(T &a, const T &b) noexcept { if (b < a) a = b; }
template <class T> void chmax(T &a, const T &b) noexcept { if (a < b) a = b; }
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cout << H << " "; debug_out(T...); }
#ifdef _DEBUG
  #define debug(...) debug_out(__VA_ARGS__)
#else
  #define debug(...) 
#endif

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  bool B1[4] = {true, true, false, false}; //1回目に反転あり
  bool B2[4] = {true, false, true, false}; //最後に反転あり
  ll x,y;
  cin >> x >> y;
  ll ans = 1LL<<60;
  rep(i,4) {
    ll res = 0;
    ll tx = x, ty = y;
    if (B1[i]) {
      tx *= -1; res++;
    }
    if (B2[i]) {
      ty *= -1; res++;
    }
    if (ty - tx >= 0) {
      res += ty-tx;
      chmin(ans, res);
    }
    debug(B1[i], B2[i], res, tx, ty);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = 0; i < (n); i++)
 
int main(){
    int N,K;
    string S;
    cin >> N >> K >> S;
    vector<int> A;
    if(S[0] == '0') A.push_back(0);
    for(int i=0;i<N;){
        int j=i;
        while(j < N && S[i] == S[j]) j++;
        A.push_back(j-i);
        i = j;
    }
    if(S[N-1] == '0') A.push_back(0);
    
    vector<int> C(A.size()+1);
    for(int i = 1;i<=A.size();i++){
        C[i] = C[i-1] + A[i-1];
    }

    int res = 0;
    for(int i=0;i<C.size();i+=2){
        int j = min(i + 2 * K + 1,(int)C.size()-1);
        res = max(res,C[j] - C[i]);
    }
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 1272
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <tuple>
#include <queue>
#include <bitset>
#include <set>
#include <map>
#include <list>

using ll = long long;
using ld = long double;
using namespace std;
const int INF = 1e9+100;
const ll INF64 = 7e18l;
const int mod = 1000000007;
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(a) (a).begin(), (a).end()
#define FIN ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);


int main(){
    FIN;
    ll n,k; cin >> n >> k;
    vector<ll> num(k,0);
    for(ll i=1;i<=n;i++) num[i%k]++;

    ll ans = 0;
    for(ll a=0;a<k;a++){
        ll b = (k-a) % k;  //c  ==  b
        if((b*2) % k != 0) continue;  //(b+c) % k != 0
        ans += num[a] * num[b] * num[b];  //num[a] * num[b] * num[c]
    }

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


Measured memory_bytes: 4784
#include <stdio.h>
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue> 
 
using namespace std;

typedef pair<int, pair<int, int> > p;

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

	int H, W, N;

	cin >> H >> W >> N;

	int max = H;

	if(W > H) {
		max = W;
	}

	int x = N / max;

	if(x * max != N) {
		x++;
	}

	cout << x << endl;
}


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

using namespace std;

int main()
{
	int n, c, p=1;
	bool f, a[50001];
	
	fill(a, a+50001, false);
	for(int i = 3; i < 50000; i+=2){
		f = true;
	a[2] = true;
		for(int j = 3; j*j <= i; j+=2){
			if(i%j == 0){
				f = false;
				break;
			}
		}
		a[i] = f;
	}
	
	while(1){
		cin >> n;
		if(n == 0){
			break;
		}
		c = 0;
		for(int i = 2; i <= n/2; i++){
			if(a[i] && a[n-i]){
				c++;
			}
		}
		cout << c << endl;
	}
	
	return 0;
}

Measured memory_bytes: 912
import java.util.*;
 
public class Main {
  	public static void main(String[] args) {
      
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int x = sc.nextInt();
      int y = sc.nextInt();
      
      int normal_route;
      int shortcut_route;
      int min;
      int[] array_k = new int[n];
      Arrays.fill(array_k, 0);
      
      for (int i = 1; i <= n; i++) {
        for (int j = i + 1; j <= n; j++) {
          normal_route = j - i;
          shortcut_route = Math.abs(x - i) + 1 + Math.abs(y - j);
          if (normal_route <= shortcut_route) {
            min = normal_route;
          } else {
            min = shortcut_route;
          }
          array_k[min] = array_k[min] + 1;
        }
      }
      
      for (int k = 1; k < n; k++) {
        System.out.println(array_k[k]);
      }
    }
}


Measured memory_bytes: 22612
#include <iostream>
using namespace std;
int main(){
    
    int x = 0;
    int sum = 0;

    cin >> x;

    
    sum = (x / 500) * 1000;
    x = x - (x / 500) * 500;

    sum += (x / 5) * 5;
   
        

    cout << sum;


    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

using namespace std;

int main()
{
    fast;
    ll k;
    cin>>k;
    
    ll s=100, count=0;
    while(s<k)
    {
        count++;
        s+=floor(0.01*s);
    }
    cout<<count;
    
    return 0;
}

Measured memory_bytes: 3656
n, w = map(int, input().split())
item = [list(map(int, input().split())) for _ in range(n)]

dp = [[float("inf")]*(10**5+10) for _ in range(n+1)]

for i in range(n+1):
    dp[i][0] = 0
for i in range(n):
    for j in range(10**5+10):
        if j >= item[i][1]:
            dp[i+1][j] = min(dp[i][j], dp[i][j-item[i][1]]+item[i][0])
        else:
            dp[i+1][j] = dp[i][j]
ans = 0
for i in range(10**5+10):
    if dp[n][i] <= w:
        ans = i

print(ans)


Measured memory_bytes: 236684
import java.util.Scanner;

public class Main {
    public static Scanner sc;
    public static void main(String[] args) throws Exception {
        sc = new Scanner(System.in);
        while (sc.hasNext()) {
            long a = sc.nextLong();
            long b = sc.nextLong();
            System.out.println(gcd(a, b) + " " + lcd(a, b));
        }
    }
    
    public static long lcd(long a, long b) {
        return (a*b)/gcd(a,b);
    }
    
    public static void calc() {
        long a = sc.nextInt();
        long b = sc.nextInt();
        long c = sc.nextInt();
        long d = sc.nextInt();
        long e = sc.nextInt();
        long f = sc.nextInt();
        
        // x?????????????§£???
        long k = Math.abs(b)*Math.abs(e)/gcd(Math.abs(b), Math.abs(e));
        long ax = (k/Math.abs(b)) * a;
        long cx = (k/Math.abs(b)) * c;
        long dx = (k/Math.abs(e)) * d;
        long fx = (k/Math.abs(e)) * f;
        float x;
        if (b*e >= 0) {
            x = (cx-fx)/(ax-dx);
        } else {
            x = (cx+fx)/(ax+dx);
        }
        
        // y?????????????§£???
        k = Math.abs(a)*Math.abs(d)/gcd(Math.abs(a), Math.abs(d));
        long by = (k/Math.abs(a)) * b;
        long cy = (k/Math.abs(a)) * c;
        long ey = (k/Math.abs(d)) * e;
        long fy = (k/Math.abs(d)) * f;
        float y;
        if (a*d >= 0) {
            y = (cy-fy)/(by-ey);
        } else {
            y = (cy+fy)/(by+ey);
        }
        
        System.out.println(String.format("%.3f",x) + " " + String.format("%.3f",y));
    }

    public static long gcd(long a, long b) {
        if (a == b) return a;
        if (a > b) {
            return gcd(a - b, b);
        } else {
            return gcd(a, b - a);
        }
    }
}

Measured memory_bytes: 26148
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
    public int minJumps(int[] heights, int K) {
        int n = heights.length;
        int[] dp = new int[n];
        for (int i = 1; i < n; i++) {
            dp[i] = 1_000_000_000;
            for (int jumps = 1; jumps <= K; jumps++) {
               if (i - jumps < 0) {
                   break;
               }
               dp[i] = Math.min(dp[i], Math.abs(heights[i - jumps] - heights[i]) + dp[i - jumps]);
            }
        }
        return dp[n - 1];
    }

    public static void main(String[] args)  {
        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
            String[] strs = br.readLine().split(" ");
            int n = Integer.parseInt(strs[0]);
            int K = Integer.parseInt(strs[1]);
            String heightsStr = br.readLine();
            String[] split = heightsStr.split(" ");
          	int[] heights = new int[n];
            for (int i = 0; i < n; i++) {
              	heights[i] = Integer.parseInt(split[i]);
            }
          	Main app = new Main();
            int result = app.minJumps(heights, K);
            System.out.println(result);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}


Measured memory_bytes: 33620
import java.util.*;

class Main {

    public static void main(String[] args) {

        Scanner cin = new Scanner(System.in);

        int a = cin.nextInt();
        int b = cin.nextInt();

        if(a <= 9 && b <= 9) {
            System.out.print(a*b);
        }
        else {
            System.out.print(-1);
        }
        
        System.out.println();
    }

}

Measured memory_bytes: 23764
<?php
// Your code here!
    $N = intval(trim(fgets(STDIN)));
    
    for($i=0;$i<$N;$i++){
        list($x,$y)=array_map('intval',explode(" ",trim(fgets(STDIN))));
        
        $X[]=$x;
        $Y[]=$y;
    }
    

    //最初の島
    for($i=0;$i<$N;$i++){
        for($j=0;$j<$N;$j++){
            if($i==$j)continue;
                $dis[] = sqrt(((($X[$i]-$X[$j])**2) + (($Y[$i]-$Y[$j])**2)));
            
        }
    }
    
    echo ($N-1)*(array_sum($dis)/count($dis))."\n";
?>

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

using ll = long long;
using P = pair<ll, ll>;

const ll MAX = 1e5;
const ll INF = 1e9;

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

int ans[50];

int main() {
  int N, M;
  cin >> N >> M;
  int k[N], a;
  for (int i = 0; i < N; i++) {
    cin >> k[i];
    for (int j = 0; j < k[i]; j++) {
      cin >> a;
      ans[a]++;
    }
  }

  int cnt = 0;
  for (int i = 0; i < 50; i++) if (ans[i] == N) cnt++;

  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 5 + 10)


def input(): return sys.stdin.readline().strip()


def resolve():
    a, b, c, x, y = map(int, input().split())
    ans = 10 ** 10
    yen = 0
    if a + b > c * 2:
        yen += (c * 2 * min(x, y))
        x, y = x - min(x, y), y - min(x, y)

        if x > 0:
            yen += min(x * a, x * 2 * c)
        else:
            yen += min(y * b, y * 2 * c)

    else:
        yen += a * x + b * y
    print(yen)


resolve()

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

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

    for(int i = 0;i < 100000;i++){
        if((i*108)/100 == n){
            cout << i << endl;
            return 0;
        }
    }

    cout << ":(" << endl;
    return 0;
}


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

int main(){
    int n,q;
    string s;
    cin>>n>>q>>s;
    vector<int>ans(n,0);
    rep(i,n-1){
        ans[i+1]=ans[i];
        if(s[i]=='A'&&s[i+1]=='C')ans[i+1]++;
    }
    rep(i,q){
        int l,r;
        cin>>l>>r;
        l--; r--;
        cout<<ans[r]-ans[l]<<endl;
    }
    return 0;
}

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

typedef long long int ll;

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

    for(ll i = 0;i < n;i++){
        if(a[i] % 2 == 0){
            if(a[i] % 3 == 0 || a[i] % 5 == 0){

            }
            else{
                cout << "DENIED";
                return 0;
            }
        }
    }

    cout << "APPROVED";

    return 0;
}

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

int main(){
	int n,ans=1e9;
	string s;
  	cin >> n >> s;
  	int a[300010];
  	a[0] = 0;
  
  	for (int i=0;i<n;i++){
      	cin >> s[i];
    	if(s[i]=='W') a[i+1]=a[i]+1;
      	else a[i+1]=a[i];
    }
  
  	for (int i=0;i<n;i++){
      
      	int k=a[i]+(n-i-1-(a[n]-a[i+1]));
      	ans=min(k,ans); 
    }
  	cout << ans <<endl;
}


Measured memory_bytes: 1796
#include<stdio.h>
int main()
{
	int a,b,c,d;
	scanf("%d%d%d%d",&a,&b,&c,&d);
	int number1,number2;
	number1 = a*b;
	number2 = c*d;
	if(number1 >= number2) printf("%d",number1);
	else printf("%d",number2);
	return 0;
 } 

Measured memory_bytes: 128
import java.util.*;

public class Main {
    public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	String s = sc.next();
	if (s.equals("SSS")) System.out.print(0);
	else if (s.equals("SSR") || s.equals("SRS") || s.equals("RSS") || s.equals("RSR")) System.out.print(1);
	else if (s.equals("SRR") || s.equals("RRS")) System.out.print(2);
	else { System.out.print(3);}
    }
}


Measured memory_bytes: 35568
#include "bits/stdc++.h"
using namespace std;
/////////////////// TYPES & MACROS ///////////////////////////////
#define mp make_pair
#define eb emplace_back
#define pb push_back
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define vv vector
#define exist(s,e) (s.find(e)!=s.end())
#define sz(x) ((int)(x).size())
// #define int ll
typedef long long ll; typedef long double ld; typedef double dd;typedef vector<int> vi; typedef pair<int, int> pii;typedef pair<ll,ll> pll;
ll INFLL=(ll)4e18, MOD=998244353; const int INF=0x3f6f6f6f;
//////////////////// DEBUG /////////////////////////////////////////
#define D(x) cerr<<#x<<" is:\t"<<x<<'\n';
#define DD(x,y) cerr<<'('<<#x<<','<<#y<<") are:\t"<<x<<' '<<y<<'\n';
#define DDD(x,y,z) cerr<<'('<<#x<<','<<#y<<','<<#z<<") are:\t"<<x<<' '<<y<<' '<<z<<'\n';
/////////////////// VARIABLES & FUNCTIONS//////////////////////////
vv<vv<int>> adj; vi vis, color, level;
int dx8[]={0,1,1,1,0,-1,-1,-1}, dy8[]={1,1,0,-1,-1,-1,0,1},dx4[]={0,1,0,-1}, dy4[]={1,0,-1,0};
inline ll mexp(ll x,ll n,ll m=MOD){ll res=1;x%=m;while(n){if(n&1)res=(res*x)%m;n>>=1;x=(x*x)%m;}return res;}
inline bool ispow2(ll x){ return x && (!(x&(x-1)));}
inline ll gcd(ll a, ll b){while (a>0 && b>0){if(a>b)a%=b;else b%=a;}return a+b;}


//////////////////// MAIN STARTS //////////////////////////////////
int32_t main(void){
auto tStart = chrono::system_clock::now();
ios_base::sync_with_stdio(false);cin.tie(NULL); cout.tie(NULL);
cout<<fixed;cerr<<fixed; cout<<setprecision(10); cerr<<setprecision(3);
// mt19937 genr(chrono::high_resolution_clock::now().time_since_epoch().count());

string s; cin>>s;
int p=0;
ll ans=0;
for(int i=sz(s)-1;i>=0;--i){
    if(s[i]=='B'){
        ans+=(sz(s)-i-1)-p++;
    }
}
cout<< ans <<'\n'; 





#ifdef DEBUG
auto _diff=chrono::system_clock::now()-tStart;
cerr<<"\nExecution time: "<<chrono::duration<dd,milli>(_diff).count()<<" ms.\n";
#endif
return 0;
}


Measured memory_bytes: 720
S = gets.chomp!
T = gets.chomp!

min_count = Float::INFINITY
(0...(S.size)).each do |i|
  count = T.size
  if S[i...(S.size)].size >= T.size
    S[i...(S.size)].split('').zip(T.split('')).each do |s, t|
      if s == t
        count -= 1
      end
    end
  end

  if min_count > count
    min_count = count
  end
end

puts min_count


Measured memory_bytes: 14760