akhauriyash/Code-Regression huggingface dataset:
using System;

namespace ABC_095_A_Csharp_ver
{
    class Program
    {
        static void Main(string[] args)
        {
            string S = Console.ReadLine();
            int s = 700;
            if (S[0] == 'o') s += 100;
            if (S[1] == 'o') s += 100;
            if (S[2] == 'o') s += 100;
            Console.WriteLine(s);
            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 11092
M, D = [int(i) for i in input().split()]
cnt = 0
for m in range(1, M+1):
    for d in range(1, D+1):
        d10 = d // 10
        d1 = d % 10
        if d10 >= 2 and d1 >= 2 and d10*d1 == m:
            cnt += 1
print(cnt)

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

N, K = map(int, input().split())
p = list(map(int, input().split()))
s = sum(p[:K])
m = s
for i in range(K, N):
    s += p[i] - p[i-K]
    m = max(m, s)
print((m + K) / 2)

Measured memory_bytes: 67824
//Aizu Online Judge Volume11-1104
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		
		while(true) {
			int xMax = scanner.nextInt();
			int yMax = scanner.nextInt();
			
			if (xMax == 0 && yMax == 0) {return;}
			
			RobotInstance rob = new RobotInstance(xMax, yMax);
			
			while(true) {
				String s = scanner.next();
				if (s.equals("STOP")) break;
				if (s.equals("RIGHT")) {
					rob.changeDirection(true);
				}
				if (s.equals("LEFT")) {
					rob.changeDirection(false);
				}
				if (s.equals("FORWARD")) {
					int n = scanner.nextInt();
					rob.forward(n);
				}
				if (s.equals("BACKWARD")) {
					int n = scanner.nextInt();
					rob.backward(n);
				}
			}
			
			System.out.println(String.format("%1$d %2$d", rob.getX(), rob.getY()));
		}
	}

	private static class RobotInstance {
		int xMax, yMax;
		int x, y;
		int vx, vy;
		int direction;
		
		public RobotInstance(int xMax, int yMax) {
			this.xMax = xMax;
			this.yMax = yMax;
			direction = 1;
			setVxVy();
			x = 1;
			y = 1;
		}
		
		public void forward(int n) {
			x = x + n * vx;
			y = y + n * vy;
			
			checkBorder();
		}

		public void backward(int n) {
			x = x - n * vx;
			y = y - n * vy;
			
			checkBorder();
		}
		
		public void changeDirection(boolean isRight) {
			if (isRight) {
				direction += 1;
			} else {
				direction -= 1;
			}
			
			if (direction == 0) {direction = 4;}
			if (direction == 5) {direction = 1;}
			
			setVxVy();
		}
		
		private void checkBorder() {
			if (x < 1) {x = 1;}
			if (x > xMax) {x = xMax;}
			if (y < 1) {y = 1;}
			if (y > yMax) {y = yMax;}
		}
		
		private void setVxVy() {
			if (direction == 1) {
				vx = 0; vy = 1;
			}
			if (direction == 2) {
				vx = 1; vy = 0;
			}
			if (direction == 3) {
				vx = 0; vy = -1;
			}
			if (direction == 4) {
				vx = -1; vy = 0;
			}
		}
		
		public int getX() {
			return x;
		}
		public int getY() {
			return y;
		}
	}
}

Measured memory_bytes: 23628
N = gets.to_i
as = gets.split.map(&:to_i).sort
bs = gets.split.map(&:to_i).sort
cs = gets.split.map(&:to_i).sort

b2a = Array.new(N, 0)
b2c = Array.new(N, 0)
N.times do |i|
    while as.length > 0 && as[0] < bs[i]
        b2a[i] += 1
        as.shift
    end
    b2a[i] += b2a[i - 1] if i > 0
end

(N - 1).downto(0) do |i|
    while cs.length > 0 && cs[-1] > bs[i]
        b2c[i] += 1
        cs.pop
    end
    b2c[i] += b2c[i + 1] if i < N - 1
end

puts N.times.map{|i| b2a[i] * b2c[i]}.inject(:+)

Measured memory_bytes: 26224
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        double[] array = new double[n];
        for (int i = 0; i < n; i++) {
            array[i] = Double.parseDouble(sc.next());
        }
        Arrays.sort(array);
        double ans = 0;
        for (int i = 0; i < n - 1; i++) {
            array[i + 1] = (array[i] + array[i + 1]) / 2;
            ans = array[i + 1];
        }
        System.out.println(ans);
    }
}


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

public class Main {

	public static void main(String[] args) throws IOException {
		InputReader in = new InputReader(System.in);
		int n = in.readInt();
		int m = in.readInt();
		int arr[] = new int[n]; 
		for(int i = 0; i<m; i++) {
			int x = in.readInt();
			int y = in.readInt();
			arr[x-1] += 1; 
			arr[y-1] += 1;
		}
		for(int i = 0; i<n; i++) {
			System.out.println(arr[i]); 
		}
	}
}
class InputReader {

	private InputStream stream;
	private byte[] buf = new byte[1024];
	private int curChar;
	private int numChars;
	private SpaceCharFilter filter;

	public InputReader(InputStream stream) {
		this.stream = stream;
	}

