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

using namespace std;

typedef long long ll;

#define eps 1e-9
#define all(a)   a.begin(),a.end()
#define mp make_pair
#define F first
#define S second
#define pb push_back
#define sz size()
#define rd(inp) scanf("%lld",&inp)
#define rd2(inp1, inp2) scanf("%lld %lld",&inp1, &inp2)
#define rl(inp) scanf("%d",&inp)
#define pf(out) printf("%lld\n", out);

const long long linf = 1e18+5;
const int mod = (int) 1e9 + 7;
const int inf = 1e9;

ll read(){
	bool minus = false;
	ll result = 0;
	char ch;
	ch = getchar();
	while (true) {
		if (ch == '-') break;
		if (ch >= '0' && ch <= '9') break;
		ch = getchar();
	}
	if (ch == '-') minus = true; else result = ch-'0';
	while (true) {
		ch = getchar();
		if (ch < '0' || ch > '9') break;
		result = result*10 + (ch - '0');
	}
	if (minus){
		return -result;
	}
	else{
		return result;
	}
}

ll fpow(ll base,ll power){
	ll result = 1;
	while (power > 0){
		if (power%2 == 1) result=(result*base);
  		base = (base*base);
  		power /= 2;
  	}
	return result;
}

#define maxn 100100
ll x[maxn];

int main(){
	ll n, a, b;
	cin >> n >> a >> b;
	ll i, j;
	for ( i = 0 ; i < n ; i ++ ){
		cin >> x[i];
	}
	ll ans = 0;
	for ( i = 1 ; i < n ; i ++ ){
		ll here = (x[i] - x[i-1]) * a;
		here = min(here, b);
		ans += here;
	}
	pf(ans);
	return 0;	
}

Measured memory_bytes: 1024
s=input()
ans = "Yes"
for i in range(int(len(s)/2)):
  if s[i*2] == "L":
    ans = "No"
    break
    
  elif s[i*2+1] == "R":
    ans = "No"
    break
if len(s)%2 == 1:
  if s[-1] == "L":
    ans = "No"
print(ans)

Measured memory_bytes: 3060
class node:
    parent = -1
    depth = 0

    def __init__(self, no, Children, k):
        self.no = no
        self.Children = Children
        self.numofchild = k
    
    def dfs(self, nodes, d):
        self.depth = d
        for i in range(self.numofchild):
            nodes[self.Children[i]].dfs(nodes, d+1)

head = -1
nodes = []
n = int(input())
for i in range(n):
    temp = node(i, [], 0)
    nodes.append(temp)

for i in range(n):
    temp = list(map(int,input().split()))
    if temp[1] > 0:
        child = temp[2 : 2+temp[1]]
        nodes[temp[0]].Children =child
        for j in range(temp[1]):
            nodes[nodes[temp[0]].Children[j]].parent = temp[0]
    nodes[temp[0]].numofchild = temp[1]

for i in range(n):
    if nodes[i].parent == -1:
        head = i
        break

nodes[head].dfs(nodes, 0)

for i in range(n):
    if nodes[i].parent == -1:
        print("node " + str(i) + ": parent = " + str(nodes[i].parent) + ", depth = " + str(nodes[i].depth) + ", root, [" + ', '.join(map(str, nodes[i].Children)) + "]")
    elif nodes[i].numofchild == 0:
        print("node " + str(i) + ": parent = " + str(nodes[i].parent) + ", depth = " + str(nodes[i].depth) + ", leaf, [" + ', '.join(map(str, nodes[i].Children)) + "]")
    else:
        print("node " + str(i) + ": parent = " + str(nodes[i].parent) + ", depth = " + str(nodes[i].depth) + ", internal node, [" + ', '.join(map(str, nodes[i].Children)) + "]")


Measured memory_bytes: 44028
#include <cmath>
#include <cstdio>
#include <iostream>

using namespace std;

int main() {

	int x, h;
	double S;

	while(cin >> x >> h) {
		if(x==0&&h==0)
			break;
		S=(x*x+x*sqrt((double)(x*x+4*h*h)));
		printf("%.6f\n", S);
	}

	return 0;

}

Measured memory_bytes: 0
import sys
from collections import deque
readline = sys.stdin.readline

def parorder(Edge, p):
    N = len(Edge)
    par = [0]*N
    par[p] = -1
    stack = [p]
    order = []
    visited = set([p])
    ast = stack.append
    apo = order.append
    while stack:
        vn = stack.pop()
        apo(vn)
        for vf in Edge[vn]:
            if vf in visited:
                continue
            visited.add(vf)
            par[vf] = vn
            ast(vf)
    return par, order

def getcld(p):
    res = [[] for _ in range(len(p))]
    for i, v in enumerate(p[1:], 1):
        res[v].append(i)
    return res

def bfs(s):
    Q = deque(s)
    used = set(s)
    dist = [0]*N
    while Q:
        vn = Q.pop()
        for vf in Edge[vn]:
            if vf not in used:
                used.add(vf)
                dist[vf] = 1 + dist[vn]
                Q.appendleft(vf)
    return dist

N = int(readline())
Edge = [[] for _ in range(N)]
for _ in range(N-1):
    a, b = map(int, readline().split())
    a -= 1
    b -= 1
    Edge[a].append(b)
    Edge[b].append(a)

dist0 = bfs([0])
st = dist0.index(max(dist0))
dists = bfs([st])
en = dists.index(max(dists))
diste = bfs([en])
D = dists[en]
path = [i for i in range(N) if dists[i] + diste[i] == D]
distp = bfs(path)

table = [1]*(N+5)
mini = 0
for i in range(N):
    if distp[i] == 0:
        continue
    fi = dists[i]
    if 2*distp[i] == fi:
        mini = max(mini, fi-1)
    else:
        mini = max(mini, fi)
    fi = diste[i]
    if 2*distp[i] == fi:
        mini = max(mini, fi-1)
    else:
        mini = max(mini, fi)

for i in range(mini+1):
    table[i] = 0
table[1] = 1
table[2] = 1
for i in range(D+1, N+1):
    table[i] = 1

print(''.join(map(str, table[1:N+1])))
            
    



