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

int N;
int main()
{
    cin >> N;
    lint t = 1;
    lint a = 1;
    for (int i=0; i<N; i++)
    {
        lint t1, a1;
        cin >> t1 >> a1;
        lint t2 = (t + t1 - 1) / t1;
        lint a2 = (a + a1 - 1) / a1;
        t = t1 * max(t2, a2);
        a = a1 * max(t2, a2);
    }
    cout << t+a << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
typedef long long ll;
using namespace std;
bool valid(int a, int b, int c) {
	if(a == b or b == c or a == c)
		return false;
	if (a >= b + c)
		return false;
	if (b >= a + c)
		return false;
	if (c >= a + b)
		return false;

	return true;
}
int main() {
	int n;
	cin >> n;
	int arr[n];
	for (int i = 0; i < n; ++i)
		cin >> arr[i];

	int ans = 0;
	for (int i = 0; i < n; ++i)
		for (int j = i + 1; j < n; ++j)
			for (int k = j + 1; k < n; ++k) {
				if (valid(arr[i], arr[j], arr[k])) {
				//	cout << i + 1 << " " << j + 1 << " " << k + 1<< endl;
					++ans;
				}
			}

	cout << ans << endl;
}

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

int main() {

 int N, K;

    int count = 0;
    cin >> N >> K;

    while (N > 0) {
        N /= K;

        count++;
        
    }
  cout << count <<endl;
return 0;
}

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

int main(){
  int n, d;
  int count = 0;
  cin >> n >> d;
  vector<vector<int>> x(n, vector<int>(d));
  for (int tsumugi = 0; tsumugi < n; tsumugi++){
    for (int matsuri = 0; matsuri < d; matsuri++){
      cin >> x.at(tsumugi).at(matsuri);
    }
  }
  
  int sumsq;
  for (int kaori = 0; kaori < n - 1; kaori++){
    for (int rio = kaori + 1; rio < n; rio++){
      sumsq = 0;
      for (int haruka = 0; haruka < d; haruka++){
        sumsq += pow(x[kaori][haruka] - 
                     x[rio][haruka], 2);
      }
      double sqrt = pow(sumsq, 0.5);
      int sqin = sqrt;
      if (sqin == sqrt)
        count += 1;
    }
  }
  
  cout << count << endl;
}

Measured memory_bytes: 384
#include <algorithm>
#include <cstring>
#include <iostream>
#include <queue>
#include <vector>

using namespace std;

long long ans = 0;
vector<long long> a, b, c, d;
int n, m, q;
void print(vector<long long> v) {
  for (int i = 0; i < v.size(); i++) {
    cout << i << ":" << v[i] << endl;
  }
}
void solve(vector<long long> A) {
  if (A.size() == n) {
    long long sum = 0;
    // cout << "--------------------------" << endl;
    // print(A);
    for (int i = 0; i < q; i++) {
      if (A[b[i]] - A[a[i]] == c[i]) {
        sum += d[i];
        // cout << "plus:" << d[i] << endl;
      }
    }
    ans = max(ans, sum);

    return;
  }
  int prev = (A.size() != 0) ? A[A.size() - 1] : 1;
  for (int i = prev; i <= m; i++) {
    vector<long long> tmp = A;
    tmp.push_back(i);
    // print(tmp);
    solve(tmp);
  }
}

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

  for (int i = 0; i < q; i++) {
    int t_a, t_b, t_c, t_d;
    cin >> t_a >> t_b >> t_c >> t_d;
    t_a--;
    t_b--;
    a.push_back(t_a);
    b.push_back(t_b);
    c.push_back(t_c);
    d.push_back(t_d);
  }
  vector<long long> v;
  // print(a);
  // print(b);
  // print(c);
  // print(d);
  solve(v);
  cout << ans << endl;
  return 0;
}

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

#define ferrari ios_base::sync_with_stdio(false); cin.tie(NULL)

const int N = 100100;

int n, m, cnt[N], ans;
bool red[N];

int main() {
	cin >> n >> m;
	red[1] = true;
	fill(cnt + 1, cnt + 1 + n, 1);
	while (m--) {
		int x, y;
		cin >> x >> y;
		if (red[x]) red[y] = true;
		cnt[x]--, cnt[y]++;
		if (cnt[x] == 0) red[x] = false;
	}
	for (int i = 1; i <= n; i++)
		ans += red[i];
	cout << ans;
}


Measured memory_bytes: 4044
// Problem Title : Maze Master
// Link : https://atcoder.jp/contests/abc151/tasks/abc151_d
// Date : 03-09-2020 00:08:15

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	
	int h, w;
	cin >> h >> w;
	vector<vector<char>> g(h, vector<char>(w));
	for(int i = 0; i < h; i++) {
		for(int j = 0; j < w; j++) {
			cin >> g[i][j];
		}
	}

	int ans = 0;
	auto bfs = [&](int x, int y) {
		const vector<vector<int>> DIRS{{0, -1}, {0, 1}, {-1, 0}, {1, 0}};
		queue<pair<int, int>> q;
		vector<vector<bool>> vis(h, vector<bool>(w, false));
		q.emplace(x, y);
		vis[x][y] = true;
		int moves;
		for(moves = 0; !q.empty(); moves++) {
			for(int i = 0, qs = q.size(); i < qs; i++) {
				auto st = q.front(); q.pop();
				for(int j = 0; j < 4; j++) {
					pair<int, int> nxt = {st.first + DIRS[j][0], st.second + DIRS[j][1]};
					if(nxt.first < 0 || nxt.first >= h || nxt.second < 0 || nxt.second >= w || g[nxt.first][nxt.second] == '#' || vis[nxt.first][nxt.second]) {
						continue;
					}
					q.emplace(nxt);
					vis[nxt.first][nxt.second] = true;
				}
			}
		}
		moves--;
		ans = max(ans, moves);
	};
	for(int i = 0; i < h; i++) {
		for(int j = 0; j < w; j++) {
			if(g[i][j] == '.') {
				bfs(i, j);
			}
		}
	}

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

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