	public int read() {
		if (numChars == -1)
			throw new InputMismatchException();
		if (curChar >= numChars) {
			curChar = 0;
			try {
				numChars = stream.read(buf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (numChars <= 0)
				return -1;
		}
		return buf[curChar++];
	}

	public int readInt() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		int res = 0;
		do {
			if (c < '0' || c > '9')
				throw new InputMismatchException();
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}

	public String readString() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		StringBuilder res = new StringBuilder();
		do {
			res.appendCodePoint(c);
			c = read();
		} while (!isSpaceChar(c));
		return res.toString();
	}

	public long readLong() {
		int c = read();
		while (isSpaceChar(c)) {
			c = read();
		}
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		long res = 0;
		do {
			if (c < '0' || c > '9') {
				throw new InputMismatchException();
			}
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}
	
	public boolean isSpaceChar(int c) {
		if (filter != null)
			return filter.isSpaceChar(c);
		return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
	}

	public String next() {
		return readString();
	}

	public interface SpaceCharFilter {
		public boolean isSpaceChar(int ch);
	}
}



Measured memory_bytes: 24404
import sys
from collections import deque

N, M=map(int, sys.stdin.readline().split())
p = []
for i in range(M):
    p.append(list(map(int, sys.stdin.readline().split())))

graph = [[] for _ in range(N + 1)]
for pi in p:
    graph[pi[0]].append(pi[1])
    graph[pi[1]].append(pi[0])

q = deque([1])
p = [0] * (N + 1)
p[1] = 1
while q:
    u = q.popleft()
    for v in graph[u]:
        if not p[v]:
            p[v] = u
            q.append(v)
            
result = p[2:]
        
if all(result):
    print("Yes")
    [print(r) for r in result] 
else:
    print("No")

Measured memory_bytes: 57816
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
	"strings"
)

func main() {
	readInt()
	A := readInts()
	B := readInts()
	C := readInts()
	var satisfaction int64
	var prev int64 = -1
	for _, a := range A {
		satisfaction += B[a-1]
		if prev+1 == a {
			satisfaction += C[prev-1]
		}
		prev = a
	}
	fmt.Println(satisfaction)
}

var reader = bufio.NewReaderSize(os.Stdin, 1024*1024)

func Min(a, b int64) int64 {
	if a > b {
		return b
	}
	return a
}

func Max(a, b int64) int64 {
	if a > b {
		return a
	}
	return b
}

func readInt() int64 {
	temp := readLine()
	res, _ := strconv.ParseInt(temp, 10, 64)
	return res
}

func readInts() []int64 {
	nums := strings.Split(readLine(), " ")
	res := make([]int64, len(nums))
	for i, str := range nums {
		res[i], _ = strconv.ParseInt(str, 10, 64)
	}
	return res
}

func readLine() string {
	str, _, err := reader.ReadLine()
	if err == io.EOF {
		return ""
	}
	return strings.TrimRight(string(str), "\r\n")
}


Measured memory_bytes: 640
h, w, k = map(int, input().split())

mod = 10 ** 9 + 7

def dfs(idx, used):
    if idx == w - 1:
        return [[]]

    ret = dfs(idx + 1, False)
    if used == False:
        ret2 = dfs(idx + 1, True)
        for l in ret2:
            ret.append(l + [idx])
    return ret

combs = dfs(0, 0)

dp = [0] * w
dp[0] = 1
for i in range(h):
    dp_new = [0] * w
    for bars in combs:
        used = set()
        for start in bars:
            dp_new[start] += dp[start + 1]
            dp_new[start + 1] += dp[start]

            used.add(start)
            used.add(start + 1)

        for i in range(w):
            if i not in used:
                dp_new[i] += dp[i]