Measured memory_bytes: 51896
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int t = sc.nextInt();
		for (int i=0;i<t;i++) {
			boolean ok = true;
			long a = sc.nextLong();
			long b = sc.nextLong();
			long c = sc.nextLong();
			long d = sc.nextLong();
			if(a<b) {
				ok = false;
			}
			if(d<b) {
				ok = false;
			}
			long gcd = gcd(b,d);
			
			if (a>=c+1) {
				long tmp = a-gcd*((a-c-1)/gcd);
				if(tmp<b) {
					ok = false;
				}
			}
			
			System.out.println(ok?"Yes":"No");
		}
	}
	
	static long gcd (long x, long y) {
		if (x<y) {
			return gcd(y,x);
		} else {
			if (x%y==0) {
				return y;
			} else {
				return gcd(y,x%y);
			}
		}
	}
}


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

#define MAX_AREA_SIZE 21

int main()
{
        int jen, jex, jey; // 宝の数、位置X、位置Y 
        bool jewel[MAX_AREA_SIZE][MAX_AREA_SIZE];
        int curX, curY;
        int step;
        char dire;
        int dist;
        bool flag;

        while(1){
                flag = true;
                for(int i=0; i<MAX_AREA_SIZE; i++){
                        for(int j=0; j<MAX_AREA_SIZE; j++){
                                jewel[i][j] = true;
                        }
                }
                // 宝物の位置をセット
                cin >> jen;
                if(jen == 0){ break; }
                for(int i=0; i<jen; i++){
                        cin >> jex >> jey;
                        jewel[jex][jey] = false;
                }
                curX = curY = 10;
                cin >> step; // なんステップ進むかを入手
                for(; step>0; step--){
                        cin >> dire >> dist; // 方向と距離を入手
                        switch(dire){
                        case 'N' : { for(; dist>0; dist--){jewel[curX][++curY]=true;} break; }
                        case 'S' : { for(; dist>0; dist--){jewel[curX][--curY]=true;} break; }
                        case 'W' : { for(; dist>0; dist--){jewel[--curX][curY]=true;} break; }
                        case 'E' : { for(; dist>0; dist--){jewel[++curX][curY]=true;} break; }
                        }
                }
                // 宝が全部ゲットできたかのチェック
                for(int i=0; i<MAX_AREA_SIZE; i++){
                        for(int j=0; j<MAX_AREA_SIZE; j++){
                                if(jewel[i][j]==false){ flag = false; }
                        }
                }

                if( flag == true ){ cout << "Yes" << endl; }
                else{ cout << "No" << endl; }
        }
        
        return 0;
}

Measured memory_bytes: 1152
#include <iostream>

int main(){
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  
  int32_t X;
  std::cin >> X;
  int32_t res = X % 100;
  int32_t div = X / 100;
  int32_t b,c,d,e,f;
  f = res / 5;
  res = res - (5 * f);
  e = res / 4;
  res = res - (4 * e);
  d = res / 3;
  res = res - (3 * d);
  c = res / 2;
  res = res - (2 * c);
  b = res;
  if (b + c + d + e + f <= div) {
    std::cout << '1' << std::endl;
  } else {
    std::cout << '0' << std::endl;
  }

  return 0;
}


Measured memory_bytes: 256
n,k=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
m=0
M=0

def cmb(n, r, p):
  if (r < 0) or (n < r):
      return 0
  r = min(r, n - r)
  return fact[n] * factinv[r] * factinv[n-r] % p

p = 10 ** 9 + 7
N = 10 ** 6  # N は必要分だけ用意する
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用
 
