akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

pair<double, double> keisan(pair<double, double> A, pair<double, double> B) {
	double A2 = A.first + B.first;
	double B2 = (A.first * A.second + B.first * B.second) / A2;
	return mp(A2, B2);
}


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


	int N;
	cin >> N;
	int A[4] = {};
	int goukei = 0;
	rep(i, N) {
		int a;
		cin >> a;
		A[a]++;
		goukei += a;
	}
	
	map<pair<int,pair<int,int>>, pair<double, double>> P;
	P[mp(A[3], mp(A[2], A[1]))] = mp(1.0, 0.0);

	rep(i, goukei) {
		map<pair<int, pair<int, int>>, pair<double, double>> P2;

		for (auto j : P) {
			int a = j.first.first;
			int b = j.first.second.first;
			int c = j.first.second.second;
			int d = a + b + c;
			double kari2 = j.second.second + 1.0 * N / d;
			if (a) {
				double kari = j.second.first * a / d;
				P2[mp(a - 1, mp(b + 1, c))] = keisan(P2[mp(a - 1, mp(b + 1, c))], mp(kari, kari2));
			}
			if (b) {
				double kari = j.second.first * b / d;
				P2[mp(a, mp(b - 1, c + 1))] = keisan(P2[mp(a, mp(b - 1, c + 1))], mp(kari, kari2));
			}
			if (c) {
				double kari = j.second.first * c / d;
				P2[mp(a, mp(b, c - 1))] = keisan(P2[mp(a, mp(b, c - 1))], mp(kari, kari2));
			}
		}
		P = P2;
	}

	cout << setprecision(15) << P[mp(0, mp(0, 0))].second << endl;

	Would you please return 0;
}

Measured memory_bytes: 2048
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <cmath>
#include <climits>
#include <map>

constexpr int SINT_MAX = std::numeric_limits<int>::max();
constexpr int SINT_MIN = std::numeric_limits<int>::min();

using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;

template<class T>
T choose(bool b, T t, T f)
{
    if (b) return t;
    else return f;    
}

const char *YesNo(bool b)
{
    return choose(b, "Yes", "No");
}

const char *YESNO(bool b)
{
    return choose(b, "YES", "NO");
}

template<template<class...> class ContT, class ValueT, size_t Dim>
struct vec_type
{
    using type = ContT<typename vec_type<ContT, ValueT, Dim-1>::type>;
};

template<template<class...> class ContT, class ValueT>
struct vec_type<ContT, ValueT, 0>
{
    using type = ValueT;
};

template<class ValueT, size_t Dim = 1>
using vec_t = typename vec_type<std::vector, ValueT, Dim>::type;


template<class ValueT, size_t Dim, class = typename std::enable_if<Dim == 0>::type>
auto make_vec(ValueT value = ValueT()) -> ValueT
{
    return value;
}

template<class ValueT, size_t Dim, class... Rest>
auto make_vec(size_t size0, Rest... rest)
{
    auto vec = make_vec<ValueT, Dim-1>(rest...);
    return std::vector(size0, vec);
}

int diffabs(int l, int r)
{
    if (l < r) return r-l;
    else return l-r;    
}


///////////////////////////////////////////////////

int main()
{
    int N;
    cin >> N;
    ll sum = 0;
    vi buk(100001, 0);
    for (int i = 0; i < N; i++)
    {
        int a;
        cin >> a;
        ++buk[a];
        sum += a;
    }

    int Q;
    cin >> Q;
    for (int i = 0; i < Q; i++)
    {
        int b, c;
        cin >> b >> c;
        sum += (ll)buk[b] * (c - b);
        buk[c] += buk[b];
        buk[b] = 0;
        cout << sum << endl;
    }
}

Measured memory_bytes: 3784
n, k = map(int, input().split())
suList = []
cnt = 0
for i in range(k):
    d = int(input())
    a = list(map(int, input().split()))
    for j in a:
        suList.append(j)
for l in range(1, n+1):
    if l not in suList:
       cnt += 1
print(cnt)

Measured memory_bytes: 9232
/*
*/
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>