    dp = [x % mod for x in dp_new]

print(dp[k-1])


Measured memory_bytes: 40176
#include <bits/stdc++.h>
using namespace std;
 
 
int main(){
	int n,ans=0;
        long k;
	long list[100001];
	long a,b,m=0;
	scanf("%d %ld",&n,&k);
	int i;
        for(i=0;i<100001;i++){
                list[i] = 0;
        }
	for(i=0;i<n;i++){
		scanf("%ld %ld",&a,&b);
		list[a] += b;
	}
	for(i=0;i<100001;i++){
		m = m + list[i];
		if(m>=k){
			ans = i;
			break;
		}
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 1024
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Console = System.Console;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var a = int.Parse(Console.ReadLine());
            var b = int.Parse(Console.ReadLine());
            var n = int.Parse(Console.ReadLine());
            var ret = (a + b) * n / 2;
            Console.WriteLine(ret);
        }
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}
int gcd(int a, int b){//ユークリッドの互除法
  if (a < b) gcd(b,a); //aの方がbよりでかいのが前提
  if (b == 0) return a; //aをbで割り切れたらreturn
  else gcd(b, a % b);
}
// 100以下の素数一覧
const int prime[25] = {
    2, 3, 5, 7, 11,
    13, 17, 19, 23, 29,
    31, 37, 41, 43, 47,
    53, 59, 61, 67, 71,
    73, 79, 83, 89, 97};

int main(){
  int n; cin >> n;
  int cnt[25];
  fill(cnt, cnt + 25,0);
  
  for(int i = 1; i <= n; i++){//1~nまでの全ての数を
    int m = i;
    for(int j = 0; j < 25; j++){//素因数分解
      while(m % prime[j] == 0){
        cnt[j]++;
        m /= prime[j];
      }
    }
  }
  
  int ans = 0;
  //p^74のケース
  rep(p,25) if(cnt[p] >= 74) ans++;
  
  //p^24とq^2とp^4 q^14のケース
  rep(p,25)rep(q,25){
    if(p==q) continue;
    if(cnt[p] >= 4 && cnt[q] >= 14) ans++;
    if(cnt[p] >= 24 && cnt[q] >= 2) ans++;
  }
  
  //p^2,q^4,r^4のケース
  rep(p,25)rep(q,25){
    for(int r = q+1; r < 25;r++){
      if(p == q || r == p) continue;
      if(cnt[p] >= 2 && cnt[q] >= 4 && cnt[r] >= 4) ans++;
    }
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
using namespace std;
const int MAXN = 2e5+5;
vector<int> factors;
int arr[MAXN];
int sum;
int ans;
int k;
int main(){
    int n;
    cin>>n>>k;
    for(int i=1;i<=n;i++){
        cin>>arr[i];
        sum+=arr[i];
    }
    for(int i=1;i*i<=sum;i++){
        if(sum%i == 0){
            factors.push_back(i);
            if(i*i!=sum){
                factors.push_back(sum/i);
            }
        }
    }
    for(int i=0;i<factors.size();i++){
        
        multiset<int> s1;
        int tempsum = 0;
        int tempsum2 = 0;
        for(int j=1;j<=n;j++){
            s1.insert(arr[j]%factors[i]);
            tempsum+=factors[i] - (arr[j]%factors[i]);
        
        }
        
        for(int x:s1){
            tempsum2+=x;
            tempsum-=factors[i] - x;
            if(tempsum == tempsum2 && tempsum<=k){
                ans = max(ans,factors[i]);
            }
        }
    }
    cout<<ans<<endl;
}

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

signed main()
{
    int N,K; cin>>N>>K;
    if(K>(N-1)*(N-2)/2){
        cout<<"-1"<<endl;
        return 0;
    }

    int cnt=(N-1)*(N-2)/2-K;
    int M=(N-1)+cnt;

    cout<<M<<endl;
    for(int i=2;i<=N;i++){
        cout<<1<<' '<<i<<endl;
    }
    for(int i=2;i<=N-1;i++){
        for(int j=i+1;j<=N;j++){
            if(cnt>0){
                cnt--;
                cout<<i<<' '<<j<<endl;
            }
        }
    }
    return 0;
}   


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

int main() {
  int N;
  string s;
  int i = 0;
  cin >> N;
  while(i<N){
    cin >> s;
    if(s == "Y"){
      cout << "Four";
      break;
      }
    i++;
    if(i == N){
      cout << "Three";
    }
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for (int i=0; i<n; i++)
#define REP(i,x,n) for (int i=x; i<n; i++)
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using ll = long long;
const int mod =1'000'000'007;

int main(){
    int a, b, h, m;
    cin >> a >> b >> h >> m;
    const double pi = acos(-1);
    double th = (double)(h*60+m)/720 * 2*pi;
    double tm = (double)m/60 * 2*pi;
    double xh = a*cos(th), yh = a*sin(th);
    double xm = b*cos(tm), ym = b*sin(tm);
    double dx = xh-xm, dy = yh-ym;
    double ans = sqrt(dx*dx + dy*dy);
    printf("%.10f\n", ans);
    return 0;
}


Measured memory_bytes: 4132
#include <bits/stdc++.h>
#define int long long
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define rep(i,l,r) for(int i=l;i<r;i++)
#define bep(i,l,r) for(int i=l;i>=r;i--)
#define ld long double
#define ff first
#define ss second
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define el '\n'
#define sz(s) s.size()
#define all(v) v.begin(),v.end()
#define mii map<int,int>
#define mr  make_pair
using namespace std;

int inf = 1e18;
const int N = 5e5+5;
int mod = 1e9+7;
int powmod(int a,int b) {int res=1;if(a>=mod)a%=mod;for(;b;b>>=1){if(b&1)res=res*a;if(res>=mod)res%=mod;a=a*a;if(a>=mod)a%=mod;}return res;}

signed main()
{
    io
    int tt = 1;
    //cin>>tt;
    while(tt--)
    {
       int n;
       cin>>n;
       map<int,int> mp;
       int arr[n];
       rep(i,0,n)
       cin>>arr[i];
       rep(i,0,n)
       {
           int ct = 0;
           int x = arr[i];
           for(int i=2;i*i<=x;++i)
           {

               if(x%i==0)
               {
                  ct = 0;
                 while(x%i==0)
                 {
                     ct++;
                     x/=i;
                 }
                 mp[i]= max(mp[i],ct);mp[i]= max(mp[i],ct);
               }

           }
           if(x!=1)
            mp[x] = max(mp[x],1LL);
       }
       int lcm = 1;
       for(auto x:mp)
        lcm = (lcm*powmod(x.ff,x.ss))%mod;
        int ans = 0;
        rep(i,0,n)
       {
           ans = (ans + (lcm*powmod(arr[i],mod-2))%mod)%mod;
       }
        cout<<ans<<el;
    }


        return 0;
    }


Measured memory_bytes: 1024
# ABC 75 B

def resolve():
    H, W = map(int, input().split())
    s = [[0] * W for _ in range(H)]
    for i in range(H):
        a = input()
        for j in range(W):
            s[i][j] = a[j]

    # 与えられた座標が範囲内でかつ爆弾なら True を返す
    def check(h, w):
        if (h < 0 or w < 0 or h >= H or w >= W):
            return False
        if (s[h][w] == '#'):
            return True
        return False

    for h in range(H):
        for w in range(W):
            if s[h][w] == '#':
                continue
            mines = 0
            for i in [-1, 0, 1]:
                for j in [-1, 0, 1]:
                    if check(h+i, w+j):
                        mines += 1
            s[h][w] = mines

    for h in range(H):
        for w in range(W):
            print(s[h][w], end='')
        print("")


if __name__ == "__main__":
    resolve()


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

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> p(n);
    int i;
    for(i = 0; i < n; i++) {
        cin >> p[i];
    }

    sort(p.begin(), p.end());

    int sum = 0;
    for(i = 0; i < k; i++) {
        sum += p[i];
    }
    cout << sum << endl;
}


Measured memory_bytes: 3628
#include<stdio.h>
#include<iostream>
#include<string.h>
#include<algorithm>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
ll n,k;
int a[20000+100];
ll ksc(ll a,ll b,ll c)
{
	ll ans=0;
	while(b)
	{
		if(b%2==1)
		ans=(ans+a)%c;
		b=b/2;
		a=(a+a)%c;
	}
	return ans;
}
int main()
{
	cin>>n>>k;
	for(int i=1;i<=n;i++)
	cin>>a[i];
	ll num1=0;
	for(int i=1;i<=n;i++)
	{
		for(int j=i+1;j<=n;j++)
		{
			if(a[i]>a[j]) num1++;
		}
	}
	ll num2=0;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=n;j++)
		{
			if(a[i]>a[j]) num2++;
		}
	}
	printf("%lld\n",(ksc(num1,k,mod)%mod+ksc(num2,k*(k-1)/2,mod)%mod)%mod);
	return 0;
}

Measured memory_bytes: 256
import java .util.ArrayList;
import java.util.Collections;
import java .util.Scanner;
public class Main {
public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);

	int inputN = sc.nextInt();
	int inputK = sc.nextInt();

	ArrayList<Long>  inH = new ArrayList<>();

	long attack = 0;

	for(int i = 0; i < inputN; i++) {
		inH.add(sc.nextLong());
	}

	Collections.sort(inH, Collections.reverseOrder());

	for(int i = inputK; i < inH.size(); i++) {
		attack += inH.get(i);
	}

	System.out.println(attack);

}
}