for i in range(2, N + 1):
  fact.append((fact[-1] * i) % p)
  inv.append((-inv[p % i] * (p // i)) % p)
  factinv.append((factinv[-1] * inv[-1]) % p)


for i in range(n-k+1):
  m+=a[i]*cmb(n-i-1,k-1,p)
  M+=a[n-1-i]*cmb(n-i-1,k-1,p)
print((M-m)%p)



Measured memory_bytes: 140236
#include<cstdio>
#define RI register int
#define CI const int&
using namespace std;
int x;
inline int gcd(CI x,CI y)
{
	return y?gcd(y,x%y):x;
}
int main()
{
	return scanf("%d",&x),printf("%d",360/gcd(x,360)),0;
}

Measured memory_bytes: 1724
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int N = sc.nextInt();
		int A = sc.nextInt();
		int B = sc.nextInt();
		int pro1=0;
		int pro2=0;
		int pro3=0;
		
		for (int i=0; i<N; i++){
			int num = sc.nextInt();
			if (num<=A){
				pro1++;
			}else if(num>=B+1){
				pro3++;
			}else{
				pro2++;
			}
		}
		int ans = Math.min(pro3, Math.min(pro1, pro2));
		System.out.println(ans);
	}

}

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

using namespace std;

#define FOR(i,s,e) for((i)=(s);(i)<(int)(e);(i)++)
#define REP(i,e) FOR(i,0,e)

#define all(o) (o).begin(), (o).end()
#define psb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))

typedef long long ll;
typedef pair<int, int> PII;

const double EPS = 1e-10;

const int M = 300;
const int T = 50;
const int P = 10;
const int R = 2000;
int m, t, p, r;

typedef struct team_def {
  int idx;  //index of the team
  int tac;  //total number of AC
  int tt;   //total time with penalty
  team_def() {idx = tac = tt = 0;}
  team_def(int _idx, int _tac, int _tt) {
    idx = _idx;
    tac = _tac;
    tt  = _tt;
  }
} team;

int my_compare(const void *pl, const void *pr) {
  team *tl = (team *)pl;
  team *tr = (team *)pr;
  
  //AC number...descending order
  if (tl->tac < tr->tac)
    return 1;
  else if (tl->tac > tr->tac)
    return -1;

  //penalty time...ascending order
  if (tl->tt < tr->tt)
    return -1;
  else if (tl->tt > tr->tt)
    return 1;

  //team index...descending order
  if (tl->idx < tr->idx)
    return 1;
  else if (tl->idx > tr->idx)
    return -1;

  return 0;
}

int ac[T][P]; //1:AC, 0:not AC
int wa[T][P]; //time with penalty
team tms[T];

int main() {
  int i, j;

  while (1) {
    memset(ac, 0, sizeof(ac));
    memset(wa, 0, sizeof(wa));
    scanf("%d%d%d%d ", &m, &t, &p, &r);
    if (!m && !p && !t && !r) break;
    for (i=0; i<r; i++) {
      int mm, tt, pp, rr;
      scanf("%d%d%d%d ", &mm, &tt, &pp, &rr);
      tt--; pp--;
      if (!rr) {
        ac[tt][pp] = 1; 
        wa[tt][pp] += mm;
      } else
        wa[tt][pp] += 20;
    }

    for (i=0; i<t; i++) {
      tms[i].idx = i; 
      tms[i].tac = tms[i].tt = 0;
    }
    for (i=0; i<t; i++)
      for (j=0; j<p; j++) {
        if (ac[i][j]) {
          tms[i].tac++;
          tms[i].tt += wa[i][j];
        }
      }

    qsort(tms, t, sizeof(team), my_compare);

    printf("%d", tms[0].idx + 1);
    for (i=1; i<t; i++) {
      if (tms[i].tac == tms[i-1].tac && tms[i].tt == tms[i-1].tt)
        printf("=");
      else
        printf(",");
      printf("%d", tms[i].idx + 1);
    }
    printf("\n");
  }

  return 0;
}

Measured memory_bytes: 1208
#include <bits/stdc++.h>
using namespace std; 
const int mod = 1e9+7;
int dp[3002][3002];
int main()
{
	string s,t;
	cin>>s>>t;
	int n = s.size(),m = t.size();
	for (int i = 0; i < n; ++i)
	{
		for(int j = 0; j < m; j++){
			if(s[i] == t[j]) {
				dp[i + 1][j + 1] = 1 + dp[i][j];
			}
			else {
				dp[i + 1][j + 1] = max(dp[i][j + 1], dp[i + 1][j]);
			}
		}
	}
	int i = n,j = m;
	string s1 = "";
	while(i > 0 && j > 0) {
		if(s[i - 1] == t[j - 1]) {
			s1 += s[i - 1];
			i--,j--;
		}
		else if(dp[i][j] == dp[i - 1][j]) {
			i--;
		}
		else j--;
	}
	reverse(s1.begin(), s1.end());
	cout << s1;
	return 0;
}

Measured memory_bytes: 35456
n = int(input())
a = list(map(int,input().split()))
sum_ls = [a[0]]
for i in range(1,n):
    sum_ls.append(sum_ls[i-1]+a[i])
check = sum_ls[n-1];ans = abs((check-sum_ls[0])-sum_ls[0])
for i in range(1,n-1):
    ans = min(ans,abs((check-sum_ls[i])-sum_ls[i]))
print(ans)

Measured memory_bytes: 24620
import sys
N = int(input())
A = list(map(int,input().split()))
k = 0
l = 0
m = 0
for i in range(N):
    if A[i] % 4 == 0:
        m += 1
    elif A[i] % 2 == 0:
        l += 1
    else:
        k += 1
if N <= 3:
    if m > 0:
        print('Yes')
        sys.exit()
    if k > 0:
        print('No')
        sys.exit()
    else:
        print('Yes')
        sys.exit()

if l == 0 and k == m + 1:
    print('Yes')
    sys.exit()


if k <= m:
    print('Yes')
else:
    print('No')

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

int bubbleSort(int *a, int n)
{
    int sw = 0;
    bool flag = true;
    for (int i = 0; flag; i++) {
        flag = false;
        for (int j = n - 1; j >= i + 1; j--) {
            if (a[j-1] > a[j]) {
                swap(a[j-1], a[j]);
                flag = true;
                sw++;
            }
        }
    }
    return sw;
}

int main()
{
    int a[101], n, sw;

    cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i];

    sw = bubbleSort(a, n);

    for (int i = 0; i < n; i++) {
        if (i) cout << " ";
        cout << a[i];
    }
    cout << endl;
    cout << sw << endl;

    return 0;
}

Measured memory_bytes: 3092
#include <stdio.h>

int main(){
	long long int min;
	long long int max ;
	int i,n;
	long long int sum = 0;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		long long int tmp;
		scanf("%lld",&tmp);
		if(i==0){
			min = tmp;
			max = tmp;
		}
		if(tmp<=min) min = tmp;
		if(tmp>=max) max = tmp;
		sum+=tmp;
	}
	printf("%lld %lld %lld\n",min,max,sum);
	return 0;
}

Measured memory_bytes: 600
using System;
using System.Collections.Generic;
using System.IO;
class Program
{
	static void Main(string[] args)
	{
		string[]str = Console.ReadLine().Split();
		int N = int.Parse(str[0]);
		int Q = int.Parse(str[1]);
		int[][]A = new int[N][];
		for(var i=0;i<N;i++){
			string[]str2 = Console.ReadLine().Split();
			A[i] = new int[3];
			A[i][0] = int.Parse(str2[0]);
			A[i][1] = int.Parse(str2[1]);
			A[i][2] = int.Parse(str2[2]);
		}
		int[]B = new int[Q];
		for(var i=0;i<Q;i++){
			B[i] = int.Parse(Console.ReadLine());
		}
		var list = new int[N*2][];
		for(var i=0;i<N;i++){
			list[i*2] = new int[3]{A[i][0]-A[i][2],1,A[i][2]};
			list[i*2+1] = new int[3]{A[i][1]-A[i][2],-1,A[i][2]};
		}
		Array.Sort(list,(x,y)=>(x[0]*2+(x[1]+1)/2).CompareTo(y[0]*2+(y[1]+1)/2));
		var xList = new HashSet<int>();
		int a1 = 0;
		int[] ans = new int[Q];
		bool flag = false;
		int min = -1;
		for(var i=0;i<Q;i++){
			while(a1<N*2 && list[a1][0]<=B[i]){
				if(list[a1][1]==1){
					xList.Add(list[a1][2]);
					if(min==-1){
						min = list[a1][2];
					} else {
						min = Math.Min(min,list[a1][2]);
					}
				} else {
					xList.Remove(list[a1][2]);
					if(min==list[a1][2]){
						flag = true;
						if(xList.Count==0){
							min = -1;
						}
					}
				}
				a1++;
			}
			if(flag){
				if(xList.Count==0){
					min = -1;
				} else {
					min = 2000000000;
					foreach(var h in xList){
						min = Math.Min(h,min);
					}
				}
				ans[i] = min;
				flag = false;
			} else {
				ans[i] = min;
			}
		}
		var sw = new StreamWriter(Console.OpenStandardOutput()){AutoFlush = false};
		Console.SetOut(sw);
		for(var i=0;i<Q;i++){
			Console.WriteLine(ans[i]);	
		}
		Console.Out.Flush();
	}
}

