akhauriyash/Code-Regression huggingface dataset:
//Coded by Abhijay Mitra
#include <iostream>
#include <stdlib.h>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <numeric>
#include <vector>
#include <iterator> 
#include <map>
#include <set>
#include <climits>
#include <queue>
#include <cmath>
#include <stack>
#include <cctype>
#include <bitset>
// #include <bits/stdc++.h>
#define double long double
#define int long long int
#define ll int
#define ibs ios_base::sync_with_stdio(false)
#define cti cin.tie(0)
#define bp __builtin_popcount
#define pb emplace_back
#define koto_memory(a) cout<<(sizeof(a)/1048576.0)<<" MB";
#define res(v) sort(all(v)),v.erase(unique(all(v)), v.end());
#define timer cerr << "Time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec "<<endl;
#define deb(x) cout<<endl<<"["<<#x<<" = "<<x<<"]"<<endl;
using vi = std::vector<int>;
using vvi = std::vector<vi>;
using pii = std::pair<int,int>;
using vpii = std::vector<pii>;
using vvpii = std::vector<vpii>;
#define mp         make_pair
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define per(i,b,a) for (int i = b; i >= a; i--)
#define all(x)     x.begin(), x.end()
using namespace std;
const int N=2e6+10;
const int inf = /*0x3f3f3f3f*/1e18+10;
// const ll M = 998244353 ; // Mulo
// const int M = 1e9+7 ; // Mulo
const double Pi = 3.14159265;
#define F first
#define S second
int parent[N],ind[N],n,m,x,y;
int find_set(int v) {
    if (v == parent[v])
        return v;
    return parent[v] = find_set(parent[v]);
}
void make_set(int v) {
    parent[v] = v;
    ind[v] = rand();
}
void union_sets(int a, int b) {
    a = find_set(a);
    b = find_set(b);
    if (a != b) {
        if (ind[a] < ind[b])
            swap(a, b);
        parent[b] = a;
    }
}
set<int>s;
void solve(){
  cin>>n;rep(i,1,n)make_set(i);
  cin>>m;
  rep(i,1,m){
    cin>>x>>y;
    union_sets(x,y);
  }
  rep(i,1,n){
    s.insert(find_set(i));
  }
  cout<<s.size()-1;
}
int32_t main()
{
  ibs;cti;
  solve();return 0;
  int xx=0;
  int t;cin>>t;while(t--){/*xx++;cout<<"Case "<<xx<<": "*/;solve();cout<<endl;}
  return 0;
}

Measured memory_bytes: 8892
#include<stdio.h>
#include<stdlib.h>

#define NEW(p,n){p=malloc((n)*sizeof(p[0]));if(p==NULL){printf("not enough memory\n");exit(1);};}
//pの型の変数n個の要素分のメモリを確保し、そのアドレスをpに代入するマクロ

#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))

//昇順
int asc(const void* a, const void* b){
    return *(int*)a-*(int*)b;
}

//降順
int desc(const void* a, const void* b){
    return *(int*)b-*(int*)a;
}

int main(void){
    int N,K;
    scanf("%d%d",&N,&K);

    //h[0]~h[N-1]に格納する
    int* h;
    NEW(h,N);
    for(int i=0;i<N;i++){
        scanf("%d",&h[i]);
    }
    qsort(h,N,sizeof(int),asc);

    int ans=h[K-1]-h[0];
    for(int i=0;i<=(N-K);i++){
        ans=MIN(ans,h[K-1+i]-h[i]);
    }
    printf("%d\n",ans);

    return 0;
}

Measured memory_bytes: 892
open System

let N = stdin.ReadLine() |> int

let A = Array.zeroCreate<int> N
let xy = Array.zeroCreate<int [] []> N

for i in [ 0..N - 1 ] do
    A.[i] <- stdin.ReadLine() |> int
    xy.[i] <- Array.zeroCreate<int []> A.[i]
    for j in [ 0..A.[i] - 1 ] do
        xy.[i].[j] <- stdin.ReadLine().Split() |> Array.map int

let mutable result = 0

for i in [ (pown 2 N) - 1..-1..0 ] do
    let mutable flag = true
    let s = Convert.ToString(i, 2).PadLeft(N, '0')

    let sl =
        s.ToCharArray()
        |> Array.filter (fun x -> x = '1')
        |> Array.length
    for j in [ 0..N - 1 ] do
        if s.[j] <> '0' then
            for k in [ 0..A.[j] - 1 ] do
                if not flag || xy.[j].[k].[1] <> int s.[xy.[j].[k].[0] - 1] - int '0' then flag <- false
    if flag && sl > result then result <- sl

result |> stdout.WriteLine


Measured memory_bytes: 18772
import java.util.Scanner;

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

        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int m = Integer.parseInt(sc.next());
        int x = Integer.parseInt(sc.next());
        int[] ary = new int[n];
        int st = 0;
        int gl = 0;

        for (int i = 0; i < m; i++) {
            int y = Integer.parseInt(sc.next());
            ary[y] = 1;
        }
        for (int i = x; i < n; i++) {
            gl += ary[i];
        }
        for (int i = x; 0 < i; i--) {
            st += ary[i];
        }
        System.out.println(Math.min(st,gl));
    }
}