Measured memory_bytes: 66500
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
#define FOR(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR1(i,n) for(int (i)=1;(i)<(n);(i)++)
#define eFOR(i,n) for(int (i)=0;(i)<=(n);(i)++)
#define eFOR1(i,n) for(int (i)=1;(i)<=(n);(i)++)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i) sort((i).begin(),(i).end(), greater<int>());
#define YES(i) cout << ((i) ? "Yes" : "No") << endl;
constexpr auto INF = 1000000000;
constexpr auto LLINF = 922337203685477580;//7;
constexpr auto mod = 1000000007;

int main() {

	int sx, sy, gx, gy;
	cin >> sx >> sy >> gx >> gy;
	FOR(i, gx - sx)cout << 'R';
	FOR(i, gy - sy)cout << 'U';
	FOR(i, gx - sx)cout << 'L';
	FOR(i, gy - sy)cout << 'D';
	cout << 'L';
	FOR(i, gy - sy + 1)cout << 'U';
	FOR(i, gx - sx + 1)cout << 'R';
	cout << "DR";
	FOR(i, gy - sy + 1)cout << 'D';
	FOR(i, gx - sx + 1)cout << 'L';
	cout << 'U' << endl;
}


Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
import java.io.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String first_line = sc.nextLine();
		String second_line = sc.nextLine();
		String third_line = sc.nextLine();
 
        System.out.print(first_line.substring(0,1));
        System.out.print(second_line.substring(1,2));
        System.out.print(third_line.substring(2,3));
    }
}

Measured memory_bytes: 35548
#include <iostream>
#include <vector>
#include <algorithm>
#include <cassert>
#include <set>
#include <map>

using namespace std;
using ll = long long;
using ull = unsigned long long;
constexpr ll TEN(int n) { return (n==0) ? 1 : 10*TEN(n-1); }

int h, w, n, md;
bool g[51][51] = {};

void answer() {
    ll res = 0;
    ll base = 1;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (g[i][j]) res = (res+base) % md;
            base = 2*base % md;
        }
    }
    cout << "! " << res << endl;
}

using T = tuple<int, int, int, int>;
map<T, int> buf;
int que(int ax, int ay, int bx, int by) {
    bx--; by--;
    if (buf.count(T(ax, ay, bx, by))) return buf[T(ax, ay, bx, by)];
    cout << "? " << ay << " " << ax << " " << by << " " << bx << endl;
    int p;
    cin >> p;
    return buf[T(ax, ay, bx, by)] = p;
}

int dfs(int y, int l, int r) {
    int nm = que(l, y, r, y+1);
    if (nm == 0) return 0;
    if (l+1 == r) {
        g[y][l] = true;
        return 1;
    }
    int md = (l+r)/2;
    if (nm != dfs(y, l, md)) dfs(y, md, r);
    return nm;
}

int main() {
    ios::sync_with_stdio(0);
    cin >> h >> w >> n >> md;
    for (int i = 0; i < h; i++) {
/*        for (int j = 0; j < w; j++) {
            g[i][j] = (que(j, i, j+1, i+1) != 0);
        }*/
        dfs(i, 0, w);
    }
    answer();
    return 0;
}



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

long long a[110][110], num[110];

void div(int x) {

    for (int i = 2; i <= x; ++i) {
        while (x % i == 0) {
            num[i] ++;
            x /= i;
        }
    }
}

int main() {
    int n;
    std::cin >> n;
    for (int i = 1; i <= n; ++i) {
        div(i);
    }
    a[0][1] = 1;
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= 75; ++j) {
            for (int k = 0; k <= num[i]; ++k) {
                if (j * (k + 1) <= 75) {
                    a[i][j * (k + 1)] += a[i - 1][j];
                }
            }
        }
    }
    printf("%lld", a[n][75]);
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <functional>
#include <queue>
#include <cmath>
#include <utility>

using namespace std;

#define int long long
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define rep1(i,n) for(int i=1;i<=(int)n;++i)

int N, Q;

vector<int> G[200010];
int	X[200010];
int ans[200010];

void dfs(int cur, int par, int sum)
{
	X[cur] += sum;

	// leaf
	if (G[cur].size() == 1 and G[cur][0] == par) return;

	for (int &nxt : G[cur]) {
		if (nxt == par) continue;
		dfs(nxt, cur, X[cur]);
	}
}

signed main()
{
	cin >> N >> Q;

	rep(i, N-1) {
		int a, b; cin >> a >> b;
		--a,--b;
		G[a].push_back(b);
		G[b].push_back(a);
	}

	rep(i, Q) {
		int p, x; cin >> p >> x;
		--p;
		X[p] += x;
	}

	dfs(0, -1, 0);

	rep(i, N) printf("%lld%c", X[i], i==N-1?'\n':' ');
}


Measured memory_bytes: 24320
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;