Measured memory_bytes: 61036
#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)%MOD)+((b+MOD)%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 PI 3.1415926535897
#define EPS (1e-10)
#define INF INT_MAX
#define INFLL LLONG_MAX
#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 MCI = std::map<char, int>;
using VPII = std::vector<PII>;
using namespace std;


signed main(){
	int N, H, W;
	cin >> N >> H >> W;

	cout << (N-H+1)*(N-W+1) << endl;

	return 0;
}

Measured memory_bytes: 256
import sys
from math import floor
def input(): return sys.stdin.readline().strip()
mod = 10**9+7

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

def main():
    N = int(input())
    if N== 1:
        print(0)
        return
    
    arr = factorization(N)
    ans = 0
    for p, i in arr:
        num = 0
        while num * (num + 1) // 2 <= i: num += 1
        ans += num - 1
    print(ans)

    

if __name__ == "__main__":
    main()


Measured memory_bytes: 63564
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n); i >= 0; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;

int main(){
    ll H,W,N;
    cin >> H >> W >> N;
    vector<ll> a(N);
    vector<ll> b(N);
    rep(i,N){
        cin >> a[i] >> b[i];
    }
    map<pair<ll,ll>,ll> ans;
    rep(i,N){
            for (ll j = -1; j <= 1; j++){
                for (ll k = -1; k <= 1; k++){
                    if (a[i] + j >= 2 && a[i] + j <= H - 1 && b[i] + k >= 2 && b[i] + k <= W - 1) ans[pair<ll,ll>(a[i] + j, b[i] + k)]++;
                }
            }
    }
    vector<ll> ans_sum(10,0);
    ll ans_sub = 0;
    for (map<pair<ll,ll>,ll>::iterator itr = ans.begin(); itr != ans.end(); itr++){
        ans_sum[itr->second]++;
        ans_sub++;
    }
    cout << (H - 2) * (W - 2) - ans_sub << endl;
    for (ll i = 1; i <= 9; i++){
        cout << ans_sum[i] << endl;
    }
}

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

int main()
{
	int n, i, j;
	cin>>n;
	
	int a[n][3], b[n][3];
	
	for(i=0; i<n; i++)
	{
	    for(j=0; j<3; j++)
	    {
	        cin>>a[i][j];
	    }
	}
	b[0][0] = a[0][0];
	b[0][1] = a[0][1];
	b[0][2] = a[0][2];
	
	if (n != 1)
	{
	    for(i=1; i<n; i++)
    	{
    	    for(j=0; j<3; j++)
    	    {
    	        if (j == 0)
    	        {
    	            b[i][j] = a[i][j] + max(b[i-1][1], b[i-1][2]);
    	        }
    	        else if (j == 1)
    	        {
    	            b[i][j] = a[i][j] + max(b[i-1][0], b[i-1][2]);
    	        }
    	        else if (j == 2)
    	        {
    	            b[i][j] = a[i][j] + max(b[i-1][1], b[i-1][0]);
    	        }
    	    }
    	}
	}
	cout<<max(b[n-1][0], max(b[n-1][1], b[n-1][2]));
	return 0;
}


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


//Tはdpの型　Dataは辺のコスト
template<typename Data,typename T>
struct ReRooting{
    struct Node{
        int to,rev;
        Data data;
        Node(int to,int rev,Data data):to(to),rev(rev),data(data){}
    };

    using F1=function<T(T,T)>;
    using F2=function<T(T,Data)>;

    vector<vector<Node>> g;
    vector<vector<T>> ldp,rdp;
    vector<int> lptr,rptr;
    const F1 f1;
    const F2 f2;
    const T ident; //Tの単位元 ex.最小値を求める場合はinf

    ReRooting(int n,const F1 &f1,const F2 &f2,const T &ident):
        g(n),ldp(n),rdp(n),lptr(n),rptr(n),f1(f1),f2(f2),ident(ident){}
    
    void add_edge(int u,int v,const Data &d){
        g[u].emplace_back( v,g[v].size(),d );
        g[v].emplace_back( u,(int)g[u].size()-1,d );
    }
    void add_edge(int u,int v,const Data &d,const Data &e){
        g[u].emplace_back( v,g[v].size(),d );
        g[v].emplace_back( u,(int)g[u].size()-1,e );
    }

    T dfs(int idx,int par){
        while(lptr[idx]!=par  && lptr[idx]<g[idx].size()){
            auto &e=g[idx][lptr[idx]];
            ldp[idx][lptr[idx]+1]=f1(ldp[idx][lptr[idx]],f2(dfs(e.to,e.rev),e.data));
            lptr[idx]++;
        }

        while(rptr[idx]!=par && rptr[idx]>=0){
            auto &e=g[idx][rptr[idx]];
            rdp[idx][rptr[idx]]=f1(rdp[idx][rptr[idx]+1],f2(dfs(e.to,e.rev),e.data));
            rptr[idx]--;
        }
        if(par<0) return rdp[idx][0];
        return f1(ldp[idx][par],rdp[idx][par+1]);
    }
    
    vector<T> solve(){
        for(int i=0;i<g.size();i++){
            ldp[i].assign(g[i].size()+1,ident);
            rdp[i].assign(g[i].size()+1,ident);
            lptr[i]=0;
            rptr[i]=(int)g[i].size()-1;
        }
        vector<T> ret;
        for(int i=0;i<g.size();i++){
            ret.push_back(dfs(i,-1));
        }
        return ret;
    }

};

signed main(){
    int n;
    cin>>n;
    using pi=pair<int,int>;
    const int INF=1<<30;

    auto f1=[](pi a,pi b){
        for(auto &t:{b.first,b.second}){
            if(a.first<t){
                a.second=a.first;
                a.first=t;
            }else if(a.second<t){
                a.second=t;
            }
        }
        return a;
    };

    auto f2=[](pi a,int d){
        return pi(max(0,a.first)+d,-INF);
    };

    ReRooting<int,pi> g(n,f1,f2,pi(-INF,-INF));

    for(int i=1;i<n;i++){
        int s,t,w;
        cin>>s>>t>>w;
        g.add_edge(s,t,w);
    }
    int ret=0;
    for(auto &p:g.solve()){
        ret=max(ret,p.first);
        ret=max(ret,p.first+p.second);
    }
    cout<<ret<<endl;
}