Measured memory_bytes: 23380
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include<vector>
#include<iomanip>
#include<map>
#include <queue>
#include<cmath>
#include<cstdio>
#include<iomanip>
#include<set>
#include <bits/stdc++.h>
 
using namespace std;
using ll = long long int;
 
#define REP(i,n) for(ll i=0;i<(ll)(n);i++) //REP(i, 5) cout<<i;
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define MOD 1000000007 //10^9+7
//#define MOD 1
 
ll gcd(ll a, ll b) {
  ll tmp;
  if ( b > a) {
    tmp = a;
    a = b;
    b = tmp;
  }
  while (a % b !=0) {
    tmp = b;
    b = a % b;
    a = tmp;
  }
  return b;
}
 
const int MAX = 2000;

long long fac[MAX], finv[MAX], inv[MAX];
 
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


void sosuu(ll n, vector<ll> &v){

  vector<ll> num(n, 0);

  FOR(i, 1, sqrt(n)){
    if(num[i]==0){
      FOR(j, 0, n/i){
        num[i+(j*i)] = 1;
      }
    }
  }
  REP(i, n){
    if(num[i]==0) v.push_back(i+1);
  }
}

ll GetDigit(ll num){
    ll digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}


int main(void){
 
  ll n;
  cin>>n;
  vector<pair<ll, ll>> v(5);
  REP(i, 5){
    ll x;
    cin>>x;
    v[i] = make_pair(x, i);
  }

  sort(v.begin(), v.end());
  ll min = v[0].first;
  ll index = v[0].second;

  // if(min>=n){
  //   cout<<'5'<<endl;
  //   return 0;
  // }
  cout<<index + (ll)ceil((double)n/(double)min)+(5-index-1)<<endl;


  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#define rep(i,n) for (int i = 0; i < n; ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int N; cin >> N;
  int ans = 0;
  for (int i = 1; i <= N; ++i) {
    if (i%2==0) continue;
    int temp = 0;
    for (int j = 1; j <= i; ++j) {
      if (i%j==0) ++temp;
    }
    if (temp==8) ++ans;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3164
def resolve():
    A, B, C, D, E, F = list(map(int, input().split()))
    target = 100*E/(100+E)
    result_con = -float("inf")
    result_all = 0
    result_suger = 0
    for i in range(31):
        for j in range(31):
            for k in range(101):
                for l in range(101):
                    total = 100*A*i + 100*B*j + C*k + D*l
                    suger = C*k + D*l
                    if total == 0:
                        continue
                    if total - suger == 0:
                        break
                    if total > F:
                        break
                    con = 100*suger/total
                    if con > target:
                        break
                    if result_con < con:
                        result_con = con
                        result_all = total
                        result_suger = suger
    print("{} {}".format(result_all, result_suger))


if '__main__' == __name__:
    resolve()

Measured memory_bytes: 40176
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<map>
#include<algorithm>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
int main(void){
    int n,a,b;
    cin>>n;
    a=n;
    int sum=0;
    while(n>0){
        int c;
        c=n%10;
        sum+=c;
        n/=10;
    }
    if(a%sum==0) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
import networkx as nx

N = int(input())
ABC = [list(map(int, input().split())) for _ in range(N - 1)]
Q, K = map(int, input().split())
XY = [list(map(int, input().split())) for _ in range(Q)]

G = nx.Graph()

for a, b, c in ABC:
    G.add_edge(a - 1, b - 1, weight=c)

# pred, dist = nx.dijkstra_predecessor_and_distance(G, K - 1)
dist = nx.shortest_path_length(G, K - 1, weight="weight", method="bellman-ford")

for x, y in XY:
    print(dist[x - 1] + dist[y - 1])



Measured memory_bytes: 221264
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

#define MOD 1000000007
#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 ALL(a) a.begin(), a.end()

int N;
string s;

bool check(bool sheep1, bool sheep2)
{
  vector<bool> sheep(N, false);
  sheep[0] = sheep1;
  sheep[1] = sheep2;
  for (int i = 2; i < N; i++)
  {
    if ((sheep[i - 1] && s[i - 1] == 'o') || (!sheep[i - 1] && s[i - 1] == 'x'))
      sheep[i] = sheep[i - 2];
    else if ((sheep[i - 1] && s[i - 1] == 'x') || (!sheep[i - 1] && s[i - 1] == 'o'))
      sheep[i] = !sheep[i - 2];
  }
  bool ok = false;
  bool check1, check2;
  if ((sheep[N - 1] && s[N - 1] == 'o') || (!sheep[N - 1] && s[N - 1] == 'x'))
    check1 = sheep[N - 2];
  else if ((sheep[N - 1] && s[N - 1] == 'x') || (!sheep[N - 1] && s[N - 1] == 'o'))
    check1 = !sheep[N - 2];
  if ((sheep[0] && s[0] == 'o') || (!sheep[0] && s[0] == 'x'))
    check2 = sheep[N - 1];
  else if ((sheep[0] && s[0] == 'x') || (!sheep[0] && s[0] == 'o'))
    check2 = !sheep[N - 1];
  if (check1 == sheep[0] && check2 == sheep[1])
    ok = true;
  if (ok)
  {
    REP(i, N)
    cout << (sheep[i] ? "S" : "W");
    cout << '\n';
    return true;
  }
  return false;
}

int main()
{
  cin >> N >> s;
  if (check(true, true))
    return 0;
  if (check(true, false))
    return 0;
  if (check(false, true))
    return 0;
  if (check(false, false))
    return 0;
  cout << -1 << endl;
  return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main() {
	int a, b, c; cin >> a >> b >> c;
	if(a==b && b==c){
		cout << 0 << endl;
		return 0;
	}else{
		int x = max(max(a,b),c);
		int n = (x-a)+(x-b)+(x-c);
		if(n%2==0){
			cout << n/2 << endl;
			return 0;
		}else{
			cout << (n+3)/2 << endl;
			return 0;
		}

	}
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner

fun main(args:Array<String>){
    val scanner=Scanner(System.`in`)

    val n=scanner.nextInt()
    val d=scanner.nextInt()
    var a= IntArray(n)
    var b=IntArray(n)

    for (i in 0 until n){
        a[i]=scanner.nextInt()
    }

    b[0]=d-a[0]
    if (b[0]<0) b[0]=-b[0]

    if (n>=2) {
        for (i in 1 until n) {
            b[i] = a[i] - a[i - 1]
            if (b[i] < 0) b[i] = -b[i]
        }
    }

    var sa=b[0]

    if (n>=2) {
        for (i in 1 until n) {
            sa = kou(sa, b[i])
        }
    }

   println(sa)
}

fun kou(n:Int,m:Int):Int{
    var t:Int
    var a=n
    var b=m
    if (m>n){
        a=m
        b=n
    }
    t=a%b
    while (t!=0){
        a=b
        b=t
        t=a%b
    }
    return b
}

Measured memory_bytes: 53288
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
#define int long long
#define INF 1e18
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<"\n";}
typedef long long ll;


signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int h,w,m;
    cin>>h>>w>>m;
    vector<vector<int>>vh(h,vector<int>());
    vector<vector<int>>vw(w,vector<int>());
    map<pair<int,int>,bool>mp;
    vector<int>x(m),y(m);
    for (int i = 0; i < m; i++)
    {
        int h,w;
        cin>>h>>w;
        h--,w--;
        x[i]=h;
        y[i]=w;
        mp[{h,w}]=true;
        vh[h].push_back(w);
        vw[w].push_back(h);
    }
    vector<int>row(h), c(w);
    for (int i = 0; i < h; i++)
    {
        row[i]=vh[i].size();

    }
    for (int i = 0; i < w; i++)
    {
        c[i]=vw[i].size();
    }
    int maxr=0,maxc=0;
    for (int i = 0; i < h; i++)
    {
        chmax(maxr,row[i]);
    }
    for (int i = 0; i < w; i++)
    {
        chmax(maxc, c[i]);
    }
    set<int>ar,ac;
    for (int i = 0; i < h; i++)
    {
       if(row[i]==maxr) ar.insert(i); 
    }
    for (int i = 0; i < w; i++)
    {
        if(c[i]==maxc) ac.insert(i);
    }
    int cnt=0;
    for (int i = 0; i < m; i++)
    {
        if(ar.find(x[i])!=ar.end()  && ac.find(y[i]) !=ac.end()){
            cnt++;
        }
    }
    if(ar.size() * ac.size() == cnt){
        cout<<maxr+maxc-1<<endl;
    }
    else{
        cout<<maxr+maxc<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 92408
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>
#include <cstring>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
#include <stack>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
#define P pair<ll, ll>

/* ---------- Constants  */
const double PI = 3.141592653589793238462643383279;
const ll MOD = 1e9 + 7;
const int INF = 1LL << 55;

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */
signed main() {
    string S, T;
    cin >> S >> T;
    int Q;
    cin >> Q;

    auto N = S.size();
    auto M = T.size();

    vector<int> s(N);
    vector<int> t(M);
    for (int i = 0; i < N; i++) {
        s[i] = S[i] == 'A' ? 1 : 2;
    }
    for (int i = 0; i < M; i++) {
        t[i] = T[i] == 'A' ? 1 : 2;
    }

    vector<int> s_sum(N + 1, 0);
    vector<int> t_sum(N + 1, 0);
    for (int i = 1; i <= N; i++) {
        s_sum[i] = s_sum[i - 1] + s[i - 1];
    }
    for (int i = 1; i <= M; i++) {
        t_sum[i] = t_sum[i - 1] + t[i - 1];
    }

    for (int i = 0; i < Q; i++) {
        int a, b, c, d;
        cin >> a >> b >> c >> d;

        if (abs((s_sum[b] - s_sum[a - 1]) - (t_sum[d] - t_sum[c - 1])) % 3 == 0) {
            cout << "YES" << endl;
        } else {
            cout << "NO" << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 4096
A,B,C,X=4.times.map{gets.to_i}
count=0

0.upto(A) do |a|
  0.upto(B) do |b|
    0.upto(C) do |c|
      count+=1 if 500*a+100*b+50*c == X
      break if 500*a+100*b+50*c >= X
    end
    break if 500*a+100*b >= X
  end
  break if 500*a >= X
end
p count

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
using namespace std;
typedef tree<pair<int,int>,null_type,less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update> oset;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
	*this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
using ll = long long;

void test_case(){
	ll n,q,x; cin >> n;
	map<ll,ll> hash;
	ll sum = 0;
	for(ll i = 0 ; i < n ; i++){
		cin >> x;
		hash[x]++;
		sum+=x;
	}
	cin >> q;
	while(q--){
		ll b , c;
		cin >> b >> c;
		sum = sum-(b*hash[b]);
		sum = sum +(c*hash[b]);
		hash[c] += hash[b];
		hash[b] = 0;
		cout<<sum<<"\n";
	}
}
 
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int T=1;
	//~ cin >> T;
	while(T--){
		test_case();
	}
	return 0;
}


Measured memory_bytes: 9580
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define equals(a,b) (fabs((a)-(b)) < EPS)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

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; }

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

template <typename T>
void print_array(const T &ary, int size){
    REP(i,size){
        cout << ary[i] << " ";
    }
    cout << endl;
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;
const double EPS = (1e-10);

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(12);
    int N,K; cin >>N>>K;
    VI cnt(N);
    REP(i,K){
        int d; cin >> d;
        REP(j,d){
            int t; cin >> t;
            t--;
            cnt[t]++;
        }

    }
    int ans = 0;
    REP(i,N){
        if(cnt[i] == 0) ans++;
    }
    cout << ans << endl;

}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll;
typedef pair<int, int> pair;
const int inf = 1000000000; //10^9
const ll inff = 1000000000000000000; //10^18

ll f(ll a) {
    ll aa = a, cou = 0;
    while(aa > 0) {
        cou++;
        aa /= 10; 
    }
    return cou;
}

int main(){
    ll n;
    cin >> n;
    ll ans = 1e9;

    for(ll a = 1; a * a <= n; a++) {
        if(n%a != 0) continue;
        ll b = n/a;
        ll k = max(f(a), f(b));
        ans = min(ans, k);
    }

    cout << ans << endl;

    return 0;
}

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

using namespace std;

int main()
{
    int A, B, C;
    cin >> A >> B >> C;
    if (A == B && A != C)
    {
        cout << "Yes" << endl;
    }
    else if (A == C && A != B)
    {
        cout << "Yes" << endl;
    }
    else if (A != B && B == C)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF 1145141919364364
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}

int kai(int x) {
	if (x == 1)return 1;
	return kai(x - 1)*x%mod;
}

int mod_pow(int x, int y, int moder) {
	int res = 1;
	while (y > 0) {
		if (y & 1)res = res * x%moder;
		x = x * x%moder;
		y >>= 1;
	}
	return res;
}

int comb(int x, int y) {
	if (y > x)return 0;
	if (x == y)return 1;
	return kai(x)* mod_pow(kai(x - y), mod - 2, mod) % mod * mod_pow(kai(y), mod - 2, mod) % mod;
}

int n;
int cnt[101];
int a2, a4, a14, a24, a74;

signed main() {
	cin >> n;
	for (int i = 2; i <= n; i++) {
		int k = i;
		for (int j = 2; j <= n; j++) {
			while (k%j == 0) {
				cnt[j]++;
				k /= j;
			}
		}
	}
	for (int i = 2; i <= n; i++) {
		if (74 <= cnt[i])a74++;
		if (24 <= cnt[i])a24++;
		if (14 <= cnt[i])a14++;
		if (4 <= cnt[i])a4++;
		if (2 <= cnt[i])a2++;
	}
	cout << a74 + a24 * (a2 - 1) + a14 * (a4 - 1) + a4 * (a4 - 1)*(a2 - 2) / 2 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ins insert
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
ll modfac(ll a){
    ll ans=1;
    while(a>1){
        ans*=a;
        ans%=1000000007;
        a--;
    }
    return ans;
}
ll modinv(ll a,ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}
struct UnionFind {
    vector<int> par;
    
    UnionFind(int n) : par(n, -1) {}

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    bool same(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y);
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    int size(int x) {
        return -par[root(x)];
    }
};
ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main(){
    ll n,h;cin >> n >>h;
    vl a(n),s(n);
    rep(i,n){
        cin >> a[i] >> s[i];
    }
    sort(all(a));
    sort(all(s));
    reverse(all(a));
    reverse(all(s));
    ll atk=0,x=0,ans=0;
    while(atk<h){
        if(s[x]>a[0]){
            atk+=s[x];
            x++;
            ans++;
            continue;
        }
        else{
            ans+=(h-atk+a[0]-1)/a[0];
            break;
        }
    }
    cout << ans <<endl;
}


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

int main() {
  int N;
  cin >> N;
  
  cout << ceil(N/2.0) << endl;
  
  return 0;
}


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

using namespace std;
const int size = 2e5 + 7;
int arr[size];
int dp[size];
int n, k;



int solve(int N){
	if(N < 0) return 0;
	if(N == 0) return 0;
	if(dp[N] != -1) return dp[N];

	dp[N] = 0;
	for(int x=0;x<n;x++){
		if(N-arr[x] >= 0 && solve(N - arr[x]) == 0) dp[N] = 1;
		// else dp[i][N] = dp[i][N] | solve(N - arr[x], 1 - i);
	}
	return dp[N];
}

int main(){
	cin>>n>>k;
	// memset(dp, 0, sizeof(dp));
	for(int x=0;x<size;x++) dp[x] = -1;
	// dp[0][0] = false;
	// dp[]

	for(int x=0;x<n;x++){
		scanf("%d",&arr[x]);
	}
	// for(int x=0;x<n;x++) cout<<arr[x]<<" ";
	if(solve(k) == 1){
		cout<<"First";
	} else cout<<"Second";
	return 0;
}

Measured memory_bytes: 5760
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
#define long long long 
typedef pair<long,long> pii;
//dilkstra法の辺のデータ生成
vector<vector<pii>> makedata(long v,long e){
    vector<vector<pii>> ans(v+1);
    long a,b,c;
    for(int i = 0;i<e;i++){
        cin >> a >> b >> c;//a->bへcost c の辺
        ans[a].push_back(make_pair(b,c));
        ans[b].push_back(make_pair(a,c));
    }
    return ans;
}
//aを始点とする、v頂点e辺の全ての点に対する最短経路(dijkstra法)
vector<long> dijkstra(long v, long e,long a){
    const long INF = 1e15;
    vector<vector<pii>> edge=makedata(v,e);// first:B second:cost
    priority_queue<pii,vector<pii>,greater<pii>> que;//first:distance second:A
    vector<long> dist(v+1,INF);
    dist[a] = 0;
    que.push(make_pair(0,a));
    while(!que.empty()){
        pii pr = que.top();
        que.pop();
        long dis = pr.first;
        long ver = pr.second;
        if(dis>dist[ver]) continue;
        for(int i = 0;i<edge[ver].size();i++){
            if(dist[edge[ver][i].first] > dist[ver]+edge[ver][i].second){
                que.push(make_pair(dist[ver]+edge[ver][i].second,edge[ver][i].first));
                dist[edge[ver][i].first]=dist[ver]+edge[ver][i].second;
            }
        }
    }
    return dist;
}
int main(){
    long n;
    cin >> n;
    vector<long> distance = dijkstra(n,n-1,1);
    for(int i = 1;i<=n;i++){
        cout << distance[i]%2 << endl;
    }
}

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

int main(){
    string a,b;
    cin >> a >> b;
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    reverse(b.begin(), b.end());
    if(a < b){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#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 < (n); ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
//cout << fixed << setprecision(10);

int main () {
  ll n, k, s;
  cin >> n >> k >> s;

  /*if (n == 1) {
    if (k == 0) cout << (s-1 >= 1 ? s-1 : s+1) << endl;
    else cout << s << endl;
    return 0;
  }*/

  vector<ll> ans(n);
  rep(i,n) {
    if (i <= k-1) ans[i] = s;
    else ans[i] = (s == (ll)1e9 ? (ll)1e9-1 : (ll)1e9);
  }

  showv(ans);
  return 0;
}

Measured memory_bytes: 2048
import math
a, b, x = map(int, input().split())

volume = a**2*b

# 45度のとき
# a^2*b = 2*x
if volume > 2*x :
  side = 2*x/(a*b)
  print(math.degrees(math.atan(b/side)))
else :
  side = (2/(a**2))*(volume-x)
  print(math.degrees(math.atan(side/a)))

Measured memory_bytes: 3060
import java.util.*;

public class Main{
   public static void main(String[] args) {
	  Scanner sc =new Scanner(System.in);
   boolean []nu=new boolean[30];
   for(int i=0;i<28;i++){
   int n=sc.nextInt()-1;
   nu[n]=true;
   }
   for(int i=0;i<30;i++){
	   if(nu[i]==false)System.out.println(i+1);
	   }
 }
}

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

int N, A[200009], B[200009];

int main() {
	cin >> N;
	for (int i = 1; i <= N; i++) { cin >> A[i]; B[A[i]] = i; }
	int s = 0, maxn = 1;
	for (int i = 1; i <= N - 1; i++) {
		if (B[i] > B[i + 1]) s = i;
		maxn = max(maxn, i - s + 1);
	}
	cout << N - maxn << endl;
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
typedef pair<double,int>Q;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int main(){
	int n,a;cin>>n>>a; ll ret = 1e18;
	rep(i,1<<n){
		ll cur=1;
		rep(j,n){
			if(((i>>j)&1)) cur*=2;
			else cur+=a;
		}
		ret=min(ret,cur);
	}
	cout<<ret<<endl;
}

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

int main() {
  int m,d,count;
  cin >> m >> d;
  for(int i=22;i<=d;i++){
    if(!(i/10==1||i%10==1)){
      int n = (i/10)*(i%10);
      if(n<=m&&n!=0){
        count++;
      }
    }
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 256
// ACLBC-C.cpp

#include <iostream>
#include <atcoder/dsu> // 無向グラフ DSU  Union-Find
using namespace std;
using namespace atcoder;
#define rep(i,n) for(int i=0;i<(n);++i)
using ll = long long;
using P = pair<int, int>;

int main()
{
    int n,m;
    cin >> n>>m;
    dsu d(n); // Union-Find
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        --a;
        --b;
        d.merge(a, b); // 点を追加する
    }
    int cnt = 0;
    //rep(i, n) if (d.leader(i) == i) cnt++;
    cnt = d.groups().size();
    int ans = cnt - 1;
    cout << ans << endl;
}


Measured memory_bytes: 8160
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define rrep(i, a, b) for (int i = (a); i < (b); ++i)
#define PI acos(-1)
#define pcnt __builtin_popcountll
#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
#define fi first
#define se second

using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using LP = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using tl = tuple<ll, ll, ll>;

template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) {if (a > b) { a = b; return true; } return false; }

ll INF = 1001001001;
ll LINF = 1001001001001001001ll;

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

    ll n; cin>>n;
    n--;
    vl dig;
    while (n >= 0) {
        dig.push_back(n % 26);
        n /= 26;
        n--;
    }
    reverse(rng(dig));
    for (auto a : dig) cout<<char('a' + a);
}

Measured memory_bytes: 3560
#include <bits/stdc++.h>
using namespace std;
int a[100010];
int main()
{
    int n;

    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        scanf("%d", &a[i]);
    }
    sort(a, a + n);
    int ans = 0, s = 1;
    for (int i = 1; i < n; i++) {
        if (a[i] == a[i - 1]) {
            s++;
        } else {
            if (s & 1) ans++;
            s = 1;
        }
    }
    if (s & 1) ans++;
    printf("%d\n", ans);
}


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

using namespace std;

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

    int digit1 = n % 10;

    string s;
    switch (digit1)
    {
    case 0:
        s = "pon";
        break;
    case 1:
        s = "pon";
        break;
    case 2:
        s = "hon";
        break;
    case 3:
        s = "bon";
        break;
    case 4:
        s = "hon";
        break;
    case 5:
        s = "hon";
        break;
    case 6:
        s = "pon";
        break;
    case 7:
        s = "hon";
        break;
    case 8:
        s = "pon";
        break;
    case 9:
        s = "hon";
        break;
    default:
        break;
    }
    cout << s << endl;
}

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

int main()
{
	int N,M;
	cin>>N>>M;
	int a=N-1;
	int b=N*a/2;
	int c=M-1;
	int d=M*c/2;
	cout<<b+d<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.lang.Math;
 
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    int H = sc.nextInt();
    int M = sc.nextInt();
    double s;

    
    double sA = 30 * H + 0.5 * M;
    double sB = 6 * M;
    
    if(sA <= sB) {
     s = sB - sA;
    } else {
     s = sA - sB;
    }
    
    double ans2 = A*A + B*B - 2*A*B*Math.cos(Math.toRadians(s));
    System.out.println(Math.sqrt(ans2));
  }
}

Measured memory_bytes: 35816
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 2000000000000000000

int N;
vector<string> S;
vector<long long> C;

long long get(int f,int ind,int sz){
	//cout<<f<<','<<ind<<','<<sz<<endl;
	static vector visited(vector(2,vector(51,vector(21,false))));
	static vector memo(vector(2,vector(51,vector(21,Inf))));
	if(visited[f][ind][sz])return memo[f][ind][sz];
	visited[f][ind][sz] = true;
	
	long long ret = Inf;
	
	for(int i=0;i<N;i++){
		string s,t;
		int sid,tid;
		if(f==0){
			s = S[i];
			t = S[ind].substr(0,sz);
			sid = i;
			tid = ind;
		}
		else{
			s = S[ind].substr(S[ind].size()-sz);
			t = S[i];
			sid = ind;
			tid = i;
		}
		
		while(true){
			if(s.size()==0||t.size()==0)break;
			if(s[0]==t.back()){
				s.erase(s.begin());
				t.pop_back();
			}
			else break;
		}
		//cout<<s<<','<<t<<endl;
		if(s.size()>0&&t.size()>0)continue;
		if(s.size()==0&&t.size()==0){
			ret = min(ret,C[i]);
		}
		else if(s.size()==0){
			string x(t.rbegin(),t.rend());
			if(x==t)ret = min(ret,C[i]);
			else ret = min(ret,C[i]+get(0,tid,t.size()));
		}
		else{
			string x(s.rbegin(),s.rend());
			if(x==s)ret = min(ret,C[i]);
			else ret = min(ret,C[i] + get(1,sid,s.size()));
		}
	}
	memo[f][ind][sz] = ret;
	return ret;
	
	
}

int main(){
	
	cin>>N;
	
	S.resize(N);
	C.resize(N);
	
	for(int i=0;i<N;i++)cin>>S[i]>>C[i];
	
	long long ans = Inf;
	
	for(int i=0;i<N;i++){
		string t(S[i].rbegin(),S[i].rend());
		if(S[i]==t)ans = min(ans,C[i]);
		ans = min(ans,get(0,i,S[i].size())+C[i]);
	}
	
	if(ans==Inf)cout<<-1<<endl;
	else cout<<ans<<endl;
	
	return 0;
}


Measured memory_bytes: 3584
#pragma GCC optimize("Ofast,O3,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
using namespace __gnu_pbds;
using namespace std;

#define endl '\n'
#define hoise cerr<<"hoise - "<<__LINE__<<"\n";
#define tham getchar();
#define FASTIO ios::sync_with_stdio(false);cin.tie(nullptr);

using ll = long long;
using ii = pair <int, int>;
using vi = vector <int>;
using vl = vector <ll>;

const int MXN = (int)2e5+6;
const double PI = acos(-1.0);
const ll mod = 1e9 + 7;

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << endl;
    err(++it, args...);
}

inline int Set(int N, int pos){return N=N | (1<<pos);}
inline int Reset(int N, int pos){return N=N & ~(1<<pos);}
inline bool Check(ll N, ll pos){return (bool)(N & (1LL<<pos));}

inline void normal(ll &a) { a %= mod; (a < 0) && (a += mod); }
inline ll modMul(ll a, ll b) { a %= mod, b %= mod; normal(a), normal(b); return (a * b) % mod; }
inline ll modAdd(ll a, ll b) { a %= mod, b %= mod; normal(a), normal(b); return (a + b) % mod; }
inline ll modSub(ll a, ll b) { a %= mod, b %= mod; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while (p) { if (p & 1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, mod - 2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }


template <typename T> using orderedSet = tree<T, null_type, greater<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T> using orderedSet1 = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
/*--------------------------------------------------------------------------------------------------------------------------*/




int main(){
	FASTIO
	double r;
	cin >> r;
	cout << fixed << setprecision(12) << 2.0 * PI * r << endl;
	
    return 0;
}

/*

*/


Measured memory_bytes: 3812
import sys
input = sys.stdin.readline


def pow_mod(x, n, mod):
    if n == 0:
        return 1

    K = 1
    while n > 1:
        if n % 2 != 0:
            K *= x
            K %= mod
        x *= x
        x %= mod
        n //= 2

    return K*x

#main関数
def main():
    """"ここに今までのコード"""

    N = int(input())
    A = list(map(int, input().split()))
    mod = 10**9+7

    plist = [0]*1000
    lcm = 1
    nokori=set()
    for a in A:
        for j in range(2, 1001):
            count_j=0
            while a % j == 0:
                count_j += 1
                a //= j
            plist[j-1]=max(plist[j-1],count_j)
        nokori |= {a}
    for x in nokori:
        lcm *= x
        lcm %= mod

    for i in range(1000):
        lcm *= pow_mod(i+1, plist[i], mod)
        lcm %= mod
    
    ans = 0

    for a in A:
        ans += lcm * pow_mod(a, mod-2, mod)
        ans %= mod

    print(ans)


if __name__ == '__main__':
    main()


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

using namespace std;

const int P = 924844033;
const int N = 200000 + 5;
const int MAX = 524288 + 5;

int n;

vector <int> G[N];
int siz[N];

int f1[MAX];
int f2[MAX];

int a[N];

int fac[N];
int inv[N];

void dfs(int u, int fa) {
  siz[u] = 1;
  for (int i = 0; i < (int) G[u].size(); ++i) {
    int v = G[u][i];
    if (v == fa) {
      continue;
    }
    dfs(v, u);
    --a[siz[v]];
    siz[u] += siz[v];
  }
  --a[n - siz[u]];
}

int lim;
int bit;

int rev(int x) {
  int ret = 0;
  for (int i = 0; i < bit; ++i) {
    ret <<= 1;
    ret |= x & 1;
    x >>= 1;
  }
  return ret;
}

int revbit[MAX];
int g[MAX];

void fft(int *f, int bit, int o) {
  for (int i = 0; i < lim; ++i) {
    if (revbit[i] > i) {
      swap(f[revbit[i]], f[i]);
    }
  }
  for (int i = 0; i < bit; ++i) {
    int len = 1 << i;
    for (int j = 0; j < lim; j += 1 << i + 1) {
      int wn = 0;
      for (int k = j; k < j + len; ++k) {
        int t = (long long) f[k + len] * g[wn] % P;
        f[k + len] = (f[k] - t) % P;
        if (f[k + len] < 0) {
          f[k + len] += P;
        }
        f[k] = (f[k] + t) % P;
        wn += o * (1 << bit - i - 1);                        
        if (wn < 0) {
          wn += lim;
        }
      }
    }
  }
}

int modexp(int a, int x, int P) {
  int ret = 1;
  while (x) {
    if (x & 1) {
      ret = (long long) ret * a % P;
    }
    a = (long long) a * a % P;
    x >>= 1;
  }
  return ret;
}

void calc() {
  while ((1 << bit) < n + n) {
    ++bit;   
  }
  lim = 1 << bit;
  for (int i = 0; i < lim; ++i) {
    revbit[i] = rev(i);
  }
  g[0] = 1;
  g[1] = modexp(5, (P - 1) / lim, P);
  for (int i = 2; i < lim; ++i) {
    g[i] = (long long) g[i - 1] * g[1] % P;
  }
  fft(f1, bit, 1);
  fft(f2, bit, 1);
  for (int i = 0; i < lim; ++i) {
    f1[i] = (long long) f1[i] * f2[i] % P;
  }
  fft(f1, bit, -1);
  int invlim = modexp(lim, P - 2, P);
  for (int i = 0; i < lim; ++i) {
    f1[i] = (long long) f1[i] * invlim % P;
  }    
}

int main() {
  scanf("%d", &n);
  for (int i = 0, u, v; i < n - 1; ++i) {
    scanf("%d %d", &u, &v);
    --v;
    --u;
    G[u].push_back(v);
    G[v].push_back(u);
  }
  dfs(0, -1);
  a[n] = n;
  fac[0] = 1;
  for (int i = 1; i <= n; ++i) {
    fac[i] = (long long) fac[i - 1] * i % P;
  }
  inv[n] = modexp(fac[n], P - 2, P);
  for (int i = n - 1; i >= 0; --i) {
    inv[i] = (long long) inv[i + 1] * (i + 1) % P;
  }
  for (int i = 1; i <= n; ++i) {
    f1[n - i] = (long long) a[i] * fac[i] % P;
  }
  for (int i = 0; i <= n - 1; ++i) {
    f2[i] = inv[i];
  }
  calc();
  for (int i = n - 1; i >= 0; --i) {
    printf("%lld\n", (long long) f1[i] * inv[n - i] % P);
  }                  
  return 0;
}

Measured memory_bytes: 37632
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define MOD (1000000007)
#define vi vector<int>
#define vl vector<ll>
#define vb vector<bool>
#define vvi vector<vi>
#define vvl vector<vl>
#define pii pair<int, int>
#define pli pair<ll, int>
#define pb push_back

#define mp make_pair
#define all(a) (a).begin(),(a).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; }

ll gcd(ll a, ll b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}

ll keta(ll n){
  string s = to_string(n);
  ll num = s.size();
  return num;
}

const ll INF = 1LL << 60;

const int dh[4] = {1,0,-1,0};
const int dw[4] = {0,1,0,-1};

struct Edge{
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w){}
};
using Graph = vector<vector<Edge>>;
using P = pair<ll, int>;

int main(){
  int n,k; cin >> n >> k;
  vi a(n);
  int s = 0;
  rep(i, n){
    cin >> a[i];
    s += a[i];
  }
  
  vi v;
  for(int i = 1; i*i <= s; i++) {
    if(s%i == 0){
      v.pb(i);
      v.pb(s/i);
    }
  }

  int ans = 0;
  for(auto i : v) {
    vi b(n);
    int sumb = 0;
    rep(j,n) b[j] = a[j]%i;
    rep(j,n) sumb += b[j];
    sort(all(b), greater<int>());
    int cnt = 0,sum = 0;
    int j = 0;
    while(sum != sumb){
      cnt += i - b[j];
      sum += i;
      j++;
    }
    if(cnt <= k) chmax(ans,i);
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int selectionSort(int* ,int);

  
int main(){
  int n,cnt,i;
  int value[100];
  
  scanf("%d",&n);
  
  for(i = 0;i < n;i++){
    scanf("%d",&value[i]);
  }

  cnt = selectionSort(value,n);

  for(i = 0;i < n;i++){
    printf("%d",value[i]);
    if(i < n-1) printf(" ");
  }
  printf("\n");
  printf("%d\n",cnt);

  return 0;

}

int selectionSort(int *A ,int n){
  int i,j,minj,tmp,cnt = 0;

  for(i = 0;i < n;i++){
    minj = i;
    for(j = i;j < n; j++){
      if(A[j] < A[minj]){
	minj = j;
      }
    }
    if(i != minj){
	tmp = A[i];
	A[i] = A[minj];
	A[minj] = tmp;
	cnt++;
    }
  }
  return cnt;
}
  

Measured memory_bytes: 604
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,M,x=0;cin>>N>>M;
  vector<int>s(N);
  vector<pair<int,int>>p(M);
  for(int i=0;i<M;i++)cin>>p.at(i).first>>p.at(i).second;
  for(int i=0;i<N;i++)s.at(i)=i+1;
  do{
    int i;
    for(i=1;i<N;i++){
      int j;
      for(j=0;j<M;j++)if(min(s.at(i),s.at(i-1))==p.at(j).first&&max(s.at(i),s.at(i-1))==p.at(j).second)break;
      if(j==M)break;
    }
    if(i==N)x++;
  }while(next_permutation(s.begin()+1,s.end()));
  cout<<x<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

signed main(){
	int n,m; cin>>n>>m;
	VI a(n);  int sum=0;
	rep(i,n){
		cin>>a[i]; sum+=a[i];
	}
	sort(RALL(a));
	if(n<m) return cout<<"No"<<endl,0;
	rep(i,m){
		if(sum>a[i]*4*m) return cout<<"No"<<endl,0;
	}
	cout<<"Yes"<<endl;
	return 0;
}


Measured memory_bytes: 256
H, W = [int(x) for x in input().split()]
A = [input() for i in range(0, H)]
i, j = 0, 0
H, W = H-1, W-1
moveX = [1, 0, -1, 0]
moveY = [0, 1, 0, -1]
while True:
    count = 0
    for k in range(0, 4):
        ii = i+moveX[k]
        jj = j+moveY[k]
        if 0 <= ii and ii <= H and 0 <= jj and jj <= W:
            if A[ii][jj] == '#':
                count += 1
    invalid = 2 if (not (i==0 and j==0)) and (not(i==H and j==W)) else 1  
    if count > invalid:
        print("Impossible")
        break
    if i < H and A[i+1][j] == '#':
        i = i+1
        continue
    if j < W and A[i][j+1] == '#':
        j = j+1
        continue
    if i == H and j == W:
        print("Possible")
        break
    else:
        print("Impossible")
        break


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

int main() {
  int a,b,c,d,n;
  cin >> a >> b >> c >> d;
  n=0;
  if (a>b) n+=b;
  else n+=a;
  if (c>d) n+=d;
  else n+=c;
  cout << n << endl;
}

Measured memory_bytes: 256