int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(12);

    int h, w;
    cin >> h >> w;
    int n;
    cin >> n;
    vector<pair<int,int>> P;
    for (int i = 0; i < n; ++i) {
        int x, y;
        cin >> x >> y;
        --x, --y;
        P.emplace_back(x, y);
    }

    vector<int> H(h, 0);
    vector<int> W(w, 0);

    for (auto& p : P) {
        int x = p.first;
        int y = p.second;
        ++H[x];
        ++W[y];
    }

    int res = 0;
    for (int i = 0; i < h; ++i) {
        res = max(res, H[i]);
    }
    for (int i = 0; i < w; ++i) {
        res = max(res, W[i]);
    }

    int mxh = *max_element(H.begin(), H.end());
    int mxw = *max_element(W.begin(), W.end());

    vector<bool> HH(h, false);
    vector<bool> WW(w, false);

    int ch = 0;
    int cw = 0;
    for (int i = 0; i < h; ++i) {
        if (H[i] == mxh) {
            HH[i] = true;
            ++ch;
        }
    }
    for (int i = 0; i < w; ++i) {
        if (W[i] == mxw) {
            WW[i] = true;
            ++cw;
        }
    }

    int cnt = 0;
    for (auto& p : P) {
        int x = p.first, y = p.second;
        if (HH[x] && WW[y]) {
            ++cnt;
        }
    }

    int ans = mxh + mxw;
    if (ch * 1LL * cw <= cnt) {
        --ans;
    }

    res = max(res, ans);

    cout << res << '\n';

    return 0;
}

Measured memory_bytes: 7924
X = int(input())
A = [0] * 201
flag = True
for i in range(200):
    A[i] = i ** 5
for i in range(200):
    if(flag == False):
        break
    for i2 in range(i):
        if abs(X - A[i]) == A[i2]:
            if X - A[i] >= 0:
                print(str(i) + " "+ str(-1 * i2))
            else:
                print(str(i) + " "+ str(i2))
            flag = False
            break

Measured memory_bytes: 9204
#include <cstdio>
#include <algorithm>

using namespace std;

int h[100000];
int dp[100000];

int main() {
    int n, k, i, j;
    
    scanf("%d %d", &n, &k);
    
    for (i = 0; i < n; i++) scanf("%d", &h[i]);
    
    for (i = 0; i < n; i++) dp[i] = 1e9;
    
    dp[0] = 0;
    
    for (i = 0; i < n - 1; i++) {
        for (j = 1; i + j < n && j <= k; j++) {
            dp[i + j] = min(dp[i + j], dp[i] + abs(h[i + j] - h[i]));
        }
    }
    
    printf("%d\n", dp[n - 1]);
    
    return 0;
}


Measured memory_bytes: 896
object Main {
  def main(args: Array[String]): Unit = {
    val s = new Main()
    s.solve()
    s.out.flush()
  }
}

class Main {
  import java.io._
  import java.util.StringTokenizer

  import scala.collection.mutable
  import scala.util.Sorting
  import math.{abs, max, min}
  import mutable.{ArrayBuffer, ListBuffer}
  import scala.reflect.ClassTag

  val MOD = 1000000007
  val out = new PrintWriter(System.out)

  def solve(): Unit = {
    val N, A, B = ni()
    val mx = min(A, B)
    val ms = max(0, A + B - N)
    out.println(s"$mx $ms")
  }

  def debug(as: Array[Boolean]): Unit = {
    System.err.println(as.map(x => if(x) "1" else "0").mkString)
  }

  def debug(as: Array[Int]): Unit = {
    System.err.println(as.mkString(" "))
  }

  def debug(as: Array[Long]): Unit = {
    System.err.println(as.mkString(" "))
  }

  def debug(s: String): Unit = {
    System.err.println(s)
  }

  class InputReader(val stream: InputStream) {
    private val reader = new BufferedReader(new InputStreamReader(stream), 32768)
    private var tokenizer: StringTokenizer = _

    def next(): String = {
      while (tokenizer == null || !tokenizer.hasMoreTokens)
        tokenizer = new StringTokenizer(reader.readLine)
      tokenizer.nextToken
    }

    def nextInt(): Int = next().toInt
    def nextLong(): Long = next().toLong
    def nextChar(): Char = next().charAt(0)
  }
  val sc = new InputReader(System.in)
  def ni(): Int = sc.nextInt()
  def nl(): Long = sc.nextLong()
  def nc(): Char = sc.nextChar()
  def ns(): String = sc.next()
  def ns(n: Int): Array[Char] = ns().toCharArray
  def na(n: Int, offset: Int = 0): Array[Int] = map(n)(_ => ni() + offset)
  def na2(n: Int, offset: Int = 0): (Array[Int], Array[Int]) = {
    val A1, A2 = Array.ofDim[Int](n)
    REP(n) { i =>
      A1(i) = ni() + offset
      A2(i) = ni() + offset
    }
    (A1, A2)
  }
  def nm(n: Int, m: Int): Array[Array[Int]] = {
    val A = Array.ofDim[Int](n, m)
    REP(n) { i =>
      REP(m) { j =>
        A(i)(j) = ni()
      }
    }
    A
  }
  def nal(n: Int): Array[Long] = map(n)(_ => nl())
  def nm_c(n: Int, m: Int): Array[Array[Char]] = map(n) (_ => ns(m))
  def REP(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {
    var i = offset
    val N = n + offset
    while(i < N) { f(i); i += 1 }
  }
  def REP_r(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {
    var i = n - 1 + offset
    while(i >= offset) { f(i); i -= 1 }
  }

  def map[@specialized A: ClassTag](n: Int, offset: Int = 0)(f: Int => A): Array[A] = {
    val res = Array.ofDim[A](n)
    REP(n)(i => res(i) = f(i + offset))
    res
  }


  def sumL(as: Array[Int]): Long = {
    var s = 0L
    REP(as.length)(i => s += as(i))
    s
  }

  def cumSum(as: Array[Int]) = {
    val cum = Array.ofDim[Long](as.length + 1)
    REP(as.length) { i =>
      cum(i + 1) = cum(i) + as(i)
    }
    cum
  }
}

Measured memory_bytes: 27204
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>

using ll = long long;
using namespace std;
const int maxn = 2e5 + 1e3;
vector<int> edges[maxn];
array<int, maxn> dis1, dis2;

void dfs(int current, int father, int dist, array<int, maxn> &cur) {
    cur[current] = dist;
    for (auto to:edges[current]) {
        if (to != father) {
            dfs(to, current, dist + 1, cur);
        }
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    for (int i = 0; i < n - 1; ++i) {
        int u, v;
        cin >> u >> v;
        edges[u].push_back(v);
        edges[v].push_back(u);
    }
    dfs(1, 0, 0, dis1);
    dfs(n, 0, 0, dis2);
    int balance = 0;
    for (int i = 1; i <= n; ++i) {
        if (dis1[i] <= dis2[i]) ++balance;
        else --balance;
    }
    if (balance > 0) {
        cout << "Fennec" << endl;
    } else {
        cout << "Snuke" << endl;
    }
}


Measured memory_bytes: 15104
import java.util.*;

public class Main {

  public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);

    int N = sc.nextInt();
    int K = sc.nextInt();

    sc.close();

    if (K % 2 == 0) {
      long c1 = N / K;
      long c2 = N / (K / 2) - c1;
      System.out.println(c1 * c1 * c1 + c2 * c2 * c2);
    } else {
      long c = N / K;
      System.out.println(c * c * c);
    }

  }

}

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

using namespace std;

void solve() {
    int n;
    long long x, ans;
    cin >> n >> x;
    vector <long long> a(n);
    for (long long &ai: a)
        cin >> ai;
    ans = 0;
    for (int i = 1; i < n; ++i) {
        if (a[i] + a[i-1] > x) {
            ans += a[i] + a[i-1] - x;
            if (a[i-1] - x <= 0) {
                a[i] = - a[i-1] + x;
            } else {
                a[i-1] = x;
                a[i] = 0;
            }
        }
    }


    cout << ans;
}

int main() {

    solve();
    return 0;
}


Measured memory_bytes: 3644
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        char[] chars = sc.next().toCharArray();
        int length = chars.length;
        int[] arr = new int[length + 1];
        for (int i = 1; i <= length; i++) {
            arr[i] = chars[i - 1] - '0';
        }
        int[][] dp = new int[length + 2][2];
        dp[length + 1][1] = 10;
        for (int i = length; i >= 0; i--) {
            dp[i][0] = Math.min(dp[i + 1][0] + arr[i], dp[i + 1][1] + arr[i] + 1);
            dp[i][1] = Math.min(dp[i + 1][0] + 10 - arr[i], dp[i + 1][1] + 10 - arr[i] - 1);
        }
        System.out.println(dp[0][0]);
    }
}