Measured memory_bytes: 58456
#include <stdio.h>
#include <iostream>
#include <vector>

int main()
{
    int n, d;
    std::cin >> n >> d;
    std::vector<int> xi, yi;
    for (int i = 0; i < n; i++)
    {
        int x, y;
        std::cin >> x >> y;
        xi.push_back(x);
        yi.push_back(y);
    }

    int c = 0;
    long long dd = ((long long)d) * d;
    for (int i = 0; i < n; i++)
    {
        long long x = xi[i];
        long long y = yi[i];
        long long t = x * x + y * y;
        if (t <= dd)
            c++;
    }
    printf("%d", c);
    return 0;
}

Measured memory_bytes: 5100
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Comparator;
import java.util.List;
import java.util.StringTokenizer;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

public class Main {
    public static void main(final String[] args) {
        final FastScanner scanner = new FastScanner(System.in);
        final int n = scanner.nextInt();
        final List<Pair> list = IntStream.range(0, n)
            .mapToObj(i -> new Pair(scanner.nextInt(), scanner.nextInt()))
            .collect(Collectors.toList());

        final List<Integer> aSortedList = list.stream()
            .map(pair -> pair.a)
            .sorted()
            .collect(Collectors.toList());

        final List<Integer> bSortedList = list.stream()
            .map(pair -> pair.b)
            .sorted(Comparator.reverseOrder())
            .collect(Collectors.toList());

        if (n % 2 == 1) {
            System.out.println(bSortedList.get(n / 2) - aSortedList.get(n / 2) + 1);
            return;
        }

        final int a = (n - 1) / 2;
        final int b = n / 2;
        final double formerBegin = aSortedList.get(a);
        final double formerEnd = bSortedList.get(b);
        final double latterBegin = aSortedList.get(b);
        final double latterEnd = bSortedList.get(a);

        final double begin = (formerBegin + latterBegin) / 2;
        final double end = (formerEnd + latterEnd) / 2;
        System.out.println((int) ((end - begin) * 2 + 1));
    }

    private static class Pair {
        final int a;
        final int b;

        Pair(final int a, final int b) {
            this.a = a;
            this.b = b;
        }
    }

    private static class FastScanner {
        private final BufferedReader reader;
        private StringTokenizer tokenizer;

        FastScanner(final InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
        }

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

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

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (final IOException e) {
                    throw new RuntimeException(e);
                }
            }

            return tokenizer.nextToken("\n");
        }
    }
}


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

using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, x) for(int i=1;i<=(int)(x);i++)
#define all(x) (x).begin(),(x).end()

#include <bits/stdc++.h>

using namespace std;

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

    vector<int> a(N);

    rep(i, N)cin >> a.at(i);

    int max_length = 0;
    int length = 0;

    rep(i, N) {
        if (i != N - 1 && a.at(i) >= a.at(i + 1)) {
            length++;
        } else {
            if(length > max_length){
                max_length = length;
            }
            length = 0;
        }
    }

    cout << max_length << endl;
}


Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Msolutions
{
    class D
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());

            List<int[]> edges = new List<int[]>();
            HashSet<int>[] sets = new HashSet<int>[N];
            for(int i = 0; i < N; i++)
            {
                sets[i] = new HashSet<int>();
            }

            int[] n = new int[N];
            for (int i = 0; i < N - 1; i++)
            {
                int[] e = Console.ReadLine().Split(' ').Select(o => int.Parse(o)).ToArray();
                edges.Add(e);
                int a = e[0] - 1, b = e[1] - 1;
                n[a]++; n[b]++;
                sets[a].Add(b);
                sets[b].Add(a);
            }

            int imax = -1, max = -1;
            for(int i = 0; i < N; i++)
            {
                if (n[i] > max)
                {
                    imax = i; max = n[i];
                }
            }

            int[] tree = Enumerable.Repeat(-1, N).ToArray();
            int[] parent = Enumerable.Repeat(-1, N).ToArray();
            int current = imax;
            tree[0] = current;
            int indexS=0,indexE = 1;
            int index = 1;
            int depth = 0;
            while (index<N)
            {
                index = indexE;
                for (int j = indexS; j < indexE; j++)
                {
                    current = tree[j];
                    MakeTree(current, tree, ref index, sets[current], parent);
                }
                depth++;
                indexS = indexE;
                indexE = index;
            }

            List<int> c = Console.ReadLine().Split(' ').Select(o => int.Parse(o)).ToList();

            int[] t = new int[N];
            int idx = 0;
            foreach(int z in c.OrderBy(x => x))
            {
                int node = tree[N - idx - 1];
                t[node] = z;
                idx++;
            }

            long sum = 0;
            foreach(int[] e in edges)
            {
                int a = e[0]-1, b = e[1]-1;
                long min = Math.Min(t[a], t[b]);
                sum += min;
            }

            Console.WriteLine(sum);
            Console.WriteLine(string.Join(" ", t));

        }

        static void MakeTree(int current, int[] tree, ref int index, HashSet<int> set, int[] parent)
        {
            foreach(int x in set)
            {
                if (x == parent[current]) continue;
                tree[index] = x;
                parent[x] = current;
                index++;
            }
        }

    }
    }


Measured memory_bytes: 23740
#include <queue>
#include <set>
#include <string>
#include <algorithm>
#include <iostream>
using namespace std;
using P = pair<int, int>;

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

	for (int i = 0; i < a + b + 1; i++) {
		if (i == a) {
			if (s[i] != '-') {
				cout << "No" << endl;
				return 0;
			}
		}
		else {
			if ('0' <= s[i] && s[i] <= '9') {

			}
			else {
				cout << "No" << endl;
				return 0;
			}
		}
	}

	cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(){
  string n; cin >> n;
  for(int i = 0; i < n.size(); i++){
    if(n[i] == '1') cout << 9;
    else if(n[i] == '9') cout << 1;
    else cout << n[i];
  }
  return 0;
}


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

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long x[] = new long[3];
		long ans = 0;

		for (int i = 0; i < x.length; i++) {
			x[i] = sc.nextInt();
		}


		Arrays.sort(x);



		ans = Math.abs(x[2]/2 - (x[2] - x[2]/2)) * x[1] * x[0];




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

}