int main()
{
    int s;
    std::cin >> s;
    char c_1 = 'a', c_2 = 'a';

    int num_1, num_2;
    num_1 = s / 100;
    num_2 = s % 100;

    if (num_1 > 12 || num_1 == 0)
    {
        if (num_2 > 12 || num_2 == 0)
            std::cout << "NA" << std::endl;
        else
            std::cout << "YYMM" << std::endl;
    }
    else
    {
        if (num_2 > 12 || num_2 == 0)
            std::cout << "MMYY" << std::endl;
        else
            std::cout << "AMBIGUOUS" << std::endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm> // sort
#include <map> // pair
#include <queue>
#include<iomanip>
#include <cmath>

#define ABS(x) ((x)>0?(x):-(x))
#define MIN(x,y) ((x)>(y)?(y):(x))

using namespace std;
unsigned long long int newton(long long int a, long long int  b)
{
	if(a==b)
		return a;
	while(a != 0 && b != 0)
	{
		if(a > b)
		{
			b += a;
			a = b-a;
			b -= a;
		}
		b %= a;
	}
	return a;
}

struct UnionFind {
	vector<int> p;
	UnionFind(int N):p(N)
	{
		for(int i=0; i< N; i++)
		{
			p[i] = i;
		}
	}
	int root(int x)
	{
		if(p[x] == x)
			return x;
		return p[x] = root(p[x]);
	}
	void unite(int x, int y)
	{
		int rx = root(x);
		int ry = root(y);
		if(rx == ry) return;
		p[rx] = ry;
	}
	bool issame(int x, int y)
	{
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};

int main()
{
	int N,K,L=1;
	cin >> N >> K;
	int i;
	L = 1 << N;
	if(K==0)
	{
		cout << "0 0";
		for(int i=1; i < L; ++i)
		{
			cout <<" "<< i << " "<< i;
		}
		cout << endl;
		return 0;
	}
	if(L<=K)
	{
		cout << -1 << endl;
		return 0;
	}
	if(N==1 && K==1)
	{
		cout << -1 << endl;
		return 0;
	}
	cout << K;
	for(i=0;i<L;++i)
	{
		if(i!=K)
			cout << " " << i;
	}
	cout << " " << K;
	for(i=L-1;i>=0;--i)
	{
		if(i!=K)
			cout << " " << i;
	}
	cout << endl;
	return 0;
}









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

using namespace std;

int main() {
  string g;
  int y;
  int m;
  int d;

  while (true) {
    cin >> g;
    if (g == "#") {
      break;
    }
    cin >> y >> m >> d;

    if (y > 31 || (y == 31 && m >= 5)) {
      y -= 30;
      g = "?";
    }

    cout << g << ' ' << y << ' ' << m << ' ' << d << endl;
  }
}


Measured memory_bytes: 3176
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int arr[4][50];
int A[10];
int n,m,q;

void thunder(ll &ans, int ind){
    //Base case -- if all array formed
    if(ind==n){
        ll tsum=0;
        for(int i=0; i<q; i++){
            if((A[arr[1][i]-1]-A[arr[0][i]-1])==arr[2][i]){
                tsum += arr[3][i];
            }
        }
        if(tsum > ans){
            ans = tsum;
        }
        return;
    }
    // We can have at current index values from prev - m
    for(int i=A[ind-1]; i<= m; i++){
        A[ind] = i;
        thunder(ans, ind+1);
    }
}

int main(){
    cin>>n>>m>>q;
    for(int i=0; i<q; i++){
        for(int j=0; j<4; j++){
            cin>>arr[j][i];
        }
    }
    ll ans=0;
    //First element of array can be from [1, m]
    for(int i=1; i<=m; i++){
        A[0] = i;
        thunder(ans, 1);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3600
#include <iostream>

using namespace std;

int main(){
	int i,t,n,r,l;
	cin >> n;
	long long xorr,a[n+1],sum,ans;
	int e;
	for(i=0;i<n;i++){
		cin >> a[i];
	}
	
	ans = 0;
	xorr = a[0];
	sum = a[0];
	r=0;
	l=0;
	while(l!=n){
		if(sum == xorr){
			ans += l-r+1;
			l++;
			xorr = xorr^a[l];
			sum += a[l];
		}else{
			sum -= a[r];
			xorr = xorr^a[r];
			r++;
		}
	}
	cout << ans << endl;
}
			

Measured memory_bytes: 1792
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
extra=0
sum=0
for i in range(len(B)):
  if B[i]+extra>=A[i]:
    sum+=A[i]
    if (A[i]-extra)>=0:
    	extra=B[i]-(A[i]-extra)
    else:
      extra=B[i]
  else:
    sum+=(B[i]+extra)
    extra=0
if A[-1]>=extra:
	print(sum+extra)
else:
  print(sum+A[-1])

Measured memory_bytes: 18476
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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

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

const int inf = INT_MAX;
const int MOD = 1000000007;
const long long INF = LLONG_MAX;

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

const long long MAX_V = 1010101;

using cost_type = long long;
// costが浮動小数点数の場合
// using cost_type = double;

struct edge {
  long long to;
  cost_type cost;
};

using Pll = pair<cost_type, long long>;

long long V;
vector<edge> Graph[MAX_V];
bool used[MAX_V];

cost_type prim(long long s) {
  priority_queue<Pll, vector<Pll>, greater<Pll>> que;

  used[s] = true;

  for (auto e : Graph[s]) {
    que.push(Pll(e.cost, e.to));
  }

  // 使用済みの辺のコスト
  cost_type res = 0;
  // 使用済みの頂点の数
  long long v_count = 1;

  while (!que.empty() && v_count < V) {
    auto elem = que.top();
    que.pop();

    auto nc = elem.first;
    auto nv = elem.second;

    if (used[nv]) continue;

    used[nv] = true;
    res += nc;
    ++v_count;

    for (auto e : Graph[nv]) {
      if (!used[e.to]) {
        que.push(Pll(e.cost, e.to));
      }
    }
  }

  return res;
}

long long E;

ll N;
using Pill = pair<int, Pll>;
vector<Pill> p;

int main() {
  cin >> N;
  V = N;
  repe(i, 1, N) {
    int x, y;
    cin >> x >> y;
    p.push_back(Pill(i, Pii(x, y)));
  }

  sort(p.begin(), p.end(),
       [](Pill a, Pill b) { return a.second.first < b.second.first; });

  rep(i, 0, N - 1) {
    Pill cp = p[i];
    Pill np = p[i + 1];
    Graph[cp.first].push_back(
        edge{np.first, np.second.first - cp.second.first});
    Graph[np.first].push_back(
        edge{cp.first, np.second.first - cp.second.first});
  }

  sort(p.begin(), p.end(),
       [](Pill a, Pill b) { return a.second.second < b.second.second; });

  rep(i, 0, N - 1) {
    Pill cp = p[i];
    Pill np = p[i + 1];
    Graph[cp.first].push_back(
        edge{np.first, np.second.second - cp.second.second});
    Graph[np.first].push_back(
        edge{cp.first, np.second.second - cp.second.second});
  }

  cout << prim(1) << endl;
}


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

using namespace std;

int main() {

	long n;
	cin >> n;

	long maxcount = 0;
	long counter = 0;
	long h=0;
	long oldh = 0;
	for (long i = 0; i < n; i++) {
		cin >> h;
		if (h <= oldh) { counter++; }
		else {
			maxcount = max(maxcount, counter);
			counter = 0; }
		oldh = h;
	}


	cout <<  max(maxcount, counter) << endl;
}

Measured memory_bytes: 256
/*
█████████───███─────────███───███─────────████████████───███████████████───████████████───████████████───█████████───────
█████████───███─────────███───███─────────████████████───███████████████───████████████───████████████───█████████───────
█████████───███─────────███───███─────────████████████───███████████████───████████████───████████████───█████████───────
███─────────███─────────███───███─────────███──────███───███───███───███───███──────███───███──────███───███─────────────
███─────────███─────────███───███─────────███──────███───███───███───███───███──────███───███──────███───███─────────────
███─────────███─────────███───███─────────███──────███───███───███───███───███──────███───███──────███───███─────────────
█████████──────███───███──────███─────────████████████───███───███───███───████████████───███──────███───█████████───────
█████████──────███───███──────███─────────████████████───███───███───███───████████████───███──────███───█████████───────
█████████──────███───███──────███─────────████████████───███───███───███───████████████───███──────███───█████████───────
███────────────███───███──────███─────────███──────███───███───███───███───███────────────███──────███─────────███───────
███────────────███───███──────███─────────███──────███───███───███───███───███────────────███──────███─────────███───────
███────────────███───███──────███─────────███──────███───███───███───███───███────────────███──────███─────────███───────
█████████─────────███─────────█████████───███──────███───███───███───███───███────────────████████████───█████████───────
█████████─────────███─────────█████████───███──────███───███───███───███───███────────────████████████───█████████───────
█████████─────────███─────────█████████───███──────███───███───███───███───███────────────████████████───█████████───────
*/
/**

**/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define fori(n) for ( int i = 0; i < (n);i++)
#define forj(n) for ( int j = 0; j < (n);j++)
#define fork(n) for ( int k = 0; k < (n);k++)
#define forghj(n) for ( int ghj = 0; ghj < (n);ghj++)
#define fori1(n) for ( int i = (n)-1; i >= 0;i--)
#define all(vector) (vector).begin(),(vector).end()
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define INF 1e9+7
#define EPS 1e-6
#define _FORTIFY_SOURCE 0
#pragma GCC optimize("Ofast")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,popcnt,abm,mmx,tune=native")
#pragma GCC optimize("fast-math")
#pragma GCC optimize "-O3"

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    cout << c - min(c, a - b);
}
/*
1
4
2 4 3 5
*/





Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
using namespace std;

char O[50], E[50];

void solve(){
	char output[101];
	int length = strlen(O) + strlen(E);
	for(int i = 0; i < length; i++){
		if(i % 2 == 0){
			output[i] = E[i/2];
		}
		else if(i % 2 == 1){
			output[i] = O[(i-1)/2];
		}
	}
	output[length] = '\0';

	cout << output << endl;
}

int main(void){
	cin >> E >> O;

	solve();

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int fun(int a)
{
    int u = 0;
    while(a)
    {
        a/=10;
        u++;
    }
    return u % 2;
}
int main()
{
  int n;
  cin >> n;
  int ans = 0;
  for(int x =1; x<=n; x++)
  {
    ans += fun(x);
  }
  cout << ans;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> pi;
typedef pair<int,int> vi;

#define F first
#define S second
#define PB push_back
#define MK make_pair
#define REP(i, a, b) for (int i=a; i <= b; i++)


int main() {
	int N, K;
	cin >> N >> K;
	int sol = 0;
	int coord;
	for(int i = 0; i < N; i++){
		cin >> coord;
		sol += 2*min(coord, K-coord);
	}
	cout << sol << "\n";
}


Measured memory_bytes: 256
#pragma region RegionDefs
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include "boost/multi_array.hpp"
#define rep(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define reps(i,j,n) for(int i=(j),i##_len=(n);i<i##_len;++i)
#define repr(i,n) for(int i=(n);i>=0;--i)
#define all(x) (x).begin(),(x).end()
using namespace std;
template<class T=int> using P  = pair<T, T>;
template<class T=int> using V  = vector<T>;
template<class T=int> using PQ = priority_queue<T>;
template<class T=int> using PQG = priority_queue<T, V<T>, greater<T>>;
typedef long long ll;
const int INF = 1e9;
const ll MOD = 1000000007LL;
void in() {}
template<class Head, class... Tail>
void in(Head&& head, Tail&&... tail)
{
    cin >> head;
    in(move(tail)...);
}
#define IN(...) int __VA_ARGS__; in(__VA_ARGS__)
#define VIN(T, v, n) V<T> v(n); for(auto& _elem:v)cin>>_elem
struct UnionFind
{
    V<int> par;
    V<int> siz;
    UnionFind(int n) : par(n), siz(n, 1)
    {
        rep(i, n) par[i] = i;
    }
    int root(int x)
    {
        while (par[x] != x) x = par[x] = par[par[x]];
        return x;
    }
    bool unite(int x, int y)
    {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) false;
        if (siz[rx] < siz[ry]) swap(rx, ry);
        siz[rx] += siz[ry];
        par[ry] = rx;
        return true;
    }
    int same(int x, int y)
    {
        return root(x) == root(y);
    }
};

#pragma endregion RegionDefs

void solve()
{
    IN(n);
    VIN(int, v, n);
    sort(all(v));
    int sum = 0;
    repr(i, n-1)
    {
        if (i == 0) break;
        auto itr = v.begin();
        repr(j, i-1)
        {
            itr = upper_bound(itr, v.begin()+j, v[i]-v[j]);
            auto a = v.begin()+j-itr;
            if (a>0) sum += a;
        }
    }
    cout << sum << endl;
}

int main()
{
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(numeric_limits<double>::max_digits10);

    solve();

    return 0;
}

Measured memory_bytes: 256
def main():
	buillist = [Building(), Building(), Building(), Building()]
	n = int(input())
	for i in range(n):
		x = input().split()
		buillist[int(x[0]) - 1].assign(int(x[1]), int(x[2]), int(x[3]))
	for b in range(4):
		for f in range(3):
			string = map(str, buillist[b].floors[f])
			string = ' '.join(string)
			buillist[b].string[f] = string
		for f in buillist[b].string:
			print(' ' + f)
		if not b == 3:
			print('####################')

class Building():
	def __init__(self):
		self.floors = [[0]*10, [0]*10, [0]*10]
		self.string = ['', '', '']

	def assign(self, f, r, v):
		self.floors[f - 1][r - 1] += v

main()



Measured memory_bytes: 5608
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
#define PI 3.141592653589793

vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}

int main(){
  ll N; cin >> N; ll ans = 0;
  for(ll i=2; i*i<=N; i++){
    ll K = N;
    if((K-1)%i==0) continue;
    while(K>=i){
      if(K%i==0) K/=i;
      else if((K-1)%i==0){
        ans++; break;
      }
      else break;
    }
    if(K==1) ans++;
  }
  auto P = prime_factorize(N-1);
  ll tmp = 1;
  for(auto c: P){
    tmp*=(c.second+1);
  }
  ans+=tmp;
  cout << ans << endl;
}

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

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int getRand(int l, int r)
{
    uniform_int_distribution<int> uid(l, r);
    return uid(rng);
}
  
#define int long long 
#define pb push_back
#define S second
#define F first
#define f(i,n) for(int i=0;i<n;i++)
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define vi vector<int>
#define pii pair<int,int>
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define precise(x) fixed << setprecision(x) 

const int MOD = 998244353;
const int N = 3005;
int dp[N][N];

void solve()
{
   int n,s;
    cin >> n >> s;
    
    int a[n];
    f(i,n) cin >> a[i];
    
    int res = 0;
    
    for(int i=0;i<n;i++)
    {
       
        for(int j=1;j<=s;j++)
        {
            if(j!= s && i > 0) dp[i][j] = dp[i-1][j];
            
            if(a[i] <= j)
            {
                if(a[i] == j) dp[i][j] += (i+1);
                else if(i > 0) dp[i][j] += dp[i-1][j-a[i]];
            }
            
            dp[i][j]%=MOD;
           
            if(j == s) res=(res+(dp[i][j]*(n-i))%MOD)%MOD;
            
        }
    }
    
    cout << res;
}

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

Measured memory_bytes: 70784
def main():
    is_prime = [i for i in range(1000000)]
    is_prime[0] = is_prime[1] = False

    for i in range(2, 1000000):
        is_prime[i] = True
    
    for i in range(2, 1000000):
        if i*i >= 1000000:
            break
        for j in range(i*i, 1000000, i):
            is_prime[j] = False
    
    while 1:
        try:
            ans = [0,0]
            n = int(input())
            for i in range(2,1000001):
                if is_prime[i]:
                    if i < n:
                        ans[0] = i
                    else:
                        if i != n:
                            ans[1] = i
                            break

            print('%s %d' % (ans[0],ans[1]))
        except:
            break

if __name__ == "__main__":
    main()         



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

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int h = in.nextInt();
		int[] a = new int[n];
		int[] b = new int[n];
		for(int i=0;i<n;i++) {
			a[i] = in.nextInt();
			b[i] = in.nextInt();
		}
		in.close();
		int amax = 0;
		for(int i=0;i<n;i++) {
			amax = Math.max(amax, a[i]);
		}
		Arrays.sort(b);
		int damage = 0;
		int count = 0;
		boolean beat = false;
		for(int i=n-1;i>=0 && b[i]>amax;i--) {
			damage += b[i];
			count++;
			if(damage>=h) {
				beat = true;
				break;
			}
		}
		if(beat) System.out.println(count);
		else System.out.println(count + (h-damage)/amax + ((h-damage)%amax==0?0:1));

	}

}


Measured memory_bytes: 81504
N, K = map(int, input().split())

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

# 期待値は(1+P)/2 https://rikeilabo.com/sum-formula-of-numerical-sequence
# 累積和を求めておく．隣接するK個の和はS_{j+K} - S_j
# 期待値の前計算→累積和の計算→隣接するK項の和の計算 (１乗オーダー)
E_list = []
for dice in dices:
    E_list.append((1 + dice) * 0.5)

S_list = []  # i番目までのサイコロの期待値の累積和
for i in range(len(dices)):
    # S_list.append(sum(E_list[:i + 1]))  # アホ
    S_list.append(E_list[0] if i == 0 else S_list[i - 1] + E_list[i])

print(max(list(S_list[j + K] - S_list[j] for j in range(len(dices) - K))) if len(dices) != K else S_list[-1])

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

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

  for(int i=0; i < 5; i++) {
    hitachi += "hi";
    if(s == hitachi) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}

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

int main() {
    int a, c ,n, q;
    cin >> q;
    for (int i = 0; i < q; i++) {
        cin >> c >> a >> n;
        int tmp, sum = 0;
        tmp = min(c, min(a, n));
        c -= tmp; a -= tmp;
        sum = tmp;
        tmp = min(c / 2, a);
        c -= tmp * 2;
        sum += tmp;
        sum += c / 3;
        cout << sum << endl;
    }
    return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define JN ios::sync_with_stdio(0) , cin.tie(0) , cout.tie(0);
#define mod 1000000007

#define pb push_back
#define mp make_pair

using namespace std;
typedef unsigned long long int ull;
typedef long long int          ll;

int n, m;
int dp[3][100005];
int a[100005], b[100005], c[100005];




int main()
{
    JN;

    cin >> n;


    for(int i=1; i<=n; i++)
        cin >> a[i] >> b[i] >> c[i];

    dp[0][1] = a[1];
    dp[1][1] = b[1];
    dp[2][1] = c[1];

    for(int i=2; i<=n; i++)
    {
        dp[0][i] = max(dp[1][i-1]+a[i], dp[2][i-1]+a[i]);
        dp[1][i] = max(dp[0][i-1]+b[i], dp[2][i-1]+b[i]);
        dp[2][i] = max(dp[0][i-1]+c[i], dp[1][i-1]+c[i]);
    }



    cout << max({dp[0][n], dp[1][n], dp[2][n]}) << "\n";

    
    
    return 0;

}

Measured memory_bytes: 2560
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#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() {
  string S;
  cin >> S;
  bool ok = false;
  if (S[0]==S[1] && S[2]==S[3] && S[1]!=S[2]) ok = true;
  if (S[0]==S[2] && S[1]==S[3] && S[2]!=S[1]) ok = true;
  if (S[0]==S[3] && S[1]==S[2] && S[3]!=S[1]) ok = true;
  if (ok) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

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

using namespace std;

int main(int argc, char const *argv[])
{
	int n, x, k;
	vector <int> m;
	int ans;
	cin >> n >> x;
	for (int i = 0; i < n; ++i)
	{
		cin >> k;
		m.push_back(k);
	}
	sort(m.begin(), m.end());
	for (int i = 0; i < m.size(); ++i)
	{
		if(x - m[i] >= 0) {
			ans ++;
			x -= m[i];
		}
	}
	while(x - m[0] >= 0) {
		x -= m[0];
		ans ++;
	}
	cout << ans;
	return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<long long> vec(N+1);
  vec[0]=2, vec[1]=1;
  for(int i=2; i<=N; i++) {
    vec[i]=vec[i-1]+vec[i-2];
  }
  cout << vec[N] << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <string>
#include <functional>
#include <set>
#define DB cerr<<"D"<<endl
#define pb push_back
using namespace std; using ll=long long; using ld=long double; const int INF=1e9; const ll LINF=1e18; const double dINF = 1e18; const ld ldINF = 1e18; const double EPS = 1e-6;
template<typename T, typename U, typename O> void caut(T a, U b, O c){cout<<"("<<a<<","<<b<<","<<c<<") ";} template<typename T, typename U> void caut(T a, U b){cout<<"("<<a<<","<<b<<") ";} template<typename T> void caut(T a){cout<<"("<<a<<") ";}
using P=pair<double,int>;
const ll M = 998244353;
void add(ll& x, ll y) {x+=y; x%=M;}
void chmax(ll& x, ll y) {if (x<y) x=y;}
const int up[]={1,-1,0,0}, lf[]={0,0,1,-1};
bool vaild(int x, int y, int hh, int ww){return 0<=x&&x<hh&&0<=y&&y<ww;}

int main() {
  string s; cin>>s;
  int w; cin>>w;
  int n=s.size();
  for(int i=0;i<n;i+=w) {
    cout<<s[i];
  }
  cout<<endl;
}

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

int main(){
    ll n, next = 1, b = 0,ans;
    cin >> n;

    rep(i,n){
        ll tmp;
        cin >> tmp;

        if(tmp != next)b++;
        else {
            next++;
        }
    }

    if(b == n)ans = -1;
    else ans = b;

    cout << ans << endl;
}

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

ll a[214514];

int main(){
	ll n,k;
	cin>>n>>k;
	for(int i=0;i<n;i++)cin>>a[i];
	double ma=0.0,cnt;
	for(int i=0;i<k;i++){
		double num=a[i];
		ma+=(1.0+num)/2.0;
	}
	cnt=ma;
	for(int i=k;i<n;i++){
		double yan=a[i-k],yojo=a[i];
		cnt+=(1.0+yojo)/2.0-(1.0+yan)/2.0;
		ma=max(ma,cnt);
	}
	cout<<fixed<<setprecision(10)<<ma;
	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define nyan "(=^･ω･^=)"
#define mkp make_pair
#define lP pair<ll, ll>
#define iP pair<int,int>
typedef long long ll;
using namespace std;

int N, x, y;
ll B[100000], W[100000];
bool vis[100000];
vector<int>v[100000];

void dfs(int x) {
	B[x] = W[x] = vis[x] = 1;
	for (int i = 0; i != v[x].size(); ++i) {
		if (!vis[v[x][i]]) {
			dfs(v[x][i]);
			B[x] *= W[v[x][i]];
			B[x] %= mod;
			W[x] *= (W[v[x][i]] + B[v[x][i]]) % mod;
			W[x] %= mod;
		}
	}
}

int main() {
	cin >> N;
	for (int i = 0; i != N - 1; ++i) {
		cin >> x >> y;
		--x;
		--y;
		v[x].push_back(y);
		v[y].push_back(x);
	}
	dfs(0);
	cout << (B[0] + W[0]) % mod << endl;
	return 0;
}

Measured memory_bytes: 11520
def main():
    N = int(input())
    A = [0] + [int(i) for i in input().split()] + [0]
    a = [abs(A[i + 1] - A[i]) for i in range(N + 1)]
    num = sum(a)
    print("\n".join(
        [str(num - a[i] - a[i + 1] + abs(A[i] - A[i + 2]))
         for i in range(N)]))

    return


main()


Measured memory_bytes: 20028
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int n = b - a;
		int result = 0;
		for(int i = 1; i <= n; i++ ) result+=i;
		System.out.println(result - b);
	}
}


Measured memory_bytes: 21076
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.util.InputMismatchException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            out.println(n / 3);
        }

    }

    static class InputReader {
        BufferedReader in;
        StringTokenizer tok;

        public String nextString() {
            while (!tok.hasMoreTokens()) {
                try {
                    tok = new StringTokenizer(in.readLine(), " ");
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
            }
            return tok.nextToken();
        }

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

        public InputReader(InputStream inputStream) {
            in = new BufferedReader(new InputStreamReader(inputStream));
            tok = new StringTokenizer("");
        }

    }
}



Measured memory_bytes: 23508
#include<stdio.h>

int main(void)
{
	int x[10000], y[10000];
	int n;
	int i, j;
	
	for (i = 0; i < 10000; i++) {
		scanf("%d %d", &x[i], &y[i]);
		
		if (x[i] > y[i]) {
			n = x[i];
			x[i] = y[i];
			y[i] = n;
		}
		
		if (x[i] == 0 && y[i] == 0) {
			break;
		}
	}
	
	for (j = 0; j < i; j++) {
		printf("%d %d\n", x[j], y[j]);
	}
	
	return (0);
}

Measured memory_bytes: 628
# import numpy as np
# import queue
# import heapq


def main():
    print(resolve())


def resolve():
    K = int(input())
    A, B = map(int, input().split())

    for n in range(A, B+1):
        if n % K == 0:
            return 'OK'

    return 'NG'


if __name__ == "__main__":
    main()


Measured memory_bytes: 9160
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define  REP(i, n) for(int i=0; i<(n); ++i)
#define  ALL(obj) (obj).begin(), (obj).end()
#define ll long long
#define ul unsigned long

signed main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  string S;
  cin >> S;
  if(S == "Sunny")
  {
    cout << "Cloudy" << '\n';
    return 0;
  }
  if(S == "Cloudy")
  {
    cout << "Rainy" << '\n';
    return 0;
  }
  if(S == "Rainy")
  {
    cout << "Sunny" << '\n';
    return 0;
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define DICE 6
int dice[DICE];

void N_move(){
    int temp;
    temp = dice[0]; dice[0] = dice[1]; dice[1] = dice[5]; dice[5] = dice[4]; dice[4] = temp;
}
void E_move(){
    int temp;
    temp = dice[0]; dice[0] = dice[3]; dice[3] = dice[5]; dice[5] = dice[2]; dice[2] = temp;
}
void S_move(){
    int temp;
    temp = dice[0]; dice[0] = dice[4]; dice[4] = dice[5]; dice[5] = dice[1]; dice[1] = temp;
}
void W_move(){
    int temp;
    temp = dice[0]; dice[0] = dice[2]; dice[2] = dice[5]; dice[5] = dice[3]; dice[3] = temp;
}
int roll_check(int a, int b){
    if(a == 1 && b == 2) return 3;
    if(a == 1 && b == 3) return 5;
    if(a == 1 && b == 4) return 2;
    if(a == 1 && b == 5) return 4;
    if(a == 2 && b == 1) return 4;
    if(a == 2 && b == 3) return 1;
    if(a == 2 && b == 4) return 6;
    if(a == 2 && b == 6) return 3;
    if(a == 3 && b == 1) return 2;
    if(a == 3 && b == 2) return 6;
    if(a == 3 && b == 5) return 1;
    if(a == 3 && b == 6) return 5;
    if(a == 4 && b == 1) return 5;
    if(a == 4 && b == 2) return 1;
    if(a == 4 && b == 5) return 6;
    if(a == 4 && b == 6) return 2;
    if(a == 5 && b == 1) return 3;
    if(a == 5 && b == 3) return 6;
    if(a == 5 && b == 4) return 1;
    if(a == 5 && b == 6) return 4;
    if(a == 6 && b == 2) return 4;
    if(a == 6 && b == 3) return 2;
    if(a == 6 && b == 4) return 5;
    if(a == 6 && b == 5) return 3;
}
int main(void){
    for(int i=0; i<6; i++){
        cin >> dice[i];
    }
    int N; cin >> N;
    int a, b; //a????????¢???b????????¢?????????    
    for(int i=0; i<N; i++){
        int temp_a = 0, temp_b = 0;
        cin >> a >> b;
        for(int i=0; i<6; i++){
            if(dice[i] == a){
                temp_a = i+1;
            }
            if(dice[i] == b){
                temp_b = i+1;
            }
        }
        cout << dice[roll_check(temp_a, temp_b) -1] << endl;
    }        
    return 0;
}
    

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

string divide[4]={"dream","dreamer","erase","eraser"};

int main(){
    string S;
    cin>>S;
    reverse(S.begin(),S.end());
    for(int i=0;i<4;i++) reverse(divide[i].begin(),divide[i].end());

    bool can=1;

    for(int i=0;i<S.size();){
        bool can2=0;
        for(int j=0;j<4;j++){
            string d = divide[j];
            if(S.substr(i,d.size())==d){
                can2=true;
                i+=d.size();
            }
        }
        if(!can2){
            can=0;
            break;
        }
    }
    if(can)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
int getday(int y,int m,int d){
    int cnt = 0;
    for(int ny = 1,nm = 1,nd = 1;ny != y || nm != m || nd != d;cnt++){
        nd++;
        //3の倍数の年ではない→奇数が20偶数が19
        //                 →常に20
        if(ny % 3 != 0 && nm % 2 == 0 && nd == 20){nd = 1;nm++;}
        if(nd == 21){nd = 1;nm++;}

        if(nm == 11){nm = 1;ny++;}
    }
    return cnt;
}
main(){
    int N;
    cin >> N;
    int level = getday(1000,1,1);
    int y3 = getday(4,1,1) - getday(1,1,1);
    rep(i,0,N){
        int y,m,d;
        cin >> y >> m >> d;
        int tmp = 0;
        if(y >= 4)tmp = ((y-1) / 3) * y3;
        y = y % 3;//４→１　５→２　６→３
        if(!y)y = 3;
        cout << level - getday(y,m,d) - tmp<< endl;
    }
}


Measured memory_bytes: 3064
package main

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

func main() {
	io := NewIo()
	defer io.Flush()
	N := io.NextInt()
	nodes := make([]Node, N*N+1)
	for i := 0; i < 2*N*N-2*N; i++ {
		a, b := io.NextInt(), io.NextInt()
		nodes[a].adj = append(nodes[a].adj, b)
		nodes[b].adj = append(nodes[b].adj, a)
	}
	ninja(nodes, N, io)
}

type Node struct {
	adj []int
}

func ninja(nodes []Node, N int, io *Io) {
	used := make([]bool, N*N+1)
	m := make([][]int, N)
	fst := 0
	for i := 0; i < N; i++ {
		m[i] = make([]int, N)
		for j := 0; j < N; j++ {
			if len(nodes[i*N+j].adj) == 2 {
				fst = i*N + j
			}
		}
	}
	m[0][0] = fst
	used[fst] = true
	for j := 1; j < N; j++ {
		u := 0
		deg := 3
		if j == N-1 {
			deg = 2
		}
		for _, v := range nodes[m[0][j-1]].adj {
			if !used[v] && len(nodes[v].adj) == deg {
				u = v
			}
		}
		m[0][j] = u
		used[u] = true
	}
	for i := 1; i < N; i++ {
		for j := 0; j < N; j++ {
			u := 0
			for _, v := range nodes[m[i-1][j]].adj {
				if !used[v] {
					u = v
				}
			}
			m[i][j] = u
			used[u] = true
		}
	}
	for _, a := range m {
		io.PrintIntSlice(a)
	}
}

// I/O template
type Io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

func NewIo() *Io {
	return &Io{
		reader: bufio.NewReader(os.Stdin),
		writer: bufio.NewWriter(os.Stdout),
	}
}

func (io *Io) Flush() {
	err := io.writer.Flush()
	if err != nil {
		panic(err)
	}
}

func (io *Io) NextLine() string {
	var buff []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buff = append(buff, line...)
		if !isPrefix {
			break
		}
	}
	return string(buff)
}

func (io *Io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	s := io.tokens[io.nextToken]
	io.nextToken++
	return s
}

func (io *Io) NextInt() int {
	i, err := strconv.Atoi(io.Next())
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) NextFloat() float64 {
	i, err := strconv.ParseFloat(io.Next(), 64)
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) Println(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}

func (io *Io) Printf(format string, a ...interface{}) {
	fmt.Fprintf(io.writer, format, a...)
}

func (io *Io) PrintIntSlice(a []int) {
	b := []interface{}{}
	for _, x := range a {
		b = append(b, x)
	}
	io.Println(b...)
}

func (io *Io) PrintStringSlice(a []string) {
	b := []interface{}{}
	for _, x := range a {
		b = append(b, x)
	}
	io.Println(b...)
}

func Log(name string, value interface{}) {
	fmt.Fprintf(os.Stderr, "%s=%+v\n", name, value)
}

func ExampleIo() {
	io := NewIo()
	defer io.Flush()
	a := make([]int, 0, 3)
	a[0], a[1], a[2] = io.NextInt(), io.NextInt(), io.NextInt()
	io.Println(a)
	io.PrintIntSlice(a)
	Log("io", a)
}



Measured memory_bytes: 3788
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()

int main(void){
	int m,k;
	cin>>m>>k;
	if(m == 1){
		if(k == 0){
			cout<<"0 0 1 1"<<endl;
		}else{
			cout<<-1<<endl;
		}
		return 0;
	}
	if(pow(2,m)<=k){
		cout<<-1<<endl;
		return 0;
	}
	cout<<k<<" ";
	rep(i,pow(2,m)){
		if(i==k) continue;
		cout<<i<<" ";
	}
	cout<<k<<" ";
	REP(i,pow(2,m)){
		if(i==k) continue;
		cout<<i<<" ";
	}
	cout<<endl;
	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define square(x) pow(x,2.0)
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
#define max_queue(x) priority_queue<x>
#define min_queue(x) priority_queue<x, vector<x>, greater<x>>
#define big_sort(v) sort(all(v), [](int a, int b) { return a > b; })//大きい順にソート
using ll = long long;
using vi = vector<ll>;
using vvi = vector<vi>;
using vs = vector<string>;
using vd = vector<long double>;
#define co(x) cout << x << endl;
#define cins(n,v) rep(i,n){cin >> v.at(i);}
#define couts(v) rep(i,v.size()){cout << v.at(i) << endl;}
// aよりもbが大きいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
/*
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
*/
int main() {
  string n;
  cin >> n;
  if(n=="RRR"){co(3);}
  else if(n=="SRR"||n=="RRS"){co(2);}
  else if(n=="SSS"){co(0);}
  else{co(1);}
  return 0;
}


Measured memory_bytes: 3620
# ===================================
# (c) MidAndFeed aka ASilentVoice
# ===================================
# import math, fractions, collections
# ===================================
x, y = [int(x) for x in input().split()]
if x == y or y == 1 or x%y == 0:
	print(-1)
else:
	temp = x
	while(temp%y == 0):
		temp += x
	print(temp)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pi;
 
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define rep(i,a,b) for (ll i=a; i<b; i++)
// #define endl "\n"
const int mod = 1000000007;
const ll INF = 1e18L + 5;

ll power(ll x, ll y) 
{ 
    ll res = 1;     // Initialize result 
   
    while (y > 0) 
    { 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = res*x; 
        res%=mod;
        // n must be even now 
        y = y>>1; // y = y/2 
        x = x*x;
        x%=mod;  // Change x to x^2 
    } 
    return res%mod; 
}

int main() {
    ios_base::sync_with_stdio(false);    //Fast I/O
    cin.tie(NULL);
 
    // freopen("input.txt", "r", stdin);    // Read and write from a file
    // freopen("output.txt", "w", stdout);
    int h, w;
    cin >> h >> w;
    vector< string > brax;
    vector< vector<int> > dp(h+1, vector<int> (w+1, 0));
    string tmp;
    for(int i=0; i<h; i++){
            cin >> tmp;
            brax.push_back(tmp);
    }
    dp[1][1]=1;
    for(int i=1; i<=h; i++){
        for(int j=1; j<=w; j++){
            if(brax[i-1][j-1]=='.')
                dp[i][j]=max(dp[i][j], dp[i-1][j]+dp[i][j-1])%mod;
            else
                dp[i][j]=0;
        }
    }

    cout << dp[h][w] << endl;

    return 0;
}

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

using namespace std;

#define int long long
#define pb push_back
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define REP(i, n) FOR(i, 0, n)

signed main () {
  cin.tie(0);
  cout << setprecision(10);

  int x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2;
  int dx = x2-x1, dy = y2 - y1;

  int x3 = x2 - dy, y3 = y2 + dx;
  int x4 = x3 - dx, y4 = y3 - dy;

  cout << x3 << " " << y3 << " "
       << x4 << " " << y4 << endl;
}


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

#define _overload3(_1, _2, _3, name, ...) name
#define repi(i, a, b) for(int i = int(a); i < int(b); i++)
#define rep(i, n) repi(i, 0, n)
#define REP(...) _overload3(__VA_ARGS__, repi, _rep,)(__VA_ARGS__)

typedef long long int ll;
typedef unsigned long long int ull;

const int MOD=(int)1e9+7;
const string alp = "abcdefghijklmnopqrstuvwxyz";
const string ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
//int dx[4] = {0,1,0,-1}, dy[4] = {-1,0,1,0};

ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll g=gcd(a,b);return a/g*b;}
ll digitsum(ll a){ll x=0;while(a>0){x+=a%10;a/=10;}return x;}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    double sum=0;
    cin>>n;
    rep(i,n){
        string type;
        double u;
        cin>>u>>type;
        if(type=="BTC") sum=sum+(u*380000);
        else sum=sum+u;
    }
    printf("%f", sum);
}

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

int main() {
  int N;
  cin >> N;
  vector<int> A(N, 0);
  for (int i = 1; i < N; i++) {
    int a;
    scanf("%d", &a);
    A[a - 1]++;
  }

  for (int i = 0; i < A.size(); i++) printf("%d\n", A[i]);

  return 0;
}

Measured memory_bytes: 4064
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        char[][] c = new char [3][];
        for (int i = 0; i < 3; i++) {
            c[i] = sc.next().toCharArray();
        }
        for (int i = 0; i < c.length; i++) {
            for (int j = i; j <= i; j++) {
                System.out.print(c[i][j]);
            }

        }
    }
}