Measured memory_bytes: 66040
# coding: utf-8
# Your code here!

N = int(input())
S = ['.'] + [x for x in input()] + ['#']

cum_white = []
count = 0
for i, s in enumerate(S):
    if s == '#':
        count += 1
    cum_white.append(count)
    
min_num = int(1e10)
for i, n_white in enumerate(cum_white):
    num = n_white + (N + 1 - i - (cum_white[-1] - n_white))
    min_num = min(min_num, num)
    
print(min_num)

Measured memory_bytes: 12396
import numpy as np
import sys
X = int(input())
if X==1:
    print('1')
    sys.exit()
maxnum = 0
for i in range(2,int(np.sqrt(X))+1):
    num = i
    while num <= X:
        num *= i
        if num/i >maxnum:
            maxnum = num/i
print(int(maxnum))

Measured memory_bytes: 12396
/// WA

#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
     
#define x first
#define y second
#define pb push_back
#define sz(x) (int) x.size()

using namespace std;
using namespace __gnu_pbds;

template<typename T>
using ordered_set = tree<T, null_type,
less<T>, rb_tree_tag, 
tree_order_statistics_node_update>;

using ll = long long;
using pii = pair<int, int>;                                   

const int MOD = 1e9 + 7;
const int INF32 = 1e9 + 1e2;

const int MAX = 1e6+2e5;

int lp[MAX]; 

unordered_map<int, int> max_map; 

int mult(ll a, ll b) {
    return (a % MOD) * (b % MOD) % MOD;
}

int binpow(int a, int b) {
    ll res = 1ll;
    while (b) {
        if (b & 1ll) 
            res = mult(res, a);
        a = mult(a, a);
        b >>= 1ll;
    }
    return res;
}
                       
int n;

vector<ll> a;

ll get() { 
    for (int i = 0; i < n; i++) { 
        ll num = a[i];
        unordered_map<int, int> temp; 
        while (num > 1) { 
            int factor = lp[num]; 
            temp[factor]++; 
            num /= factor; 
        } 
        for (auto it : temp) { 
            max_map[it.x] = max(max_map[it.x], it.y); 
        } 
    } 
    ll ans = 1; 
    for (auto it : max_map) { 
        ans = (ans * binpow(it.x, it.y)) % MOD; 
    } 
    return ans; 
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> n;
    lp[0] = lp[1] = 1; 
    for (int i = 2; i < MAX; ++i) { 
        if (lp[i])  
            continue;
        for (int j = i*2; j < MAX; j += i)  
            if (!lp[j])  
                lp[j] = i; 
        lp[i] = i; 
    }
    a.resize(n);
    for (ll& x : a)
        cin >> x;
    ll lcm = get();
    ll ans = 0;
    for (ll x : a) {
        ans += mult(lcm, binpow(x, MOD-2));
        if (ans >= MOD)
            ans -= MOD;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 5504
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.HashMap;
import java.util.NoSuchElementException;

class Main {
	public static void main(String[] args) {
		new Main().run();
	}

	void run() {
		Scanner sc = new Scanner();
		long N = sc.nextLong();
		long P = sc.nextLong();
		if (N == 1) {
			System.out.println(P);
			return;
		}
		long ans = 1;
		for (long div = 2; div * div <= P; ++div) {
			long cnt = 0;
			while (P % div == 0) {
				P /= div;
				++cnt;
				if (cnt >= N) {
					ans *= div * (cnt / N);
					cnt = 0;
				}
			}
		}
		System.out.println(ans);
	}

	void tr(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}

}

class Scanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	private void skipUnprintable() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
	}

	public boolean hasNext() {
		skipUnprintable();
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		return (int) nextLong();
	}
}


