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

// template {{{
#define  range(i, l, r) for (int i = (int)(l); i < (int)(r); (i) += 1)
#define rrange(i, l, r) for (int i = (int)(r) - 1; i >= (int)(l); (i) -= 1)

#define  whole(f, x, ...) ([&](decltype((x)) container) { return (f)(  begin(container),  end(container), ## __VA_ARGS__); })(x)
#define rwhole(f, x, ...) ([&](decltype((x)) container) { return (f)( rbegin(container), rend(container), ## __VA_ARGS__); })(x)

#define debug(x) cerr << "(" << __LINE__ << ")" << #x << ": " << (x) << endl

using i32 = int;
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;

// constexpr i32 mod   = 998244353;
constexpr i32 mod   = 1e9 + 7;
constexpr i32 inf   = 1001001001;
constexpr i64 infll = 1001001001001001001ll;

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

struct IoSetup { IoSetup(int x = 15){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(x); cerr << fixed << setprecision(x); } } iosetup;

template <typename T = i64> T input() { T x; cin >> x; return x; }

template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { range(i, 0, v.size()) { os << v[i] << (i + 1 != v.size() ? " " : ""); } return os; }
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }

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

template <typename T> vector<T> make_vector(size_t a, T b) { return vector<T>(a, b); }
template <typename... Ts> auto make_vector(size_t a, Ts... ts) { return vector<decltype(make_vector(ts...))>(a, make_vector(ts...)); }

template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
// }}}

void solver() {
    int n = input();
    vector< i64 > as(n);
    cin >> as;

    if (*whole(min_element, as) == 0) {
        cout << 0 << endl;
        return;
    }

    i64 ans = 1;
    for (auto a: as) {
        if (__builtin_mul_overflow(a, ans, &ans)) {
            cout << -1 << endl;
            return;
        }
    }

    if (ans > 1000000000000000000) {
        cout << -1 << endl;
        return;
    }

    cout << ans << endl;
}

signed main(int argc, char *argv[]) {
    solver();
}


Measured memory_bytes: 3936
#include <cstdio>
#include <string>
#include <algorithm>

int main() {
  std::string s;
  for (int i = 0; i < 4; ++i) {
    char c;
    scanf(" %c", &c);
    s += c;
  }
  std::sort(s.begin(), s.end());
  if (s == "1479") {
    puts("YES");
  } else {
    puts("NO");
  }
}


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

int main() {
  int n, m;
  cin >> n >> m;
  
  long long i;
  vector<vector<long long>> x(n, vector<long long>(2));
  for(i = 0; i < n; i++){
    cin >> x.at(i).at(0) >> x.at(i).at(1);
  }
  
  sort(x.begin(), x.end());
  
  long long buy = 0, ans = 0;
  i = 0;
  while(1){
    if(buy + x.at(i).at(1) < m){
      ans += x.at(i).at(1) * x.at(i).at(0);
      buy += x.at(i).at(1);
      i++;
    }
    else{
      ans += (m - buy) * x.at(i).at(0);
      break;
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 5760
/**
*    created: 07.07.2020 21:21:08
**/
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using bint = boost::multiprecision::cpp_int;
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pcnt(bit) __builtin_popcountll(bit)
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return 1;} return 0;}
template<class T> bool chmin(T &a, const T &b) {if (b < a) {a = b; return 1;} return 0;}
const long double pi = acos(-1.0);
const int MAX = 1000010;
const int INF = 1LL << 60;
const int MOD = 1000000007;
// const int MOD = 998244353;

signed main() {

    cin.tie(0);
    ios_base::sync_with_stdio(false);

    string s; cin >> s;
    map<char,int> mp;
    rep(i,s.size()) mp[s[i]]++;
    bool ok = true;
    for (auto p : mp) if (p.second > 1) ok = false;
    if (ok) cout << "yes" << endl;
    else cout << "no" << endl;
    return 0;
}

Measured memory_bytes: 3600
n,m,c=map(int,input().split())
b=list(map(int,input().split()))
ans=0
for i in range(n):
  a=list(map(int,input().split()))
  sum=0
  for j in range(m):
    sum+=a[j]*b[j]
  if sum>-c:
    ans+=1
print(ans)

Measured memory_bytes: 3064
/*
 * 2669.cc: A-Z Cat
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 20;
const int INF = 1 << 30;

/* typedef */

/* global variables */

int dp[MAX_N + 1][2];

/* subroutines */

/* main */

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

  int n = s.size();

  for (int i = 0; i <= n; i++) dp[i][0] = dp[i][1] = INF;
  dp[0][0] = 0;

  for (int i = 0; i < n; i++)
    for (int j = 0; j < 2; j++) {
      if (dp[i][j] < INF) {
	int ndp = dp[i][j] + 1;
	if (dp[i + 1][j] > ndp) dp[i + 1][j] = ndp;

	if (s[i] == 'A' || s[i] == 'Z') {
	  int j0 = (s[i] == 'A') ? 0 : 1;
	  int j1 = j0 ^ 1;
	  if (j == j0) {
	    if (dp[i + 1][j1] > dp[i][j]) dp[i + 1][j1] = dp[i][j];
	  }
	}
      }
    }

  //for (int i = 0; i <= n; i++) printf("(%d,%d)", dp[i][0], dp[i][1]);
  //putchar('\n');
  
  int m = n - dp[n][0];
  if (m <= 0) puts("-1");
  else {
    for (int i = 0; i < m; i += 2) cout << "AZ";
    cout << endl;
  }

  return 0;
}

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

int main(){
    int x,a,b;
    cin >> x >> a >> b;
    if(abs(a-b) > x) cout << "dangerous" << endl;
    else if(abs(a-b) <= x && a-b < 0) cout << "safe" << endl;
    else cout << "delicious" << endl;
}


Measured memory_bytes: 256
K, A, B = [int(_) for _ in input().split()]

if B - A <= 2 or K <= A:
    print(K + 1)