Measured memory_bytes: 35564
N = int(input())
h = [int(x) for x in input().split()]

dp = [float('inf') for _ in range(N)]
dp[0] = 0
dp[1] = abs(h[1] - h[0])

for i in range(2, N):
    dp[i] = min(dp[i], dp[i-1] + abs(h[i] - h[i-1]))
    dp[i] = min(dp[i], dp[i-2] + abs(h[i] - h[i-2]))
#     dp[i] = min(dp[i-1] + abs(h[i] - h[i-1]), dp[i-2] + abs(h[i] - h[i-2]))
print(dp[-1])

Measured memory_bytes: 13928
#include<stdio.h>

int main()
{
    
    int count;
    int sum;
    int result[1000];
    int i;
    char buffer[1002];
    
    for(count=0;;count++)
    {
        fgets(buffer, 1002, stdin);
        if('0'==buffer[0]) break;
        sum=0;
        for(i=0;'\n'!=buffer[i];i++)
        {
            sum += buffer[i] - '0';
        }
        result[count] = sum;
    }
    for(i=0;i<count;i++)
    {
        printf("%d\n", result[i]);
    }
    return(0);
}


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

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

const int mod=1e9+7;
const int mx=2077;

ll binom[mx][mx];

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	for (int i=0; i<mx; i++) {
		binom[i][0]=binom[i][i]=1;
		for (int j=1; j<i; j++)
			binom[i][j]=(binom[i-1][j]+binom[i-1][j-1])%mod;
	}
	int N,K; cin>>N>>K;
	int x=N-K+1;
	for (int i=1; i<=K; i++) {
		if(i>x) cout<<0<<"\n";
		else cout<<(binom[N-K+1][i]*binom[K-1][K-i])%mod<<"\n";
	}
	return 0;
}