Measured memory_bytes: 23252
#include<cstdio>
#include<algorithm>
using namespace std;
int n, S[110];
int R[11100][2], RC;
void Add_Edge(int a, int b) {
	RC++;
	S[a] += b, S[b] += a;
	R[RC][0] = a, R[RC][1] = b;
}
int main() {
	int i, j;
	scanf("%d", &n);
	int m = n / 2 * 2;
	for (i = 1; i <= m; i++) {
		for (j = i+1; j <= m; j++) {
			if (i == j || i + j == m + 1)continue;
			Add_Edge(i, j);
		}
	}
	if (n % 2 == 1) {
		for (i = 1; i <= m; i++)Add_Edge(i, n);
	}
	printf("%d\n", RC);
	for (i = 1; i <= RC; i++)printf("%d %d\n", R[i][0], R[i][1]);
	//for (i = 1; i <= n; i++)printf("%d\n", S[i]);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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

    map<char, int> ma;
    for(char c='a'; c<='z'; c++) ma[c] = 0;
    for(int i=0; i<N; i++) ma[s[i]]++;

    ll ans = 1;
    int mod = 1000000007;

    for(char c='a'; c<='z'; c++){
        ans = ans * (ma[c]+1) % mod;
    }

    cout << ans-1 << endl;

}

Measured memory_bytes: 512
/*---> 20 April 2020 <--- > 02:03:04 <---*/
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
// #pragma GCC optimize("unroll-loops")
// #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
//#pragma GCC target ("sse4")
#include <bits/stdc++.h>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
//template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
#define int long long
#define F first
#define S second
#define mod 1000000007
#define inf (int)1e18+5
#define sz(x) (int)x.size()
#define PI 3.141592653589793238510
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define __ ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define vi vector<int>
#define vpii vector<pair<int,int> > 
#define vvi vector<vector<int> >
#define PRINT_TIME cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s." <<endl;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename   enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
typedef long double ld;
typedef pair<int,int> pii;
///////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////
const int N=1e5+5;

int32_t main(){__
	int n,m;
	cin>>n>>m;
	int x,sumi=0;
	for(int i=0;i<m;i++)
		cin>>x,sumi+=x;
	cout<<max(-1LL,n-sumi)<<"\n";
return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

main() {
    int64_t n;
    cin >> n;

    vector<int64_t> a(n);
    unordered_map<int64_t, int64_t> counts;
    for (auto&& aa : a) {
        cin >> aa;
        ++counts[aa];
    }

    vector<int64_t> nums;
    nums.reserve(counts.size());
    for (auto kv : counts) {
        nums.push_back(kv.second);
    }

    sort(nums.rbegin(), nums.rend());

    vector<int64_t> cum(nums.size() + 1);
    for (auto i : irange(0uL, nums.size())) {
        cum[i + 1] = cum[i] + nums[i];
    }

    for (auto k : irange(1L, n + 1)) {
        if (k > nums.size()) {
            cout << 0 << "\n";
            continue;
        }
        auto r = irange(0L, k - 1);
        auto it = partition_point(r.begin(), r.end(), [&](int64_t i) {
            return cum.back() - cum[i + 1] < (k - i - 1) * nums[i];
        });
        auto idx = it - r.begin();

        auto ans = (cum.back() - cum[idx]) / (k - idx);
        cout << ans << "\n";
    }
}

Measured memory_bytes: 20724
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using vpii = vector<pair<int, int>>;
using vpll = vector<pair<ll, ll>>;
// ceil() 切り上げ, floor() 切り捨て
// next_permutation(all(x))

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

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

	vector<bool> check(n+1, false);
	vector<int> R;
	R.push_back(1);
	check[1] = true;
	ll now = 0;
	ll loop_start;

	while (1)
	{
		if (check[C[now]])
		{
			loop_start = C[now];
			break ;
		}
		R.push_back(C[now]);
		check[C[now]]= true;
		now = C[now]-1;
	}

	ll s;
	for (int i = 0; i < (int)R.size(); i++)
	{
		if (R[i] == loop_start)
			s = (ll)i;
	}

	ll loop_size = (ll)R.size() - s;
	ll idx;
	if (k <= s)
		idx = k;
	else
	{
		k -= s;
		k %= loop_size;
		idx = k + s;
		if (k / loop_size > 0)
			idx--;
	}
//	for (int i = 0; i < (int)R.size(); i++)
//		cout << R[i] << endl;
	cout << R[idx] << endl;
}



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

words_list = [input()]
c = 1

for i in range(1,N):
    new_word = input()
    words_list.append(new_word)
    
    if new_word in words_list[:i-1]:
        c += 0
        
    elif new_word[0] != words_list[i-1][len(words_list[i-1])-1]:
        c += 0
        
    else:
        c += 1

if c == N:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9192
// Your day breaks, your mind aches
// You find that all the words of kindness linger on
// When she no longer needs you
//#pragma GCC optimize ("Ofast,unroll-loops")
//#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
#include <unistd.h>
using namespace std;
#define fastio ios::sync_with_stdio(0);cin.tie(0)
#define debug(x) cout << #x << " = " << x << endl
#define For(i,a,b) for (int i = a; i < b; i++)
#define roF(i,a,b) for (int i = a; i >= b; i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(v) (v).begin(),(v).end()

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

const int N = 2e5;
const ll INF = 1e18;
const ld EPS = 10e-9;

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll random(ll a, ll b) { return uniform_int_distribution<ll> (a, b) (rng); }

int n, ta, ao;
bool used[N], below[N];
int h[N], anc[N];
bool ok;
vi adj[N];

void BFS(int root) {
	used[root] = true;
	h[root] = 0;
	anc[root] = -1;
	queue<int> q;
	q.push(root);
	while (not q.empty()) {
		int u = q.front();
		q.pop();
		for (int v : adj[u]) {
			if (not used[v]) {
				used[v] = true;
				h[v] = h[u] + 1;
				anc[v] = u;
				q.push(v);
			}
		}
	}
}

void DFS(int u) {
	used[u] = true;
	if (u == ta) ok = true;
	if (ok) below[u] = true;
	for (int v : adj[u]) {
		if (not used[v]) DFS(v);
	}
	if (u == ta) ok = false;
}