Measured memory_bytes: 9556
#include<stdio.h>
#include<stdlib.h>
int sum(int);
void add(int,int);
int comp( const void *c1, const void *c2 );
int a[101],b[101],bit[101],n;

int main(void){
  int j,ans;

  while(scanf("%d",&n),n){
    for(j=0;j<101;j++)
      bit[j]=0;
    for(j=0;j<n;j++){
      scanf("%d",&a[j]);
      b[j]=a[j];
    }
    qsort(b,n,sizeof(int),comp);
    for(j=0;j<n;j++)
      a[j]=(int *)bsearch(&a[j],b,n,sizeof(int),comp)-b;
    
    ans=0;
    for(j=0;j<n;j++){
      ans += j - sum(a[j]);
      add(a[j],1);
}
    printf("%d\n",ans);
    }
  return 0;
}

int sum(int i){
  int s=0;i+=1;
  while(i>0){
    s += bit[i];
    i -= i & -i;
  }
  return s;
}

void add(int i,int x){
  i+=1;
  while(i <= n){
    bit[i]+=x;
    i += i & -i;
  }
}

int comp( const void *c1, const void *c2 ){
  int tmp1 = *(int *)c1;
  int tmp2 = *(int *)c2;

  if( tmp1 < tmp2 )  return -1;
  if( tmp1 == tmp2 ) return  0;
  if( tmp1 > tmp2 )  return  1;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N=1e6+10;
int a[N],n,b;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)cin>>a[i];
	for(int i=1;i<=n;i++)
	{
		for(int j=i+1;j<=n;j++)
		b+=a[i]*a[j];
	}cout<<b;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <math.h>
#include <vector>
#include <map>
using namespace std;
int main() {
  int A, B;
  cin >> A >> B;
  if (A >= 13) {
	  cout << B;
	}
  else if (A >= 6) {
	  cout << B / 2;
	}
  else {
	  cout << 0;
	}
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int Maxn=1e5+10;
int N;
int A[3][Maxn];
int Dp[3][Maxn];
int main()
{
	cin>>N;
	for(int i=1;i<=N;i++) cin>>A[0][i]>>A[1][i]>>A[2][i];
	for(int i=1;i<=N;i++)
	{
		Dp[0][i]=A[0][i]+max(Dp[1][i-1],Dp[2][i-1]);
		Dp[1][i]=A[1][i]+max(Dp[0][i-1],Dp[2][i-1]);
		Dp[2][i]=A[2][i]+max(Dp[0][i-1],Dp[1][i-1]);
	}
	cout<<max(Dp[0][N],max(Dp[1][N],Dp[2][N]))<<endl;
	return 0;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
#define rep(i,a,b) for (register int i=(a); i<=(b); ++i)
#define per(i,a,b) for (register int i=(a); i>=(b); --i)
using namespace std;
 
inline char getch() {
	static char buf[300000], *p1 = buf, *p2 = buf;
	return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 300000, stdin), p1 == p2) ? EOF : *p1++;
}
inline int read() {
	char ch = getch(); int x = 0;
	while (!isdigit(ch)) ch = getch();
	while (isdigit(ch)) { x = (x<<3) + (x<<1) + ch - '0'; ch = getch(); }
	return x;
}
 
const int maxm = 100005, MOD = 1000000007;
int p[30][3][3], q[3][3], t[3][3], A[3][3];
int x, last = -1, n, m;
 
inline void mul33(int a[3][3], int b[3][3], int c[3][3]) {
	t[0][0] = (1LL * a[0][0] * b[0][0] + 1LL * a[0][1] * b[1][0] + 1LL * a[0][2] * b[2][0]) % MOD;
	t[0][1] = (1LL * a[0][0] * b[0][1] + 1LL * a[0][1] * b[1][1] + 1LL * a[0][2] * b[2][1]) % MOD;
	t[0][2] = (1LL * a[0][0] * b[0][2] + 1LL * a[0][1] * b[1][2] + 1LL * a[0][2] * b[2][2]) % MOD;
	t[1][0] = (1LL * a[1][0] * b[0][0] + 1LL * a[1][1] * b[1][0] + 1LL * a[1][2] * b[2][0]) % MOD;
	t[1][1] = (1LL * a[1][0] * b[0][1] + 1LL * a[1][1] * b[1][1] + 1LL * a[1][2] * b[2][1]) % MOD;
	t[1][2] = (1LL * a[1][0] * b[0][2] + 1LL * a[1][1] * b[1][2] + 1LL * a[1][2] * b[2][2]) % MOD;
	t[2][0] = (1LL * a[2][0] * b[0][0] + 1LL * a[2][1] * b[1][0] + 1LL * a[2][2] * b[2][0]) % MOD;
	t[2][1] = (1LL * a[2][0] * b[0][1] + 1LL * a[2][1] * b[1][1] + 1LL * a[2][2] * b[2][1]) % MOD;
	t[2][2] = (1LL * a[2][0] * b[0][2] + 1LL * a[2][1] * b[1][2] + 1LL * a[2][2] * b[2][2]) % MOD;
	c[0][0] = t[0][0]; c[0][1] = t[0][1]; c[0][2] = t[0][2];
	c[1][0] = t[1][0]; c[1][1] = t[1][1]; c[1][2] = t[1][2];
	c[2][0] = t[2][0]; c[2][1] = t[2][1]; c[2][2] = t[2][2];
}
 
inline void mul31(int a[3][3], int b[3][3], int c[3][3]) {
	t[0][0] = (1LL * a[0][0] * b[0][0] + 1LL * a[0][1] * b[1][0] + 1LL * a[0][2] * b[2][0]) % MOD;
	t[1][0] = (1LL * a[1][0] * b[0][0] + 1LL * a[1][1] * b[1][0] + 1LL * a[1][2] * b[2][0]) % MOD;
	t[2][0] = (1LL * a[2][0] * b[0][0] + 1LL * a[2][1] * b[1][0] + 1LL * a[2][2] * b[2][0]) % MOD;
	c[0][0] = t[0][0]; c[1][0] = t[1][0]; c[2][0] = t[2][0];
}
 