else:
    ans = (K - A + 1) % 2
    N = (K - A + 1) // 2 - 1
    ans += B + (B-A) * N
    print(ans)


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

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

using namespace std;

int main(){
  int D,G;
  cin >> D >> G;
  int p[D], c[D];
  rep(i,D) cin >> p[i] >> c[i];

  //compleat pattern
  int ans = 10000;
  bool comp[D];
  rep(i,1<<D){
    int score = 0;
    int solveCnt = 0;
    int x = i;
    int cnt = 0;
    fill(comp,comp+D,false);
    while(x > 0){
      if(x % 2) comp[cnt] = true;
      x /= 2;
      cnt ++;
    }
    rep(j,D){
      if(comp[j]){
        solveCnt += p[j];
        score += c[j] + p[j] * (j+1) * 100;
      }
    }
    if(score >= G) ans = min(ans,solveCnt);

    for(int j = D-1; j >= 0; j --){
      if(comp[j] == false)
      rep(k,p[j]){
        score += 100 * (j+1);
        solveCnt ++;
        if(score >= G) ans = min(ans,solveCnt);
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

const int MAX = 100000;

int partition(int A[], int p, int r) {
  int x = A[r];
  int i = p - 1;
  for (int j = p; j < r; ++j) {
    if (A[j] <= x) {
      ++i;
      int t = A[i];
      A[i] = A[j];
      A[j] = t;
    }
  }
  int u = A[i + 1];
  A[i + 1] = A[r];
  A[r] = u;
  return i + 1;
}

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

  int n, q;
  int A[MAX];
  
  cin >> n;
  for (int i = 0; i < n; ++i)
    cin >> A[i];

  q = partition(A, 0, n - 1);
  for (int i = 0; i < n; ++i) {
    if (i == q) cout << "[" << A[i] << "]";
    else cout << A[i];
    if (i == n - 1) cout << "\n";
    else cout << " ";
  }

  return 0;
}



Measured memory_bytes: 3488
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner scn = new Scanner(System.in);
		int N = scn.nextInt();
		long K = scn.nextLong();
		long[] X = new long[N];
		for(int i = 0;i < N;i++) {
			X[i] = scn.nextLong();
		}

		for(int i = 0;i < N;i++) {
			for(int j = i+1;j < N;j++) {
				if(X[i] > X[j]) {
					long buf = X[i];
					X[i] = X[j];
					X[j] = buf;
				}
			}
		}
		int ans = 0;
		for(int i = 0;i < N;i++) {
			if(K - X[i] < 0) {
				K -= X[i];
				break;
			}
			ans++;
			K -= X[i];
		}
		if(K>0)ans--;

		System.out.println(ans);
		scn.close();
	}
}


Measured memory_bytes: 22996
n, m = gets.chomp.split.map(&:to_i)
if m == 0
  puts 0
  exit
end
a1 = []
a2 = []
a3 = []
a4 = []
a5 = []
a6 = []
a7 = []
a8 = []
r1 = r2 = r3 = r4 = r5 = r6 = r7 = r8 = 0
n.times do |i|
  x, y, z = gets.chomp.split.map(&:to_i)
  a1[i] = x + y + z
  a2[i] = x + y - z
  a3[i] = x - y + z
  a4[i] = x - y - z
  a5[i] = -x + y + z
  a6[i] = -x + y - z
  a7[i] = -x - y + z
  a8[i] = -x - y - z
end
puts [
  a1.sort.reverse[0...m].inject(:+),
  a2.sort.reverse[0...m].inject(:+),
  a3.sort.reverse[0...m].inject(:+),
  a4.sort.reverse[0...m].inject(:+),
  a5.sort.reverse[0...m].inject(:+),
  a6.sort.reverse[0...m].inject(:+),
  a7.sort.reverse[0...m].inject(:+),
  a8.sort.reverse[0...m].inject(:+)
].max

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

int main()
{
    int A,B,C,X;
  	int count = 0;
    cin >> A >> B >> C >> X;
    
    for (int i=0; i<A+1; i++)
    {
        for (int j=0; j<B+1; j++)
        {
            for (int k=0; k<C+1; k++)
            {
                if(X-500*i-100*j-50*k == 0)
                {
                    count++;
                }
            }
        }
    }
    cout << count << endl;

    return 0;
}

Measured memory_bytes: 256
a,b,c,d = gets.chomp.split(' ').map(&:to_i)
e = c.lcm(d)

total = 0
total += (b / c) - ((a-1) / c)
total += (b / d) - ((a-1) / d)
total -= (b / e) - ((a-1) / e)
puts b - a + 1 - total

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

int main() {
    int H;
    cin >> H;
    vector<int> A(H+1);
    for (int i = 1; i <= H; i++) {
        cin >> A.at(i);
    }
    for (int i = 1; i <= H; i++) {
        cout << "node " << i << ": ";
        cout << "key = " << A.at(i) << ", ";
        if (i/2 <= H and i/2 > 0) cout << "parent key = " << A.at(i/2) << ", ";
        if (2*i <= H) cout << "left key = " << A.at(2*i) << ", ";
        if (2*i + 1 <= H) cout << "right key = " << A.at(2*i + 1) << ", ";
        cout << endl; 
    }

    return 0;
}


Measured memory_bytes: 3100
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
      return Array.new(size1){init}
  else
      return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

N,X,T=get_i
puts (N+X-1)/X*T

Measured memory_bytes: 14404
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = (s); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i = (n); i >= 0; i--)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

template <class Iit>
void vout(const Iit &begin,const Iit &end,ostream &out) {
    for(auto it = begin; it != end; it++) {
        auto tmp = it;
        if (++tmp == end) out << *it << '\n';
        else out << *it << " ";
    }
}