int main() {
	fastio;
	cin >> n >> ta >> ao;
	For(i,0,n-1) {
		int u, v;
		cin >> u >> v;
		adj[u].pb(v);
		adj[v].pb(u);
	}
	BFS(ao);
	int ans = 0;
	int subir = (h[ta] % 2 == 0 ? (h[ta] / 2 - 1) : h[ta] / 2);
	ans += subir;
	For(i,0,subir) ta = anc[ta];
	memset(used, 0, sizeof(used));
	DFS(ao);
	int maxi = 0;
	For(i,0,n+1) if (below[i]) maxi = max(maxi, h[i]);
	bool tak = true;
	int h_ao = h[ao] + subir;
	int h_ta = h[ta];
	while (1) {
		//debug(h_ta);
		//debug(h_ao);
		if (h_ao == h_ta) break;
		if (tak) {
			if (h_ta < maxi) h_ta++;
			else h_ta--;
		} else {
			ans++;
			h_ao++;
		}
		tak = not tak;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 12416
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>

using namespace std;

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

const ll inf = (ll)2e9 + 1;
const ll mod = (ll)1e9 + 7;

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

	ll x = -1, x0 = -1;
	ll id = -1;
	ll c = 0;
	for (int i = 0; i < n; i++)
	{
		ll a;
		cin >> a;
		if (i == 0)
		{
			x = a;
			id = i;
		}

		if (a > x)
		{
			x0 = x;
			x = a;
			c = 0;
			id = i;
		}
		else if (a == x)
		{
			c++;
		}
		else if (a > x0)
		{
			x0 = a;
		}
		else
		{

		}
	}

	for (int i = 0; i < n; i++)
	{
		if (c >= 2)
		{
			cout << x << endl;
		}
		else
		{
			if (id == i)
			{
				cout << x0 << endl;
			}
			else
			{
				cout << x << endl;
			}
		}
	}
}

Measured memory_bytes: 1664
N = int(input())
As = list(map(int, input().split()))
from collections import defaultdict

d = defaultdict(int)
for a in As:
    d[a] += 1
cnt = 0
for k in d.keys():
    # print((d[k]-1)*(d[k])//2,"d")
    cnt += (d[k]-1)*(d[k])//2

for a in As:
    x = d[a]
    waru = x*(x-1)//2
    kakeru = (x-1)*(x-2) //2
    print(cnt-waru+kakeru)



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

using i64 = int64_t;

const double PI = acos(-1);

int main(){
    double a, b, x;
    cin >> a >> b >> x;
    double theta1 = atan(a*b*b/(2.0*x))*180.0/PI;
    double theta2 = atan((2*a*a*b-2*x)/(a*a*a))*180.0/PI;
    double theta3 = atan(b/a)*180.0/PI;
    if(theta1 <= theta3)
        printf("%.10lf\n", atan((2*a*a*b-2*x)/(a*a*a))*180.0/PI);
    else
        printf("%.10lf\n", atan(a*b*b/(2.0*x))*180.0/PI);

    return 0;
}


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

int main(){
  string S;
  cin >> S;
  int ans = 753;
  int S_num[S.size()];
  for(int i=0;i<S.size();i++){
    char c = S[i];
    S_num[i] = c - '0';
  }
  for(int i=0;i<S.size()-2;i++){
    if(S_num[i]*100+S_num[i+1]*10+S_num[i+2]<753){
      ans = min(753-(S_num[i]*100+S_num[i+1]*10+S_num[i+2]),ans);
    }else{
      ans = min(S_num[i]*100+S_num[i+1]*10+S_num[i+2]-753,ans);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
/*
    Author: Nguyen Tan Bao
    Status:
    Idea:
*/

#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, int> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

const ll MODBASE = 1000000007LL;
const int MAXN = 200010;
const int MAXM = 1000;
const int MAXK = 16;
const int MAXQ = 200010;

ll MOD = 998244353;
ll dp[MAXN], f[MAXN], rev[MAXN];

ll binPowMod(ll a, ll b) {
    a %= MOD;
    ll res = 1;
    while (b > 0) {
        if (b & 1LL) res = res * a % MOD;
        a = a * a % MOD;
        b >>= 1LL;
    }
    return res;
}

ll add(ll a, ll b) {
    return (a + b) % MOD;
}

ll sub(ll a, ll b) {
    return (a - b + MOD) % MOD;
}

ll mul(ll a, ll b) {
    return a * b % MOD;
}

ll C(int n, int k) {
    if (k < 0 || k > n) return 0;
    return mul(f[n], mul(rev[n-k], rev[k]));
}

int n, m, k;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin >> n >> m >> k;
    dp[1] = m;
    FOR(i,2,n) dp[i] = mul(dp[i-1], m-1);
    f[0] = 1;
    rev[0] = binPowMod(f[0], MOD-2);
    FOR(i,1,n) {
        f[i] = mul(f[i-1], i);
        rev[i] = binPowMod(f[i], MOD-2);
    }
    ll res = 0;
    FOR(i,0,k) {
        int area = n - i;
        res = add(res, mul(dp[area], C(n-1, area-1)));
    }
    cout << res;
    return 0;
}


Measured memory_bytes: 8292
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>

#include <set>
#include <map>
#include <iomanip>

using namespace std;

#define rep(i, n) for(long long i = 0; i < (long long)(n); i++)
#define rrep(i, n) for(long long i = (long long)(n - 1); i >= 0; i--)
#define all(x) (x).begin(),(x).end()

using ll = long long;

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

	if (n == m)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int a,b,C;
    double S,L,h,t;
    double PI=acos(-1);
     
    scanf("%d %d %d",&a,&b,&C);
    h=b*sin(C*PI/180);
    t=b*cos(C*PI/180);
    S=0.5*a*h;
    L=a+b+sqrt(h*h+(a-t)*(a-t));
     
    printf("%lf\n",S);
    printf("%lf\n",L);
    printf("%lf\n",h);
     
    return 0;
}


Measured memory_bytes: 2108