int main(){
  int A, B, C;
  cin >> A >> B >> C;
  cout << C << " "<< A << " " << B << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
    	
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int N = sc.nextInt();
		
		int cnt = N / 4;
		int cnt_j = N / 3;
		int ans = 0;
		for(int i=0;i < cnt + 1;i++){
			for(int j=0;j < cnt_j;j++){
				ans = i * 4 + j * 7;
				if(ans == N){
			   		System.out.println("Yes");
			   		sc.close();
			   		return;
				}
			}
		}
		
   		System.out.println("No");
		
   		sc.close();
        return ;

    }
    
}



Measured memory_bytes: 23764
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <bitset>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
template < class T > inline bool chmax(T& a, T b) {if (a < b) { a=b; return true; } return false; }
template < class T > inline bool chmin(T& a, T b) {if (a > b) { a=b; return true; } return false; }
#define DEBUG_VLL(vec) REP(sz, vec.size()) std::cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const long long MOD = 1000000007;
const long long HIGHINF = (long long)1e18;
const int INF = (int)1e9;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b, m; cin >> a >> b >> m;
    V<int> av(a), bv(b);
    for (int i = 0; i < a; i++) cin >> av[i];
    for (int i = 0; i < b; i++) cin >> bv[i];
    int ans = *min_element(ALL(av)) + *min_element(ALL(bv));
    for (int i = 0; i < m; i++) {
        int x, y, c; cin >> x >> y >> c;
        x--, y--;
        chmin(ans, max(av[x] + bv[y] - c, 0));
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <set>
#include <math.h>
using namespace std;





int main(){
	set<int> prime;
	vector<int> strong_p;

	for(int i=2;i<=100000;i++){
		bool is_prime = true;
		int t = sqrt(i)+1;
		for(int j=2;j<t;j++){
			if(i%j==0){
				//cout << i << endl;
				is_prime = false;
				break;
			}
		}
		if(is_prime) prime.insert(i);
	}

	for(auto e:prime){
		if(prime.find((e+1)/2) != prime.end()) strong_p.push_back(e);
	}


	//for(auto e: prime) cout << e << endl;

	//for(auto e:strong_p) cout << e << endl;

	//cout << strong_p.size() << endl;

	int ans[100001];

	int s = strong_p.size();

	for(int i=0;i<strong_p[0];i++){
		ans[i] = 0;
	}

	for(int i=0;i<s;i++){
		for(int j=strong_p[i]; j<strong_p[i+1];j++){
			ans[j] = i+1;
		}
	}

	for(int i=strong_p[s-1];i<=100000;i++){
		ans[i] = s;
	}
	
	int Q;
	cin >> Q;

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

	for(int i=0;i<Q;i++){
		cout << ans[r[i]] - ans[l[i]-1] << endl;
	}



	return 0;
}

Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// head

int n,x;
map<int,int> cnt;
bool check() {
	if (SZ(cnt)==1&&cnt.begin()->fi==0) return 1;
	if (n%3!=0) return 0;
	vector<PII> v;
	for (auto p:cnt) v.pb(p);
	if (SZ(v)>3) return 0;
	if (SZ(v)==3) {
		return (v[0].fi^v[1].fi^v[2].fi)==0&&v[0].se==v[1].se&&v[1].se==v[2].se;
	} else {
		return v[0].fi==0&&v[1].se==2*v[0].se;
	}
}

int main() {
	scanf("%d",&n);
	rep(i,0,n) {
		scanf("%d",&x);
		cnt[x]++;
	}
	puts(check()?"Yes":"No");
}


Measured memory_bytes: 4988
#include <stdio.h>

////HUKHJKJKHJKK
int main()

{
    int a,b;
    scanf("%d%d",&a,&b);
    if(b%a==0)

    {
        
    printf("%d\n",a+b);

    }
    else {
        printf("%d\n",b-a);
    }


    return 0;
}



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


int main(){
    int n,m;
    bool ok=true;
    cin>>n>>m;
    vector<pair<int,int>> p(m);
    vector<int> ans(n);
    rep(i,n){
        ans[i]=-1;
    }

    rep(i,m){
        cin>>p[i].first>>p[i].second;
        if(ans[p[i].first-1]!=-1 && ans[p[i].first-1]!=p[i].second){
            ok=false;
        }
        ans[p[i].first-1]=p[i].second;
    }

    rep(i,n){
        if(ans[i]==-1){
            if(i==0 && n>1){
                ans[i]=1;
            }
            else{
                ans[i]=0;
            }
        }
    }
    if(n>2 && ans[0]==0) ok=false;

    int a=0;
    rep(i,n){
        a+=ans[i]*pow(10,n-i-1);
    }

    if(ok==false){
        cout<<-1<<endl;
        return 0;
    }
    cout<<a<<endl;
    return 0;
}


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

int main(){
  int x[5];
  for(int i = 0;i < 5;i++)
    cin >> x[i];
  for(int i = 0;i < 5;i++){
    if(x[i] == 0){
      cout << i + 1 << endl;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime> 
#include <memory.h>
#include <assert.h>

using namespace std;

using ll = long long;
using pii = pair<int, int>;
const int INF = 1e9 + 1;
const int LLINF = 1e18 + 1;

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

    if(a <= 8 && b <= 8) cout << "Yay!" << endl;
    else cout << ":(" << endl;
 
    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <clocale>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i, s, n) for(int i = (s), i##_len=(n); i < i##_len; ++i)
#define FORS(i, s, n) for(int i = (s), i##_len=(n); i <= i##_len; ++i)
#define VFOR(i, s, n) for(int i = (s); i < (n); ++i)
#define VFORS(i, s, n) for(int i = (s); i <= (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) FORS(i, 0, n)
#define VREP(i, n) VFOR(i, 0, n)
#define VREPS(i, n) VFORS(i, 0, n)
#define RFOR(i, s, n) for(int i = (s), i##_len=(n); i >= i##_len; --i)
#define RFORS(i, s, n) for(int i = (s), i##_len=(n); i > i##_len; --i)
#define RREP(i, n) RFOR(i, n, 0)
#define RREPS(i, n) RFORS(i, n, 0)
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v), greater<decltype(v[0])>())
#define SZ(x) ((int)(x).size())
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())

using ll = long long;
using ull = unsigned long long;
using Pi_i = pair<int, int>;
using VB = vector<bool>;
using VC = vector<char>;
using VD = vector<double>;
using VI = vector<int>;
using VLL = vector<ll>;
using VS = vector<string>;
using VSH = vector<short>;
using VULL = vector<ull>;

const int MOD = 1000000007;
const int INF = 1000000000;
const int NIL = -1;

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


int main(){
    multimap<string, int> M;
    int q; cin >> q;
    REP(i, q){
        string key, L, R;
        int op, x; cin >> op;
        switch(op){
            case 0:
                cin  >> key >> x;
                M.insert(MP(key, x));
                break;
            case 1:
                cin >> key;
                for(auto itr = M.find(key); itr != M.end(); ++itr){
                    if(itr->first == key) cout << itr->second << "\n";
                    if(itr->first > key) break;
                }
                break;
            case 2:
                cin >> key;
                M.erase(key);
                break;
            case 3:
                cin >> L >> R;
                for(auto itr = M.lower_bound(L); itr != M.end(); ++itr){
                    if(L <= itr->first && itr->first <= R)
                        cout << itr->first << " " << itr->second << "\n";
                    if(itr->first > R)
                        break;
                }
                break;
        }
    }
    return 0;
}



Measured memory_bytes: 24860
#include <stdio.h>
void Shortest(int,int);
int n, u, d[100], k[100], v[100][100], c[100][100];
int main(){
    int i, j, u;
    scanf ("%d", &n);
    for ( i = 0; i < n; i++){
        scanf("%d", &u);
        scanf("%d", &k[u]);
        for ( j = 0; j < k[u]; j++){
            scanf("%d %d", &v[u][j], &c[u][j]);
        }
        
    }
    for ( i = 0;i < n;i++){
        d[i] = 1000000;
    }
    Shortest(0,0);
    for(i = 0; i < n; i++){
        printf("%d %d\n", i, d[i]);
        
    }
    return 0;
    
}
void Shortest(int p, int x){
    int i;
    d[p] = x;
    for (i =0; i < k[p]; i++){
        if(d[v[p][i]] > x + c[p][i]){
            Shortest(v[p][i],x+c[p][i]);
            
        }
    }
    return;
}



Measured memory_bytes: 2144
#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>;
#include <vector>
#include<algorithm>

int main() {
    int d,t,s;
    cin>>d>>t>>s;
    if (s*t>=d){
      cout<<"Yes"<<endl;
    }else{
      cout<<"No"<<endl;
    }
  return 0;
}


Measured memory_bytes: 3636
// in case of multiple test cases and N=1e5 don't intialize arrays as global except for graph vector-array
// always check whether or not you are doing mod of a negative number
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>
 
using namespace __gnu_pbds;
using namespace std;

#define double      	long double
#define int         	long long
#define pb          	push_back
#define pii         	pair<int,int>
#define vi          	vector<int>
#define vii         	vector<pii>
#define mi          	map<int,int>
#define mii         	map<pii,int>
#define all(a)      	(a).begin(),(a).end()
#define sz(x)       	(int)x.size()
#define endl        	"\n"
#define repp(i,a,b) 	for(int i=a;i<b;i++)
#define rep(i,a,b) 		for(int i=a;i<=b;i++)
#define brep(i,a,b)     for(int i=a;i>=b;i--)
#define deb1(x)      	cout << #x << "=" << x << endl
#define deb2(x, y)  	cout << #x << "=" << x << "," << #y << "=" << y << endl
#define deb3(x, y, z)  	cout << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define trace(v) 		for(auto it=v.begin();it!=v.end();it++)cout<<*it<<" ";cout<<endl;
#define tracearr(a,l,r) for(int iii=l;iii<=r;iii++)cout << a[iii] << " ";cout << endl;
#define PI          	3.1415926535897932384626
#define F 				first
#define S 				second
#define clr(x,y) 		memset(x, y, sizeof(x))
#define IOS         	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);


typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
// *s.find_by_order(1) - gives the 2nd samllest element in set
// s.order_of_key(x)   - gives the number of elements in the set which are strictly smaller than x


const int N=1e5 + 5;
const int MOD=1e9 + 7;

int32_t main()
{
	IOS;
	int T=1;
	//cin >> T;
	// int numOfSetBits = __builtin_popcountll(n);
	std::cout << std::fixed << std::setprecision(12);
	while(T--)
	{
		int m;
		cin >> m;
		int val = 7%m;
		rep(i,1,1e7)
		{
			if(val==0)
			{
				cout << i;
				return 0;
			}
			val = (val*10 + 7)%m;
		}
		cout << "-1";
	}
}

Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <limits>
#include <climits>
#include <utility>
#include <algorithm>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

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

    vector<int> H(N);
    for (int i = 0; i < N; ++i) {
        cin >> H[i];
    }

    for (int i = N-2; i >= 0; --i) {
        if (H[i] > H[i+1]) {
            H[i]--;
        }
    }

    for (int i = 0; i < N-1; ++i) {
        if (H[i] > H[i+1]) {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;

    return 0;
}


Measured memory_bytes: 888
#include <stdio.h>
#include <math.h>
#include <string.h>

int main(){
    
    int w,n,i,t;
    int W[30],a[30],b[30];
    
    scanf("%d",&w);
    for (i=0; i<w; i++) {
        W[i]=i+1;
    }
    
    scanf("%d",&n);
    for (i=0; i<n; i++) {
        scanf("%d,%d",&a[i],&b[i]);
    }
    
    for (i=0; i<n; i++) {
        t=W[a[i]-1];
        W[a[i]-1]=W[b[i]-1];
        W[b[i]-1]=t;
    }
    
    for (i=0; i<w; i++) {
        printf("%d\n",W[i]);
    }

    
    
    return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <vector>
using namespace std;

struct city {
    int number;
    int prefect;
    int year;
    int id;
};

void printid(int p, int id){
    cout << setfill('0') << right << setw(6) << p;
    cout << setfill('0') << right << setw(6) << id << endl;
}

int main(){
    int n,m;
    cin >> n >> m;
    vector<city> cities;
    for(int i=0;i<m;i++) {
        int x;
        int y;
        cin >> x >> y;
        cities.push_back({i,x,y});
    }

    sort(cities.begin(), cities.end(),
         [](const city& x, const city& y)
    {
        return x.year < y.year;
    });
    stable_sort(cities.begin(), cities.end(),
         [](const city& x, const city& y)
    {
        return x.prefect < y.prefect;
    });


    int count = 1;
    for(int i=0;i<m;i++) {
        cities[i].id = count;
        count++;
        if(cities[i].prefect!=cities[i+1].prefect) {
            count = 1;
        }
    }

    sort(cities.begin(), cities.end(),
         [](const city& x, const city& y)
    {
        return x.number < y.number;
    });

    for(int i=0;i<m;i++) {
        printid(cities[i].prefect, cities[i].id);
    }

    return 0;

}


Measured memory_bytes: 3176
#include<bits/stdc++.h>
using namespace std;
const int N = 1e6 + 19, Mod = 1e9 + 7;
int n, m, q, A[N];
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    cin >> n >> m;
    int cnt = 0;
    for (int i = 1; i <= n; i ++)
        cin >> A[i], cnt += A[i];
    int cc = 0;
    for (int i = 1; i <= n; i ++)
        if (A[i] * 4LL * m >= cnt)
            cc ++;
    if (cc >= m)
        printf("Yes\n");
    else
        printf("No\n");
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <functional>
#include <cstdlib>
typedef long long int lld;
const lld mod = 1000000007;
const int st = 200000;
lld myexp(lld x, lld y)
{
    if(!y) return 1;
    if(y&1) return (x * myexp(x*x % mod, y>>1) % mod);
    else return myexp(x*x % mod, y>>1);
}
lld fact[200003];
lld inv[200003];
lld binom(int n, int r)
{
    if(r < 0 || n < r) return 0;
    return ((fact[n] * inv[r]) % mod) * inv[n-r] % mod;
}
int main()
{
    fact[0] = 1;
    for(int i=1;i<=st;i++)
        fact[i] = i * fact[i-1] % mod;
    inv[st] = myexp(fact[st], mod-2);
    for(int i=st-1;i>=0;i--)
        inv[i] = (i+1) * inv[i+1] % mod;

    long long int ans = 1;
    int n,m;
    scanf("%d%d", &n, &m);
    for(int i=2;i*i<=m;i++)
    {
        int cnt = 0;
        while(m%i==0)
        {
            cnt++;
            m/=i;
        }
        ans = ans * binom(n+cnt-1, cnt) % mod;
    }
    if(m != 1) ans = ans * n % mod;
    printf("%lld\n", ans);
}

Measured memory_bytes: 3328
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_macros)]
#![allow(unused_imports)]

use std::str::FromStr;
use std::io::*;
use std::collections::*;
use std::cmp::*;

struct Scanner<I: Iterator<Item = char>> {
    iter: std::iter::Peekable<I>,
}

macro_rules! exit {
    () => {{
        exit!(0)
    }};
    ($code:expr) => {{
        if cfg!(local) {
            writeln!(std::io::stderr(), "===== Terminated =====")
                .expect("failed printing to stderr");
        }
        std::process::exit($code);
    }}
}

impl<I: Iterator<Item = char>> Scanner<I> {
    pub fn new(iter: I) -> Scanner<I> {
        Scanner {
            iter: iter.peekable(),
        }
    }

    pub fn safe_get_token(&mut self) -> Option<String> {
        let token = self.iter
            .by_ref()
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            Some(token)
        }
    }

    pub fn token(&mut self) -> String {
        self.safe_get_token().unwrap_or_else(|| exit!())
    }

    pub fn get<T: FromStr>(&mut self) -> T {
        self.token().parse::<T>().unwrap_or_else(|_| exit!())
    }

    pub fn vec<T: FromStr>(&mut self, len: usize) -> Vec<T> {
        (0..len).map(|_| self.get()).collect()
    }

    pub fn mat<T: FromStr>(&mut self, row: usize, col: usize) -> Vec<Vec<T>> {
        (0..row).map(|_| self.vec(col)).collect()
    }

    pub fn char(&mut self) -> char {
        self.iter.next().unwrap_or_else(|| exit!())
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.get::<String>().chars().collect()
    }

    pub fn mat_chars(&mut self, row: usize) -> Vec<Vec<char>> {
        (0..row).map(|_| self.chars()).collect()
    }

    pub fn line(&mut self) -> String {
        if self.peek().is_some() {
            self.iter
                .by_ref()
                .take_while(|&c| !(c == '\n' || c == '\r'))
                .collect::<String>()
        } else {
            exit!();
        }
    }

    pub fn peek(&mut self) -> Option<&char> {
        self.iter.peek()
    }
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin.bytes().map(|c| c.unwrap() as char));
    let N: usize = sc.get();
    let mut sum_digit = 0;
    let mut rem = N;
    while rem != 0 {
        sum_digit += rem % 10;
        rem /= 10;
    }
    if N % sum_digit == 0 {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 4352
#include "iostream"
#include "vector"
#include "algorithm"

using namespace std;

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

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

int main()
{
    int N, M;
    std::cin >> N >> M;

    std::vector<int> A(N);
    int A_total = 0;
    for (int i = 0; i < N; i++)
    {
        std::cin >> A[i];
        A_total += A[i];
    }
    // A_total = std::accumulate(A.begin(), A.end(), 0);  // 合計はこれでも算出できる

    
    double th = (double)A_total / (4 * (double)M);
    std::sort(A.begin(), A.end(), std::greater<int>());
    if (A[M-1] >= th)
        std::cout << "Yes" << std::endl;
    else
        std::cout << "No" << std::endl;

    // bool flag = true;
    // for (int i = 0; i < M; i++)
    // {
    //     if ((float)A[i] < th)
    //     {
    //         flag = false;
    //         break;
    //     }
    // }

    // if (flag == true)
    //     std::cout << "Yes" << std::endl;
    // else if (flag == false)
    //     std::cout << "No" << std::endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define REP(i,m,n) for(int i = m; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a)  (a).rbegin(),(a).rend()
#define dup(x,y) (((x)+(y)-1) / (y)) //整数型のまま切り上げ演算する
#define PI 3.14159265359
typedef long long LL;
template<class T> inline void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> inline void chmin(T& a, T b) { if (a > b) { a = b; } }
template<class T> inline T gcd(T x, T y) { if (y == 0) { return x; } else if (x == 0) { return y; }return gcd(y, x % y); }
template<class T> inline T lcm(T x, T y) { return (x * y) / gcd(x, y); }
template<class T> inline vector<T> convert_to_binary_number(T x) { vector<T> binary_num; while (x != 1) { binary_num.push_back(x % 2); x /= 2; } binary_num.push_back(1); return binary_num; }
template<class T> inline void print_vector(vector<T> vec) { for (int i = 0; i < vec.size(); i++) { cout << vec[i] << " "; } cout << endl;}
const LL MOD = 1e9 + 7;
const LL INF = 1LL << 60;

int main(void){
    LL N;
    cin >> N;

    vector<LL> a(N);
    rep(i, N) cin >> a[i];

    LL count = 0;
    for(LL i = 0; i < N; i++) {
        for(LL j = 0; j < 30; j++) {
            if(a[i]%2 == 0){
                a[i] /= 2;
                count++;
            }
        }        
    }
    cout << count << endl;

    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1000000007
#define maxn 1000000009b
int main()
{
    int N;
    cin >> N;
    ll H[N];
    for (int i = 0; i < N; i++)
    {
        cin >> H[i];
    }
    ll ans = 0;
    ll count = 0;
    for (int i = 1; i < N; i++)
    {
        if (H[i - 1] >= H[i])
        {
            count++;
        }
        else
        {
            ans = max(count, ans);
            count = 0;
        }
    }
    ans = max(count, ans);
    cout << ans << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

int cnt[100000];

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

    for(int i = 1; i<= 100; ++i){
        for(int j=1; j<= 100; ++j){
            for(int k=1; k<=100; ++k){
                int ans = i*i + j*j + k*k;
                ans += i*j + j*k + i*k;
//                cout << i << " " << j << " " << k << " :" << ans << endl;
                cnt[ans]++;
            }
        }
    }


    for(int i=1; i<=N; ++i){
        cout << cnt[i] << endl;
    }
}

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

int main(){
    int n,m,a,i,j,sum=0,val;
    cin>>n>>m;
    for(i=1;i<=m;i++){
        cin>>a;
        sum+=a;
    }
    val=n-sum;
    if(val>=0){
        cout<<val<<endl;
    }
    else{
        cout<<"-1"<<endl;
    }
    return 0;
}


Measured memory_bytes: 3636
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    n,m = LI()
    a = LI()
    q = []
    for c in a:
        heapq.heappush(q,-c)
    for i in range(m):
        t = -heapq.heappop(q)
        heapq.heappush(q,-(t//2))

    return -sum(q)


print(main())





Measured memory_bytes: 16728
n = int(input())
if n < 600:
    print(8)
elif n < 800:
    print(7)
elif n < 1000:
    print(6)
elif n < 1200:
    print(5)
elif n < 1400:
    print(4)
elif n < 1600:
    print(3)
elif n < 1800:
    print(2)
else:
    print(1)


Measured memory_bytes: 61672
#include <iostream>
#include <limits>
#include <vector>

long long cnt = 0;

void merge(std::vector<long long> &s, int left, int mid, int right)
{
    int n1 = mid - left;
    int n2 = right - mid;
    std::vector<long long> L(n1+1);
    std::vector<long long> R(n2+1);

    for (int i = 0; i < n1; i++) {
        L[i] = s[left + i];
    }
    for (int i = 0; i < n2; i++) {
        R[i] = s[mid + i];
    }
    L[n1] = std::numeric_limits<int>::max();
    R[n2] = std::numeric_limits<int>::max();

    // std::cout << "==== merge ====" << std::endl;
    // for (int i = 0; i < n1; i++) {
    //     std::cout << L[i] << " ";
    // }
    // std::cout << std::endl;
    // for (int i = 0; i < n2; i++) {
    //     std::cout << R[i] << " ";
    // }
    // std::cout << std::endl;
    // std::cout << "||" << std::endl;
    // std::cout << "\\/" << std::endl;


    int i = 0;
    int j = 0;
    for (int k = left; k < right; k++) {
        if (L[i] <= R[j]) {
            s[k] = L[i];
            i++;
        }
        else {
            if (i != n1) cnt += n1 - i;
            s[k] = R[j];
            j++;
        }
    }

    // for (int i = left; i < right; i++) {
    //     std::cout << s[i] << " ";
    // }
    // std::cout << std::endl;
}

void mergesort(std::vector<long long> &s, int left, int right)
{
    if (left + 1 < right) {
        int mid = left + (right - left) / 2;
        mergesort(s, left, mid);
        mergesort(s, mid, right);
        merge(s, left, mid, right);
    }
}

int main(int argc, char const *argv[])
{
    int n;
    std::cin >> n;
    std::vector<long long> s(n);
    for (int i = 0; i < n; i++) {
        std::cin >> s[i];
    }

    mergesort(s, 0, n);
    std::cout << cnt << std::endl;

    return 0;
}

Measured memory_bytes: 4148
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
typedef long long ll;
#define _GLIBCXX_DEBUG
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<char> cvec;
typedef vector<double> dvec;
typedef pair<ll, ll> LP;
typedef tuple<ll, ll, ll> LT;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
#define fs first
#define sc second
int main()	{
  int n;
  cin>>n;
  int t,a;
  int tmp=1000000;
  cin>>t>>a;
  vector<int>at(n);
  rep(i,n){
    int h;
    cin>>h;
    at[i]=1000*t-6*h;
    tmp=min(tmp,abs(at[i]-1000*a));
  }
  rep(i,n){
    if(abs(at[i]-1000*a)==tmp){
      cout<<i+1<<endl;
    }
  }
}

Measured memory_bytes: 3656
#include<stdio.h>

int main()
{
	int a, b;
	scanf("%d %d", &a, &b);
	
	if (b % a == 0)
	{
		printf("%d", a + b);
	}
	
	else
	{
		printf("%d", b - a);
	}
	
	return 0;
}

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

vector<int> C[26];

int search(int i, int now){
	int ng = -1, ok = C[i].size();
	while(ok - ng > 1){
		int mid = (ng + ok)/2;
		if(C[i][mid] > now) ok = mid;
		else ng = mid;
	}
	if(ok == C[i].size()) return -1;
	else return ok;
}

int main(){
	string A;
	cin >> A;
	int bit = 0;
	vector<int> par;
	int le[A.size()];
	for(int i = A.size() - 1; i >= 0; --i){
		int t = A[i] - 'a';
		bit |= (1<<t);
		if(bit + 1 == (1<<26)){
			par.push_back(i);
			bit = 0;
		}
		le[i] = par.size() + 1;
	}
	for(int i = 0; i < A.size(); i++){
		int t = A[i] - 'a';
		C[t].push_back(i);
	}
	int len = par.size();
	vector<char> ans;
	int now = -1;
	for(int i = 0; i < len + 1; ++i){
		for(int j = 0; j < 26; ++j){
			if(search(j, now) != -1){
				if(C[j][search(j, now)] == A.size() - 1){
					if(1 == len - i){
						char c = 'a' + j;
						ans.push_back(c);
						now = C[j][search(j, now)];
						break;
					}
				}else{
					if(le[C[j][search(j, now)] + 1] == len - i){
						char c = 'a' + j;
						ans.push_back(c);
						now = C[j][search(j, now)];
						break;
					}
				}
			}else{
				char c = 'a' + j;
				ans.push_back(c);
				break;
			}
		}
	}
	for(int i = 0; i < len + 1; ++i) cout << ans[i];
	return 0;
}

Measured memory_bytes: 2180
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstddef>
#include<queue>
#include<math.h>
#include<iomanip>
using namespace std;

int main()
{
    int X, Y, Z;
    cin >> X >> Y >> Z;
    cout << Z << " " << X << " " << Y << endl;
    return 0;
}


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

using namespace std;

#define int long long

signed main() {
	while(true) {
		int n;
		cin >> n;
		if (n == 0)break;

		vector<int> ps(n);
		vector<int> js(n - 1);
		int sum = 0;
		for (int i = 0; i < n; i++) {
			cin >> ps[i];
			sum += ps[i];
		}
		for (int i = 0; i < n - 1; i++) {
			cin >> js[i];
		}
		sort(js.begin(), js.end());
		reverse(js.begin(), js.end());

		int res = sum * n;
		for (int i = 0; i < n - 1; i++) {
			sum += js[i];
			int tmp = sum * (n - i - 1);
			res = max(res, tmp);
		}

		cout << res << endl;
	}
}


Measured memory_bytes: 3900
import sys


inint = lambda: int(sys.stdin.readline())
inintm = lambda: map(int, sys.stdin.readline().split())
inintl = lambda: list(inintm())
instrm = lambda: map(str, sys.stdin.readline().split())
instrl = lambda: list(instrm())

x1, y1, x2, y2 = inintm()

print("{} {} {} {}".format(x2-(y2-y1), y2+(x2-x1), x1-(y2-y1), y1+(x2-x1)))

Measured memory_bytes: 61848
#include<bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[])
{
	
		     //  #ifndef ONLINE_JUDGE
	      //  // for getting input from input.txt
	      //  freopen("input.txt", "r", stdin);
	      //  // for writing output to output.txt
	      //  freopen("output.txt", "w", stdout);
	      // #endif
	string s;
	cin>>s;
	for (int i = 0; i < s.length(); ++i)
		{
			if(i%2 ==0){
				cout<<s[i];
			}
		}	
	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
vector<long long >v;
int main()
{
    long long t,a,b,n,c,x,p;
    string s;
    cin>>a>>b>>c;
    swap(a,b);
    swap(a,c);
    cout<<a<<" "<<b<<" "<<c;


}


Measured memory_bytes: 256
import java.util.*;

class Main {
	
	static int[] height;
	final static int size = 10;

	public static void main (String [] args){
		printAns();	
	}

	public static void init(){
		height = new int[size];
		Scanner sc = new Scanner(System.in);
	
		for(int i=0; i<size; i++){
			height[i] = sc.nextInt();
		}
	}

	public static void sort(){
		int max;
		for(int i=0; i<size; i++){
			max = i;
			for(int j=i+1; j<size; j++)
				if(height[max]<height[j]) max = j;
			swap(i, max);
		}	
	}

	public static void swap(int i, int j){
		int tmp = height[i];
		height[i] = height[j];
		height[j] = tmp;
	}

	public static void printAns(){
		init();
		sort();

		for(int i=0; i<3; i++) System.out.println(height[i]);
	}
}

Measured memory_bytes: 12000
n = gets.to_s.to_i
edges = Array.new(n-1){ gets.to_s.split.map{|t|t.to_i} }

g = Array.new(n+1){ [] }
edges.each do |u, v, c|
  g[u] << [v, c]
  g[v] << [u, c]
end

ans = Array.new(n+1){ 0 }
used = Array.new(n+1){ false }

q = [1]
used[1] = true

while q.any?
  
  v = q.shift
  g[v].each do |(u, c)|
    next if used[u]
    used[u] = true
    ans[u] = ( c.even? ? ans[v] : 1 - ans[v] )
    q.push u
  end
end

puts ans[1, n]

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

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

  string t = s;
  reverse(t.begin(), t.end());
  for (int i = 0; i < t.size(); ++i) {
    if (t[i] == 'b')
      t[i] = 'd';
    else if (t[i] == 'd')
      t[i] = 'b';
    else if (t[i] == 'p')
      t[i] = 'q';
    else
      t[i] = 'p';
  }

  cout << (s == t ? "Yes" : "No") << endl;
}


Measured memory_bytes: 512
/*
the top of the losers
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define sz(v)   ((int)(v).size())
#define  all(v)    ((v).begin()),((v).end())
#define  allr(v)    ((v).rbegin()),((v).rend())
#define   pb         push_back
#define   mp         make_pair
#define    Lcm(a,b)  ((a*b)/(__gcd(a,b)))
#define    X            real()
#define    Y            imag()
#define    clr(v,d)      memset( v, d ,sizeof(v))
#define   angle(n)      atan2((n.imag()),(n.real()))
#define   vec(a,b)       ((b)-(a))
#define   length(a)      hypot( (a.imag()),(a.real()) )
#define   normalize(a)      (a)/(length(a))
#define    dp(a,b)          (((conj(a))*(b)).real())
#define    cp(a,b)          (((conj(a))*(b)).imag())
#define    lengthsqrt(a)       dp(a,a)
#define    rotate0( a,ang)    ((a)*exp( point(0,ang) ))
#define    rotateA(about,p,ang)   (rotate0(vec(about,p),ang)+about)
#define    lcm(a,b)                ((a*b)/(__gcd(a,b)))
#define    reflection0(m,v)         (conj((v)/(m))*(m))
#define     reflectionA(m,v,p0)     (conj( (vec(p0,v))/(vec(p0,m)) ) * (vec(p0,m)) ) + p0
#define     same(p1,p2)               ( dp(  vec(p1,p2),vec(p1,p2)) < eps )
#define     point                    complex<double>
#define     point        complex<double>
#define    cp(a,b)          (((conj(a))*(b)).imag())
#define    PI  acos(-1)
typedef  long long     ll ;
typedef  unsigned long long     ull ;
const double eps= (1e-9);
using namespace std;
using namespace __gnu_pbds;
int dcmp(long double a,long double b){   return fabsl(a-b)<=eps ? 0: (a>b)? 1:-1  ;}
int getBit(ll num, int idx) {return ((num >> idx) & 1ll) == 1;}
int setBit1(int num, int idx) {return num | (1<<idx);}
ll setBit0(ll num, int idx) {return num & ~(1ll<<idx);}
ll flipBit(ll num, int idx) {return num ^ (1ll<<idx);}
int countNumBit1(int mask) {int ret=0; while (mask) 	{mask &= (mask-1);++ret;	}return ret;}
void GO(){ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);}
const int N=100000+9;
const ll inf=1e16;
int a[N],b[N],c[N];
ll dist[N];
bool vis[N];
vector< vector< pair<int,int> > > g(N);
ll dijk(int s,int ta){

   for(int i=1;i<=100000;i++){
    dist[i]=inf;
   }
   priority_queue< pair<ll,int> ,vector<pair<ll,int> > ,greater< pair<ll,int> > > pq;
   pq.push(mp(0,1));
   dist[1]=0;

   while(sz(pq)>0){
    int cur=pq.top().second;
    ll add=pq.top().first;
    pq.pop();
    if(vis[cur]) continue;
    vis[cur]=1;

    for(int i=0;i<sz(g[cur]);i++){
        int nw=g[cur][i].first;
        ll co=g[cur][i].second;
        if(dist[nw]>add+co){
            dist[nw]=add+co;
            pq.push(mp(add+co,nw));
        }
    }
   }
   if(dist[ta]==inf) return -1;
   return dist[ta];
}
int main(){
    GO();
    int n,m;
    cin>>n>>m;
    for(int i=0;i<m;i++){
        cin>>a[i]>>b[i]>>c[i];
        //v[a[i]].pb(mp(0,i));
        //v[b[i]].pb(mp(1,i));
        g[a[i]].pb(mp(b[i],c[i]));
        g[b[i]].pb(mp(a[i],c[i]));
    }
    for(int i=n;i>=2;i--){
        g[i].pb(mp(i-1,0));
    }

    cout<<dijk(1,n)<<endl;
}

























Measured memory_bytes: 11380
#include <iostream>
using namespace std;
int main() {
  int R;
  cin >> R;
  if (R < 1200) {
    cout << "ABC" << endl;
  } else if (R < 2800) {
    cout << "ARC" << endl;
  } else {
    cout << "AGC" << endl;
  }
}

Measured memory_bytes: 256
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.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author anand.oza
 */
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);
        C4N solver = new C4N();
        solver.solve(1, in, out);
        out.close();
    }

    static class C4N {
        static final int CAP = 3500;

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            long n = in.nextInt();

            for (long b = 1; b <= CAP; b++) {
                for (long c = 1; c <= CAP; c++) {
                    long d = 4 * b * c - n * b - n * c;
                    if (d == 0) {
                        continue;
                    }
                    long a = (n * b * c) / d;
                    if (a > 0 && a <= CAP && n * (a * b + b * c + c * a) == 4 * a * b * c) {
                        out.println(a + " " + b + " " + c);
                        return;
                    }
                }
            }
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

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

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

    }
}



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

int main() {
    int n;
    cin >> n;
    vector<pair<ll, ll>> jobs(n);
    rep(i, n) cin >> jobs[i].second >> jobs[i].first;
    sort(jobs.begin(), jobs.end());
    int timer = 0;
    rep(i, n) {
        timer += jobs[i].second;
        if (timer > jobs[i].first) {
            cout << "No\n";
            return 0;
        }
    }
    cout << "Yes\n";
}

Measured memory_bytes: 3328
n = gets.to_i

hs = gets.split.map(&:to_i)
processed = Array.new(n, false)

res = "Yes"
(n-1).downto(0) do |idx|
    i = hs[idx]
    last_n = idx == 0 ? 0 : hs[idx - 1]
    next_n = idx == hs.size - 1 ? 10**9 + 1 : hs[idx + 1]
    if i < last_n - 1
        res = "No"
        break
    end
    if i == last_n - 1
        hs[idx - 1] -= 1
        next
    end
end

puts res


Measured memory_bytes: 9356
#include "bits/stdc++.h"
using namespace std;

int main() {
	int N;
	cin >> N;
	map<long long, int>mp;
	for (int i = 0; i < N; ++i) {
		int n;
		cin >> n;
		mp[n]++;
	}
	vector<long long>A;
	vector<long long>B;
	long long ans = 0;
	for (auto p : mp) {
		if (p.second>=2) {
			A.push_back(p.first);
		}		
		if (p.second >= 4) {
			B.push_back(p.first);
		}
	}
	sort(A.rbegin(),A.rend());	
	sort(B.rbegin(), B.rend());
	if (A.size() >= 2) {
		ans = max(ans,A[0] * A[1]);
	}
	if (B.size() >= 1) {
		ans = max(ans, B[0] * B[0]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 9720
def main():
    N, M = map(int, input().split())
    S = [i == "B" for i in input()]
    ab = [list(map(int, input().split())) for _ in [0]*M]
    graph = [set() for _ in [0]*N]
    [graph[a-1].add(b-1) for a, b in ab]
    [graph[b-1].add(a-1) for a, b in ab]

    status = [[0, 0] for _ in [0]*N]

    for i in range(N):
        for j in graph[i]:
            status[i][S[j]] += 1

    que = []
    for i, (p, q) in enumerate(status):
        if (p == 0) ^ (q == 0):
            que.append(i)

    while que:
        i = que.pop()
        c = S[i]
        for j in graph[i]:
            if i != j:
                graph[j].remove(i)
            status[j][c] -= 1
            p, q = status[j]
            if (p == 0) ^ (q == 0):
                que.append(j)
        graph[i] = set()

    for i in graph:
        if i:
            print("Yes")
            return
    print("No")


main()


Measured memory_bytes: 126768
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
using namespace std;
#define COUT(v) cout<<(v)<<endl
#define CIN(n)  int(n);cin >> (n)
#define LCIN(n) LL(n);cin >> (n)
#define SCIN(n) string(n);cin >> (n)
#define YES(n) cout<<((n)? "YES" : "NO")<<endl
#define Yes(n) cout<<((n)? "Yes" : "No")<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) <<endl

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)

#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<LL,LL>
#define I vector<int>
#define S set<int>
#define pb(v) push_back(v)
#define V vector
#define rt return
#define rmsame(a) sort(ALL(a)),a.erase(unique(ALL(a)), a.end())

typedef string::const_iterator State;
class PalseError {};
class Edge{
public:
    LL from,to,value;
    Edge(LL a,LL b,LL c){
        from = a;
        to = b;
        value = c;
    }
    Edge(LL a,LL b){
        from = a;
        to = b;
    }
};

int main(){
    CIN(x);CIN(t);
    COUT(max(x-t,0));
    return 0;
}


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

int main() {
    int h, w;
    cin >> h >> w;
    vector<string> s(h);
    for (int i = 0; i < h; ++i) cin >> s[i];

    vector<vector<int>> cnt(h, vector<int>(w));

    for (int i = 0; i < h; ++i) {
        vector<int> done(w);
        for (int j = 0; j < w; ++j) {
            if (s[i][j] == '#') continue;
            if(done[j]) continue;
            
            int l = 0;
            while(j+l < w) {
                if (s[i][j+l] == '#') break;
                ++l; 
            }
            for (int k = 0; k < l; ++k) {
                cnt[i][j+k] += l;
                done[j+k] = 1;
            }
        }
    }

    for (int j = 0; j < w; ++j) {
        vector<int> done(h);
        for (int i = 0; i < h; ++i) {
            if (s[i][j] == '#') continue;
            if(done[i]) continue;
        
            int l = 0;
            while(i+l < h) {
                if (s[i+l][j] == '#') break;
                ++l; 
            }
            for (int k = 0; k < l; ++k) {
                cnt[i+k][j] += l;
                done[i+k] = 1;
            }
        }
    }

    int ans = 0;
    for (int i = 0; i < h; ++i) for (int j = 0; j < w; ++j) ans = max(ans, cnt[i][j] - 1);
    cout << ans << endl;

    return 0;
}   

Measured memory_bytes: 20096