inline void mulPower(int k, int a[3][3]) {
	per (i, 29, 0) if (k>>i&1) mul31(p[i], a, a);
}
 
 
int main() {
	p[0][0][0] = 1; p[0][0][1] = 0; p[0][0][2] = 1;
	p[0][1][0] = 2; p[0][1][1] = 1; p[0][1][2] = 2;
	p[0][2][0] = 1; p[0][2][1] = 1; p[0][2][2] = 2;
	q[0][0] = 1; q[0][1] = 0; q[0][2] = 0;
	q[1][0] = 2; q[1][1] = 1; q[1][2] = 0;
	q[2][0] = 1; q[2][1] = 1; q[2][2] = 1;
	rep (i, 1, 29) mul33(p[i-1], p[i-1], p[i]);
	A[0][0] = 1; n = read(); m = read();
	while (m--) {
		x = read();
		mulPower(x-last-1, A);
		mul31(q, A, A);
		last = x;
	}
	mulPower(n-last-1, A);
	printf("%d\n", A[2][0]);
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define REP(i, a, n) for (long long i = (a); i < (long long)(n); ++i)
#define REPC(i, a, n) for (long long i = (a); i <= (long long)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init)                                          \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T> using VEC = std::vector<T>;
template <class T> using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail> void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T> ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec)
    os << v << ",";
  os << "}";
  return os;
}
template <typename T> ostream &operator<<(ostream &os, set<T> &s) {
  os << "{";
  for (auto p : s)
    os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m)
    os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}

int main() {
  int N,K;
  cin>>N>>K;
  double sum = 0;
  REP(i, 1, N+1){
    int wins = max(0,(int)ceil(log2((double)K/i)));
    double per = pow(0.5, wins)/N;
    // DUMP(i, wins, per, sum);
    sum+=per;
  }
  printf("%.16lf\n", sum);

  return 0;
}


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

// template {{{  0 
// using {{{ 1
using ll = long long int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vii = vector<pii>;
using vll = vector<pll>;
// }}} 1
// definition {{{ 1
// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%lld", &x)
#define Scll2(x,y) scanf("%lld%lld", &x, &y)
#define Scll3(x,y,z) scanf("%lld%lld%lld", &x, &y, &z)
#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2
// constants {{{ 2
#define EPS (1e-7)
#define INF (2e9)
#define PI (acos(-1))
// }}} 2
// systems {{{ 2
#define Repe(x,y,z) for(ll x = z; x < y; x++)
#define Rep(x,y) Repe(x,y,0)
#define RRepe(x,y,z) for(ll x = y-z-1; x >= 0; x--)
#define RRep(x,y) RRepe(x,y,0)
// }}} 2
// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n")
#define YESNO(a) (a)?printf("YES\n"):printf("NO\n")
// }}} 2
// }}} 1
// input {{{ 1
// }}} 1
// random {{{ 1
ll rnd(){
    static ll x = time(0);
    x = x ^ (x << 13); x = x ^ (x >> 7);
    return x = x ^ (x << 17);
}
// }}}
// }}} 0

int N;
vector<vi> ex(100000);
vector<vi> ey(100000);
vi xid(100000,-1);
vi yid(100000,-1);

void dfsy( int from, int id );

void dfsx( int from, int id ){
    if( xid[from] > 0 ) return;
    xid[from] = id;
    for( int to : ex[from] ){
        dfsy( to, id );
    }
}
void dfsy( int from, int id ){
    if( yid[from] > 0 ) return;
    yid[from] = id;
    for( int to : ey[from] ){
        dfsx( to, id );
    }
}

int main() {

    Scd(N);

    int x,y;
    Rep(i,N){
        Scd2(x,y);
        x--,y--;
        ex[x].push_back(y);
        ey[y].push_back(x);
    }


    int id = 1;
    stack<int> s;
    Rep(i,100000){
        if( xid[i] > 0 ) continue;
        if( ex[i].size() ){
            dfsx(i,id++);
        }
    }

    vl cntx(100001);
    vl cnty(100001);
    Rep(i,100000){
        if( xid[i] > 0 ) cntx[xid[i]]++;
        if( yid[i] > 0 ) cnty[yid[i]]++;
    }

    ll ans = 0;
    Rep(i,100000){
        ans += cntx[i]*cnty[i];
    }

    printf ("%lld\n", ans-N );

    return 0;
}




Measured memory_bytes: 12416
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cstring>

#define rep0(i, n) for (i = 0; i < n; i++)
#define rep(s, i, n) for (i = s; i < n; i++)
using namespace std;

int X,Y;
bool ans;

int main()
{
    int i,a;
    cin >> X >> Y;

    rep0(i, X+1)
    {
        a=i*2+(X-i)*4;
        if(a==Y) {ans=true; break;}
    }
    if(ans)
    cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define faster ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define ll long long
#define ld long double
#define p0(a) cout << a << " "
#define p1(a) cout << a << endl
#define vi vector<int>
#define pii pair<int,int>
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define REP(i,a,b) for(ll i = a; i < b; i++)
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) (a * b) / gcd(a, b)
#define bins(v, x) binary_search(v.begin(), v.end(), x)
#define pi 2*acos(0.0)
const int INF = 1e7;
const int mod = 1e9 + 7;
 
ll modExp(ll base, ll exp, ll mod) {
   ll res = 1;
   while (exp > 0) {
    	if (exp % 2 == 1) {
        	res= (res * base) % mod;
		}
      exp = exp >> 1;
      base = (base * base) % mod;
   }
   return res;
}
 
ll nCr(ll n, ll k) { 
   ll C[n + 1][k + 1]; 
   
   REP(i,0,n+1){ 
      REP(j,0,min(i,k)+1) {
         if(j==0 || j==i) {
            C[i][j] = 1;  
         } else {
            C[i][j] = C[i-1][j-1] + C[i-1][j]; 
         }
      } 
   }
   return C[n][k]; 
}

bool compare(pair<int, int>&i, pair<int, int>&j) {
    return (i.S > j.S || (i.S == j.S && i.F > j.F));
}

int main() {
   //freopen("input.txt","r",stdin);
   //freopen("output.txt","w",stdout);

   ld a, b;
   cin >> a >> b;

   ld prod = a * b;
   cout << (ll)floor(prod);
}

