akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define pb emplace_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
#define dame(a) {out(a);return 0;}
#define decimal cout<<fixed<<setprecision(15);
#define dupli(a) a.erase(unique(all(a)),a.end())
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef tuple<ll,ll,ll,ll> PPP;
typedef multiset<ll> S;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
using vvvvi=vector<vvvi>;
using vp=vector<P>;
using vvp=vector<vp>;
using vb=vector<bool>;
using vvb=vector<vb>;
const ll inf=1001001001001001001;
const ll INF=1001001001;
const ll mod=1000000007;
const double eps=1e-10;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outvvp(T v){rep(i,v.size())outvp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void yesno(T b){if(b)out("yes");else out("no");}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
template<class T> void YESNO(T b){if(b)out("YES");else out("NO");}
template<class T> void noyes(T b){if(b)out("no");else out("yes");}
template<class T> void NoYes(T b){if(b)out("No");else out("Yes");}
template<class T> void NOYES(T b){if(b)out("NO");else out("YES");}
void outs(ll a,ll b){if(a>=inf-100)out(b);else out(a);}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll modpow(ll a,ll b){a%=mod;if(b==0)return 1;if(b&1)return a*modpow(a,b-1)%mod;ll k=modpow(a,b/2);return k*k%mod;}
ll ma;
string s;
ll dp[305][305][305];
ll dfs(int i,int j,int k){
    if(i==j)return 1;
    if(i>j)return 0;
    if(dp[i][j][k]!=-1)return dp[i][j][k];
    if(s[i]==s[j])chmax(dp[i][j][k],dfs(i+1,j-1,k)+2);
    chmax(dp[i][j][k],dfs(i+1,j,k));
    chmax(dp[i][j][k],dfs(i,j-1,k));
    if(k!=ma)chmax(dp[i][j][k],dfs(i+1,j-1,k+1)+2);
    return dp[i][j][k];
}

int main(){
    cin>>s;
    ll n=s.size();cin>>ma;
    rep(i,n)rep(j,n)rep(t,ma+1)dp[i][j][t]=-1;
    out(dfs(0,n-1,0));
    //rep(i,n)rep(j,n)rep(t,ma+1)if(dp[i][j][t]!=-1)cout<<i<<' '<<j<<' '<<t<<' '<<dp[i][j][t]<<endl;
}

Measured memory_bytes: 219392
a, b, c, d = map(int, input().split())
#a, b, c, d = 3,4,5,2
if a + b > c + d:
    result = "Left"
elif a + b == c + d:
    result = "Balanced"
elif a + b < c + d:
    result = "Right"
print(result)


Measured memory_bytes: 38384
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define LL long long
#define INF 999999999
using namespace std;

int main(){
  int x=0;
  int N;

  cin >> N;
  char S[N];
  int ans=0;
  REP(i, N){
    cin >> S[i];
    if(S[i] == 'I'){
      x++;
    }else x--;
    ans = max(x, ans);
  }
  cout << ans << endl;
  
  return 0;
}



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

#define rep(i, a, b) for (ll i = (a); i < (b); i++)
typedef uint64_t ull;
typedef int64_t ll;
typedef pair<ll, ll> PLL;

const ll T = 55555;
vector<bool> is_prime(T+1,true);

signed main() {
    vector<ll> v;
    is_prime[0]=is_prime[1]=false;
    rep(i,2,T+1){
        if (!is_prime[i])
            continue;
        for (ll k=i*2; k<=T; k+=i){
            is_prime[k]=false;
        }
        if (i % 5 == 1)
            v.push_back(i);
    }

    // a_iとして、a_i mod 5 == 1 となるものだけを集めると
    // 任意の5つを選んだ時に、5の倍数となる
    // cout<<v.size()<<endl;
    ll n;
    cin>>n;
    rep(i,0,n){
        if (i>0)
            cout<<" ";
        cout<<v[i];
    }
    cout<<endl;


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 2e9
using namespace std;
typedef long long llong;
typedef long double ldouble;

using Graph = vector<vector<int>>;

int main(){
  llong sum;
  llong H, N;
  cin >> H >> N;
  for(llong i=0; i<N; ++i){
    int a;
    cin >> a;
    sum += a;
  }
  if(sum>=H) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
MAX = 55555
def get_prime_array(N):
    f = [True] * (N + 1)
    for i in range(2, N + 1):
        if f[i]:
            for j in range(i + i, N + 1, i):
                f[j] = False
    return f

def m():
    n = int(input())
    f = get_prime_array(MAX)
    a = []
    for i in range(6, len(f)):
        if f[i] and i % 5 == 1:
            a.append(i)
            if len(a) == n:
                break
    ans = ""
    for j in a:
        ans += str(j) + " "
    return ans

print(m())

Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main(){
    string s;
    cin >> s;
    int ans=1000;
    rep(i,s.size()-2){
        int a;
        a = 100*(s[i] - '0') + 10*(s[i+1] - '0') + s[i+2] - '0';
        ans = min(ans,abs(753-a));
    }
    cout << ans << endl;
}

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

const int MaxN = 100000 + 5, MaxM = 100000 + 5;

int N, M;
int P[MaxM], Y[MaxM], lnk[MaxM];
int Ans[MaxM], cnt[MaxN];

void init() {
    scanf("%d %d", &N, &M);
    for (int i = 1; i <= M; ++i)
        scanf("%d %d", &P[i], &Y[i]), lnk[i] = i;
}

inline bool cmp(int x, int y) {
    if (P[x] != P[y]) return P[x] < P[y];
    else return Y[x] < Y[y];
}

void solve() {
    sort(lnk + 1, lnk + 1 + M, cmp);
    for (int I = 1; I <= M; ++I) {
        int i = lnk[I];
        cnt[P[i]]++;
        Ans[i] = cnt[P[i]];
    }

    for (int i = 1; i <= M; ++i)
        printf("%06d%06d\n", P[i], Ans[i]);
}

int main() {
    init();
    solve();
    return 0;
}

Measured memory_bytes: 3456
#include <iostream>
using namespace std;
int main(void){
    int bow, n, number[30]={}, a, b;
    char commma;
    cin >> bow >> n;
    for(int i=1; i<=bow; i++){
        number[i]=i;
    }
    for(int i=0; i<n; i++){
        cin >> a >> commma >> b;
        int tmp=number[a];
        number[a]=number[b];
        number[b]=tmp;
    }
    for(int i=1; i<=bow; i++){
        cout << number[i] << endl;
    }
    return 0;
}



Measured memory_bytes: 3080
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<vector>
using namespace std;
#define ll long long
#define MAX 200200
#define MOD 1000000007
#define inv2 500000004
inline int read()
{
	int x=0;bool t=false;char ch=getchar();
	while((ch<'0'||ch>'9')&&ch!='-')ch=getchar();
	if(ch=='-')t=true,ch=getchar();
	while(ch<='9'&&ch>='0')x=x*10+ch-48,ch=getchar();
	return t?-x:x;
}
int fpow(int a,int b)
{
	int s=1;
	while(b){if(b&1)s=1ll*s*a%MOD;a=1ll*a*a%MOD;b>>=1;}
	return s;
}
int n,a[MAX],tot,ans;
int cnt[MAX];
int c1[MAX],c2[MAX];
int lb(int x){return x&(-x);}
void add(int x,int w){while(x<=n)c1[x]=(c1[x]+w)%MOD,++c2[x],x+=lb(x);}
int getsum1(int x){int ret=0;while(x)ret=(ret+c1[x])%MOD,x-=lb(x);return ret;}
int getsum2(int x){int ret=0;while(x)ret+=c2[x],x-=lb(x);return ret;}
int D[MAX],invD[MAX],zero[MAX],S[MAX];
int main()
{
	n=read();tot=1;
	for(int i=1;i<=n;++i)++cnt[a[i]=read()];
	for(int i=n-1;i;--i)cnt[i]+=cnt[i+1];
	for(int i=1;i<=n;++i)tot=1ll*tot*(cnt[i]-=(n-i))%MOD;
	if(!tot){puts("0");return 0;}
	S[0]=D[0]=1;
	for(int i=1;i<=n;++i)
	{
		int x=1ll*(cnt[i]-1)*fpow(cnt[i],MOD-2)%MOD;
		if(!x)S[zero[i]=zero[i-1]+1]=i,D[i]=D[i-1];
		else zero[i]=zero[i-1],D[i]=1ll*D[i-1]*x%MOD;
		invD[i]=fpow(D[i],MOD-2);
	}
	for(int i=1;i<=n;++i)
	{
		ans=(ans+1ll*(getsum1(a[i])-getsum1(S[zero[a[i]]]-1)+MOD)*D[a[i]]%MOD*tot%MOD*inv2%MOD)%MOD;
		add(a[i],invD[a[i]]);
	}
	for(int i=1;i<=n;++i)c1[i]=c2[i]=0;
	for(int i=n;i;--i)
	{
		ans-=1ll*(getsum1(a[i]-1)-getsum1(S[zero[a[i]]]-1)+MOD)*D[a[i]]%MOD*tot%MOD*inv2%MOD;
		ans=(ans+1ll*getsum2(a[i]-1)*tot)%MOD;ans=(ans+MOD)%MOD;
		add(a[i],invD[a[i]]);
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 6528
def divcnt(n):
	cnt = 0
	for i in range(1,n + 1):
		if n % i == 0:cnt+=1
	return cnt

n = int(input())
ans = 0
for i in range(1,n + 1):
	if divcnt(i) == 8 and i % 2 == 1:ans+=1
print(ans)

Measured memory_bytes: 3060
package main

import "fmt"

func main() {
	var s string
	fmt.Scanln(&s)

	rec := 0
	ans := 0
	for i := 0; i < len(s); i++{
		if s[i] == 'W'{
			ans += rec
		}else{
      rec++
    }
	}
	fmt.Println(ans)
}


Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    char c;
    cin >> c;
    if (   c == 'a'
        || c == 'e'
        || c == 'i'
        || c == 'o'
        || c == 'u')
        cout << "vowel" << endl;
    else
        cout << "consonant" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//for(int i = 0; i < n; i++)
 
int main() {
  int n, a, b, ans = 0;
  long long x;
  string s;
  cin >> a >> b >> n;
  for(int i = 0; i < 10; i++) {
  }
  cout << n / a * b << endl;
}

Measured memory_bytes: 256
L = raw_input().split()
a = int(L[0])
b = int(L[1])
d = int(0)
r = int(0)
f = float(0)

d = a / b
r = a % b
f = float(a) / float(b)

print "{0} {1} {2:f}".format(d,r,f)

Measured memory_bytes: 6404
#include <bits/stdc++.h>
#define X first
#define Y second
#define pb push_back

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    vector <int> ans(n);
    set <int> x;
    int ptr = 0;
    int s = 0;
    for (int d = 2; d <= 30000; d++)
    {
        if (ptr == n - 1)
            break;
        if (d % 2 == 0 || d % 3 == 0)
        {
            x.insert(d);
            ans[ptr++] = d;
            s += d;
        }
    }
    bool ok = false;
    for (int d = 2; d <= 30000; d++)
    {
        if (((s + d) % 2 == 0) && ((s + d) % 3 == 0) && __gcd(d, s) != 1)
        {
            if (x.find(d) == x.end()) {
                ans[n - 1] = d;
                ok = true;
                break;
            }
        }
    }
    assert(ok);
    for (auto e : ans)
        cout << e << ' ';
    cout << '\n';
    return 0;
}


Measured memory_bytes: 1408
#define fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define all(x) begin(x),end(x)
#include <bits/stdc++.h>
#define pll pair<ll,ll>
#define vi vector<int>
#define ld long double
#define ll long long
#define pb push_back
#define mid (l+r)/2
#define S second
#define F first
using namespace std;
ll n,a,b;
int main(){
    fast,cin>>n>>a>>b;
    ll x = n/(a+b);
    cout<<x*a+min(a,n%(a+b))<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n,m,a[123456],d[123456];
int main(){
	cin>>n>>m;
	for(int i=0;i<n+1;i++)d[i]=100000;
	for(int i=0;i<m;i++){
		cin>>a[i];
		d[a[i]]=0;
	}
	d[0]=1;
	if(a[0]!=1)d[1]=1;
	for(int i=2;i<=n;i++){
		if(d[i]==0);
		else{
			d[i]=d[(i-1)]+d[(i-2)];
			d[i]%=1000000007;
		}
	}
	cout<<d[n]<<endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
#include <bitset>
#define M 1000000007
#define M1 998244353

#define tr(container, it) \
    for (typeof(container.begin()) it = container.begin(); it != container.end(); it++)

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

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

ll power(ll x, ll n)
{
    ll result = 1;
    while (n)
    {
        if (n % 2 == 1)
            result = result * x;
        n = n / 2;
        x = x * x;
    }
    return result;
}

ll gcd(ll a, ll b)
{
    if (!b)
        return a;
    return gcd(b, a % b);
}

ll lcm(ll a, ll b)
{
    return (a * b) / gcd(a, b);
}

inline ll mul(ll x, ll y, ll m)
{
    ll z = 1LL * x * y;
    if (z >= m)
    {
        z %= m;
    }
    return z;
}

ll powmod(ll x, ll y, ll m)
{
    ll r = 1;
    while (y)
    {
        if (y & 1)
        {
            r = mul(r, x, m);
        }
        y >>= 1;
        x = mul(x, x, m);
    }
    return r;
}

void start()
{
    fast;
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}
/***********************************************************************************************************/

int solve(int *a, int n, int *dp, int k)
{
    if (n == 1)
    {
        return dp[n] = 0;
    }
    if (dp[n] != -1)
    {
        return dp[n];
    }
    int ans = INT_MAX;
    for (int i = 1; i < min(k + 1, n); i++)
    {
        ans = min(ans, abs(a[n - 1] - a[n - 1 - i]) + solve(a, n - i, dp, k));
    }
    return dp[n] = ans;
}

int main()
{
    start();
    int n, k;
    cin >> n >> k;
    int a[n];
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    int dp[n + 1];
    memset(dp, -1, sizeof(dp));
    cout << solve(a, n, dp, k);
    return 0;
}

Measured memory_bytes: 13756
import types

_atcoder_code = """
# Python port of AtCoder Library.

__version__ = '0.0.1'
"""

atcoder = types.ModuleType('atcoder')
exec(_atcoder_code, atcoder.__dict__)

_atcoder_dsu_code = """
import typing


class DSU:
    '''
    Implement (union by size) + (path compression)
    Reference:
    Zvi Galil and Giuseppe F. Italiano,
    Data structures and algorithms for disjoint set union problems
    '''

    def __init__(self, n: int = 0):
        self._n = n
        self.parent_or_size = [-1] * n

    def merge(self, a: int, b: int) -> int:
        assert 0 <= a < self._n
        assert 0 <= b < self._n

        x = self.leader(a)
        y = self.leader(b)

        if x == y:
            return x

        if -self.parent_or_size[x] < -self.parent_or_size[y]:
            x, y = y, x

        self.parent_or_size[x] += self.parent_or_size[y]
        self.parent_or_size[y] = x

        return x

    def same(self, a: int, b: int) -> bool:
        assert 0 <= a < self._n
        assert 0 <= b < self._n

        return self.leader(a) == self.leader(b)

    def leader(self, a: int) -> int:
        assert 0 <= a < self._n

        if self.parent_or_size[a] < 0:
            return a

        self.parent_or_size[a] = self.leader(self.parent_or_size[a])
        return self.parent_or_size[a]

    def size(self, a: int) -> int:
        assert 0 <= a < self._n

        return -self.parent_or_size[self.leader(a)]

    def groups(self) -> typing.List[typing.List[int]]:
        leader_buf = [self.leader(i) for i in range(self._n)]

        result = [[] for _ in range(self._n)]
        for i in range(self._n):
            result[leader_buf[i]].append(i)

        return list(filter(lambda r: r, result))
"""

atcoder.dsu = types.ModuleType('atcoder.dsu')
exec(_atcoder_dsu_code, atcoder.dsu.__dict__)
dsu = atcoder.dsu

#c
# from atcoder import dsu
n,m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(m)]
ds = dsu.DSU(n)
for i in ab:
    ds.merge(i[0]-1,i[1]-1)
    
s = ds.groups()

print(len(s)-1)

Measured memory_bytes: 41912
import java.util.Scanner

import scala.collection.Searching._
import scala.annotation.tailrec
import scala.collection.mutable
import scala.collection.immutable._
import scala.io.StdIn.readLine

class IUnionFind(val size: Int) {

  private case class Node(var parent: Option[Int], var treeSize: Int)

  private val nodes = Array.fill[Node](size)(new Node(None, 1))

  def union(t1: Int, t2: Int): IUnionFind = {
    if (t1 == t2) return this

    val root1 = root(t1)
    val root2 = root(t2)
    if (root1 == root2) return this

    val node1 = nodes(root1)
    val node2 = nodes(root2)

    if (node1.treeSize < node2.treeSize) {
      node1.parent = Some(t2)
      node2.treeSize += node1.treeSize
    } else {
      node2.parent = Some(t1)
      node1.treeSize += node2.treeSize
    }
    this
  }

  def connected(t1: Int, t2: Int): Boolean = t1 == t2 || root(t1) == root(t2)

  def root(t: Int): Int = nodes(t).parent match {
    case None => t
    case Some(p) => root(p)
  }
}

object Main {
  val m = (1 << 9) - 1

  def solve(sc: => Scanner): Unit = {
    val N = sc.nextInt
    println((1 to 40).map(x => (2 to 10).map(y => math.pow(x, y).toInt).toList).flatten.sorted.reverse.dropWhile(_ > N).head)
  }

  def recursive(now: Int, A: Array[List[Int]]): Int = {
    if (A(now).size == 0) (now) else {
      val next = A(now).head
      A(now) = A(now).filter(_ != next)
      A(next) = A(next).filter(_ != now)
      recursive(next, A)
    }
  }

  def check(A: Array[List[Int]]): Boolean = {
    A.map(_.size == 0).fold(true)((a, b) => a & b)
  }

  def shift(n: Long): Long = {
    if (n == 0) (0) else if (n == 1) (1) else (shift(n - 1) << 1)
  }

  def unShift(n: Long): Long = {
    if (n == 0) (0) else (unShift(n >> 1) + 1)
  }

  def calc(v: Long): Long = (v + 1) * v / 2

  def gcd(i: Long, j: Long): Long = {
    if (i < j) (gcd(j, i)) else (if (j == 0) (i) else (gcd(j, i % j)))
  }

  def main(args: Array[String]): Unit = {
    val sc: Scanner = new Scanner(System.in)
    solve(sc)
  }
}

object Util {
  def getPermutation(begin: Long = 0): Stream[Long] =
    Stream.cons(begin, getPermutation(begin + 1))

  def getPrimeList(): Stream[Long] =
    getPrimeListRecursive(getPermutation(begin = 2))

  private def getPrimeListRecursive(A: Stream[Long]): Stream[Long] =
    Stream.cons(A.head, getPrimeListRecursive(A.tail.filter(_ % A.head != 0)))

  def fib(a: Long = 0, b: Long = 1, mod: Long = Long.MaxValue): Stream[Long] = a #:: fib(b % mod, (a + b) % mod, mod)
}

Measured memory_bytes: 25416
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define pi 3.141592653
#define pb push_back
#define pp pop_back
#define mp make_pair
#define in insert
#define ff first
#define ss second
#define mod 1000000007
#define rep(i,n) for(int i = 0 ; i<n ; i++)
#define repr(i,n) for(int i = n-1 ; i>=0 ; i--)
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 
#define SORT(v) sort(v.begin(),v.end())
void solve();
ll gc(ll a,ll b)
{
    if(b==0) return a;
    return gc(b,a%b);
}
signed main()
{
    fast;
    int t = 1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
}
void solve() 
{
    ll h;
    cin>>h;
    ll ans =0;
    ll x =1;
    while(h!=0){
        ans+=x;
        h=h/2;
        x = x*2;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <string.h>
#include <math.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <deque>
#include <queue>

#define rep(i, n) for(int i = 0; i < n; ++i)
#define REP(i, m, n) for(int i = m; i < n; ++i)
#define rrep(i,n) for(int i = n; i >= 0; --i)
#define RREP(i, m, n) for(int i = n; i >= m; --i)

typedef long long ll;
typedef unsigned long long ull;
typedef std::pair<int, int> pii;
typedef std::pair<long long, long long> pll;

using namespace std;

const long long mod = 1000000007;

struct primeFactor {
	long long prime;
	long long power;
};

std::vector<primeFactor> primeFactorization(long long number) {
	std::vector<primeFactor> primeFactors;

	if (number == 0) {
		primeFactor pf;
		pf.prime = 0;
		pf.power = 1;
		primeFactors.push_back(pf);
		return primeFactors;
	}

	long long quotient = number;
	for (long long i = 2; i*i <= quotient; ++i) {
		if (quotient%i == 0) {
			primeFactor pf;
			pf.prime = i;
			pf.power = 1;

			quotient /= i;
			while (quotient%i == 0) {
				++pf.power;
				quotient /= i;
			}

			primeFactors.push_back(pf);
		}
	}
	if (quotient != 1) {
		primeFactor pf;
		pf.prime = quotient;
		pf.power = 1;
		primeFactors.push_back(pf);
	}

	return primeFactors;
}

ll gcd(ll m, ll n) {
	ll g = 1;

	while (m != 0) {
		if (m < n) swap(m, n);

		if (m & 1) {
			if (n & 1) {
				m = (m - n) >> 1;
			}
			else {
				n = n >> 1;
			}
		}
		else {
			if (n & 1) {
				m = m >> 1;
			}
			else {
				n = n >> 1;
				m = m >> 1;
				g = g << 1;
			}
		}
	}

	return g * n;
}

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

	ll a, b;
	cin >> a >> b;
	cout << primeFactorization(gcd(a, b)).size() + 1 << "\n";

    return 0;
}


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

typedef struct node Node;

struct node{
  int id;
  int p,lft,rht;
  node(){
    p=-1;
    lft=-1;
    rht=-1;
  }
};

vector<Node> nodes(26);

int Input(int*);
void Preorder(int);
void Inorder(int);
void Postorder(int);

int main(int argc,char* argv[]){
  int n;
  int rnode;

  cin>>n;

  rnode=Input(&n);

  cout<<"Preorder"<<endl;
  Preorder(rnode);
  cout<<endl;

  cout<<"Inorder"<<endl;
  Inorder(rnode);
  cout<<endl;
  
  cout<<"Postorder"<<endl;
  Postorder(rnode);
  cout<<endl;
  
  return 0;
}

int Input(int *n){
  int id,left,right;
  set<int> sall,sseg;
  
  for(int i=0;i<*n;i++){
    nodes[i].id=i;
    cin>>id>>left>>right;
    nodes[id].lft=left;
    nodes[id].rht=right;

    sall.insert(id);
    sseg.insert(left);sseg.insert(right);
  }

  set<int>::iterator its;
  for(its=sall.begin();its!=sall.end();its++){
    if(sseg.find(*its)==sseg.end())
      return *its;
  }
  return -1;
}

void Preorder(int nowp){

  cout<<" "<<nodes[nowp].id;

  if(nodes[nowp].lft!=-1)
    Preorder(nodes[nowp].lft);
  if(nodes[nowp].rht!=-1)
    Preorder(nodes[nowp].rht);
}

void Inorder(int nowp){

  if(nodes[nowp].lft!=-1)
    Inorder(nodes[nowp].lft);

  cout<<" "<<nodes[nowp].id;

  if(nodes[nowp].rht!=-1)
    Inorder(nodes[nowp].rht);
}

void Postorder(int nowp){

  if(nodes[nowp].lft!=-1)
    Postorder(nodes[nowp].lft);
  if(nodes[nowp].rht!=-1)
    Postorder(nodes[nowp].rht);

  cout<<" "<<nodes[nowp].id;
}

Measured memory_bytes: 1204
#include <bits/stdc++.h>
using namespace std;
int N, ans, d[5001][5001];
string S;
int main() {
    cin >> N >> S;
    for (int i=N-1;i>=0;--i) {
        for (int j=N-1;j>i;--j) {
            if (S[i] == S[j]) d[i][j] = min(j-i, d[i+1][j+1] + 1);
            else d[i][j] = 0;
            ans = max(ans, d[i][j]);
        }
    }
    cout << ans;
}

Measured memory_bytes: 96768
import java.io.*;
import java.util.*;

public class Main {

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

    public static void main(String[] args) {
        FastReader scanner = new FastReader();
        int N = scanner.nextInt();
        int W = scanner.nextInt();

        int[] wt = new int[N];
        int[] val = new int[N];

        for (int i = 0; i < N; i++) {
            wt[i] = scanner.nextInt();
            val[i] = scanner.nextInt();
        }
        long[][] DP = new long[N + 1][W + 1];

        for (int i = 1; i <= N; i++) {
            for (int j = 1; j <= W; j++) {
                if (wt[i - 1] <= j) {
                    DP[i][j] = Math.max(DP[i - 1][j], DP[i - 1][j - wt[i - 1]] + val[i - 1]);
                } else {
                    DP[i][j] = DP[i - 1][j];
                }
            }
        }
        System.out.println(DP[N][W]);
    }
}

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

F_list = []
for i in range(1, int(N**(1/2))+1):
  if N % i == 0:
    A = i
    B = N // A
    F = max(len(str(A)), len(str(B)))
    F_list.append(F)

print(min(F_list))


Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <algorithm>

using namespace std;
typedef long long int ll;
typedef vector<ll> vec;

int main(int argc, char const *argv[])
{
    ll N, A, B;
    cin >> N;
    cin >> A >> B;
    vector<ll> p(N);

    for (ll i = 0; i < N; i++)
    {
        cin >> p[i];
    }
    ll size = p.size();
    sort(p.begin(), p.end());

    ll cnt = 0;
    for (cnt = 0; cnt < size; cnt++)
    {
        bool flag = true;
        for (ll i = 0; i <= p.size(); i++)
        {
            if (i == p.size())
            {
                flag = false;
                break;
            }
            if (p[i] <= A)
            {
                p.erase(p.begin() + i);
                break;
            }
        }
        if (flag)
        {
            for (ll i = 0; i <= p.size(); i++)
            {
                if (i == p.size())
                {
                    flag = false;
                    break;
                }
                if (A + 1 <= p[i] && p[i] <= B)
                {
                    p.erase(p.begin() + i);
                    break;
                }
            }
        }

        if (flag)
        {
            for (ll i = 0; i <= p.size(); i++)
            {
                if (i == p.size())
                {
                    flag = false;
                    break;
                }
                if (B + 1 <= p[i])
                {
                    p.erase(p.begin() + i);
                    break;
                }
            }
        }

        if(!flag) break;
    }

    cout << cnt << endl;
}


Measured memory_bytes: 256
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let s = iterator.next().unwrap();
    let k: u64 = iterator.next().unwrap().parse().unwrap();

    let count1: u64 = count(s.to_string());
    let count2: u64 = count(format!("{}{}", s, s));
    let count3: u64 = count(format!("{}{}{}", s, s, s));

    let ans: u64 =
        if (count1 * 2) == count2 {
            count1 * k
        } else if (count1 + 2 * (count2 - count1)) == count3 {
            count1 * k + (k - 1)
        } else {
            count1 * k + k / 2
        };

    return ans.to_string();
}

fn count(s: String) -> u64 {
    let mut result = 0;

    let mut prev = ' ';
    let mut con = 0;
    for curr in s.chars() {
        if curr != prev {
            result += con / 2;
            prev = curr;
            con = 1;
        } else {
            con += 1;
        }
    }
    result += con / 2;

    result
}


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

int main(void)
{
    using namespace std;
    string moji;
    cin >> moji;
    int q;
    cin >> q;

    for (int i = 0; i < q; i++) {
        string order;
        cin >> order;
        if (order == "print") {
            int a, b;
            cin >> a >> b;
            cout << moji.substr(a, b-a+1) << "\n";
        } else if (order == "reverse") {
            int a, b;
            cin >> a >> b;
            string old = moji.substr(a, b-a+1);
            reverse(old.begin(), old.end());
            moji.replace(a, (b-a+1), old);
        } else if (order == "replace") {
            int a, b;
            string p;
            cin >> a >> b >> p;
            moji.replace(a, b-a+1, p);
        }
    }
    return 0;
}


Measured memory_bytes: 3212
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b;
    cin>>a>>b;
    if(a==1)a+=100;
    if(b==1)b+=100;
    if(a>b)cout<<"Alice"<<endl;
    else if(b>a)cout<<"Bob"<<endl;
    else cout<<"Draw"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s,t;
  cin >> s >> t;
  sort(s.begin(),s.end());
  sort(t.begin(),t.end());
  reverse(t.begin(),t.end());
  if (s<t){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

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

int main() {
    int h1, m1, h2, m2, k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    int h = h2 - h1;
    int m = m2 - m1;
    cout << h * 60 + m - k << endl;
    return 0;
}


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

using namespace std;
#define ll long long
#define ld long double

int main()
{
    ios_base::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL);
    string s;
    cin >> s;
    int n = s.length();
    bool ok = true;
    for(int i=0;i<n;i+=2) {
        if(s[i] != 'h' || s[i+1] != 'i') {
            ok = false;
            break;
        }
    }
    cout << ((ok) ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
using namespace std;

int dif[111111];

int main(void)
{
	int n, k, i, ans = 0;

	scanf("%d %d" ,&n, &k);
	if (n <= k)
	{
		printf("%d\n" ,n);
		return 0;
	}

	int prev, now;
	for (i = 1; i <= n; i++)
	{
		prev = now;
		scanf("%d" ,&now);

		dif[i - 1] = now - prev - 1;
	}

	sort(dif + 1, dif + n);
	for (i = 1; i <= n - k; i++)
		ans += dif[i];

	printf("%d\n" ,ans + n);
	return 0;
}


Measured memory_bytes: 3152
#include <iostream>
#include <string>
#include <array>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <iomanip>

#define FOR(i, a, b) for(decltype(b) i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

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

using namespace std;

#ifdef INPUT
#include <sstream>
stringstream input(R"(
5 3 6 8
-10 3 1 5 -100
100 6 14
)");
#define cin input
#endif

int main()
{
	int n, m, x, y;
	cin >> n >> m >> x >> y;

	REP (i, n)
	{
		int a;
		cin >> a;
		x = max(x, a);
	}

	REP (i, m)
	{
		int a;
		cin >> a;
		y = min(y, a);
	}

	cout << (x < y ? "No War" : "War") << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef pair<int,int> P;
constexpr ll INF = (1LL << 60);
int main(){ 
  int n;
  cin >> n;
  vector<int> a(n);
  vector<ll> cum(n+1,0);
  rep(i,n) cin >> a[i];
  rep(i,n) cum[i+1] = cum[i] + a[i];
  ll res = INF;
  for (int i = 1; i < n; i++) {
    res = min(abs(cum[n] - 2 * cum[i]), res);
  }
  cout << res << endl;
  return 0;
} 

Measured memory_bytes: 2560
def check(table)
  result = 0
  if table.sum <= 2
    result = 1 if table.find {|x| x == 2}
  else
    (1..7).each do |i|
      tmp = table.dup
      if tmp[i].nonzero? and tmp[i + 1].nonzero? and tmp[i + 2].nonzero?
        3.times {|x| tmp[i + x] -= 1}
        result += check(tmp)
        return 1 if result.nonzero?
      end
      (1..9).each do |j|
        tmp1 = table.dup
        if tmp1[j] >= 3
          tmp1[j] -= 3
          result += check(tmp1)
          return 1 if result.nonzero?
        end
      end
    end
  end
  result
end

$<.readlines.map(&:chomp).map {|n| n.chars.map(&:to_i)}.each do |data|
  table = Array.new(10, 0)
  data.each {|i| table[i] += 1}
  result = (1..9).map do |i|
    added = table.dup
    added[i] += 1
    next if added[i] > 4
    check(added).nonzero? ? i : nil
  end.compact
  puts result.empty? ? 0 : result.join(" ")
end


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

using LL = int64_t;

int main()
{
    LL N; cin >> N;
    vector<int> c(N);
    for (int i = 0; i < N; ++i) {
        cin >> c[i]; --c[i];
    }
    vector<vector<int>> G(N);
    for (int i = 0; i < N-1; ++i) {
        int u, v; cin >> u >> v; --u, --v;
        G[u].push_back(v);
        G[v].push_back(u);
    }

    vector<vector<LL>> split(N);
    vector<LL> sz(N, 1);
    vector<map<int,LL>> dp(N);

    auto dfs = [&](auto&& dfs, int v, int p)->void{
        for (int u : G[v]) {
            if (u == p) continue;
            dfs(dfs, u, v);
            sz[v] += sz[u];

            LL ret = sz[u];
            if (dp[u].count(c[v])) ret -= dp[u][c[v]];
            split[c[v]].push_back(ret);

            if (dp[u].size() > dp[v].size()) swap(dp[u], dp[v]);
            for (auto& tp : dp[u]) dp[v][tp.first] += tp.second;
        }

        dp[v][c[v]] = sz[v];
    };

    dfs(dfs, 0, -1);

    for (int i = 0; i < N; ++i) {
        split[i].push_back(N - dp[0][i]);
    }

    vector<LL> ans(N, N*(N+1)/2);
    for (int i = 0; i < N; ++i) {
        for (LL a : split[i]) {
            ans[i] -= a * (a + 1) / 2;
        }
    }

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

    return 0;
}


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

int main() {

  int cnt[100] = {0};
  int cnt_max = 0;
  int input;

  while( cin >> input ) {

    cnt[input-1]++;
    cnt_max = max( cnt_max, cnt[input-1] );

  }

  for ( int i = 0; i < 100; i++ ) {

    if ( cnt[i] == cnt_max ) cout << i+1 << endl;

  }

  return 0;

}

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

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

  int temp[S.size()];
  int temp1=0;
  int max =0;
  for(int i=0; i<S.size() ;i++){

    if(S[i]=='A'||S[i]=='T'||S[i]=='C'||S[i]=='G'){
      temp1++;
      temp[i] = temp1;
    }
    else{
      temp1 =0;
      temp[i] = temp1;
    }
  }
  
  for(int i=0; i<S.size() ;i++){
    if(temp[i]>max){
      max=temp[i];
    }
  }

cout << max <<endl;
}
  

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

/* {{{ */
#define PI(N) (M_PI * (N) / 180) //?§???????????????¢??????????????????
#define CL(N) cout << (N) << endl
#define DCT(N) (cout << "debug " << (N) << endl)
#define REP(i, N) for (int i = 0; i < (N); i++)
/* }}} */

int main()
{
    double  a, b, c;
                
    cin >> a >> b >> c;
    
    printf("%f\n", a * b / 2 * sin(PI(c)));
    printf("%f\n", a + b + sqrt(a * a + b * b - 2 * a * b * cos(PI(c))));
    printf("%f\n", b * sin(PI(c)));
    
    return (0);
}

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

int main() {
  int goal_money;
  cin >> goal_money;
  
  int result = 0;
  for(int i = 0; i < 30; i++){
    for(int j = 0; j < 30; j++){
      if((i*4 + j* 7) == goal_money) result++;   
    }
  }
  if(result != 0){
    cout << "Yes" << endl;
  }
  if(result == 0){
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
n, m = [int(i) for i in input().split()]
A = [0 for i in range(n)]
visited = [False for i in range(n)]
store = []
s = dict()
for i in range(n):
    s[i] = set()
for i in range(m):
    store.append([int(i) for i in input().split()])
for i in range(m):
    s[store[i][0]-1].add(store[i][1])
    if len(s[store[i][0]-1]) > 1:
        print(-1)
        break
else:
    if n == 1:
        if len(s[0]) > 0:
            for i in s[0]:
                print(i)
        else:
            print(0)
    else: # 2 or 3 digits
        if len(s[0]) > 0 and 0 in s[0]:
            print(-1)
        else:
            A[0] = 1
            for i in s[0]:
                A[0] = i
            for i in s[1]:
                A[1] = i
            if n == 3:
                for i in s[2]:
                    A[2] = i
            ans = "".join(str(i) for i in A)
            print(ans)

Measured memory_bytes: 3064
n = int(input())

def h(n):
    if int(n/26):
        if n % 26 == 0:
            return h(int(n/26) - 1) + 'z'
        else:
            return h(int(n/26)) + chr(96 + (n % 26))
    else:
        if n > 0:
            return chr(96 + n)
        else:
            return ''

print(h(n))


Measured memory_bytes: 9156
import java.util.*;
import java.lang.*;
import java.io.*;

public class Main
{
    public static void main (String[] args)
    {
        // your code goes here
        Scanner s = new Scanner(System.in);
        String str = s.next();
        int sum = 0;
        for(int j=0; j<str.length(); j++)
        {
            sum+=Character.getNumericValue(str.charAt(j));
        }
        if(sum%9==0)
            System.out.println("Yes");
        else
            System.out.println("No");
    }
}

Measured memory_bytes: 40416
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
bool valid(int x){
	vector<int> ans;
	while(x){
		ans.push_back(x%10); x/=10;
	}
	for(int i=0;i+1<ans.size();i++){
		if(abs(ans[i+1]-ans[i])>1) return 0;
	}
	return 1;
}
const int N = 60;
int dp[N][12];
LL sum[N];
int main(){

	for(int i=0;i<=9;i++) {
		dp[1][i]=1;
	}
	sum[1]=9;
	for(int i=2;i<=12;i++){
		for(int j=0;j<=9;j++){
			for(int d=-1;d<=1;d++){
				if(j+d>=0 && j+d<=9)
					dp[i][j]+=dp[i-1][j+d];
			}
		}
		for(int j=1;j<=9;j++) sum[i]+=dp[i][j];
		//printf("%lld\n", sum[i]);
	}
for(int i=1;i<=12;i++) sum[i]+=sum[i-1];
	int len=1;
	int n; cin>>n;
	while(sum[len]<n) len++;

	//printf("len=%d\n", len);
	n -= sum[len-1];
	int ans[12]={0};
	for(int i=1;i<=len;i++){
		int val;
		if(i==1) {
			val=1;
		} else {
			val=max(ans[i-1] - 1, 0);
		}
		int tmp = 0;
		while(tmp < n) {
			tmp += dp[len-i+1][val];
			//printf("tmp = %d, val = %d\n", tmp, val);
			if (tmp >= n) {
				ans[i] = val; 
				n -= (tmp - dp[len-i+1][val]);
				break;
			}
			val ++;
		}
	}
	for(int i=1;i<=len;i++) printf("%d", ans[i]);
}

/*
int main() {
	int C=0;
	for(int i=1;;i++){
		if(valid(i)) {
			printf("%d, %d\n", ++C, i);
		}
	}
}
*/

Measured memory_bytes: 256
def prepare(n, MOD):
    # 1! - n! の計算
    f = 1
    factorials = [1]  # 0!の分
    for m in range(1, n + 1):
        f *= m
        f %= MOD
        factorials.append(f)
    # n!^-1 の計算
    inv = pow(f, MOD - 2, MOD)
    # n!^-1 - 1!^-1 の計算
    invs = [1] * (n + 1)
    invs[n] = inv
    for m in range(n, 1, -1):
        inv *= m
        inv %= MOD
        invs[m - 1] = inv

    return factorials, invs
    #nCr = (factorials[n]%MOD * invs[r]%MOD * invs[n-r]%MOD)%MOD
def main2():
    n,k=map(int, input().split())
    MOD = 10**9 + 7
    facs,invs = prepare(n+k,MOD)
    red = n-k
    j=0
    blue = 0
    # . R . R . R . R .
    #仕切りで考えると仕切りの数はN-k+1
    #1からj個まで
    for i in range(1,k+1):
        tmp = (facs[red+1]%MOD * invs[i]%MOD * invs[red+1-i]%MOD)%MOD * (facs[k-1]%MOD * invs[i-1]%MOD * invs[k-i]%MOD)%MOD
        if(red+1-i<0):
            tmp = 0
        print(tmp%MOD)

if __name__ == '__main__':
    main2()


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

#define For(i, l, r) for (register int i = (l), i##end = (int)(r); i <= i##end; ++i)
#define Fordown(i, r, l) for (register int i = (r), i##end = (int)(l); i >= i##end; --i)
#define Rep(i, r) for (register int i = (0), i##end = (int)(r); i < i##end; ++i)
#define Set(a, v) memset(a, v, sizeof(a))
#define Cpy(a, b) memcpy(a, b, sizeof(a))
#define debug(x) cout << #x << ": " << (x) << endl

using namespace std;

template<typename T> inline bool chkmin(T &a, T b) { return b < a ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, T b) { return b > a ? a = b, 1 : 0; }

inline int read() {
	int x(0), sgn(1); char ch(getchar());
	for (; !isdigit(ch); ch = getchar()) if (ch == '-') sgn = -1;
	for (; isdigit(ch); ch = getchar()) x = (x * 10) + (ch ^ 48);
	return x * sgn;
}

void File() {
	freopen (".in", "r", stdin);
	freopen (".out", "w", stdout);
}

int main () {

	int n = read(), k = read();

	puts((n + 1) / 2 >= k ? "YES" : "NO");

    return 0;

}

Measured memory_bytes: 256
//g++ -std=c++11 -Wall -O2 -o main.exe main.cpp
 
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <algorithm>
#include <complex>
#include <numeric>
//最大公約数: gcd()
//最小公倍数: lcm()
 
using namespace std;
 
template <typename T>
void sortasc(vector<T> &v){ //vectorを昇順にソート
    sort(v.begin(), v.end(), std::greater<int>());
    return;
}
 
template <typename T>
void sortdesc(vector<T> &v){ //vectorを降順にソート
    sort(v.begin(), v.end(), std::less<int>());
    return;
}
 
int main(){
    int n, a, b;

    cin >> n;
    if(n == 1)
    {
        cout << "Hello World" << endl;
        return 0;
    }
    else{
        cin >> a >> b;
        cout << (a + b) << endl;
        return 0;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int (i) = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int (i) = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int (i) = (int)(a);(x);++(i))
#define repr(i, a, n) for(int (i) = ((int)(a)-1);(i) >= (int)(n);--(i))
#define reper(i, a, n) for(int (i) = (int)(a);(i) >= (int)(n);--(i))
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define SIZE(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define RNG(x, a, n) &((x)[a]), &((x)[n])
#define ADD(a, b) ((((a)%MOD)+((b)%MOD))%MOD)
#define MUL(a, b) ((((a)%MOD)*((b)%MOD))%MOD)
#define CEIL(x) ((int)ceil(((double)x)))
#define POW(x, y) ((int)pow(x, y))
#define UNIQUE(x) (x).erase(unique(ALL((x))), (x).end())
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl;
#define no cout << "no" << endl;
#define fcout cout << fixed << setprecision(10)
#define pb push_back
#define pf push_front
#define mp make_pair
#define mt make_tuple
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define EPS (1e-20)
#define INF 2147483647
#define MOD 1000000007
using llint = long long;
using VI = std::vector<int>;
using PII = std::pair<int, int>;
using SI = std::set<int>;
using MII = std::map<int, int>;
using TIII = std::tuple<int, int, int>;
using VLL = std::vector<llint>;
using MCI = std::map<char, int>;
using namespace std;


int N;
PII t[110];
int v[110];
int T;


double maxV(int i, double x){
	if(0 <= x && x <= t[i].fi) return v[i]+(t[i].fi-x);
	if(t[i].fi <= x && x <= t[i].se) return v[i];
	if(t[i].se <= x && x <= T) return v[i]+(x-t[i].se);
	return -1;
}


double maxV(double x){
	double res = INF;
	rep(i, 0, N+2) chmin(res, maxV(i, x));
	return res;
}


double solve(){
	double ans = 0;
	for(double x = 0;x < T;x+=0.5) ans += (maxV(x)+maxV(x+0.5))*0.25;
	return ans;
}


signed main(){
	cin >> N;
	repe(i, 1, N){
		cin >> t[i].se;
		T += t[i].se;
		t[i].fi = t[i-1].se;
		t[i].se += t[i].fi;
	}
	t[N+1].fi = t[N+1].se = t[N].se;
	repe(i, 1, N) cin >> v[i];

	fcout << solve() << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{long long d=0,t=0,s=0;double t1=0.0,t2=0.0;
    cin>>d>>t>>s;
    t1=(double)d/(double)(s);
    t2=(double)t;
    if(t1<=t2)
    cout<<"Yes";
    else
    cout<<"No";
}

Measured memory_bytes: 3592
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <map>
#include <set>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;

int main() {
  ll N, M;
  cin >> N >> M;
  vector<ll> x(M), y(M);
  for (int i = 0; i < M; i++) {
    cin >> x[i] >> y[i];
    x[i]--;
    y[i]--;
  }
  vector<bool> has_red(N, false);
  vector<ll> ball_cnt(N, 1);
  has_red[0] = true;
  for (int i = 0; i < M; i++) {
    if (has_red[x[i]]) has_red[y[i]] = true;
    ball_cnt[x[i]]--;
    ball_cnt[y[i]]++;
    if (ball_cnt[x[i]] == 0) has_red[x[i]] = false;
  }
  ll ans = 0;
  for (int i = 0; i < N; i++) {
    if (has_red[i]) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <functional>
#include <ctime>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iomanip>
#include <float.h>
#include <math.h>
using namespace std;
using ll = long long;


unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

class UnionFind {
public:
    vector <ll> par;
    vector <ll> siz;
    UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    ll root(ll x) {
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) {
        return root(x) == root(y);
    }

    ll size(ll x) {
        return siz[root(x)];
    }
};

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}

int main() {
    ll n;
    cin >> n;
    vector<ll> z(n);
    for (int i = 0; i < n; i++) {
        cin >> z[i];
    }
    ll ans = 0;
    while (true) {
        ll shu = 0;
        vector<ll> zan(n);
        for (int i = 0; i < n; i++) {
            zan[i] = z[i]/n;
            shu += zan[i];
            z[i] %= n;
        }
        for (int i = 0; i < n; i++) {
            z[i] += shu-zan[i];
        }
        ll m = 0;
        ans += shu;
        for (int i = 0; i < n; i++) {
            if (z[i] >= n) {
                m = 1;
                break;
            }
        }
        if (m == 0)break;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3584
#include<cstdio>
#include<algorithm>
 
using namespace std;
 
int n,i,x,y,z;
 
int main(){
	int t;
	scanf("%d",&n);
	for(i=1;i<=n;i++){
		scanf("%d",&t);
		if(t%4==0) x++; else
		if(t%2==0) y++; else z++;
	}
	//printf("%d %d %d\n",x,y,z); 
	if(z==x+1 && y || z>x+1) puts("No"); else puts("Yes");
	return 0;
}

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



int main()
{	
	int n;
	cin>>n;
	int arr[n+1] = {};

	for(int i = 0;i<n-1;i++){
		int a;
		cin>>a;
		arr[a] +=1;
	}

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

Measured memory_bytes: 4400
import bisect
n,m = map(int, input().split( ))

t = m//n

fct_sup = int(m**(1/2)) + 1

fct = []
fct2 = []
for f in range(1,fct_sup+1):
    if m%f == 0:
        fct.append(f)
        fct2.append(m//f)
if fct[-1] == fct2[-1]:
    fct.pop()
fct2.reverse()
fct += fct2
i = bisect.bisect_right(fct,t)
print(fct[i-1])



Measured memory_bytes: 3064
import java.util.*;
// warm-up
public class Main {

	static void solve() {
		Scanner sc = new Scanner(System.in);
		Set<Integer> a = new HashSet<Integer>();
		Set<Integer> b = new HashSet<Integer>();
		int n = sc.nextInt(), no = sc.nextInt();
		while (no-->0) {
			int c = sc.nextInt(), d = sc.nextInt();
			if (c==1||d==1) a.add((c==1) ? d : c); 
			if (c==n||d==n) b.add((c==n) ? d : c); 
		}
		a.retainAll(b);
		System.out.println(a.isEmpty() ? "IMPOSSIBLE" : "POSSIBLE");
		sc.close();		
	}

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

}

Measured memory_bytes: 73368
#include<bits/stdc++.h>
#define LL long long
using namespace std;

LL n;
double p[3000], dp[3000][6000];
bool vis[3000][3000];

double solve(int pos, int heads) {
	if(pos == n) {
		int tails = n - heads;
		if(heads > tails) return 1.0;
		return 0.0;
	}
	if(vis[pos][heads+n]) return dp[pos][heads+n];
	vis[pos][heads+n] = 1;
	double &prob = dp[pos][heads+n];
	prob = solve(pos+1, heads+1) * p[pos];
	prob += solve(pos+1, heads) * (1.0 - p[pos]);
	return prob;
}

int main() {
	memset(dp, -1, sizeof(dp));
	cin>>n;
	for(int i = 0; i < n; i++) cin>>p[i];
	double ans = solve(0, 0);
	printf("%.12lf\n", ans);
	return 0;
}


Measured memory_bytes: 149760
#include <stdio.h>
int main(){
  long n;
  long limit[5] = {0};
  long min = 0;
  long time = 0;

  scanf("%ld", &n);
  
  for(int i = 0; i < 5; i++){
    scanf("%ld", &limit[i]);
  }

  for(int i = 1; i < 5; i++){
    if(limit[min] > limit[i]){
      min = i;
    }
  }

  time = n / limit[min] + 5;
  if(n % limit[min] == 0){
    time -= 1;
  }
  printf("%ld", time);

  printf("\n");

}


Measured memory_bytes: 128