int main(void)
{
    IOS
    const ll LINF = 1LL << 60;
    int A, B, Q;
    cin >> A >> B >> Q;
    vector<ll> a(A), b(B);
    REP(i,A) cin >> a[i];
    REP(i,B) cin >> b[i];

    vector<ll> ab(A,LINF), ba(B,LINF);
    REP(i,A) {
        auto it = lower_bound(ALL(b),a[i]);
        if (it != b.end()) {  // a-b
            ab[i] = min(ab[i],abs(*it-a[i]));
        }
        if (it != b.begin()) { // b-a
            it--;
            ab[i] = min(ab[i],abs(a[i]-*it));
        }
    }
    REP(i,B) {
        auto it = lower_bound(ALL(a),b[i]);
        if (it != a.end()) {  // b-a
            ba[i] = min(ba[i],abs(*it-b[i]));
        }
        if (it != a.begin()) { // a-b
            it--;
            ba[i] = min(ba[i],abs(b[i]-*it));
        }
    }

    //vout(ALL(ab),cerr);
    //vout(ALL(ba),cerr);

    REP(i,Q) {
        ll X; cin >> X;
        ll ans = LINF;

        auto ita = lower_bound(ALL(a),X);
        int aidx = distance(a.begin(),ita);
        if (aidx != A) {
            ans = min(ans,abs(a[aidx]-X) + ab[aidx]);
        }
        if (aidx != 0) {
            ans = min(ans,abs(a[aidx-1]-X) + ab[aidx-1]);
        }

        auto itb = lower_bound(ALL(b),X);
        int bidx = distance(b.begin(),itb);
        if (bidx != B) {
            ans = min(ans,abs(b[bidx]-X) + ba[bidx]);
        }
        if (bidx != 0) {
            ans = min(ans,abs(b[bidx-1]-X) + ba[bidx-1]);
        }

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


    return 0;
}

Measured memory_bytes: 4480
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
#include<assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr int INFI = 1000000007;
const int mod = 1000000007;


int main(){
  int N;
  cin >> N;
  ll A,B;
  A = B = 1;
  for(int i=0; i<N; i++){
    int a,b;
    cin >> a >> b;
    ll n;
    n = max((A+a-1)/a,(B+b-1)/b);
    A = n*a;
    B = n*b;
  }
  cout << A+B << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <fstream>
#include <cmath>
#include <bits/stdc++.h>

using namespace std;


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


Measured memory_bytes: 256
// C - String Transformation

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

string normalize(string s) {
	char c = 'A';
	unordered_map<char, char> table;

	string result = "";
	for (int i=0; i<s.size(); i++) {
		if (! table[s[i]]) {
			table[s[i]] = c;
			result.push_back(c);
			c++;
		} else {
			result.push_back(table[s[i]]);
		}
	}

	return result;
}

int main() {
	string S, T;
	cin >> S >> T;

	S = normalize(S);
	T = normalize(T);

	//cout << S << endl; // **** debug ****
	//cout << T << endl; // **** debug ****

	string ans;
	if (S == T) ans = "Yes";
	else ans = "No";

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 4068
//2018-1-17
//miaomiao
//
#include <bits/stdc++.h>
using namespace std;

#define pb push_back
#define For(i, a, b) for(int i = (a); i <= (int)(b); ++i)
#define Forr(i, a, b) for(int i = (a); i >= (int)(b); --i)

#define N (200000+5)
const int P = 1e9 + 7;

inline int Mul(int a, int b){return 1ll * a * b % P;}

int Pow(int a, int anum){
	int ret = 1;
	while(anum){
		if(anum & 1) ret = Mul(ret, a);
		a = Mul(a, a); anum >>= 1;
	}
	return ret;
}

struct node{
	int p, c, w;
	bool operator <(const node &rhs)const{return w < rhs.w;}
}ball[N];

vector<node> col[N];
int tot[N], tot2[N], fac[N], rfac[N];

int main(){	
	int n, x, y;

	scanf("%d%d%d", &n, &x, &y);
	For(i, 1, n){
		scanf("%d%d", &ball[i].c, &ball[i].w);
		ball[i].p = i;
		
		col[ball[i].c].pb(ball[i]);
	}

	int sw;
	For(i, 1, n) if(col[i].size()>0){
		sort(col[i].begin(), col[i].end());
		tot[i] = 1; sw = col[i][0].w;

		For(j, 1, col[i].size()-1){
			if(sw+col[i][j].w > x) break;
			++tot[i];
		}
	}

	sort(ball+1, ball+n+1);
	sw = ball[1].w; ++tot2[ball[1].c];

	int tw = -1;
	For(i, 2, n) if(ball[i].c != ball[1].c){
		tw = ball[i].w; break;
	}
	
	For(i, 2, n){
		if(sw + ball[i].w > y) continue;
		if(ball[i].c == ball[1].c){
			if(tw == -1 || tw+ball[i].w > y) continue;
		}

		++tot2[ball[i].c];
	}

	int ans, sum = 0;
	
	fac[0] = 1;
	For(i, 1, n){
		fac[i] = Mul(fac[i-1], i);

		if(tot2[i]) tot[i] = max(tot[i], tot2[i]), sum += tot[i];
		else tot[i] = 0;
	}
	rfac[n] = Pow(fac[n], P-2);
	Forr(i, n-1, 0) rfac[i] = Mul(rfac[i+1], i+1);
	
	ans = fac[sum];
	For(i, 1, n) ans = Mul(ans, rfac[tot[i]]);
	printf("%d\n", ans);

	return 0;
}

Measured memory_bytes: 15232
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define int long long
int dp[1000000];
main(){
	int n,w,c,i,j,a,b,mx=-1;
	cin>>n>>w;
	for (i=0;i<=1000000;++i){
		dp[i]=910000000000;
	}
	dp[0]=0;
	for (i=0;i<n;++i){
		cin>>a>>b;
		for (j=100000;j>=b;--j){
			dp[j]=min(dp[j],dp[j-b]+a);
		}
	}
	for(i=0;i<=1000000;++i){
		if (dp[i]<=w){
			mx=max(mx,i);
		}
	}
	cout <<mx;
}

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

#define PI 3.14159265358979323846264338327950L

int main()
{
  long double a,b; // a short b long
  long double h,m; // h hort m minte
  cin >> a >> b >> h >> m;
  
  
  long double clen = (long double)(a * a + b * b) - (long double)(2.0 * a * b) * cos(PI * (h / 6.0 + (m / 360.0) - m / 30.0));
  
  cout << fixed;
  cout << setprecision(20);  
  cout << sqrtl(clen) << endl;
}

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

using namespace std;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}


typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { -1,0, 1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
// #define mp make_pair
//#define endl '\n'

int main() {
  int n, a, b;
  cin >> n >> a >> b;
  cout << min(n*a, b) << endl;

}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

int main() {
	char a[8][8];
	int i,j;
	for(i=0;i<8;i++){
		for(j=0;j<8;j++){
			cin>>a[i][j];
		}
	}
	cout<<90<<endl;
	for(i=0;i<8;i++){
		for(j=0;j<8;j++){
			cout<<a[7-j][i];
		}
		cout<<endl;
	}
	cout<<180<<endl;
	for(i=0;i<8;i++){
		for(j=0;j<8;j++){
			cout<<a[7-i][7-j];
		}
		cout<<endl;
	}
	cout<<270<<endl;
	for(i=0;i<8;i++){
		for(j=0;j<8;j++){
			cout<<a[j][7-i];
		}
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define SHIFT_LEFT(n) (1LL<<((ll)n))
#define SUBS(s,f,t) ((s).substr((f),(t)-(f)))
#define ALL(a) (a).begin(),(a).end()
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;cin>>s;
  ll n = s.size();
  bool fl = true;
  for(int i=0;i<n/2;i++){
    if(s[i] != s[n-i-1])fl = false;
  }
  for(int i=0;i<n/4;i++){

    if(s[i]!=s[n/2-i-1])fl = false;
    if(s[n-i-1]!=s[n/2+i+1])fl = false;
  }
  if(fl)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);    
    char c; cin >> c;
    if('A' <= c && c <= 'Z') {
        cout << 'A' << endl;
    } else {
        cout << 'a' << endl;
    }


    return 0;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define ces(d) cout<<" "<<endl;

int main() {

int Q;
vector<int> L(100000);
vector<int> R(100000);
vector<int> dp(100001);
int max=0;

cin>>Q;

fx(Q){
	cin>>L.at(x)>>R.at(x);
	if(max<R.at(x)){
		max=R.at(x);
	}
}

for(int n=3;n<=max;n+=2){
	bool second=false;
	for(int h=1;h<=sqrt(n);h++){
		if(n%h==0||((n+1)/2)%h==0){
			if(second){
				dp.at(n)--;
				break;
			}else{
				second=true;
				dp.at(n)++;
			}
		}
	}
dp.at(n)+=dp.at(n-2);

}

fx(Q){
	if(L.at(x)-2<0){
		ce(dp.at(R.at(x)));
	}else{
		ce(dp.at(R.at(x))-dp.at(L.at(x)-2));
	}
}


}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
using f80 = __float80;
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
static const int dy[4] = {0,1,0,-1}, dx[4] = {1,0,-1,0};
#define _overload3(_1,_2,_3,name,...) name
#define repi(i,start,end) for(i64 i=(start);i<(end);++i)
#define _rep(i,n) repi(i,0,n)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,start,end) for(i64 i=(start);i>end;--i)
#define pb push_back
#define rng(a) a.begin(),a.end()
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define sz(x) (i64)(x).size()
#define bit(n) (1LL<<(n))
#define fi first
#define se second
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define v(T) vector<T>
#define vv(T) v(v(T))
typedef v(i64) vi;
typedef v(vi) vvi;
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;}

i64 pow_mod(i64 n, i64 k, i64 m){
  i64 r = 1;
  for(;k;k>>=1){
    if(k&1) r=(r*n)%m;
    n=(n*n)%m;
  }
  return r;
}

struct UnionFind {
  vi par;
  vi rank;

  UnionFind(i64 n=1){
    init(n);
  }

  void init(i64 n=1){
    par.resize(n);
    rank.resize(n);
    rep(i,n) par[i] = i, rank[i]=1;
  }

  i64 root(i64 x){
    if(par[x] == x) return x;
    i64 r = root(par[x]);
    return par[x] = r;
  }

  i64 root_rank(i64 x){
    return rank[root(x)];
  }

  bool unite(i64 x, i64 y){
    i64 rx = root(x);
    i64 ry = root(y);
    if(rx==ry) return false;
    par[ry] = rx;
    rank[rx] += rank[ry];
    return true;
  }

  bool same(i64 x, i64 y){
    return root(x) == root(y);
  }
};

vvi g;

void Main()
{
  i64 n,m,k;
  cin >> n >> m >> k;

  UnionFind tree(n);

  vi f(n,1);
  i64 a,b;

  rep(i,m){
    cin >> a >> b;
    a--;b--;
    tree.unite(a,b);
    f[a]++;
    f[b]++;
  }

  rep(i,k){
    cin >> a >> b;
    a--;b--;
    if(tree.same(a,b)){
      f[a]++;
      f[b]++;
    }
  }

  rep(i,n){
    cout << tree.root_rank(i)-f[i];
    if(i!=n-1) cout << " ";
    else cout << endl;
  }

}

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


Measured memory_bytes: 3712
#include<iostream>
#include<string>
#include<map>
#include<vector>
using namespace std;
int main(void){
	string str;
	vector<string> w;
	map<string,int> word;
	unsigned int max=0,length=0;

	while(cin>>str){
		w.push_back(str);
		if(word.find(str) != word.end()){
			word[str]++;//ツ出ツ個サツ嘉アツ青板づーツカツウツδ督ト
		}else{
			word.insert(make_pair(str,1));
		}
	}
	map<string,int>::iterator it;
	for(it=word.begin();it!=word.end();it++){//ツ催頻ツ出ツづーツ仰づ淞づゥ
		if(max<it->second)
			max=it->second;
	}
	for(it=word.begin();it!=word.end();it++){
		if(max==it->second)
			cout<<it->first<<" ";
	}
	for(unsigned int i=0;i<w.size();i++){
		if(length<w[i].size()){
			length=w[i].size();
		}
	}
	for(unsigned int i=0;i<w.size();i++){
		if(length==w[i].size()){
			cout<<w[i]<<endl;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 0
func bitAllSearch(from value: Int) -> [[Int]] {
    (0..<(1<<value)).reduce([[Int]]()) { result, bit in
        result + [(0..<value).reduce([Int]()) {
            if bit & 1<<$1 != 0 {
                return $0 + [$1]
            } else {
                return $0
            }
        }]
    }
}

func character(string: String, of index: Int) -> Character {
    let i = string.index(string.startIndex, offsetBy: index)
    return string[i]
}

let firstLine = readLine()!.split(separator: " ").compactMap { Int($0) }
let h = firstLine[0]
let w = firstLine[1]
let k = firstLine[2]

let chwList = (1...h).map { _ in readLine()! }
let hBitList = bitAllSearch(from: h)
let wBitList = bitAllSearch(from: w)

var result = 0
hBitList.forEach { hBits in
    wBitList.forEach { wBits in
        var total = 0
        hBits.forEach { hBit in
            wBits.forEach { wBit in
                if character(string: chwList[hBit], of: wBit) == "#" {
                    total += 1
                }
            }
        }
        if total == k {
            result += 1
        }
    }
}
print(result)


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


int main()
{
    int t=1;
    //cin>>t;

    while( t-- )
    {
        int a[5];
        int ans;

        for( int i=0 ; i<5 ; i++ )
        {
            cin>>a[i];
            if( a[i]==0 )
                ans=i+1;
        }
        cout<<ans;

    }
    return 0;
}


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

int main() {
  int A, B, C, D, L, R;
  cin >> A >> B >> C >> D;
  L = A + B;
  R = C + D;
  if (L > R) {
    cout << "Left" << endl;
  } else if (L == R) {
    cout << "Balanced" << endl;
  } else {
    cout << "Right" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
// AtCoder Beginner Contest 127 - Problem E: Cell Distance (https://atcoder.jp/contests/abc127/tasks/abc127_e)
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

const int MAX { 200010 };
const ll MOD { 1000000007 };

int xs[MAX], ys[MAX];

ll fast_exp(ll a, ll n)
{
    ll res = 1, base = a;

    while (n)
    {
        if (n & 1)
            res = (res * base) % MOD;

        base = (base * base) % MOD;
        n >>= 1;
    }
            
    return res;
}

ll inv(ll x)
{
    return fast_exp(x, MOD - 2);
}

ll binom(ll N, ll M)
{
    ll n = 1, a = 1, b = 1;

    for (ll i = 1; i <= N; ++i)
        n = (n * i) % MOD;

    for (ll i = 1; i <= (N - M); ++i)
        a = (a * i) % MOD;

    for (ll i = 1; i <= M; ++i)
        b = (b * i) % MOD;

    ll res = (n * inv(a)) % MOD;
    res = (res * inv(b)) % MOD;

    return res;
}

ll solve(ll N, ll M, ll K)
{
    // As distâncias entre as coordenadas x e y são independentes
    memset(xs, 0, sizeof xs);
    memset(ys, 0, sizeof ys);

    // Para um par de pontos P e Q, há (N x M - 2, K - 2) escolhas possíveis para os demais
    // pontos
    ll options = binom(N*M - 2, K - 2), ans = 0;

    // Há (N - d) maneiras de escolher um ponto com coordenada x = xi tal que existe ao menos
    // um ponto com coordenada x = xj e que xi + xj = d
    // Como a coordenada y de ambos pontos é livre, então há (N - d) x M^2 escolhas possíveis
    // para pares de pontos com distância 
    for (int d = 1; d < N; ++d)
    {
        ll qtd = ((N - d) * M) % MOD;
        qtd = (qtd * M) % MOD;
        qtd = (qtd * options) % MOD;
        qtd = (d * qtd) % MOD;

        ans = (ans + qtd) % MOD;
    }

    // O mesmo vale para y, invertendo-se os valores de N e M 
    for (int d = 1; d < M; ++d)
    {
        ll qtd = ((M - d) * N) % MOD;
        qtd = (qtd * N) % MOD;
        qtd = (qtd * options) % MOD;
        qtd = (d * qtd) % MOD;

        ans = (ans + qtd) % MOD;
    }

    return ans;
}

int main()
{
    ios::sync_with_stdio(false);

    ll N, M, K;
    cin >> N >> M >> K;

    auto ans = solve(N, M, K);

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include<string>
using namespace std;
int main(){
    int H,W;
    cin>>H>>W;
    int h,w;
    cin>>h>>w;
    if(H>h&&W>w){
        cout<<H*W-h*W-w*H+h*w;
    }
    else {
        cout<<"0";
    }
}

Measured memory_bytes: 256
from fractions import gcd
n, m = map(int, input().split())
lst = list(map(int, input().split()))

norm = 0
tmp = lst[0]
while tmp%2 == 0:
  tmp = tmp//2
  norm += 1

for i in range(n):
  count = 0
  tmp = lst[i]
  while tmp%2 == 0:
    tmp = tmp//2
    count += 1
  if norm != count:
    print(0)
    exit()
  lst[i] = lst[i]//2
    
lst = sorted(list(set(lst)))

def lcm(a, b): # a, b の最大公約数を求める
  return(a*b//gcd(a, b))

def lcms(List): # list[a[0], a[1], ... , a[n]]の最小公倍数を求める
  if len(List) == 1:
    return List[0]
  ans = lcm(List[0], List[1])
  for i in range(2, len(List)):
    ans = lcm(ans, List[i])
  return ans
    
lcm = lcms(lst)
ans = m//lcm
if ans%2 == 0:
  ans = ans//2
else:
  ans = ans//2 + 1
print(ans)

Measured memory_bytes: 16344
using System;
using System.Collections.Generic;

namespace abc109_b
{
	class Program
	{
		static void Main(string[] args)
		{
			int n = int.Parse(Console.ReadLine());
			List<string> list = new List<string>();
			string s = Console.ReadLine(); list.Add(s);
			bool ret = true;
			for (int i = 1; i < n; i++)
			{
				string x = Console.ReadLine();
				if (s[s.Length - 1] != x[0]) ret = false;
				if (list.Contains(x)) ret = false;
				s = x; list.Add(x);
			}
			Console.WriteLine(ret ? "Yes" : "No");
		}
	}
}

Measured memory_bytes: 13148
n = int(input())
 
def dfs(s):
    if int(s) > n:
        return 0
    if s.count('3') > 0 and s.count('5') > 0 and s.count('7') > 0:
        cnt = 1
    else:
        cnt = 0
    cnt += dfs(s + '3')
    cnt += dfs(s + '5')
    cnt += dfs(s + '7')
    return cnt
 
 
print(dfs('0'))

Measured memory_bytes: 3064
#include<cstdio>
using namespace std;
double dp[301][301][301];
int main(){
    int n,a,x[3]={};
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&a);
        x[a-1]++;
    }
    for(int k=0;k<=x[2];k++){
        for(int j=0;j+k<=x[2]+x[1];j++){
            for(int i=0;i+j+k<=x[2]+x[1]+x[0];i++){
                if(i){
                    dp[i][j][k]+=(double)i/(i+j+k)*dp[i-1][j][k];
                }
                if(j){
                    dp[i][j][k]+=(double)j/(i+j+k)*dp[i+1][j-1][k];
                }
                if(k){
                    dp[i][j][k]+=(double)k/(i+j+k)*dp[i][j+1][k-1];
                }
                if(i||j||k){
                    dp[i][j][k]+=(double)n/(i+j+k);
                }
                //printf("%d %d %d %f\n",i,j,k,dp[i][j][k]);
            }
        }
    }
    printf("%.10f\n",dp[x[0]][x[1]][x[2]]);
}

Measured memory_bytes: 213120
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using ld = long double;
const int INF = 1 << 29;
const ll LINF = 1l << 61;
const ld PI = abs(acos(-1));
#define pq priotity_queue
#define pb push_back
#define mp make_pair
#define rep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define cbuf(buf, init) memset(buf, init, sizeof(buf))

template <class T>
constexpr T modp(T x, T y)
{
    return (y + x % y) % y;
}
template <class T>
constexpr T sq(T x)
{
    return x * x;
}
template <class T>
constexpr double divd(T x, T y)
{
    static_cast<double>(x) / static_cast<double>(y);
}

template <class T>
T nextInput()
{
    T t;
    cin >> t;
    return t;
}

#define netint nextInput<ll>()
#define netstr nextInput<string>()

template <class T>
void print(T&& t)
{
    cout << forward<T&&>(t) << endl;
}

void print(double t) { cout << fixed << setprecision(14) << t << endl; }

//

int main()
{
    //
    ll N = netint;
    int P, W, G, Y;
    P = W = G = Y = 0;
    rep(i, 0, N)
    {
        char ch;
        cin >> ch;
        switch (ch) {
            case 'P':
                P++;
                break;
            case 'W':
                W++;
                break;
            case 'G':
                G++;
                break;
            case 'Y':
                Y++;
                break;
        }
    }

    ll cnt = 0;
    cnt += P ? 1 : 0;
    cnt += W ? 1 : 0;
    cnt += G ? 1 : 0;
    cnt += Y ? 1 : 0;
    if (cnt == 3)
        print("Three");
    else
        print("Four");
}


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

class Main{
	public static void main(String args[]){
		try(Scanner sc=new Scanner(System.in)){
			int n=sc.nextInt();//頂点数
			int inf=100000000;
			int[] d=new int[n+1];//始点からの距離
			int[][] w=new int[n+1][n+1];//各頂点ごとの距離
			Arrays.fill(d, inf);
			for(int i=0; i<n; i++) {
				int u=sc.nextInt();
				int k=sc.nextInt();
				for(int j=0; j<k; j++){
					int v=sc.nextInt();
					int c=sc.nextInt();//辺の重み
					w[u][v]=c;
				}
			}
			d[0]=0;
			for(int t=0; t<n; t++) {
				boolean update=false;
				for(int i=0; i<n; i++) {
					for(int j=0; j<n; j++) {
						if(d[i]<inf && w[i][j]>0) {
							if(d[j]>d[i]+w[i][j]) {
								d[j]=d[i]+w[i][j];
								update=true;
							}
						}
					}
				}
				if(! update) break;
			}
			for(int i=0; i<n; i++) {
				System.out.println(i+" "+d[i]);
			}
		}
	}
}


Measured memory_bytes: 39988
#include<iostream>
#include<vector>
using namespace std;
int main() {
	vector<vector<int>>table;
	int x = 0;
	int y = 0;
	int i = 0;
	while (cin >> x >> y) {
		if (x == 0 && y == 0) {
			break;
		}
		table.resize(i + 1);
		if (y<=x) {
			table[i].push_back(y);
			table[i].push_back(x);
		}
		else {
			table[i].push_back(x);
			table[i].push_back(y);
		}
		i = i + 1;
		
	}
	for (int i = 0;i <table.size();i++) {
		cout << table[i][0] <<" "<< table[i][1] << endl;


	}


}

Measured memory_bytes: 3220
#pragma GCC optimize(3, "Ofast", "inline")
#include <bits/stdc++.h>
#if __cplusplus >= 201103L
#include <chrono>
using namespace std::chrono;
#endif
using namespace std;
#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#ifdef LOCAL
#define prln(x) (cout << #x << ' ' << x << endl)
#define pr(x) (cout << #x << ' ' << x << ' ' )
#define prv(x) (cout << x << ' ')
#else
#define prln(x) 
#define pr(x)
#define prv(x)
#endif
#define clr(x) memset((x), 0, sizeof((x)))
#define clr1(x) memset((x), -1, sizeof((x)))
#define endl "\n"
#define pi acos(-1)
#define rep(i, st, ed) for (int i = (st); i <= (ed); ++i)
#define rep0(i, st, ed) for (int i = (st); i < (ed); ++i)
#define per0(i, st, ed) for (int i = (st); i > ed; --i)
#define per(i, st, ed) for (int i = (st); i >= ed; --i)
#define chmin(a, b) (a = a > b ? b : a)
#define chmax(a, b) (a = a < b ? b : a)
template<class T> void _sf(T &x) {cin >> x;}
void _sf(int &x) {scanf("%d", &x);}
void _sf(ll &x) {scanf("%lld", &x);}
void _sf(double &x) {scanf("%lf", &x);}
void _sf(char &x) {scanf(" %c", &x);}
void _sf(char *x) {scanf("%s", x);}
void sf() {}
template <class T, class...U> void sf(T & head, U&... tail) { _sf(head); sf(tail...);}
template<class T> void _out(const T &x) { cout << x; }
void _out(const int &x) { printf("%d", x); }
void _out(const ll &x) { printf("%lld", x); }
void _out(const double &x) { printf("%.16f", x); }
void _out(const char &x) { putchar(x); }
void _out(const char *x) { printf("%s", x); }
template<class T,class U> void _out(const pair<T,U> &x) {_out(x.F); putchar(' '); _out(x.S);}
template<class T> void _out(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _out(*i++)) if (i != x.cbegin()) putchar(' '); }
void out() {}
template<class T, class... U> void out(const T &head, const U &... tail) { _out(head); putchar(sizeof...(tail) ? ' ' : '\n'); out(tail...); }
const int mod = 1e9 + 7;
const int INF = 0x3f3f3f3f;

int read() {
    int x = 0, f = 1;
    char ch = getchar();
    while (ch < '0' || ch > '9') {
        if (ch == '-') f = -1;
        ch = getchar();
    }
    while (ch >= '0' && ch <= '9') {
        x = x * 10 + ch - '0';
        ch = getchar();
    }
    return x * f;
}


int main(){
    #ifdef LOCAL
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif
    int h, w, n;
    sf(h, w, n);
    int ans = n / max(h, w) + (n % max(h, w) != 0);
    out(ans);
    return 0;
}

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

const int MOD = 1000000007;
const int MAX = 2*1e5;

bool IsPrime(long long n){
  if(n == 1) return false;
  for(long long i = 2; i * i < n; i++){
    if(n%i == 0) return false;
  }
  return true;
}

vector<pair<long long, long long>> PrimeFactorize(long long n){
  vector<pair<long long, long long>> res;
  long long a = 0;
  for(long long i = 2; i * i <= n; i++){
    a = 0;
    if(n%i == 0){
      if(IsPrime(i)){
        while(n % i == 0){
          n /= i;
          a++;
        }
        res.push_back(make_pair(i, a));
    }}}
  if(n!= 1) res.push_back(make_pair(n, 1));
  return res;
}

long long modpow(long long a, long long n, long long mod){
  long long res = 1;
  while(n > 0){
    //nを２進数に分解してビットの立っているところだけ掛け算していく。
    if (n &  1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

// a inverse (mod m)
// a^(-1) = a^(p-2) (mod p)
long long modinv(long long a, long long mod){
  return modpow(a, mod-2, mod);
}

long long Comb(long long n, long long k){
  if(n < k) return 0;
  if(n < 0 || k < 0) return 0;
  // return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
  long long ans = 1;
  for(long long i = 0; i < k; i++){
    ans = ans * (n - i) % MOD;
    ans = ans * modinv(k - i, MOD) % MOD;
  }
  return ans;
}

int main(){
  long long n,m;
  cin >> n >> m;

  vector<pair<long long, long long>> res;
  res = PrimeFactorize(m);

  // CombInit();

  long long ans = 1;
  long long size = res.size();
  for(long long i = 0; i < size; i++){
    long long num = Comb(res[i].second + n - 1, res[i].second);
    // ans = (ans * Comb(res[i].second + n - 1, res[i].second)) % MOD;
    ans = (ans * num) % MOD;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
//ll gcd(ll a,ll b){if(a%b==0)return b;return gcd(b,a%b);}
//ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=ll(1e16)+ll(7);
const ll MOD=1000000007LL;
#define out(a) cout<<fixed<<setprecision((a))
//tie(a,b,c) = make_tuple(10,9,87);
#define pop_(a) __builtin_popcount((a))
ll keta(ll a){ll r=0;while(a){a/=10;r++;}return r;}
ll ketawa(ll a){ll r=0;while(a){r+=a%10;a/=10;}return r;}

vector<ll> enum_div(ll n){//yakusu
  vector<ll> ret;
  for(ll i=1 ; i*i<=n ; ++i){
      if(n%i == 0){
        ret.push_back(i);
        if(i*i!=n)ret.push_back(n/i);
      }
  }
  return ret;
}

int main(){
  ll n,ans=0;
  cin >> n;
  FOR(i,3,n+1){
    if(i%2==0)continue;
    if(enum_div(i).size()==8)ans++;
  } 
  cout << ans << endl;
}


Measured memory_bytes: 256
import sys
import collections

N = int(input())
D = list(map(int,input().split()))

if D[0] != 0:
    print(0)
    sys.exit()
DD = collections.Counter(D)
max_key = max(DD.keys())
result = 1
last_v = 0
for k in range(max_key + 1):
    if not k in DD:
        print(0)
        sys.exit()
    v = DD[k]
    if k == 0:
        if v > 1:
            print(0)
            sys.exit()
        last_v = v
        continue
    result *= last_v ** v
    last_v = v
print(result % 998244353)


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

#define INF 1000000000000
#define int long long

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

    for(int i = 0; i < s.size(); i++) {
        cout << char(((s[i] - 'A') + n) % 26 + 'A');
    }
    cout << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <iomanip>
#include <algorithm>
#include <sstream>
#include <string>
#include <math.h>
#include <set>
#include <deque>
#include <queue>
#include <list>
using namespace std;
typedef long long ll;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int a, b;
    cin >> a >> b;
    int c = b - a;
    c--;
    int ans = 0;
    while(c > 0){
        ans += c;
        c--;
    }
    cout << ans - a << endl;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std; 
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define int long long int
#define ld long double
#define endl "\n"
#define rep(i,a,b) for(int i=a;i<b;i++)
#define reprev(i,a,b) for(int i=b-1;i>=a;i--)
#define all(c) c.begin(),c.end()
#define sz(c) (int)c.size()
#define ff first
#define ss second
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define vin(a,n) vi a(n); rep(i,0,n) cin>>a[i];
#define vout(a) rep(i,0,sz(a)) cout<<a[i]<<" "; cout<<endl;
#define pb push_back
#define mp  make_pair
#define mod 1000000007
#define mod2 998244353
#define inf LLONG_MAX
#define pi 3.1415926535897932384626
#define tr(container, it) \
for(auto it = container.begin(); it != container.end(); it++)

int power(int x, unsigned int y, int p)  
{  
    int res = 1;     // Initialize result  
  
    x = x % p; // Update x if it is more than or  
                // equal to p 
   
    if (x == 0) return 0; // In case x is divisible by p; 
  
    while (y > 0)  
    {  
        // If y is odd, multiply x with result  
        if (y & 1)  
            res = (res*x) % p;  
  
        // y must be even now  
        y = y>>1; // y = y/2  
        x = (x*x) % p;  
    }  
    return res;  
}

signed main()
{
    IOS
    int n,k;
    cin>>n>>k;
    vin(p,n);
    sort(all(p));
    int ans=0;
    rep(i,0,k) ans+=p[i];
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
#define N      510
// #define inf    0x7f7f7f7f
#define int    long long
using namespace std;
int a[N][N] = {};
int read()
{
    int  s = 0, w = 1;
    char c = getchar();
    while ((c < '0' || c > '9') && c != '-')
        c = getchar();
    if (c == '-')
        c = getchar(), w = -1;
    while (c <= '9' && c >= '0')
        s = (s << 3) + (s << 1) + c - '0', c = getchar();
    return s * w;
}
int n;
int b[N][N] = {}, c[N][N] = {};
int f[N][N] = {};
signed main()
{
    n = read();
    for (int i = 1; i <= n; ++i)
        for (int j = 1; j <= n; ++j)
            if (i != j)
                a[i][j] = read();
    for (int i = 1; i <= n; ++i)
        for (int j = n; j >= i + 1; --j)
        {
            b[i][j] = b[i][j + 1];
            for (int k = 1; k <= i; ++k)
                b[i][j] += a[j][k];
        }
    for (int i = 1; i <= n; ++i)
        for (int j = i + 1; j <= n + 1; ++j)
        {
            c[i][j] = c[i][j - 1];
            for (int k = i; k <= j - 1; ++k)
                c[i][j] += a[k][j];
        }
    memset(f, 0x7f, sizeof(f));
    f[0][0] = 0;
    for (int i = 0; i <= n; ++i)
        for (int j = i; j <= n; ++j)
            if (f[i][j] < 1e18)
                for (int k = j + 1; k <= n + 1; ++k)
                    f[j][k] = min(f[j][k], f[i][j] + c[j + 1][k] + b[j][k + 1] - b[i][k + 1]);
    int minn = 1e18;
    for (int i = 0; i <= n; ++i)
        minn = min(minn, f[i][n + 1]);
    printf("%lld\n", minn);
    return 0;
}


Measured memory_bytes: 8320
#include<bits/stdc++.h>
#define db double
#define ll long long
#define uint unsigned int
#define ull unsigned ll
#define fir first
#define sec second
#define pb push_back
#define pll pair<ll,ll>
#define pdb pair<db,db>
#define pii pair<int,int>
#define sc(x) scanf("%d",&(x))
#define sz(x) (int)(x).size()
#define ms(x) memset((x),0,sizeof(x));
#define all(x) (x).begin(), (x).end()
#define er(x) cerr<<(x)<<" ";
#define err(x) cerr<<#x<<": "<<(x)<<" ";
#define errn cerr<<endl;
using namespace std;
#define mod 1000000007
const db pi=acos(-1.0);
template <class T> void R(T &x) { cin>>x; }
void R(int &x) { scanf("%d",&x); }
void R(ll &x) { scanf("%lld",&x); }
void R(double &x) { scanf("%lf",&x); }
void R(char &x) { scanf(" %c",&x); }
void R(char *x) { scanf("%s",x); }
ll _pow(ll a,ll b) { ll res=1ll; while(b){ if(b&1)
res=res*a%mod; a=a*a%mod; b>>=1; } return res; }
///_____________________________________________

#define mxn 505

struct node {
    int a,b,c,d;
    void out() {
        printf("%d %d %d %d\n",a,b,c,d);
    }
};

int n,m;
vector <node> ans;
int a[mxn][mxn];

int main()
{
    while(~sc(n))
    {
        R(m);
        ans.clear();
        for(int i=1;i<=n;i++) {
            for(int j=1;j<=m;j++) {
                R(a[i][j]);
            }
        }
        for(int i=1;i<=n;i++) {
            for(int j=1;j<m;j++) {
                if(a[i][j]%2) {
                    ans.pb(node{i,j,i,j+1});
                    a[i][j+1]++;
                }
            }
        }
        for(int i=1;i<n;i++) {
            if(a[i][m]%2) {
                ans.pb(node{i,m,i+1,m});
                a[i+1][m]++;
            }
        }
        printf("%d\n",sz(ans));
        for(int i=0;i<sz(ans);i++) ans[i].out();
    }
    return 0;
}




Measured memory_bytes: 5232