Measured memory_bytes: 3732
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <string>
#include <unordered_set>
#include <vector>
#define REP(i, n) for(int i = 0; i < n; ++i)

using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

int main()
{
	LLONG N, D; cin >> N >> D;
	int count = 0;
	REP(i, N)
	{
		LLONG x, y; cin >> x >> y;
		if (x * x + y * y <= D * D) ++count;
	}
	cout << count << endl;
}

Measured memory_bytes: 3628
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <ratio>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <climits>
#define ll long long
#define ld long double
#define mp make_pair
#define pb push_back
#define in insert
#define vll vector<ll>
#define endl "\n"
#define pll pair<ll,ll>
#define f first
#define s second
#define FOR(i,a,b) for(int i=(a),_b=(b); i<=_b; i++)
#define int ll
#define sz(x) (ll)x.size()
#define all(x) (x.begin(),x.end())
using namespace std;

 
const ll INF = LLONG_MAX;
const ll N =(1e5+5); // TODO : change value as per problem
const ll MOD = 1e9+7;

int x[N];
int arr[N];
int pre[N];
void solve(){
	int a,b,c,d;
	cin >>a>>b>>c>>d;
	cout<<max(a*b,c*d)<<endl;
}
signed main(){
 
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
     // freopen(".in","r",stdin);freopen(".out","w",stdout);
    
     ll tt=1;   
     // cin >> tt;
    while(tt--){    
        solve();
    }    
}

Measured memory_bytes: 3608
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <math.h>
#include <vector>

#include <bits/stdc++.h>
using namespace std;

#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#define MAX(a, b) (((a) > (b)) ? (a) : (b))
#define TRUE (0)
#define FALSE (1)

// This value shold be close to used maximum value.  
#define NUM_MAX 20000000005

// void sort(uint32_t *num, uint32_t size);
int main()
{   
 
    vector<long long> vec(0);
    // vector<long long> res_vec(0);
    // uint64_t res_arr[NUM_MAX];
    // uint32_t sum = 0;
    uint64_t monster;
    uint64_t hissatsu;
    uint64_t result;
    uint64_t sum;

    // uint32_t res_i = 0;
    // string str_temp, str_temp2;
    uint64_t temp, temp2;
    uint64_t i, j, k, l, m, n, o, size;
    // uint32_t count = 0;
    // string str;
    // uint8_t k_flag;
 
    cin >> monster >> hissatsu;

    for (i = 0; i < monster; i++) {
        cin >> temp;
        vec.push_back(temp);
    }

    if (hissatsu >= monster) {
        result = 0;
    } else {
        sort(vec.begin(), vec.end());
    
        sum = 0;
        for (i = 0; i < monster - hissatsu; i++) {
            sum = sum + vec[i];
        }
        result = sum;
    }
    
    cout << result << endl;

    return 0;
}

// void sort(uint32_t *num, uint32_t size) {
//     uint32_t i, j, k;
//     uint32_t sorted_num;
//     uint32_t array[NUM_MAX] = {0};

//     for (i = 1; i < size + 1; i++) {
//         array[num[i - 1]]++;
//     }

//     sorted_num = 0;

//     for (i = 0; i < NUM_MAX; i++) {
//         for (j = 0; j < array[i]; j++) {
//             num[j + sorted_num] = i;
//         }
//         sorted_num += j;
//         j = 0;
//     }

//     return;
// }


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

//↓0-originか1-originでn回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   //0-origin昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) //1-origin昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  //0-origin降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   //1-origin降順
//rep2 -> 第二引数 m から n 回繰り返し ex) m=5 n=3 なら i=5,i=6,i=7 まで
#define rep2(i,m,n) for(int i = ((int)(m)); i < ((int)(n))+((int)(m)); i++)
#define SIZE(x) ((int)((x).size()))
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii; //2次元配列
typedef vector<ll> vll;
typedef vector<string> vs;
template<typename T> bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1;} return 0;}
template<typename T> bool chmin(T &a, const T &b){ if(a>b){ a=b; return 1;} return 0;}


/*FUNCs=================================================*/
/*GRAPH_TEMPLATE=============================================*/
template<typename T_n>
class Edge {
public:
    int srch; //searched?探索状態記録「null = -1」
    int to; //辺の行き先
    T_n cost; //辺の重み
    Edge(int t, T_n w) : srch(-1), to(t), cost(w) {}
    Edge(int src, int t, T_n w) : srch(src), to(t), cost(w) {}
};
template<typename T_n>
using Edges = vector<Edge<T_n>>;  //重み付き辺集合,行き先を
template<typename T_n>
using W_Graph = vector<Edges<T_n>>; //重み付きグラフ
using Graph = vector<vector<int>>;  //通常グラフ

 
/*===========================================================*/
bool can;
int seen[100100];

void dfs_solve(const W_Graph<int> &G, int i) {
    if(G[i].empty()) return;
    for(auto e : G[i]) {
        //距離が偶数
        if(e.cost%2 == 0) {
            if(seen[e.to] == -1) {
                seen[e.to] = seen[i];
                dfs_solve(G, e.to);  //未訪問だったNodeについて再帰
            }
        }
        //距離が奇数
        else {
            if(seen[e.to] == -1) {
                seen[e.to] = (seen[i] == 1 ? 0 : 1);
                dfs_solve(G, e.to);  //未訪問だったNodeについて再帰
            }
        }
    }
}

/*MAIN==================================================*/
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化

    //入力
    int n; cin >> n;
    W_Graph<int> G(n+1); //  <- 1-origin
    rep1(i,n-1) {
        int u, v, w; cin >> u >> v >> w;
        G[u].push_back(Edge<int>(v, w));
        G[v].push_back(Edge<int>(u, w));
    }

    memset(seen, -1, sizeof(seen)); //seenを初期化    
    seen[1] = 1;                    //探索開始位置の色を'1'に設定
    dfs_solve(G, 1);

    //出力
    rep1(ans, n) cout << seen[ans] << '\n';
}

Measured memory_bytes: 8192
require 'prime'

N = gets.to_i
ary = Prime.prime_division(N)
n = N
cnt = 0
ary.each do |a|
    e = 0
    a[1].times do
        e += 1
        if n % (a[0]**e) == 0
            n = n.div(a[0]**e)
            cnt += 1
        end
    end
end
puts cnt

Measured memory_bytes: 14488