Measured memory_bytes: 32512
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <math.h>
#define MOD 1000000007
typedef long long ll;
using namespace std;

int main(){
  int n;
  cin>>n;
  int ans=0;
  if(n<105) ans=0;
  else if(n<135) ans=1;
  else if(n<165) ans=2;
  else if(n<189) ans=3;
  else if(n<195) ans=4;
  else ans=5;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        @SuppressWarnings("resource")
        Scanner sc = new Scanner(System.in);
        String s  = sc.next();
        int a = Integer.valueOf(s.substring(0, 1));
        int b = Integer.valueOf(s.substring(1, 2));
        int c = Integer.valueOf(s.substring(2, 3));
        int d = Integer.valueOf(s.substring(3, 4));
        if (a + b + c + d == 7) {
            System.out.println(a + "+" + b + "+" + c + "+" + d + "=7");
            return;
        }
        if (a + b + c - d == 7) {
            System.out.println(a + "+" + b + "+" + c + "-" + d + "=7");
            return;
        }
        if (a + b - c + d == 7) {
            System.out.println(a + "+" + b + "-" + c + "+" + d + "=7");
            return;
        }
        if (a + b - c - d == 7) {
            System.out.println(a + "+" + b + "-" + c + "-" + d + "=7");
            return;
        }
        if (a - b + c + d == 7) {
            System.out.println(a + "-" + b + "+" + c + "+" + d + "=7");
            return;
        }
        if (a - b + c - d == 7) {
            System.out.println(a + "-" + b + "+" + c + "-" + d + "=7");
            return;
        }
        if (a - b - c + d == 7) {
            System.out.println(a + "-" + b + "-" + c + "+" + d + "=7");
            return;
        }
        if (a - b - c - d == 7) {
            System.out.println(a + "-" + b + "-" + c + "-" + d + "=7");
            return;
        }
    }

}

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

long long A, B, K;

int main() {
  cin >> A >> B >> K;
  
  for (int i = 0; i < 1; i++){
    
  if(A > K){
    A = A - K;
    B = B;
    break;
  }
  
  else{
    if(B >= (K - A)){
      B = B - (K - A);
      A = 0;
    }
    else {
    A = 0;
    B = 0;
    }
    break;
  }
  }
  
      cout << A << " " << B << endl;

}

Measured memory_bytes: 256